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: ! The real*8,complex*16 notatiton is used so that the
 16: ! PETSc double/complex variables are not affected by
 17: ! compiler options like -r4,-r8, sometimes invoked
 18: ! by the user. NAG compiler does not like integer*4,real*8

 20: #if defined(PETSC_USE_FORTRANKIND)
 21: #define integer8 integer(kind=selected_int_kind(10))
 22: #define integer4 integer(kind=selected_int_kind(5))
 23: #define PetscTruth logical(kind=4)
 24: #else
 25: #define integer8 integer*8
 26: #define integer4 integer*4
 27: #define PetscTruth logical*4
 28: #endif

 30: #if (PETSC_SIZEOF_VOID_P == 8)
 31: #define PetscFortranAddr integer8
 32: #define PetscOffset integer8
 33: #else
 34: #define PetscOffset integer4
 35: #define PetscFortranAddr integer4
 36: #endif

 38: #if defined(PETSC_USE_64BIT_INDICES)
 39: #define PetscInt integer8
 40: #else
 41: #define PetscInt integer4
 42: #endif

 44: #if (PETSC_SIZEOF_INT == 4)
 45: #define PetscFortranInt integer4
 46: #elif (PETSC_SIZEOF_INT == 8)
 47: #define PetscFortranInt integer8
 48: #endif
 49: !
 50: #if (PETSC_SIZEOF_SIZE_T == 8)
 51: #define PetscSizeT integer8
 52: #else
 53: #define PetscSizeT integer4
 54: #endif
 55: !
 56: #if defined(PETSC_HAVE_MPIUNI)
 57: #define MPI_Comm PetscFortranInt
 58: #define PetscMPIInt PetscFortranInt
 59: #else
 60: #define MPI_Comm integer
 61: #define PetscMPIInt integer
 62: #endif
 63: !
 64: #define PetscEnum PetscFortranInt
 65: #define PetscErrorCode PetscFortranInt
 66: #define PetscCookie PetscFortranInt
 67: #define PetscEvent PetscFortranInt
 68: !
 69: #if defined(PETSC_FORTRAN_PETSCTRUTH_INT)
 70: #undef PetscTruth
 71: #define PetscTruth PetscEnum
 72: #endif
 73: !
 74: #define PetscDataType PetscEnum
 75: #define PetscFPTrap PetscEnum
 76: !
 77: #if defined (PETSC_USE_FORTRANKIND)
 78: #define PetscFortranFloat real(kind=selected_real_kind(5))
 79: #define PetscFortranDouble real(kind=selected_real_kind(10))
 80: #define PetscFortranLongDouble real(kind=selected_real_kind(16))
 81: #define PetscFortranComplex complex(kind=selected_real_kind(10))
 82: #define PetscChar(a) character(len = a) ::
 83: #else
 84: #define PetscFortranFloat real*4
 85: #define PetscFortranDouble real*8
 86: #define PetscFortranLongDouble real*16
 87: #define PetscFortranComplex complex*16
 88: #define PetscChar(a) character*(a)
 89: #endif

 91: #if defined(PETSC_USE_COMPLEX)
 92: #define PETSC_SCALAR PETSC_COMPLEX
 93: #else
 94: #if defined(PETSC_USE_SINGLE)
 95: #define PETSC_SCALAR PETSC_FLOAT
 96: #elif defined(PETSC_USE_LONG_DOUBLE)
 97: #define PETSC_SCALAR PETSC_LONG_DOUBLE
 98: #else
 99: #define PETSC_SCALAR PETSC_DOUBLE
100: #endif     
101: #endif
102: !
103: !     Macro for templating between real and complex
104: !
105: #if defined(PETSC_USE_COMPLEX)
106: #define PetscScalar PetscFortranComplex
107: !
108: ! F90 uses real(), conjg() when KIND parameter is used.
109: !
110: #if defined (PETSC_MISSING_DREAL)
111: #define PetscRealPart(a) real(a)
112: #define PetscConj(a) conjg(a)
113: #define PetscImaginaryPart(a) aimg(a)
114: #else
115: #define PetscRealPart(a) dreal(a)
116: #define PetscConj(a) dconjg(a)
117: #define PetscImaginaryPart(a) daimg(a)
118: #endif
119: #define MPIU_SCALAR MPI_DOUBLE_COMPLEX
120: #else
121: #if defined (PETSC_USE_SINGLE)
122: #define PetscScalar PetscFortranFloat
123: #define MPIU_SCALAR MPI_REAL
124: #elif defined(PETSC_USE_LONG_DOUBLE)
125: #define PetscScalar PetscFortranLongDouble
126: #define MPIU_SCALAR MPI_2DOUBLE_PRECISION
127: #else
128: #define PetscScalar PetscFortranDouble
129: #define MPIU_SCALAR MPI_DOUBLE_PRECISION
130: #endif
131: #define PetscRealPart(a) a
132: #define PetscConj(a) a
133: #define PetscImaginaryPart(a) a
134: #endif

136: #if defined (PETSC_USE_SINGLE)
137: #define PetscReal PetscFortranFloat
138: #elif defined(PETSC_USE_LONG_DOUBLE)
139: #define PetscReal PetscFortranLongDouble
140: #else
141: #define PetscReal PetscFortranDouble
142: #endif

144: !
145: !    Allows the matrix Fortran Kernels to work with single precision
146: !    matrix data structures
147: !
148: #if defined(PETSC_USE_COMPLEX)
149: #define MatScalar PetscScalar 
150: #elif defined(PETSC_USE_MAT_SINGLE)
151: #define MatScalar real*4
152: #else
153: #define MatScalar PetscScalar
154: #endif
155: !
156: !     PetscLogDouble variables are used to contain double precision numbers
157: !     that are not used in the numerical computations, but rather in logging,
158: !     timing etc.
159: !
160: #define PetscObject PetscFortranAddr
161: #define PetscLogDouble PetscFortranDouble
162: !
163: !     Macros for error checking
164: !
165: #if defined(PETSC_USE_ERRORCHECKING)
166: #define SETERRQ(n,s,ierr) call MPI_Abort(PETSC_COMM_WORLD,n,ierr)
167: #define CHKERRQ(n) if (n .ne. 0) call MPI_Abort(PETSC_COMM_WORLD,n,n)
168: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
169: #else
170: #define SETERRQ(n,s,ierr)
171: #define CHKERRQ(n)
172: #define CHKMEMQ
173: #endif

175: #define PetscMatlabEngine PetscFortranAddr

177: #if defined(PETSC_STDCALL)
178: #define PETSC_DEC_ATTRIBUTES(A,B) DEC$ ATTRIBUTESC, ALIAS:B ::A
179: #else
180: #define PETSC_DEC_ATTRIBUTES(A,B)
181: #endif

183: #if !defined(PetscFlush)
184: #if defined(PETSC_HAVE_FLUSH)
185: #define PetscFlush(a)    call flush(a)
186: #elif defined(PETSC_HAVE_FLUSH_)
187: #define PetscFlush(a)    call flush_(a)
188: #else
189: #define PetscFlush(a)
190: #endif
191: #endif

193: #endif