Date: 2022-03-31T04:49:11+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)

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

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

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

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

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

    155: !
    156: !    Allows the matrix Fortran Kernels to work with single precision
    157: !    matrix data structures
    158: !
    159: #define MatScalar PetscScalar
    160: !
    161: !     PetscLogDouble variables are used to contain double precision numbers
    162: !     that are not used in the numerical computations, but rather in logging,
    163: !     timing etc.
    164: !
    165: #define PetscObject PetscFortranAddr
    166: #define PetscLogDouble PetscFortranDouble
    167: !
    168: !     Macros for error checking
    169: !
    170: #define SETERRQ(c,ierr,s)  call PetscError(c,ierr,0,s); return
    171: #define SETERRA(c,ierr,s)  call PetscError(c,ierr,0,s); call MPIU_Abort(c,ierr)
    172: #define SETERRABORT(c,ierr,s)  call PetscError(c,ierr,0,s); call MPI_Abort(c,ierr)
    173: #define ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr;return;endif
    174: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
    175: #define c,ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);call MPI_Abort(c,ierr;endif
    176: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)

    178: #define PetscMatlabEngine PetscFortranAddr

    180: #if !defined(PetscFlush)
    181: #if defined(PETSC_HAVE_FORTRAN_FLUSH)
    182: #define PetscFlush(a)    flush(a)
    183: #elif defined(PETSC_HAVE_FORTRAN_FLUSH_)
    184: #define PetscFlush(a)    flush_(a)
    185: #else
    186: #define PetscFlush(a)
    187: #endif
    188: #endif

    190: #define PetscRandom type(tPetscRandom)
    191: #define PetscRandomType character*(80)
    192: #define PetscBinarySeekType PetscEnum

    194: #define PetscBuildTwoSidedType PetscEnum

    196: #define PetscSubcomm type(tPetscSubcomm)
    197: #define PetscSubcommType PetscEnum

    199: #define PetscOptions type(tPetscOptions)

    201: #define PetscFunctionList PetscFortranAddr

    203: #define PetscInfoCommFlag PetscEnum
    204: #endif