Actual source code: petscsys.h
petsc-3.10.5 2019-03-28
Report Typos and Errors

      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)
     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/petscerror.h"
     19: #include "petsc/finclude/petsclog.h"
     20: #include "petsc/finclude/petscbag.h"

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

     28: #if defined(PETSC_USE_FORTRANKIND)
     29: #define integer8 integer(kind=selected_int_kind(10))
     30: #define integer4 integer(kind=selected_int_kind(5))
     31: #define integer2 integer(kind=selected_int_kind(3))
     32: #define integer1 integer(kind=selected_int_kind(1))
     33: #define PetscBool  logical(kind=4)
     34: #else
     35: #define integer8 integer*8
     36: #define integer4 integer*4
     37: #define integer2 integer*2
     38: #define integer1 integer*1
     39: #define PetscBool  logical*4
     40: #endif

     42: #if (PETSC_SIZEOF_VOID_P == 8)
     43: #define PetscOffset integer8
     44: #define PetscFortranAddr integer8
     45: #else
     46: #define PetscOffset integer4
     47: #define PetscFortranAddr integer4
     48: #endif

     50: #if defined(PETSC_USE_64BIT_INDICES)
     51: #define PetscInt integer8
     52: #else
     53: #define PetscInt integer4
     54: #endif
     55: #define PetscInt64 integer8
     56: #if defined(PETSC_USING_F90) && !defined(PETSC_USE_FORTRANKIND)
     57: #define PetscObjectState integer4
     58: #define PetscObjectId integer4
     59: #else
     60: #define PetscObjectState PetscInt64
     61: #define PetscObjectId PetscInt64
     62: #endif

     64: #if (PETSC_SIZEOF_INT == 4)
     65: #define PetscFortranInt integer4
     66: #elif (PETSC_SIZEOF_INT == 8)
     67: #define PetscFortranInt integer8
     68: #endif
     69: !
     70: #if (PETSC_SIZEOF_SIZE_T == 8)
     71: #define PetscSizeT integer8
     72: #else
     73: #define PetscSizeT integer4
     74: #endif
     75: !
     76: #if defined(PETSC_HAVE_MPIUNI)
     77: #define MPI_Comm PetscFortranInt
     78: #define MPI_Group PetscFortranInt
     79: #define PetscMPIInt PetscFortranInt
     80: #else
     81: #define MPI_Comm integer
     82: #define MPI_Group integer
     83: #define PetscMPIInt integer
     84: #endif
     85: !
     86: #define PetscEnum PetscFortranInt
     87: #define PetscErrorCode PetscFortranInt
     88: #define PetscClassId PetscFortranInt
     89: #define PetscLogEvent PetscFortranInt
     90: #define PetscLogStage PetscFortranInt
     91: #define PetscVoid PetscFortranAddr
     92: !
     93: #if defined(PETSC_FORTRAN_PETSCTRUTH_INT)
     94: #undef PetscBool
     95: #define PetscBool  PetscEnum
     96: #endif
     97: !
     98: #define PetscCopyMode PetscEnum
     99: !
    100: #define PetscDataType PetscEnum
    101: #define PetscFPTrap PetscEnum
    102: !
    103: #if defined (PETSC_USE_FORTRANKIND)
    104: #define PetscFortranFloat real(kind=selected_real_kind(5))
    105: #define PetscFortranDouble real(kind=selected_real_kind(10))
    106: #define PetscFortranLongDouble real(kind=selected_real_kind(19))
    107: #if defined(PETSC_USE_REAL_SINGLE)
    108: #define PetscFortranComplex complex(kind=selected_real_kind(5))
    109: #elif defined(PETSC_USE_REAL_DOUBLE)
    110: #define PetscFortranComplex complex(kind=selected_real_kind(10))
    111: #elif defined(PETSC_USE_REAL___FLOAT128)
    112: #define PetscFortranComplex complex(kind=selected_real_kind(20))
    113: #endif
    114: #define PetscChar(a) character(len = a) ::
    115: #else
    116: #define PetscFortranFloat real*4
    117: #define PetscFortranDouble real*8
    118: #define PetscFortranLongDouble real*16
    119: #if defined(PETSC_USE_REAL_SINGLE)
    120: #define PetscFortranComplex complex*8
    121: #elif defined(PETSC_USE_REAL_DOUBLE)
    122: #define PetscFortranComplex complex*16
    123: #elif defined(PETSC_USE_REAL___FLOAT128)
    124: #define PetscFortranComplex complex*32
    125: #endif
    126: #define PetscChar(a) character*(a)
    127: #endif

    129: #if defined(PETSC_USE_COMPLEX)
    130: #define PETSC_SCALAR PETSC_COMPLEX
    131: #else
    132: #if defined(PETSC_USE_REAL_SINGLE)
    133: #define PETSC_SCALAR PETSC_FLOAT
    134: #elif defined(PETSC_USE_REAL___FLOAT128)
    135: #define PETSC_SCALAR PETSC___FLOAT128
    136: #else
    137: #define PETSC_SCALAR PETSC_DOUBLE
    138: #endif
    139: #endif
    140: #if defined(PETSC_USE_REAL_SINGLE)
    141: #define  PETSC_REAL  PETSC_FLOAT
    142: #define PetscIntToReal(a) real(a)
    143: #elif defined(PETSC_USE_REAL___FLOAT128)
    144: #define PETSC_REAL PETSC___FLOAT128
    145: #define PetscIntToReal(a) dble(a)
    146: #else
    147: #define  PETSC_REAL  PETSC_DOUBLE
    148: #define PetscIntToReal(a) dble(a)
    149: #endif
    150: !
    151: !     Macro for templating between real and complex
    152: !
    153: #define PetscComplex PetscFortranComplex
    154: #if defined(PETSC_USE_COMPLEX)
    155: #define PetscScalar PetscFortranComplex
    156: !
    157: ! F90 uses real(), conjg() when KIND parameter is used.
    158: !
    159: #define PetscRealPart(a) real(a)
    160: #define PetscConj(a) conjg(a)
    161: #define PetscImaginaryPart(a) aimag(a)
    162: #else
    163: #if defined (PETSC_USE_REAL_SINGLE)
    164: #define PetscScalar PetscFortranFloat
    165: #elif defined(PETSC_USE_REAL___FLOAT128)
    166: #define PetscScalar PetscFortranLongDouble
    167: #elif defined(PETSC_USE_REAL_DOUBLE)
    168: #define PetscScalar PetscFortranDouble
    169: #endif
    170: #define PetscRealPart(a) a
    171: #define PetscConj(a) a
    172: #define PetscImaginaryPart(a) 0.0
    173: #endif

    175: #if defined (PETSC_USE_REAL_SINGLE)
    176: #define PetscReal PetscFortranFloat
    177: #elif defined(PETSC_USE_REAL___FLOAT128)
    178: #define PetscReal PetscFortranLongDouble
    179: #elif defined(PETSC_USE_REAL_DOUBLE)
    180: #define PetscReal PetscFortranDouble
    181: #endif

    183: !
    184: !    Allows the matrix Fortran Kernels to work with single precision
    185: !    matrix data structures
    186: !
    187: #define MatScalar PetscScalar
    188: !
    189: !     PetscLogDouble variables are used to contain double precision numbers
    190: !     that are not used in the numerical computations, but rather in logging,
    191: !     timing etc.
    192: !
    193: #define PetscObject PetscFortranAddr
    194: #define PetscLogDouble PetscFortranDouble
    195: !
    196: !     Macros for error checking
    197: !
    198: #define SETERRQ(c,ierr,s)  call PetscError(c,ierr,0,s); return
    199: #define SETERRA(c,ierr,s)  call PetscError(c,ierr,0,s); call MPIU_Abort(c,ierr)
    200: #define CHKERRQ(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);return;endif
    201: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);call MPIU_Abort(MPI_COMM_SELF,ierr);endif
    202: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)

    204: #define PetscMatlabEngine PetscFortranAddr

    206: #if !defined(PetscFlush)
    207: #if defined(PETSC_HAVE_FORTRAN_FLUSH)
    208: #define PetscFlush(a)    flush(a)
    209: #elif defined(PETSC_HAVE_FORTRAN_FLUSH_)
    210: #define PetscFlush(a)    flush_(a)
    211: #else
    212: #define PetscFlush(a)
    213: #endif
    214: #endif

    216: #define PetscRandom type(tPetscRandom)
    217: #define PetscRandomType character*(80)
    218: #define PetscBinarySeekType PetscEnum

    220: #define PetscBuildTwoSidedType PetscEnum
    221: #define PetscSubcommType PetscEnum

    223: #define PetscOptions type(tPetscOptions)

    225: #define PetscFunctionList PetscFortranAddr

    227: #endif