Actual source code: petscdef.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 (__PETSCDEF_H)
 12: !
 13: #include "petscconf.h"
 14: !
 15: #define MPI_Comm integer
 16: !
 17: #define PetscEnum integer
 18: !
 19: #define PetscTruth PetscEnum
 20: #define PetscDataType PetscEnum
 21: #define PetscFPTrap PetscEnum

 23: #define PetscErrorCode integer
 24: #define PetscCookie integer
 25: #define PetscEvent integer
 26: #define PetscMPIInt integer
 27: !
 28: !
 29: ! The real*8,complex*16 notatiton is used so that the
 30: ! PETSc double/complex variables are not affected by
 31: ! compiler options like -r4,-r8, sometimes invoked
 32: ! by the user. NAG compiler does not like integer*4,real*8

 34: #if defined(PETSC_USE_FORTRANKIND)
 35: #define integer8 integer(kind=selected_int_kind(10))
 36: #define integer4 integer(kind=selected_int_kind(5))
 37: #else
 38: #define integer8 integer*8
 39: #define integer4 integer*4
 40: #endif

 42: #if (PETSC_SIZEOF_VOID_P == 8)
 43: #define PetscFortranAddr integer8
 44: #define PetscOffset 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

 56: #if defined (PETSC_USE_FORTRANKIND)
 57: #define PetscFortranFloat real(kind=selected_real_kind(5))
 58: #define PetscFortranDouble real(kind=selected_real_kind(10))
 59: #define PetscFortranLongDouble real(kind=selected_real_kind(16))
 60: #define PetscFortranComplex complex(kind=selected_real_kind(10))
 61: #define PetscChar(a) character(len = a) ::
 62: #else
 63: #define PetscFortranFloat real*4
 64: #define PetscFortranDouble real*8
 65: #define PetscFortranLongDouble real*16
 66: #define PetscFortranComplex complex*16
 67: #define PetscChar(a) character*(a)
 68: #endif

 70: #if defined(PETSC_USE_COMPLEX)
 71: #define PETSC_SCALAR PETSC_COMPLEX
 72: #else
 73: #if defined(PETSC_USE_SINGLE)
 74: #define PETSC_SCALAR PETSC_FLOAT
 75: #elif defined(PETSC_USE_LONG_DOUBLE)
 76: #define PETSC_SCALAR PETSC_LONG_DOUBLE
 77: #else
 78: #define PETSC_SCALAR PETSC_DOUBLE
 79: #endif     
 80: #endif
 81: !
 82: !     Macro for templating between real and complex
 83: !
 84: #if defined(PETSC_USE_COMPLEX)
 85: #define PetscScalar PetscFortranComplex
 86: !
 87: ! F90 uses real(), conjg() when KIND parameter is used.
 88: !
 89: #if defined (PETSC_MISSING_DREAL)
 90: #define PetscRealPart(a) real(a)
 91: #define PetscConj(a) conjg(a)
 92: #define PetscImaginaryPart(a) aimg(a)
 93: #else
 94: #define PetscRealPart(a) dreal(a)
 95: #define PetscConj(a) dconjg(a)
 96: #define PetscImaginaryPart(a) daimg(a)
 97: #endif
 98: #define MPIU_SCALAR MPI_DOUBLE_COMPLEX
 99: #else
100: #if defined (PETSC_USE_SINGLE)
101: #define PetscScalar PetscFortranFloat
102: #define MPIU_SCALAR MPI_REAL
103: #elif defined(PETSC_USE_LONG_DOUBLE)
104: #define PetscScalar PetscFortranLongDouble
105: #define MPIU_SCALAR MPI_2DOUBLE_PRECISION
106: #else
107: #define PetscScalar PetscFortranDouble
108: #define MPIU_SCALAR MPI_DOUBLE_PRECISION
109: #endif
110: #define PetscRealPart(a) a
111: #define PetscConj(a) a
112: #define PetscImaginaryPart(a) a
113: #endif

115: #if defined (PETSC_USE_SINGLE)
116: #define PetscReal PetscFortranFloat
117: #elif defined(PETSC_USE_LONG_DOUBLE)
118: #define PetscReal PetscFortranLongDouble
119: #else
120: #define PetscReal PetscFortranDouble
121: #endif

123: !
124: !    Allows the matrix Fortran Kernels to work with single precision
125: !    matrix data structures
126: !
127: #if defined(PETSC_USE_COMPLEX)
128: #define MatScalar PetscScalar 
129: #elif defined(PETSC_USE_MAT_SINGLE)
130: #define MatScalar real*4
131: #else
132: #define MatScalar PetscScalar
133: #endif
134: !
135: !     PetscLogDouble variables are used to contain double precision numbers
136: !     that are not used in the numerical computations, but rather in logging,
137: !     timing etc.
138: !
139: #define PetscObject PetscFortranAddr
140: #define PetscLogDouble PetscFortranDouble
141: !
142: !     Macros for error checking
143: !
144: #if defined(PETSC_USE_ERRORCHECKING)
145: #define SETERRQ(n,s,ierr) call MPI_Abort(PETSC_COMM_WORLD,n,ierr)
146: #define CHKERRQ(n) if (n .ne. 0) call MPI_Abort(PETSC_COMM_WORLD,n,n)
147: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
148: #else
149: #define SETERRQ(n,s,ierr)
150: #define CHKERRQ(n)
151: #define CHKMEMQ
152: #endif

154: #define PetscMatlabEngine PetscFortranAddr

156: #if defined(PETSC_STDCALL)
157: #define PETSC_DEC_ATTRIBUTES(A,B) DEC$ ATTRIBUTESC, ALIAS:B ::A
158: #else
159: #define PETSC_DEC_ATTRIBUTES(A,B)
160: #endif

162: #endif