Actual source code: petscsys.h
petsc-3.14.4 2021-02-03
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)
33: #if (PETSC_SIZEOF_VOID_P == 8)
34: #define PetscOffset integer8
35: #define PetscFortranAddr integer8
36: #else
37: #define PetscOffset integer4
38: #define PetscFortranAddr integer4
39: #endif
41: #if defined(PETSC_USE_64BIT_INDICES)
42: #define PetscInt integer8
43: #else
44: #define PetscInt integer4
45: #endif
46: #define PetscInt64 integer8
47: #define PetscObjectState PetscInt64
48: #define PetscObjectId PetscInt64
50: #if (PETSC_SIZEOF_INT == 4)
51: #define PetscFortranInt integer4
52: #elif (PETSC_SIZEOF_INT == 8)
53: #define PetscFortranInt integer8
54: #endif
55: !
56: #if (PETSC_SIZEOF_SIZE_T == 8)
57: #define PetscSizeT integer8
58: #else
59: #define PetscSizeT integer4
60: #endif
61: !
62: #if defined(PETSC_HAVE_MPIUNI)
63: #define MPI_Comm MPIUNI_FInt
64: #define MPI_Group MPIUNI_FInt
65: #define PetscMPIInt MPIUNI_FInt
66: #else
67: #define MPI_Comm integer4
68: #define MPI_Group integer4
69: #define PetscMPIInt integer4
70: #endif
71: !
72: #define PetscEnum PetscFortranInt
73: #define PetscErrorCode PetscFortranInt
74: #define PetscClassId PetscFortranInt
75: #define PetscLogEvent PetscFortranInt
76: #define PetscLogStage PetscFortranInt
77: #define PetscVoid PetscFortranAddr
78: !
79: #define PetscCopyMode PetscEnum
80: !
81: #define PetscDataType PetscEnum
82: #define PetscFPTrap PetscEnum
83: !
84: #define PetscFortranFloat real(kind=selected_real_kind(5))
85: #define PetscFortranDouble real(kind=selected_real_kind(10))
86: #define PetscFortranLongDouble real(kind=selected_real_kind(19))
87: #if defined(PETSC_USE_REAL_SINGLE)
88: #define PetscFortranComplex complex(kind=selected_real_kind(5))
89: #elif defined(PETSC_USE_REAL_DOUBLE)
90: #define PetscFortranComplex complex(kind=selected_real_kind(10))
91: #elif defined(PETSC_USE_REAL___FLOAT128)
92: #define PetscFortranComplex complex(kind=selected_real_kind(20))
93: #endif
94: #define PetscChar(a) character(len = a) ::
96: #if defined(PETSC_USE_COMPLEX)
97: #define PETSC_SCALAR PETSC_COMPLEX
98: #else
99: #if defined(PETSC_USE_REAL_SINGLE)
100: #define PETSC_SCALAR PETSC_FLOAT
101: #elif defined(PETSC_USE_REAL___FLOAT128)
102: #define PETSC_SCALAR PETSC___FLOAT128
103: #else
104: #define PETSC_SCALAR PETSC_DOUBLE
105: #endif
106: #endif
107: #if defined(PETSC_USE_REAL_SINGLE)
108: #define PETSC_REAL PETSC_FLOAT
109: #define PetscIntToReal(a) real(a)
110: #elif defined(PETSC_USE_REAL___FLOAT128)
111: #define PETSC_REAL PETSC___FLOAT128
112: #define PetscIntToReal(a) dble(a)
113: #else
114: #define PETSC_REAL PETSC_DOUBLE
115: #define PetscIntToReal(a) dble(a)
116: #endif
117: !
118: ! Macro for templating between real and complex
119: !
120: #define PetscComplex PetscFortranComplex
121: #if defined(PETSC_USE_COMPLEX)
122: #define PetscScalar PetscFortranComplex
123: !
124: ! F90 uses real(), conjg() when KIND parameter is used.
125: !
126: #define PetscRealPart(a) real(a)
127: #define PetscConj(a) conjg(a)
128: #define PetscImaginaryPart(a) aimag(a)
129: #else
130: #if defined (PETSC_USE_REAL_SINGLE)
131: #define PetscScalar PetscFortranFloat
132: #elif defined(PETSC_USE_REAL___FLOAT128)
133: #define PetscScalar PetscFortranLongDouble
134: #elif defined(PETSC_USE_REAL_DOUBLE)
135: #define PetscScalar PetscFortranDouble
136: #endif
137: #define PetscRealPart(a) a
138: #define PetscConj(a) a
139: #define PetscImaginaryPart(a) 0.0
140: #endif
142: #if defined (PETSC_USE_REAL_SINGLE)
143: #define PetscReal PetscFortranFloat
144: #elif defined(PETSC_USE_REAL___FLOAT128)
145: #define PetscReal PetscFortranLongDouble
146: #elif defined(PETSC_USE_REAL_DOUBLE)
147: #define PetscReal PetscFortranDouble
148: #endif
150: !
151: ! Allows the matrix Fortran Kernels to work with single precision
152: ! matrix data structures
153: !
154: #define MatScalar PetscScalar
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: #define SETERRQ(c,ierr,s) call PetscError(c,ierr,0,s); return
166: #define SETERRA(c,ierr,s) call PetscError(c,ierr,0,s); call MPIU_Abort(c,ierr)
167: #define CHKERRQ(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);return;endif
168: #define CHKERRA(ierr) if (ierr .ne. 0) then;call PetscErrorF(ierr);call MPIU_Abort(MPI_COMM_SELF,ierr);endif
169: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
171: #define PetscMatlabEngine PetscFortranAddr
173: #if !defined(PetscFlush)
174: #if defined(PETSC_HAVE_FORTRAN_FLUSH)
175: #define PetscFlush(a) flush(a)
176: #elif defined(PETSC_HAVE_FORTRAN_FLUSH_)
177: #define PetscFlush(a) flush_(a)
178: #else
179: #define PetscFlush(a)
180: #endif
181: #endif
183: #define PetscRandom type(tPetscRandom)
184: #define PetscRandomType character*(80)
185: #define PetscBinarySeekType PetscEnum
187: #define PetscBuildTwoSidedType PetscEnum
189: #define PetscSubcomm type(tPetscSubcomm)
190: #define PetscSubcommType PetscEnum
192: #define PetscOptions type(tPetscOptions)
194: #define PetscFunctionList PetscFortranAddr
196: #define PetscInfoCommFlag PetscEnum
197: #endif