Actual source code: petscsysdef.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)
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 PetscTruth logical(kind=4)
28: #else
29: #define integer8 integer*8
30: #define integer4 integer*4
31: #define PetscTruth logical*4
32: #endif
34: #if (PETSC_SIZEOF_VOID_P == 8)
35: #define PetscFortranAddr integer8
36: #define PetscOffset integer8
37: #else
38: #define PetscOffset integer4
39: #define PetscFortranAddr integer4
40: #endif
42: #if defined(PETSC_USE_64BIT_INDICES)
43: #define PetscInt integer8
44: #else
45: #define PetscInt integer4
46: #endif
48: #if (PETSC_SIZEOF_INT == 4)
49: #define PetscFortranInt integer4
50: #elif (PETSC_SIZEOF_INT == 8)
51: #define PetscFortranInt integer8
52: #endif
53: !
54: #if (PETSC_SIZEOF_SIZE_T == 8)
55: #define PetscSizeT integer8
56: #else
57: #define PetscSizeT integer4
58: #endif
59: !
60: #if defined(PETSC_HAVE_MPIUNI)
61: #define MPI_Comm PetscFortranInt
62: #define PetscMPIInt PetscFortranInt
63: #else
64: #define MPI_Comm integer
65: #define PetscMPIInt integer
66: #endif
67: !
68: #define PetscEnum PetscFortranInt
69: #define PetscErrorCode PetscFortranInt
70: #define PetscCookie PetscFortranInt
71: #define PetscLogEvent PetscFortranInt
72: #define PetscLogStage PetscFortranInt
73: #define PetscVoid PetscFortranAddr
74: !
75: #if defined(PETSC_FORTRAN_PETSCTRUTH_INT)
76: #undef PetscTruth
77: #define PetscTruth PetscEnum
78: #endif
79: !
80: #define PetscDataType PetscEnum
81: #define PetscFPTrap PetscEnum
82: !
83: #if defined (PETSC_USE_FORTRANKIND)
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(16))
87: #if defined(PETSC_USE_SCALAR_SINGLE)
88: #define PetscFortranComplex complex(kind=selected_real_kind(5))
89: #else
90: #define PetscFortranComplex complex(kind=selected_real_kind(10))
91: #endif
92: #define PetscChar(a) character(len = a) ::
93: #else
94: #define PetscFortranFloat real*4
95: #define PetscFortranDouble real*8
96: #define PetscFortranLongDouble real*16
97: #if defined(PETSC_USE_SCALAR_SINGLE)
98: #define PetscFortranComplex complex*8
99: #else
100: #define PetscFortranComplex complex*16
101: #endif
102: #define PetscChar(a) character*(a)
103: #endif
105: #if defined(PETSC_USE_COMPLEX)
106: #define PETSC_SCALAR PETSC_COMPLEX
107: #else
108: #if defined(PETSC_USE_SCALAR_SINGLE)
109: #define PETSC_SCALAR PETSC_FLOAT
110: #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
111: #define PETSC_SCALAR PETSC_LONG_DOUBLE
112: #else
113: #define PETSC_SCALAR PETSC_DOUBLE
114: #endif
115: #endif
116: !
117: ! Macro for templating between real and complex
118: !
119: #if defined(PETSC_USE_COMPLEX)
120: #define PetscScalar PetscFortranComplex
121: !
122: ! F90 uses real(), conjg() when KIND parameter is used.
123: !
124: #if defined (PETSC_MISSING_DREAL)
125: #define PetscRealPart(a) real(a)
126: #define PetscConj(a) conjg(a)
127: #define PetscImaginaryPart(a) aimg(a)
128: #else
129: #define PetscRealPart(a) dreal(a)
130: #define PetscConj(a) dconjg(a)
131: #define PetscImaginaryPart(a) daimg(a)
132: #endif
133: #else
134: #if defined (PETSC_USE_SCALAR_SINGLE)
135: #define PetscScalar PetscFortranFloat
136: #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
137: #define PetscScalar PetscFortranLongDouble
138: #else
139: #define PetscScalar PetscFortranDouble
140: #endif
141: #define PetscRealPart(a) a
142: #define PetscConj(a) a
143: #define PetscImaginaryPart(a) a
144: #endif
146: #if defined (PETSC_USE_SCALAR_SINGLE)
147: #define PetscReal PetscFortranFloat
148: #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
149: #define PetscReal PetscFortranLongDouble
150: #else
151: #define PetscReal PetscFortranDouble
152: #endif
154: !
155: ! Allows the matrix Fortran Kernels to work with single precision
156: ! matrix data structures
157: !
158: #if defined(PETSC_USE_COMPLEX)
159: #define MatScalar PetscScalar
160: #elif defined(PETSC_USE_SCALAR_MAT_SINGLE)
161: #define MatScalar real*4
162: #else
163: #define MatScalar PetscScalar
164: #endif
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 PetscFortranAddr
171: #define PetscLogDouble PetscFortranDouble
172: !
173: ! Macros for error checking
174: !
175: #if defined(PETSC_USE_ERRORCHECKING)
176: #define SETERRQ(n,s,ierr) call MPI_Abort(PETSC_COMM_WORLD,n,ierr)
177: #define CHKERRQ(n) if (n .ne. 0) call MPI_Abort(PETSC_COMM_WORLD,n,n)
178: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
179: #else
180: #define SETERRQ(n,s,ierr)
181: #define CHKERRQ(n)
182: #define CHKMEMQ
183: #endif
185: #define PetscMatlabEngine PetscFortranAddr
187: #if !defined(PetscFlush)
188: #if defined(PETSC_HAVE_FLUSH)
189: #define PetscFlush(a) call flush(a)
190: #elif defined(PETSC_HAVE_FLUSH_)
191: #define PetscFlush(a) call flush_(a)
192: #else
193: #define PetscFlush(a)
194: #endif
195: #endif
197: #define PetscRandom PetscFortranAddr
198: #define PetscRandomType character*(80)
199: #define PetscBinarySeekType PetscEnum
201: #endif