Actual source code: petscdef.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 (__PETSCDEF_H)
12: !
13: #include "petscconf.h"
14: !
15: ! The real*8,complex*16 notatiton is used so that the
16: ! PETSc double/complex variables are not affected by
17: ! compiler options like -r4,-r8, sometimes invoked
18: ! by the user. NAG compiler does not like integer*4,real*8
20: #if defined(PETSC_USE_FORTRANKIND)
21: #define integer8 integer(kind=selected_int_kind(10))
22: #define integer4 integer(kind=selected_int_kind(5))
23: #else
24: #define integer8 integer*8
25: #define integer4 integer*4
26: #endif
28: #if (PETSC_SIZEOF_VOID_P == 8)
29: #define PetscFortranAddr integer8
30: #define PetscOffset integer8
31: #else
32: #define PetscOffset integer4
33: #define PetscFortranAddr integer4
34: #endif
36: #if defined(PETSC_USE_64BIT_INDICES)
37: #define PetscInt integer8
38: #else
39: #define PetscInt integer4
40: #endif
42: #if (PETSC_SIZEOF_INT == 4)
43: #define PetscFortranInt integer4
44: #elif (PETSC_SIZEOF_INT == 8)
45: #define PetscFortranInt integer8
46: #endif
47: !
48: #if (PETSC_SIZEOF_SIZE_T == 8)
49: #define PetscSizeT integer8
50: #else
51: #define PetscSizeT integer4
52: #endif
53: !
54: #if defined(PETSC_HAVE_MPIUNI)
55: #define MPI_Comm PetscFortranInt
56: #define PetscMPIInt PetscFortranInt
57: #else
58: #define MPI_Comm integer
59: #define PetscMPIInt integer
60: #endif
61: !
62: #define PetscEnum PetscFortranInt
63: #define PetscErrorCode PetscFortranInt
64: #define PetscCookie PetscFortranInt
65: #define PetscEvent PetscFortranInt
66: !
67: #define PetscTruth PetscEnum
68: #define PetscDataType PetscEnum
69: #define PetscFPTrap PetscEnum
70: !
71: #if defined (PETSC_USE_FORTRANKIND)
72: #define PetscFortranFloat real(kind=selected_real_kind(5))
73: #define PetscFortranDouble real(kind=selected_real_kind(10))
74: #define PetscFortranLongDouble real(kind=selected_real_kind(16))
75: #define PetscFortranComplex complex(kind=selected_real_kind(10))
76: #define PetscChar(a) character(len = a) ::
77: #else
78: #define PetscFortranFloat real*4
79: #define PetscFortranDouble real*8
80: #define PetscFortranLongDouble real*16
81: #define PetscFortranComplex complex*16
82: #define PetscChar(a) character*(a)
83: #endif
85: #if defined(PETSC_USE_COMPLEX)
86: #define PETSC_SCALAR PETSC_COMPLEX
87: #else
88: #if defined(PETSC_USE_SINGLE)
89: #define PETSC_SCALAR PETSC_FLOAT
90: #elif defined(PETSC_USE_LONG_DOUBLE)
91: #define PETSC_SCALAR PETSC_LONG_DOUBLE
92: #else
93: #define PETSC_SCALAR PETSC_DOUBLE
94: #endif
95: #endif
96: !
97: ! Macro for templating between real and complex
98: !
99: #if defined(PETSC_USE_COMPLEX)
100: #define PetscScalar PetscFortranComplex
101: !
102: ! F90 uses real(), conjg() when KIND parameter is used.
103: !
104: #if defined (PETSC_MISSING_DREAL)
105: #define PetscRealPart(a) real(a)
106: #define PetscConj(a) conjg(a)
107: #define PetscImaginaryPart(a) aimg(a)
108: #else
109: #define PetscRealPart(a) dreal(a)
110: #define PetscConj(a) dconjg(a)
111: #define PetscImaginaryPart(a) daimg(a)
112: #endif
113: #define MPIU_SCALAR MPI_DOUBLE_COMPLEX
114: #else
115: #if defined (PETSC_USE_SINGLE)
116: #define PetscScalar PetscFortranFloat
117: #define MPIU_SCALAR MPI_REAL
118: #elif defined(PETSC_USE_LONG_DOUBLE)
119: #define PetscScalar PetscFortranLongDouble
120: #define MPIU_SCALAR MPI_2DOUBLE_PRECISION
121: #else
122: #define PetscScalar PetscFortranDouble
123: #define MPIU_SCALAR MPI_DOUBLE_PRECISION
124: #endif
125: #define PetscRealPart(a) a
126: #define PetscConj(a) a
127: #define PetscImaginaryPart(a) a
128: #endif
130: #if defined (PETSC_USE_SINGLE)
131: #define PetscReal PetscFortranFloat
132: #elif defined(PETSC_USE_LONG_DOUBLE)
133: #define PetscReal PetscFortranLongDouble
134: #else
135: #define PetscReal PetscFortranDouble
136: #endif
138: !
139: ! Allows the matrix Fortran Kernels to work with single precision
140: ! matrix data structures
141: !
142: #if defined(PETSC_USE_COMPLEX)
143: #define MatScalar PetscScalar
144: #elif defined(PETSC_USE_MAT_SINGLE)
145: #define MatScalar real*4
146: #else
147: #define MatScalar PetscScalar
148: #endif
149: !
150: ! PetscLogDouble variables are used to contain double precision numbers
151: ! that are not used in the numerical computations, but rather in logging,
152: ! timing etc.
153: !
154: #define PetscObject PetscFortranAddr
155: #define PetscLogDouble PetscFortranDouble
156: !
157: ! Macros for error checking
158: !
159: #if defined(PETSC_USE_ERRORCHECKING)
160: #define SETERRQ(n,s,ierr) call MPI_Abort(PETSC_COMM_WORLD,n,ierr)
161: #define CHKERRQ(n) if (n .ne. 0) call MPI_Abort(PETSC_COMM_WORLD,n,n)
162: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
163: #else
164: #define SETERRQ(n,s,ierr)
165: #define CHKERRQ(n)
166: #define CHKMEMQ
167: #endif
169: #define PetscMatlabEngine PetscFortranAddr
171: #if defined(PETSC_STDCALL)
172: #define PETSC_DEC_ATTRIBUTES(A,B) DEC$ ATTRIBUTESC, ALIAS:B ::A
173: #else
174: #define PETSC_DEC_ATTRIBUTES(A,B)
175: #endif
177: #if !defined(PetscFlush)
178: #if defined(PETSC_HAVE_FLUSH)
179: #define PetscFlush(a) call flush(a)
180: #elif defined(PETSC_HAVE_FLUSH_)
181: #define PetscFlush(a) call flush_(a)
182: #else
183: #define PetscFlush(a)
184: #endif
185: #endif
187: #endif