Date: 2024-07-30T17:31:10+00:00

Actual source code: petscsys.h

      1: !
      2: !
      3: !  Part of the base include file for Fortran use of PETSc.
      4: !  Note: This file should contain only define statements and
      5: !  not the declaration of variables.

      7: ! No spaces for #defines as some compilers (PGI) also adds
      8: ! those additional spaces during preprocessing - bad for fixed format
      9: !
     10: #if !defined (PETSCSYSDEF_H)
     11: #define PETSCSYSDEF_H
     12: #include "petscconf.h"
     13: #if defined (PETSC_HAVE_MPIUNI)
     14: #include "petsc/mpiuni/mpiunifdef.h"
     15: #endif
     16: #include "petscversion.h"
     17: #include "petsc/finclude/petscviewer.h"
     18: #include "petsc/finclude/petsclog.h"
     19: #include "petsc/finclude/petscbag.h"

     21: !
     22: ! The real*8,complex*16 notatiton is used so that the
     23: ! PETSc double/complex variables are not affected by
     24: ! compiler options like -r4,-r8, sometimes invoked
     25: ! by the user. NAG compiler does not like integer*4,real*8

     27: #define integer8 integer(kind=selected_int_kind(10))
     28: #define integer4 integer(kind=selected_int_kind(5))
     29: #define integer2 integer(kind=selected_int_kind(3))
     30: #define integer1 integer(kind=selected_int_kind(1))
     31: #define PetscBool  logical(kind=4)
     32: #define PetscBool3  integer(kind=selected_int_kind(5))

     34: #if (PETSC_SIZEOF_VOID_P == 8)
     35: #define PetscOffset integer8
     36: #define PetscFortranAddr integer8
     37: #define PetscCount integer8
     38: #else
     39: #define PetscOffset integer4
     40: #define PetscFortranAddr integer4
     41: #define PetscCount integer4
     42: #endif

     44: #if defined(PETSC_USE_64BIT_INDICES)
     45: #define PetscInt integer8
     46: #else
     47: #define PetscInt integer4
     48: #endif
     49: #define PetscInt64 integer8
     50: #define PetscObjectState PetscInt64
     51: #define PetscObjectId PetscInt64

     53: #if (PETSC_SIZEOF_INT == 4)
     54: #define PetscFortranInt integer4
     55: #elif (PETSC_SIZEOF_INT == 8)
     56: #define PetscFortranInt integer8
     57: #endif
     58: !
     59: ! Fortran does not support unsigned, though ISO_C_BINDING
     60: ! supports INTEGER(KIND=C_SIZE_T). We don't use that here
     61: ! only to avoid importing the module.
     62: #if (PETSC_SIZEOF_SIZE_T == 8)
     63: #define PetscSizeT integer8
     64: #else
     65: #define PetscSizeT integer4
     66: #endif
     67: !
     68: #if defined(PETSC_HAVE_MPIUNI)
     69: #define MPI_Comm MPIUNI_FInt
     70: #define MPI_Group MPIUNI_FInt
     71: #define PetscMPIInt MPIUNI_FInt
     72: #else
     73: #define MPI_Comm integer4
     74: #define MPI_Group integer4
     75: #define PetscMPIInt integer4
     76: #endif
     77: !
     78: #define PetscEnum PetscFortranInt
     79: #define PetscErrorCode PetscFortranInt
     80: #define PetscClassId PetscFortranInt
     81: #define PetscLogEvent PetscFortranInt
     82: #define PetscLogStage PetscFortranInt
     83: #define PetscVoid PetscFortranAddr
     84: !
     85: #define PetscCopyMode PetscEnum
     86: !
     87: #define PetscDataType PetscEnum
     88: #define PetscFPTrap PetscEnum
     89: !
     90: #define PetscFortranFloat real(kind=selected_real_kind(5))
     91: #define PetscFortranDouble real(kind=selected_real_kind(10))
     92: #define PetscFortranLongDouble real(kind=selected_real_kind(19))
     93: #if defined(PETSC_USE_REAL_SINGLE)
     94: #define PetscFortranComplex complex(kind=selected_real_kind(5))
     95: #elif defined(PETSC_USE_REAL_DOUBLE)
     96: #define PetscFortranComplex complex(kind=selected_real_kind(10))
     97: #elif defined(PETSC_USE_REAL___FLOAT128)
     98: #define PetscFortranComplex complex(kind=selected_real_kind(20))
     99: #endif
    100: #define PetscChar(a) character(len = a) ::

    102: #if defined(PETSC_USE_COMPLEX)
    103: #define PETSC_SCALAR PETSC_COMPLEX
    104: #else
    105: #if defined(PETSC_USE_REAL_SINGLE)
    106: #define PETSC_SCALAR PETSC_FLOAT
    107: #elif defined(PETSC_USE_REAL___FLOAT128)
    108: #define PETSC_SCALAR PETSC___FLOAT128
    109: #else
    110: #define PETSC_SCALAR PETSC_DOUBLE
    111: #endif
    112: #endif
    113: #if defined(PETSC_USE_REAL_SINGLE)
    114: #define  PETSC_REAL  PETSC_FLOAT
    115: #define PetscIntToReal(a) real(a)
    116: #elif defined(PETSC_USE_REAL___FLOAT128)
    117: #define PETSC_REAL PETSC___FLOAT128
    118: #define PetscIntToReal(a) dble(a)
    119: #else
    120: #define  PETSC_REAL  PETSC_DOUBLE
    121: #define PetscIntToReal(a) dble(a)
    122: #endif
    123: !
    124: !     Macro for templating between real and complex
    125: !
    126: #define PetscComplex PetscFortranComplex
    127: #if defined(PETSC_USE_COMPLEX)
    128: #define PetscScalar PetscFortranComplex
    129: !
    130: ! F90 uses real(), conjg() when KIND parameter is used.
    131: !
    132: #define PetscRealPart(a) real(a)
    133: #define PetscConj(a) conjg(a)
    134: #define PetscImaginaryPart(a) aimag(a)
    135: #else
    136: #if defined (PETSC_USE_REAL_SINGLE)
    137: #define PetscScalar PetscFortranFloat
    138: #elif defined(PETSC_USE_REAL___FLOAT128)
    139: #define PetscScalar PetscFortranLongDouble
    140: #elif defined(PETSC_USE_REAL_DOUBLE)
    141: #define PetscScalar PetscFortranDouble
    142: #endif
    143: #define PetscRealPart(a) a
    144: #define PetscConj(a) a
    145: #define PetscImaginaryPart(a) 0.0
    146: #endif

    148: #if defined (PETSC_USE_REAL_SINGLE)
    149: #define PetscReal PetscFortranFloat
    150: #elif defined(PETSC_USE_REAL___FLOAT128)
    151: #define PetscReal PetscFortranLongDouble
    152: #elif defined(PETSC_USE_REAL_DOUBLE)
    153: #define PetscReal PetscFortranDouble
    154: #endif

    156: !
    157: !    Allows the matrix Fortran Kernels to work with single precision
    158: !    matrix data structures
    159: !
    160: #define MatScalar PetscScalar
    161: !
    162: !     PetscLogDouble variables are used to contain double precision numbers
    163: !     that are not used in the numerical computations, but rather in logging,
    164: !     timing etc.
    165: !
    166: #define PetscObject PetscFortranAddr
    167: #define PetscLogDouble PetscFortranDouble
    168: !
    169: !     Macros for error checking
    170: !
    171: #define SETERRQ(c, ierr, s)  call PetscError(c, ierr, 0, s); return
    172: #define SETERRA(c, ierr, s)  call PetscError(c, ierr, 0, s); call MPIU_Abort(c, ierr)
    173: #if defined(PETSC_HAVE_FORTRAN_FREE_LINE_LENGTH_NONE)
    174: #define CHKERRQ(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr,__LINE__,__FILE__);return;endif
    175: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr,__LINE__,__FILE__);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
    176: #define CHKERRMPI(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr,__LINE__,__FILE__);return;endif
    177: #define CHKERRMPIA(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr,__LINE__,__FILE__);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
    178: #else
    179: #define CHKERRQ(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);return;endif
    180: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
    181: #define CHKERRMPI(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr);return;endif
    182: #define CHKERRMPIA(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
    183: #endif
    184: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
    185: #define PetscCall(func) call func; CHKERRQ(ierr)
    186: #define PetscCallMPI(func) call func; CHKERRMPI(ierr)
    187: #define PetscCallA(func) call func; CHKERRA(ierr)
    188: #define PetscCallMPIA(func) call func; CHKERRMPIA(ierr)
    189: #define PetscCheckA(err, c, ierr, s) if (.not.(err)) then; SETERRA(c, ierr, s); endif
    190: #define PetscCheck(err, c, ierr, s) if (.not.(err)) then; SETERRQ(c, ierr, s); endif

    192: #define PetscMatlabEngine PetscFortranAddr

    194: #if !defined(PetscFlush)
    195: #if defined(PETSC_HAVE_FORTRAN_FLUSH)
    196: #define PetscFlush(a)    flush(a)
    197: #elif defined(PETSC_HAVE_FORTRAN_FLUSH_)
    198: #define PetscFlush(a)    flush_(a)
    199: #else
    200: #define PetscFlush(a)
    201: #endif
    202: #endif

    204: #define PetscRandom type(tPetscRandom)
    205: #define PetscRandomType character*(80)
    206: #define PetscBinarySeekType PetscEnum

    208: #define PetscBuildTwoSidedType PetscEnum

    210: #define PetscSubcomm type(tPetscSubcomm)
    211: #define PetscSubcommType PetscEnum

    213: #define PetscOptions type(tPetscOptions)

    215: #define PetscBench type(tPetscBench)

    217: #define PetscFunctionList PetscFortranAddr

    219: #define PetscInfoCommFlag PetscEnum
    220: #endif