Actual source code: petscsys.h

petsc-master 2019-09-15
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)
 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/petscerror.h"
 19: #include "petsc/finclude/petsclog.h"
 20: #include "petsc/finclude/petscbag.h"

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

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

 42: #if (PETSC_SIZEOF_VOID_P == 8)
 43: #define PetscOffset integer8
 44: #define PetscFortranAddr 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
 55: #define PetscInt64 integer8
 56: #if defined(PETSC_USING_F90) && !defined(PETSC_USE_FORTRANKIND)
 57: #define PetscObjectState integer4
 58: #define PetscObjectId integer4
 59: #else
 60: #define PetscObjectState PetscInt64
 61: #define PetscObjectId PetscInt64
 62: #endif

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

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

170: #if defined (PETSC_USE_REAL_SINGLE)
171: #define PetscReal PetscFortranFloat
172: #elif defined(PETSC_USE_REAL___FLOAT128)
173: #define PetscReal PetscFortranLongDouble
174: #elif defined(PETSC_USE_REAL_DOUBLE)
175: #define PetscReal PetscFortranDouble
176: #endif

178: !
179: !    Allows the matrix Fortran Kernels to work with single precision
180: !    matrix data structures
181: !
182: #define MatScalar PetscScalar
183: !
184: !     PetscLogDouble variables are used to contain double precision numbers
185: !     that are not used in the numerical computations, but rather in logging,
186: !     timing etc.
187: !
188: #define PetscObject PetscFortranAddr
189: #define PetscLogDouble PetscFortranDouble
190: !
191: !     Macros for error checking
192: !
193: #define SETERRQ(c,ierr,s)  call PetscError(c,ierr,0,s); return
194: #define SETERRA(c,ierr,s)  call PetscError(c,ierr,0,s); call MPIU_Abort(c,ierr)
195: #define CHKERRQ(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);return;endif
196: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);call MPIU_Abort(MPI_COMM_SELF,ierr);endif
197: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)

199: #define PetscMatlabEngine PetscFortranAddr

201: #if !defined(PetscFlush)
202: #if defined(PETSC_HAVE_FORTRAN_FLUSH)
203: #define PetscFlush(a)    flush(a)
204: #elif defined(PETSC_HAVE_FORTRAN_FLUSH_)
205: #define PetscFlush(a)    flush_(a)
206: #else
207: #define PetscFlush(a)
208: #endif
209: #endif

211: #define PetscRandom type(tPetscRandom)
212: #define PetscRandomType character*(80)
213: #define PetscBinarySeekType PetscEnum

215: #define PetscBuildTwoSidedType PetscEnum
216: #define PetscSubcommType PetscEnum

218: #define PetscOptions type(tPetscOptions)

220: #define PetscFunctionList PetscFortranAddr

222: #endif