Actual source code: petscsysdef.h
petsc-3.5.4 2015-05-23
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)
12: #include "petscconf.h"
13: #include finclude/petscviewerdef.h
14: #include finclude/petscerrordef.h
15: #include finclude/petsclogdef.h
16: #include finclude/petscdrawdef.h
18: !
19: ! The real*8,complex*16 notatiton is used so that the
20: ! PETSc double/complex variables are not affected by
21: ! compiler options like -r4,-r8, sometimes invoked
22: ! by the user. NAG compiler does not like integer*4,real*8
24: #if defined(PETSC_USE_FORTRANKIND)
25: #define integer8 integer(kind=selected_int_kind(10))
26: #define integer4 integer(kind=selected_int_kind(5))
27: #define integer2 integer(kind=selected_int_kind(3))
28: #define integer1 integer(kind=selected_int_kind(1))
29: #define PetscBool logical(kind=4)
30: #else
31: #define integer8 integer*8
32: #define integer4 integer*4
33: #define integer2 integer*2
34: #define integer1 integer*1
35: #define PetscBool logical*4
36: #endif
38: #if (PETSC_SIZEOF_VOID_P == 8)
39: #define PetscFortranAddr integer8
40: #define PetscOffset integer8
41: #else
42: #define PetscOffset integer4
43: #define PetscFortranAddr integer4
44: #endif
46: #if defined(PETSC_USE_64BIT_INDICES)
47: #define PetscInt integer8
48: #else
49: #define PetscInt integer4
50: #endif
51: #define Petsc64bitInt integer8
52: #define PetscObjectState Petsc64bitInt
54: #if (PETSC_SIZEOF_INT == 4)
55: #define PetscFortranInt integer4
56: #elif (PETSC_SIZEOF_INT == 8)
57: #define PetscFortranInt integer8
58: #endif
59: !
60: #if (PETSC_SIZEOF_SIZE_T == 8)
61: #define PetscSizeT integer8
62: #else
63: #define PetscSizeT integer4
64: #endif
65: !
66: #if defined(PETSC_HAVE_MPIUNI)
67: #define MPI_Comm PetscFortranInt
68: #define MPI_Group PetscFortranInt
69: #define PetscMPIInt PetscFortranInt
70: #else
71: #define MPI_Comm integer
72: #define MPI_Group integer
73: #define PetscMPIInt integer
74: #endif
75: !
76: #define PetscEnum PetscFortranInt
77: #define PetscErrorCode PetscFortranInt
78: #define PetscClassId PetscFortranInt
79: #define PetscLogEvent PetscFortranInt
80: #define PetscLogStage PetscFortranInt
81: #define PetscVoid PetscFortranAddr
82: !
83: #if defined(PETSC_FORTRAN_PETSCTRUTH_INT)
84: #undef PetscBool
85: #define PetscBool PetscEnum
86: #endif
87: !
88: #define PetscCopyMode PetscEnum
89: !
90: #define PetscDataType PetscEnum
91: #define PetscFPTrap PetscEnum
92: !
93: #if defined (PETSC_USE_FORTRANKIND)
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) ::
105: #else
106: #define PetscFortranFloat real*4
107: #define PetscFortranDouble real*8
108: #define PetscFortranLongDouble real*16
109: #if defined(PETSC_USE_REAL_SINGLE)
110: #define PetscFortranComplex complex*8
111: #elif defined(PETSC_USE_REAL_DOUBLE)
112: #define PetscFortranComplex complex*16
113: #elif defined(PETSC_USE_REAL___FLOAT128)
114: #define PetscFortranComplex complex*32
115: #endif
116: #define PetscChar(a) character*(a)
117: #endif
119: #if defined(PETSC_USE_COMPLEX)
120: #define PETSC_SCALAR PETSC_COMPLEX
121: #else
122: #if defined(PETSC_USE_REAL_SINGLE)
123: #define PETSC_SCALAR PETSC_FLOAT
124: #elif defined(PETSC_USE_REAL___FLOAT128)
125: #define PETSC_SCALAR PETSC___FLOAT128
126: #else
127: #define PETSC_SCALAR PETSC_DOUBLE
128: #endif
129: #endif
130: #if defined(PETSC_USE_REAL_SINGLE)
131: #define PETSC_REAL PETSC_FLOAT
132: #elif defined(PETSC_USE_REAL___FLOAT128)
133: #define PETSC_REAL PETSC___FLOAT128
134: #else
135: #define PETSC_REAL PETSC_DOUBLE
136: #endif
137: !
138: ! Macro for templating between real and complex
139: !
140: #if defined(PETSC_USE_COMPLEX)
141: #define PetscScalar PetscFortranComplex
142: !
143: ! F90 uses real(), conjg() when KIND parameter is used.
144: !
145: #if defined (PETSC_MISSING_DREAL)
146: #define PetscRealPart(a) real(a)
147: #define PetscConj(a) conjg(a)
148: #define PetscImaginaryPart(a) aimag(a)
149: #else
150: #define PetscRealPart(a) dreal(a)
151: #define PetscConj(a) dconjg(a)
152: #define PetscImaginaryPart(a) daimag(a)
153: #endif
154: #else
155: #if defined (PETSC_USE_REAL_SINGLE)
156: #define PetscScalar PetscFortranFloat
157: #elif defined(PETSC_USE_REAL___FLOAT128)
158: #define PetscScalar PetscFortranLongDouble
159: #elif defined(PETSC_USE_REAL_DOUBLE)
160: #define PetscScalar PetscFortranDouble
161: #endif
162: #define PetscRealPart(a) a
163: #define PetscConj(a) a
164: #define PetscImaginaryPart(a) a
165: #endif
167: #if defined (PETSC_USE_REAL_SINGLE)
168: #define PetscReal PetscFortranFloat
169: #elif defined(PETSC_USE_REAL___FLOAT128)
170: #define PetscReal PetscFortranLongDouble
171: #elif defined(PETSC_USE_REAL_DOUBLE)
172: #define PetscReal PetscFortranDouble
173: #endif
175: !
176: ! Allows the matrix Fortran Kernels to work with single precision
177: ! matrix data structures
178: !
179: #define MatScalar PetscScalar
180: !
181: ! PetscLogDouble variables are used to contain double precision numbers
182: ! that are not used in the numerical computations, but rather in logging,
183: ! timing etc.
184: !
185: #define PetscObject PetscFortranAddr
186: #define PetscLogDouble PetscFortranDouble
187: !
188: ! Macros for error checking
189: !
190: #if defined(PETSC_USE_ERRORCHECKING)
191: #define SETERRQ(c,n,s,ierr) call MPI_Abort(PETSC_COMM_WORLD,n,ierr)
192: #define CHKERRQ(n) if (n .ne. 0) call MPI_Abort(PETSC_COMM_WORLD,n,n)
193: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
194: #else
195: #define SETERRQ(c,n,s,ierr)
196: #define CHKERRQ(n)
197: #define CHKMEMQ
198: #endif
200: #define PetscMatlabEngine PetscFortranAddr
202: #if !defined(PetscFlush)
203: #if defined(PETSC_HAVE_FLUSH)
204: #define PetscFlush(a) call flush(a)
205: #elif defined(PETSC_HAVE_FLUSH_)
206: #define PetscFlush(a) call flush_(a)
207: #else
208: #define PetscFlush(a)
209: #endif
210: #endif
212: #define PetscRandom PetscFortranAddr
213: #define PetscRandomType character*(80)
214: #define PetscBinarySeekType PetscEnum
216: #define PetscBuildTwoSidedType PetscEnum
219: #endif