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: #else
47: #error "Unknown integer size"
48: #endif
49: !
50: #if defined(PETSC_HAVE_MPIUNI)
51: #define MPI_Comm PetscFortranInt
52: #define PetscMPIInt PetscFortranInt
53: #else
54: #define MPI_Comm integer
55: #define PetscMPIInt integer
56: #endif
57: !
58: #define PetscEnum PetscFortranInt
59: #define PetscErrorCode PetscFortranInt
60: #define PetscCookie PetscFortranInt
61: #define PetscEvent PetscFortranInt
62: !
63: #define PetscTruth PetscEnum
64: #define PetscDataType PetscEnum
65: #define PetscFPTrap PetscEnum
66: !
67: #if defined (PETSC_USE_FORTRANKIND)
68: #define PetscFortranFloat real(kind=selected_real_kind(5))
69: #define PetscFortranDouble real(kind=selected_real_kind(10))
70: #define PetscFortranLongDouble real(kind=selected_real_kind(16))
71: #define PetscFortranComplex complex(kind=selected_real_kind(10))
72: #define PetscChar(a) character(len = a) ::
73: #else
74: #define PetscFortranFloat real*4
75: #define PetscFortranDouble real*8
76: #define PetscFortranLongDouble real*16
77: #define PetscFortranComplex complex*16
78: #define PetscChar(a) character*(a)
79: #endif
81: #if defined(PETSC_USE_COMPLEX)
82: #define PETSC_SCALAR PETSC_COMPLEX
83: #else
84: #if defined(PETSC_USE_SINGLE)
85: #define PETSC_SCALAR PETSC_FLOAT
86: #elif defined(PETSC_USE_LONG_DOUBLE)
87: #define PETSC_SCALAR PETSC_LONG_DOUBLE
88: #else
89: #define PETSC_SCALAR PETSC_DOUBLE
90: #endif
91: #endif
92: !
93: ! Macro for templating between real and complex
94: !
95: #if defined(PETSC_USE_COMPLEX)
96: #define PetscScalar PetscFortranComplex
97: !
98: ! F90 uses real(), conjg() when KIND parameter is used.
99: !
100: #if defined (PETSC_MISSING_DREAL)
101: #define PetscRealPart(a) real(a)
102: #define PetscConj(a) conjg(a)
103: #define PetscImaginaryPart(a) aimg(a)
104: #else
105: #define PetscRealPart(a) dreal(a)
106: #define PetscConj(a) dconjg(a)
107: #define PetscImaginaryPart(a) daimg(a)
108: #endif
109: #define MPIU_SCALAR MPI_DOUBLE_COMPLEX
110: #else
111: #if defined (PETSC_USE_SINGLE)
112: #define PetscScalar PetscFortranFloat
113: #define MPIU_SCALAR MPI_REAL
114: #elif defined(PETSC_USE_LONG_DOUBLE)
115: #define PetscScalar PetscFortranLongDouble
116: #define MPIU_SCALAR MPI_2DOUBLE_PRECISION
117: #else
118: #define PetscScalar PetscFortranDouble
119: #define MPIU_SCALAR MPI_DOUBLE_PRECISION
120: #endif
121: #define PetscRealPart(a) a
122: #define PetscConj(a) a
123: #define PetscImaginaryPart(a) a
124: #endif
126: #if defined (PETSC_USE_SINGLE)
127: #define PetscReal PetscFortranFloat
128: #elif defined(PETSC_USE_LONG_DOUBLE)
129: #define PetscReal PetscFortranLongDouble
130: #else
131: #define PetscReal PetscFortranDouble
132: #endif
134: !
135: ! Allows the matrix Fortran Kernels to work with single precision
136: ! matrix data structures
137: !
138: #if defined(PETSC_USE_COMPLEX)
139: #define MatScalar PetscScalar
140: #elif defined(PETSC_USE_MAT_SINGLE)
141: #define MatScalar real*4
142: #else
143: #define MatScalar PetscScalar
144: #endif
145: !
146: ! PetscLogDouble variables are used to contain double precision numbers
147: ! that are not used in the numerical computations, but rather in logging,
148: ! timing etc.
149: !
150: #define PetscObject PetscFortranAddr
151: #define PetscLogDouble PetscFortranDouble
152: !
153: ! Macros for error checking
154: !
155: #if defined(PETSC_USE_ERRORCHECKING)
156: #define SETERRQ(n,s,ierr) call MPI_Abort(PETSC_COMM_WORLD,n,ierr)
157: #define CHKERRQ(n) if (n .ne. 0) call MPI_Abort(PETSC_COMM_WORLD,n,n)
158: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
159: #else
160: #define SETERRQ(n,s,ierr)
161: #define CHKERRQ(n)
162: #define CHKMEMQ
163: #endif
165: #define PetscMatlabEngine PetscFortranAddr
167: #if defined(PETSC_STDCALL)
168: #define PETSC_DEC_ATTRIBUTES(A,B) DEC$ ATTRIBUTESC, ALIAS:B ::A
169: #else
170: #define PETSC_DEC_ATTRIBUTES(A,B)
171: #endif
173: #endif