Actual source code: petscsys.h
petsc-3.13.6 2020-09-29
1: !
2: !
3: ! Base include file for Fortran use of the PETSc package.
4: !
5: #include "petscconf.h"
6: #include "petscversion.h"
7: #include "petsc/finclude/petscsys.h"
9: !
10: ! The following block allows one to write constants that match the
11: ! precision of PetscReal as, for example, x = .7_PETSC_REAL_KIND
12: !
13: PetscReal,Parameter :: PetscReal_Private = 1.0
14: Integer,Parameter :: PETSC_REAL_KIND = Selected_Real_Kind(Precision(PetscReal_Private))
17: #if !defined(PETSC_AVOID_MPIF_H)
18: #if defined(PETSC_HAVE_MPIUNI)
19: #include "petsc/mpiuni/mpif.h"
20: #else
21: !
22: ! This code is extremely fragile; it assumes the format of the mpif.h file has
23: ! a particular structure that does not change with MPI implementation versions. But since
24: ! mpif.h is a bit of a deadwater and PETSC_PROMOTE_FORTRAN_INTEGER is
25: ! rarely used it is maybe ok to include fragile code
26: !
27: #if defined(PETSC_HAVE_MPICH_NUMVERSION) && defined(PETSC_PROMOTE_FORTRAN_INTEGER)
28: #define INTEGER integer4
29: #define MPI_STATUS_IGNORE(A) mpi_status_ignore(5)
30: #define MPI_STATUSES_IGNORE(B,C) mpi_statuses_ignore(5,1)
31: #elif defined(PETSC_HAVE_OMPI_MAJOR_VERSION) && defined(PETSC_PROMOTE_FORTRAN_INTEGER)
32: #define integer integer4
33: #define INTEGER integer4
34: #endif
35: #include "mpif.h"
36: #if defined(PETSC_HAVE_MPICH_NUMVERSION) && defined(PETSC_PROMOTE_FORTRAN_INTEGER)
37: #undef INTEGER
38: #undef MPI_STATUS_IGNORE
39: #undef MPI_STATUSES_IGNORE
40: #elif defined(PETSC_HAVE_OMPI_MAJOR_VERSION) && defined(PETSC_PROMOTE_FORTRAN_INTEGER)
41: #undef integer
42: #undef INTEGER
43: #endif
44: #endif
45: #endif
47: type tPetscOptions
48: PetscFortranAddr:: v PETSC_FORTRAN_TYPE_INITIALIZE
49: end type tPetscOptions
51: PetscOptions, parameter :: PETSC_NULL_OPTIONS = tPetscOptions(0)
53: ! ------------------------------------------------------------------------
54: ! Non Common block Stuff declared first
55: !
56: ! Flags
57: !
58: PetscBool, parameter :: PETSC_TRUE = .true.
59: PetscBool, parameter :: PETSC_FALSE = .false.
61: PetscInt, parameter :: PETSC_DECIDE = -1
62: PetscInt, parameter :: PETSC_DETERMINE = -1
63: PetscInt, parameter :: PETSC_DEFAULT_INTEGER = -2
65: PetscReal, parameter :: PETSC_DEFAULT_REAL = -2.0d0
67: PetscEnum, parameter :: PETSC_FP_TRAP_OFF = 0
68: PetscEnum, parameter :: PETSC_FP_TRAP_ON = 1
70: PetscFortranAddr, parameter :: PETSC_STDOUT = 0
71: !
72: ! PETSc DataTypes
73: !
74: #if defined(PETSC_USE_REAL_SINGLE)
75: #define PETSC_REAL PETSC_FLOAT
76: #elif defined(PETSC_USE_REAL___FLOAT128)
77: #define PETSC_REAL PETSC___FLOAT128
78: #else
79: #define PETSC_REAL PETSC_DOUBLE
80: #endif
81: #define PETSC_FORTRANADDR PETSC_LONG
83: PetscEnum, parameter :: PETSC_DATATYPE_UNKNOWN = 0
84: PetscEnum, parameter :: PETSC_DOUBLE = 1
85: PetscEnum, parameter :: PETSC_COMPLEX = 2
86: PetscEnum, parameter :: PETSC_LONG = 3
87: PetscEnum, parameter :: PETSC_SHORT = 4
88: PetscEnum, parameter :: PETSC_FLOAT = 5
89: PetscEnum, parameter :: PETSC_CHAR = 6
90: PetscEnum, parameter :: PETSC_BIT_LOGICAL = 7
91: PetscEnum, parameter :: PETSC_ENUM = 8
92: PetscEnum, parameter :: PETSC_BOOL = 9
93: PetscEnum, parameter :: PETSC___FLOAT128 = 10
94: PetscEnum, parameter :: PETSC_OBJECT = 11
95: PetscEnum, parameter :: PETSC_FUNCTION = 12
96: PetscEnum, parameter :: PETSC_STRING = 13
97: PetscEnum, parameter :: PETSC___FP16 = 14
98: PetscEnum, parameter :: PETSC_STRUCT = 15
99: PetscEnum, parameter :: PETSC_INT = 16
100: !
101: !
102: !
103: PetscEnum, parameter :: PETSC_COPY_VALUES = 0
104: PetscEnum, parameter :: PETSC_OWN_POINTER = 1
105: PetscEnum, parameter :: PETSC_USE_POINTER = 2
106: !
107: ! ------------------------------------------------------------------------
108: ! PETSc mathematics include file. Defines certain basic mathematical
109: ! constants and functions for working with single and double precision
110: ! floating point numbers as well as complex and integers.
111: !
112: ! Representation of complex i
113: !
114: #if defined(PETSC_USE_REAL_SINGLE)
115: PetscFortranComplex, parameter :: PETSC_i = (0.0e0,1.0e0)
116: #else
117: PetscFortranComplex, parameter :: PETSC_i = (0.0d0,1.0d0)
118: #endif
119: !
120: ! ----------------------------------------------------------------------------
121: ! BEGIN PETSc aliases for MPI_ constants
122: !
123: ! These values for __float128 are handled in the common block (below)
124: ! and transmitted from the C code
125: !
126: #if !defined(PETSC_USE_REAL___FLOAT128)
127: #if defined (PETSC_USE_REAL_SINGLE)
128: integer4, parameter :: MPIU_REAL = MPI_REAL
129: #else
130: integer4, parameter :: MPIU_REAL = MPI_DOUBLE_PRECISION
131: #endif
133: integer4, parameter :: MPIU_SUM = MPI_SUM
135: #if defined(PETSC_USE_COMPLEX)
136: #if defined (PETSC_USE_REAL_SINGLE)
137: integer4, parameter :: MPIU_SCALAR = MPI_COMPLEX
138: #else
139: integer4, parameter :: MPIU_SCALAR = MPI_DOUBLE_COMPLEX
140: #endif
141: #else
142: #if defined (PETSC_USE_REAL_SINGLE)
143: parameter (MPIU_SCALAR = MPI_REAL)
144: #else
145: parameter(MPIU_SCALAR = MPI_DOUBLE_PRECISION)
146: #endif
147: #endif
148: #endif
150: #if defined(PETSC_USE_64BIT_INDICES)
151: integer4, parameter :: MPIU_INTEGER = MPI_INTEGER8
152: #else
153: integer4, parameter :: MPIU_INTEGER = MPI_INTEGER
154: #endif
156: ! A PETSC_NULL_FUNCTION pointer
157: !
158: external PETSC_NULL_FUNCTION
159: !
160: ! Possible arguments to PetscPushErrorHandler()
161: !
162: external PETSCTRACEBACKERRORHANDLER
163: external PETSCABORTERRORHANDLER
164: external PETSCEMACSCLIENTERRORHANDLER
165: external PETSCATTACHDEBUGGERERRORHANDLER
166: external PETSCIGNOREERRORHANDLER
167: !
168: external PetscIsInfOrNanScalar
169: external PetscIsInfOrNanReal
170: PetscBool PetscIsInfOrNanScalar
171: PetscBool PetscIsInfOrNanReal
174: ! ----------------------------------------------------------------------------
175: !
176: ! Random numbers
177: !
178: type tPetscRandom
179: sequence
180: PetscFortranAddr:: v PETSC_FORTRAN_TYPE_INITIALIZE
181: end type tPetscRandom
183: PetscRandom, parameter :: PETSC_NULL_RANDOM = tPetscRandom(0)
184: !
185: #define PETSCRAND 'rand'
186: #define PETSCRAND48 'rand48'
187: #define PETSCSPRNG 'sprng'
188: #define PETSCRANDER48 'rander48'
189: !
190: !
191: !
192: PetscEnum, parameter :: PETSC_BINARY_INT_SIZE = 4
193: PetscEnum, parameter :: PETSC_BINARY_FLOAT_SIZE = 4
194: PetscEnum, parameter :: PETSC_BINARY_CHAR_SIZE = 1
195: PetscEnum, parameter :: PETSC_BINARY_SHORT_SIZE = 2
196: PetscEnum, parameter :: PETSC_BINARY_DOUBLE_SIZE = 8
197: #if defined(PETSC_USE_COMPLEX)
198: PetscEnum, parameter :: PETSC_BINARY_SCALAR_SIZE = 16
199: #else
200: PetscEnum, parameter :: PETSC_BINARY_SCALAR_SIZE = 8
201: #endif
203: PetscEnum, parameter :: PETSC_BINARY_SEEK_SET = 0
204: PetscEnum, parameter :: PETSC_BINARY_SEEK_CUR = 1
205: PetscEnum, parameter :: PETSC_BINARY_SEEK_END = 2
207: PetscEnum, parameter :: PETSC_BUILDTWOSIDED_ALLREDUCE = 0
208: PetscEnum, parameter :: PETSC_BUILDTWOSIDED_IBARRIER = 1
209: PetscEnum, parameter :: PETSC_BUILDTWOSIDED_REDSCATTER = 2
211: type tPetscSubcomm
212: sequence
213: PetscFortranAddr:: v PETSC_FORTRAN_TYPE_INITIALIZE
214: end type tPetscSubcomm
216: PetscSubcomm, parameter :: PETSC_NULL_SUBCOMM = tPetscSubcomm(0)
218: !
219: ! PetscSubcommType
220: !
221: PetscEnum, parameter :: PETSC_SUBCOMM_GENERAL = 0
222: PetscEnum, parameter :: PETSC_SUBCOMM_CONTIGUOUS = 1
223: PetscEnum, parameter :: PETSC_SUBCOMM_INTERLACED = 2
225: #if defined(_WIN32) && defined(PETSC_USE_SHARED_LIBRARIES)
226: !DEC$ ATTRIBUTES DLLEXPORT::PetscReal_Private
227: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_REAL_KIND
228: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_NULL_OPTIONS
229: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_TRUE
230: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_FALSE
231: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_DECIDE
232: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_DETERMINE
233: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_DEFAULT_INTEGER
234: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_DEFAULT_REAL
235: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_FP_TRAP_OFF
236: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_FP_TRAP_ON
237: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_STDOUT
238: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_INT
239: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_DOUBLE
240: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_COMPLEX
241: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_LONG
242: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_SHORT
243: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_FLOAT
244: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_CHAR
245: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BIT_LOGICAL
246: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_ENUM
247: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BOOL
248: !DEC$ ATTRIBUTES DLLEXPORT::PETSC___FLOAT128
249: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_OBJECT
250: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_FUNCTION
251: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_STRING
252: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_STRUC
253: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_DATATYPE_UNKNOWN
254: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_COPY_VALUES
255: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_OWN_POINTER
256: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_USE_POINTER
257: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_i
258: !DEC$ ATTRIBUTES DLLEXPORT::MPIU_REAL
259: !DEC$ ATTRIBUTES DLLEXPORT::MPIU_SUM
260: !DEC$ ATTRIBUTES DLLEXPORT::MPIU_SCALAR
261: !DEC$ ATTRIBUTES DLLEXPORT::MPIU_INTEGER
262: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_NULL_RANDOM
263: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BINARY_INT_SIZE
264: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BINARY_FLOAT_SIZE
265: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BINARY_CHAR_SIZE
266: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BINARY_SHORT_SIZE
267: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BINARY_DOUBLE_SIZE
268: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BINARY_SCALAR_SIZE
269: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BINARY_SEEK_SET
270: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BINARY_SEEK_CUR
271: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BINARY_SEEK_END
272: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BUILDTWOSIDED_ALLREDUCE
273: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BUILDTWOSIDED_IBARRIER
274: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_BUILDTWOSIDED_REDSCATTER
275: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_SUBCOMM_GENERAL
276: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_SUBCOMM_CONTIGUOUS
277: !DEC$ ATTRIBUTES DLLEXPORT::PETSC_SUBCOMM_INTERLACED
278: #endif
279: !
280: ! include other sys components
281: !
282: #include "../src/sys/f90-mod/petscerror.h"
283: #include "../src/sys/f90-mod/petsclog.h"
284: #include "../src/sys/f90-mod/petscbag.h"
286: ! ----------------------------------------------------------------------------
287: !
288: ! PetscInfoCommFlag Enum
289: !
290: !
291: ! PetscInfoCommFlag
292: !
293: PetscEnum PETSC_INFO_COMM_ALL
294: PetscEnum PETSC_INFO_COMM_NO_SELF
295: PetscEnum PETSC_INFO_COMM_ONLY_SELF
296: parameter(PETSC_INFO_COMM_ALL=-1)
297: parameter(PETSC_INFO_COMM_NO_SELF=0)
298: parameter(PETSC_INFO_COMM_ONLY_SELF=1)