Actual source code: petscsysdef.h
petsc-3.4.2 2013-07-02

      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 finclude/petscviewerdef.h
     14:  #include finclude/petscerrordef.h
     15:  #include finclude/petsclogdef.h
     16:  #include 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 PetscBool  logical(kind=4)
     28: #else
     29: #define integer8 integer*8
     30: #define integer4 integer*4
     31: #define PetscBool  logical*4
     32: #endif

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

     42: #if defined(PETSC_USE_64BIT_INDICES)
     43: #define PetscInt integer8
     44: #else
     45: #define PetscInt integer4
     46: #endif

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

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

    157: #if defined (PETSC_USE_REAL_SINGLE)
    158: #define PetscReal PetscFortranFloat
    159: #elif defined(PETSC_USE_REAL___FLOAT128)
    160: #define PetscReal PetscFortranLongDouble
    161: #elif defined(PETSC_USE_REAL_DOUBLE)
    162: #define PetscReal PetscFortranDouble
    163: #endif

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

    190: #define PetscMatlabEngine PetscFortranAddr

    192: #if !defined(PetscFlush)
    193: #if defined(PETSC_HAVE_FLUSH)
    194: #define PetscFlush(a)    call flush(a)
    195: #elif defined(PETSC_HAVE_FLUSH_)
    196: #define PetscFlush(a)    call flush_(a)
    197: #else
    198: #define PetscFlush(a)
    199: #endif
    200: #endif

    202: #define PetscRandom PetscFortranAddr
    203: #define PetscRandomType character*(80)
    204: #define PetscBinarySeekType PetscEnum

    206: #define PetscBuildTwoSidedType PetscEnum

    209: #endif