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 type(tPetscDevice)
87: #define PetscDeviceContext type(tPetscDeviceContext)
88: !
89: #define PetscCopyMode PetscEnum
90: !
91: #define PetscDataType PetscEnum
92: #define PetscFPTrap PetscEnum
93: !
94: #define PetscFortranFloat real(kind=selected_real_kind(5))
95: #define PetscFortranDouble real(kind=selected_real_kind(10))
96: #define PetscFortranLongDouble real(kind=selected_real_kind(19))
97: #if defined(PETSC_USE_REAL_SINGLE)
98: #define PetscFortranComplex complex(kind=selected_real_kind(5))
99: #elif defined(PETSC_USE_REAL_DOUBLE)
100: #define PetscFortranComplex complex(kind=selected_real_kind(10))
101: #elif defined(PETSC_USE_REAL___FLOAT128)
102: #define PetscFortranComplex complex(kind=selected_real_kind(20))
103: #endif
104: #define PetscChar(a) character(len = a) ::
106: #if defined(PETSC_USE_COMPLEX)
107: #define PETSC_SCALAR PETSC_COMPLEX
108: #else
109: #if defined(PETSC_USE_REAL_SINGLE)
110: #define PETSC_SCALAR PETSC_FLOAT
111: #elif defined(PETSC_USE_REAL___FLOAT128)
112: #define PETSC_SCALAR PETSC___FLOAT128
113: #else
114: #define PETSC_SCALAR PETSC_DOUBLE
115: #endif
116: #endif
117: #if defined(PETSC_USE_REAL_SINGLE)
118: #define PETSC_REAL PETSC_FLOAT
119: #define PetscIntToReal(a) real(a)
120: #elif defined(PETSC_USE_REAL___FLOAT128)
121: #define PETSC_REAL PETSC___FLOAT128
122: #define PetscIntToReal(a) dble(a)
123: #else
124: #define PETSC_REAL PETSC_DOUBLE
125: #define PetscIntToReal(a) dble(a)
126: #endif
127: !
128: ! Macro for templating between real and complex
129: !
130: #define PetscComplex PetscFortranComplex
131: #if defined(PETSC_USE_COMPLEX)
132: #define PetscScalar PetscFortranComplex
133: !
134: ! F90 uses real(), conjg() when KIND parameter is used.
135: !
136: #define PetscRealPart(a) real(a)
137: #define PetscConj(a) conjg(a)
138: #define PetscImaginaryPart(a) aimag(a)
139: #else
140: #if defined (PETSC_USE_REAL_SINGLE)
141: #define PetscScalar PetscFortranFloat
142: #elif defined(PETSC_USE_REAL___FLOAT128)
143: #define PetscScalar PetscFortranLongDouble
144: #elif defined(PETSC_USE_REAL_DOUBLE)
145: #define PetscScalar PetscFortranDouble
146: #endif
147: #define PetscRealPart(a) a
148: #define PetscConj(a) a
149: #define PetscImaginaryPart(a) 0.0
150: #endif
152: #if defined (PETSC_USE_REAL_SINGLE)
153: #define PetscReal PetscFortranFloat
154: #elif defined(PETSC_USE_REAL___FLOAT128)
155: #define PetscReal PetscFortranLongDouble
156: #elif defined(PETSC_USE_REAL_DOUBLE)
157: #define PetscReal PetscFortranDouble
158: #endif
160: !
161: ! Allows the matrix Fortran Kernels to work with single precision
162: ! matrix data structures
163: !
164: #define MatScalar PetscScalar
165: !
166: ! PetscLogDouble variables are used to contain double precision numbers
167: ! that are not used in the numerical computations, but rather in logging,
168: ! timing etc.
169: !
170: #define PetscObject type(tPetscObject)
171: #define PetscLogDouble PetscFortranDouble
172: !
173: #define PetscObjectIsNull(obj) (obj%v == 0 .or. obj%v == -2 .or. obj%v == -3)
174: !
175: ! Macros for error checking
176: !
177: #define SETERRQ(c, ierr, s) call PetscError(c, ierr, 0, s); return
178: #define SETERRA(c, ierr, s) call PetscError(c, ierr, 0, s); call MPIU_Abort(c, ierr)
179: #if defined(PETSC_HAVE_FORTRAN_FREE_LINE_LENGTH_NONE)
180: #define CHKERRQ(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr,__LINE__,__FILE__);return;endif
181: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr,__LINE__,__FILE__);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
182: #define CHKERRMPI(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr,__LINE__,__FILE__);return;endif
183: #define CHKERRMPIA(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr,__LINE__,__FILE__);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
184: #else
185: #define CHKERRQ(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);return;endif
186: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
187: #define CHKERRMPI(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr);return;endif
188: #define CHKERRMPIA(ierr) if (ierr .ne. 0) then;call PetscErrorMPI(ierr);call MPIU_Abort(PETSC_COMM_SELF,ierr);endif
189: #endif
190: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
191: #define PetscCall(func) call func; CHKERRQ(ierr)
192: #define PetscCallMPI(func) call func; CHKERRMPI(ierr)
193: #define PetscCallA(func) call func; CHKERRA(ierr)
194: #define PetscCallMPIA(func) call func; CHKERRMPIA(ierr)
195: #define PetscCheckA(err, c, ierr, s) if (.not.(err)) then; SETERRA(c, ierr, s); endif
196: #define PetscCheck(err, c, ierr, s) if (.not.(err)) then; SETERRQ(c, ierr, s); endif
198: #define PetscMatlabEngine type(tPetscMatlabEngine)
200: #if !defined(PetscFlush)
201: #if defined(PETSC_HAVE_FORTRAN_FLUSH)
202: #define PetscFlush(a) flush(a)
203: #elif defined(PETSC_HAVE_FORTRAN_FLUSH_)
204: #define PetscFlush(a) flush_(a)
205: #else
206: #define PetscFlush(a)
207: #endif
208: #endif
210: #define PetscRandom type(tPetscRandom)
211: #define PetscRandomType character*(80)
212: #define PetscBinarySeekType PetscEnum
214: #define PetscBuildTwoSidedType PetscEnum
216: #define PetscSubcomm type(tPetscSubcomm)
217: #define PetscSubcommType PetscEnum
219: #define PetscOptions type(tPetscOptions)
221: #define PetscBench type(tPetscBench)
223: #define PetscFunctionList PetscFortranAddr
225: #define PetscInfoCommFlag PetscEnum
227: #define PetscExodusIIInt integer4
229: #endif