Actual source code: petscsysdef.h
petsc-3.6.2 2015-10-02
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:  #include petsc/finclude/petscviewerdef.h
     14:  #include petsc/finclude/petscerrordef.h
     15:  #include petsc/finclude/petsclogdef.h
     16:  #include petsc/finclude/petscdrawdef.h

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

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

     38: #if (PETSC_SIZEOF_VOID_P == 8)
     39: #define PetscFortranAddr integer8
     40: #define PetscOffset integer8
     41: #else
     42: #define PetscOffset integer4
     43: #define PetscFortranAddr integer4
     44: #endif

     46: #if defined(PETSC_USE_64BIT_INDICES)
     47: #define PetscInt integer8
     48: #else
     49: #define PetscInt integer4
     50: #endif
     51: #define Petsc64bitInt integer8
     52: #define PetscObjectState Petsc64bitInt

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

    119: #if defined(PETSC_USE_COMPLEX)
    120: #define PETSC_SCALAR PETSC_COMPLEX
    121: #else
    122: #if defined(PETSC_USE_REAL_SINGLE)
    123: #define PETSC_SCALAR PETSC_FLOAT
    124: #elif defined(PETSC_USE_REAL___FLOAT128)
    125: #define PETSC_SCALAR PETSC___FLOAT128
    126: #else
    127: #define PETSC_SCALAR PETSC_DOUBLE
    128: #endif
    129: #endif
    130: #if defined(PETSC_USE_REAL_SINGLE)
    131: #define  PETSC_REAL  PETSC_FLOAT
    132: #elif defined(PETSC_USE_REAL___FLOAT128)
    133: #define PETSC_REAL PETSC___FLOAT128
    134: #else
    135: #define  PETSC_REAL  PETSC_DOUBLE
    136: #endif
    137: !
    138: !     Macro for templating between real and complex
    139: !
    140: #if defined(PETSC_USE_COMPLEX)
    141: #define PetscScalar PetscFortranComplex
    142: !
    143: ! F90 uses real(), conjg() when KIND parameter is used.
    144: !
    145: #define PetscRealPart(a) real(a)
    146: #define PetscConj(a) conjg(a)
    147: #define PetscImaginaryPart(a) aimag(a)
    148: #else
    149: #if defined (PETSC_USE_REAL_SINGLE)
    150: #define PetscScalar PetscFortranFloat
    151: #elif defined(PETSC_USE_REAL___FLOAT128)
    152: #define PetscScalar PetscFortranLongDouble
    153: #elif defined(PETSC_USE_REAL_DOUBLE)
    154: #define PetscScalar PetscFortranDouble
    155: #endif
    156: #define PetscRealPart(a) a
    157: #define PetscConj(a) a
    158: #define PetscImaginaryPart(a) a
    159: #endif

    161: #if defined (PETSC_USE_REAL_SINGLE)
    162: #define PetscReal PetscFortranFloat
    163: #elif defined(PETSC_USE_REAL___FLOAT128)
    164: #define PetscReal PetscFortranLongDouble
    165: #elif defined(PETSC_USE_REAL_DOUBLE)
    166: #define PetscReal PetscFortranDouble
    167: #endif

    169: !
    170: !    Allows the matrix Fortran Kernels to work with single precision
    171: !    matrix data structures
    172: !
    173: #define MatScalar PetscScalar
    174: !
    175: !     PetscLogDouble variables are used to contain double precision numbers
    176: !     that are not used in the numerical computations, but rather in logging,
    177: !     timing etc.
    178: !
    179: #define PetscObject PetscFortranAddr
    180: #define PetscLogDouble PetscFortranDouble
    181: !
    182: !     Macros for error checking
    183: !
    184: #if defined(PETSC_USE_ERRORCHECKING)
    185: #define SETERRQ(c,n,s,ierr) call MPI_Abort(PETSC_COMM_WORLD,n,ierr)
    186: #define CHKERRQ(n) if (n .ne. 0) call MPI_Abort(PETSC_COMM_WORLD,n,n)
    187: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
    188: #else
    189: #define SETERRQ(c,n,s,ierr)
    190: #define CHKERRQ(n)
    191: #define CHKMEMQ
    192: #endif

    194: #define PetscMatlabEngine PetscFortranAddr

    196: #if !defined(PetscFlush)
    197: #if defined(PETSC_HAVE_FLUSH)
    198: #define PetscFlush(a)    call flush(a)
    199: #elif defined(PETSC_HAVE_FLUSH_)
    200: #define PetscFlush(a)    call flush_(a)
    201: #else
    202: #define PetscFlush(a)
    203: #endif
    204: #endif

    206: #define PetscRandom PetscFortranAddr
    207: #define PetscRandomType character*(80)
    208: #define PetscBinarySeekType PetscEnum

    210: #define PetscBuildTwoSidedType PetscEnum

    213: #endif