Actual source code: petscsys.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 (PETSCSYSDEF_H)
 11: #define 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/petsclog.h"
 19: #include "petsc/finclude/petscbag.h"

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

 27: #define integer8 integer(kind=selected_int_kind(10))
 28: #define integer4 integer(kind=selected_int_kind(5))
 29: #define integer2 integer(kind=selected_int_kind(3))
 30: #define integer1 integer(kind=selected_int_kind(1))
 31: #define PetscBool  logical(kind=4)
 32: #define PetscBool3  integer(kind=selected_int_kind(5))

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

 44: #if defined(PETSC_USE_64BIT_INDICES)
 45: #define PetscInt integer8
 46: #else
 47: #define PetscInt integer4
 48: #endif
 49: #define PetscInt64 integer8
 50: #define PetscObjectState PetscInt64
 51: #define PetscObjectId PetscInt64

 53: #if (PETSC_SIZEOF_INT == 4)
 54: #define PetscFortranInt integer4
 55: #elif (PETSC_SIZEOF_INT == 8)
 56: #define PetscFortranInt integer8
 57: #endif
 58: !
 59: ! Fortran does not support unsigned, though ISO_C_BINDING
 60: ! supports INTEGER(KIND=C_SIZE_T). We don't use that here
 61: ! only to avoid importing the module.
 62: #if (PETSC_SIZEOF_SIZE_T == 8)
 63: #define PetscSizeT integer8
 64: #else
 65: #define PetscSizeT integer4
 66: #endif
 67: !
 68: #if defined(PETSC_HAVE_MPIUNI)
 69: #define MPI_Comm MPIUNI_FInt
 70: #define MPI_Group MPIUNI_FInt
 71: #define PetscMPIInt MPIUNI_FInt
 72: #else
 73: #define MPI_Comm integer4
 74: #define MPI_Group integer4
 75: #define PetscMPIInt integer4
 76: #endif
 77: !
 78: #define PetscEnum PetscFortranInt
 79: #define PetscErrorCode PetscFortranInt
 80: #define PetscClassId PetscFortranInt
 81: #define PetscLogEvent PetscFortranInt
 82: #define PetscLogStage PetscFortranInt
 83: #define PetscVoid PetscFortranAddr
 84: !
 85: #define PetscDeviceType PetscEnum
 86: #define PetscDevice PetscFortranAddr
 87: !
 88: #define PetscCopyMode PetscEnum
 89: !
 90: #define PetscDataType PetscEnum
 91: #define PetscFPTrap PetscEnum
 92: !
 93: #define PetscFortranFloat real(kind=selected_real_kind(5))
 94: #define PetscFortranDouble real(kind=selected_real_kind(10))
 95: #define PetscFortranLongDouble real(kind=selected_real_kind(19))
 96: #if defined(PETSC_USE_REAL_SINGLE)
 97: #define PetscFortranComplex complex(kind=selected_real_kind(5))
 98: #elif defined(PETSC_USE_REAL_DOUBLE)
 99: #define PetscFortranComplex complex(kind=selected_real_kind(10))
100: #elif defined(PETSC_USE_REAL___FLOAT128)
101: #define PetscFortranComplex complex(kind=selected_real_kind(20))
102: #endif
103: #define PetscChar(a) character(len = a) ::

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

151: #if defined (PETSC_USE_REAL_SINGLE)
152: #define PetscReal PetscFortranFloat
153: #elif defined(PETSC_USE_REAL___FLOAT128)
154: #define PetscReal PetscFortranLongDouble
155: #elif defined(PETSC_USE_REAL_DOUBLE)
156: #define PetscReal PetscFortranDouble
157: #endif

159: !
160: !    Allows the matrix Fortran Kernels to work with single precision
161: !    matrix data structures
162: !
163: #define MatScalar PetscScalar
164: !
165: !     PetscLogDouble variables are used to contain double precision numbers
166: !     that are not used in the numerical computations, but rather in logging,
167: !     timing etc.
168: !
169: #define PetscObject PetscFortranAddr
170: #define PetscLogDouble PetscFortranDouble
171: !
172: !     Macros for error checking
173: !
174: #define SETERRQ(c, ierr, s)  call PetscError(c, ierr, 0, s); return
175: #define SETERRA(c, ierr, s)  call PetscError(c, ierr, 0, s); call MPIU_Abort(c, ierr)
176: #if defined(PETSC_HAVE_FORTRAN_FREE_LINE_LENGTH_NONE)
177: #define CHKERRQ(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr,__LINE__,__FILE__);return;endif
178: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr,__LINE__,__FILE__);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
179: #define CHKERRMPI(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr,__LINE__,__FILE__);return;endif
180: #define CHKERRMPIA(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr,__LINE__,__FILE__);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
181: #else
182: #define CHKERRQ(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);return;endif
183: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
184: #define CHKERRMPI(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr);return;endif
185: #define CHKERRMPIA(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
186: #endif
187: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
188: #define PetscCall(func) call func; CHKERRQ(ierr)
189: #define PetscCallMPI(func) call func; CHKERRMPI(ierr)
190: #define PetscCallA(func) call func; CHKERRA(ierr)
191: #define PetscCallMPIA(func) call func; CHKERRMPIA(ierr)
192: #define PetscCheckA(err, c, ierr, s) if (.not.(err)) then; SETERRA(c, ierr, s); endif
193: #define PetscCheck(err, c, ierr, s) if (.not.(err)) then; SETERRQ(c, ierr, s); endif

195: #define PetscMatlabEngine PetscFortranAddr

197: #if !defined(PetscFlush)
198: #if defined(PETSC_HAVE_FORTRAN_FLUSH)
199: #define PetscFlush(a)    flush(a)
200: #elif defined(PETSC_HAVE_FORTRAN_FLUSH_)
201: #define PetscFlush(a)    flush_(a)
202: #else
203: #define PetscFlush(a)
204: #endif
205: #endif

207: #define PetscRandom type(tPetscRandom)
208: #define PetscRandomType character*(80)
209: #define PetscBinarySeekType PetscEnum

211: #define PetscBuildTwoSidedType PetscEnum

213: #define PetscSubcomm type(tPetscSubcomm)
214: #define PetscSubcommType PetscEnum

216: #define PetscOptions type(tPetscOptions)

218: #define PetscBench type(tPetscBench)

220: #define PetscFunctionList PetscFortranAddr

222: #define PetscInfoCommFlag PetscEnum
223: #endif