Actual source code: petscsys.h

petsc-3.9.4 2018-09-11
Report Typos and Errors
  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 ::                                                 &
 14:      &                        PetscReal_Private = 1.0
 15:        Integer,Parameter   :: PETSC_REAL_KIND                                 &
 16:      &  = Selected_Real_Kind(Precision(PetscReal_Private))


 19: #if !defined(PETSC_AVOID_MPIF_H)
 20: #include "mpif.h"
 21: #endif

 23:       type tPetscOptions
 24:         PetscFortranAddr:: v
 25:       end type tPetscOptions

 27:       PetscOptions, parameter :: PETSC_NULL_OPTIONS =                        &
 28:      &                           tPetscOptions(-1)

 30: ! ------------------------------------------------------------------------
 31: !     Non Common block Stuff declared first
 32: !
 33: !     Flags
 34: !
 35:       PetscBool  PETSC_TRUE
 36:       PetscBool  PETSC_FALSE
 37: #if defined(PETSC_FORTRAN_PETSCTRUTH_INT)
 38:       parameter (PETSC_TRUE = 1,PETSC_FALSE = 0)
 39: #else
 40:       parameter (PETSC_TRUE = .true.,PETSC_FALSE = .false.)
 41: #endif
 42:       PetscInt   PETSC_DECIDE,PETSC_DETERMINE
 43:       parameter (PETSC_DECIDE=-1,PETSC_DETERMINE=-1)

 45:       PetscInt  PETSC_DEFAULT_INTEGER
 46:       parameter (PETSC_DEFAULT_INTEGER = -2)

 48:       PetscReal PETSC_DEFAULT_REAL
 49:       parameter (PETSC_DEFAULT_REAL=-2.0d0)

 51:       PetscEnum PETSC_FP_TRAP_OFF
 52:       PetscEnum PETSC_FP_TRAP_ON
 53:       parameter (PETSC_FP_TRAP_OFF = 0,PETSC_FP_TRAP_ON = 1)

 55:       PetscFortranAddr PETSC_STDOUT

 57:       parameter (PETSC_STDOUT  = 0)
 58: !
 59: !     PETSc DataTypes
 60: !
 61:       PetscEnum PETSC_INT
 62:       PetscEnum PETSC_DOUBLE
 63:       PetscEnum PETSC_COMPLEX
 64:       PetscEnum PETSC_LONG
 65:       PetscEnum PETSC_SHORT
 66:       PetscEnum PETSC_FLOAT
 67:       PetscEnum PETSC_CHAR
 68:       PetscEnum PETSC_BIT_LOGICAL
 69:       PetscEnum PETSC_ENUM
 70:       PetscEnum PETSC_BOOL
 71:       PetscEnum PETSC___FLOAT128
 72:       PetscEnum PETSC_OBJECT
 73:       PetscEnum PETSC_FUNCTION
 74:       PetscEnum PETSC_STRING
 75:       PetscEnum PETSC_STRUCT
 76:       PetscEnum PETSC_DATATYPE_UNKNOWN

 78: #if defined(PETSC_USE_REAL_SINGLE)
 79: #define PETSC_REAL PETSC_FLOAT
 80: #elif defined(PETSC_USE_REAL___FLOAT128)
 81: #define PETSC_REAL PETSC___FLOAT128
 82: #else
 83: #define PETSC_REAL PETSC_DOUBLE
 84: #endif
 85: #define PETSC_FORTRANADDR PETSC_LONG

 87:       parameter (PETSC_INT=0,PETSC_DOUBLE=1,PETSC_COMPLEX=2)
 88:       parameter (PETSC_LONG=3,PETSC_SHORT=4,PETSC_FLOAT=5)
 89:       parameter (PETSC_CHAR=6,PETSC_BIT_LOGICAL=7,PETSC_ENUM=8)
 90:       parameter (PETSC_BOOL=9,PETSC___FLOAT128=10)
 91:       parameter (PETSC_OBJECT=11,PETSC_FUNCTION=12)
 92:       parameter (PETSC_STRING=12,PETSC_STRUCT=13)
 93:       parameter (PETSC_DATATYPE_UNKNOWN=14)
 94: !
 95: !
 96: !
 97:       PetscEnum PETSC_COPY_VALUES
 98:       PetscEnum PETSC_OWN_POINTER
 99:       PetscEnum PETSC_USE_POINTER

101:       parameter (PETSC_COPY_VALUES = 0)
102:       parameter (PETSC_OWN_POINTER = 1)
103:       parameter (PETSC_USE_POINTER = 2)
104: !
105: ! ------------------------------------------------------------------------
106: !     PETSc mathematics include file. Defines certain basic mathematical
107: !    constants and functions for working with single and double precision
108: !    floating point numbers as well as complex and integers.
109: !
110: !     Representation of complex i
111: !
112:       PetscFortranComplex PETSC_i
113: #if defined(PETSC_USE_REAL_SINGLE)
114:       parameter (PETSC_i = (0.0e0,1.0e0))
115: #else
116:       parameter (PETSC_i = (0.0d0,1.0d0))
117: #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:       integer MPIU_REAL
128: #if defined (PETSC_USE_REAL_SINGLE)
129:       parameter (MPIU_REAL = MPI_REAL)
130: #else
131:       parameter(MPIU_REAL = MPI_DOUBLE_PRECISION)
132: #endif

134:       integer MPIU_SUM
135:       parameter (MPIU_SUM = MPI_SUM)

137:       integer MPIU_SCALAR
138: #if defined(PETSC_USE_COMPLEX)
139: #if defined (PETSC_USE_REAL_SINGLE)
140:       parameter(MPIU_SCALAR = MPI_COMPLEX)
141: #else
142:       parameter(MPIU_SCALAR = MPI_DOUBLE_COMPLEX)
143: #endif
144: #else
145: #if defined (PETSC_USE_REAL_SINGLE)
146:       parameter (MPIU_SCALAR = MPI_REAL)
147: #else
148:       parameter(MPIU_SCALAR = MPI_DOUBLE_PRECISION)
149: #endif
150: #endif
151: #endif

153:       integer MPIU_INTEGER
154: #if defined(PETSC_USE_64BIT_INDICES)
155:       parameter(MPIU_INTEGER = MPI_INTEGER8)
156: #else
157:       parameter(MPIU_INTEGER = MPI_INTEGER)
158: #endif

160: !
161: ! ----------------------------------------------------------------------------
162: !    BEGIN COMMON-BLOCK VARIABLES
163: !
164: !
165: !     PETSc world communicator
166: !
167:       MPI_Comm PETSC_COMM_WORLD
168:       MPI_Comm PETSC_COMM_SELF
169: !
170: !     Fortran Null
171: !
172:       PetscChar(80)       PETSC_NULL_CHARACTER
173:       PetscInt         PETSC_NULL_INTEGER(1)
174:       PetscFortranDouble PETSC_NULL_DOUBLE(1)
175: !
176: !      A PETSC_NULL_FUNCTION pointer
177: !
178:       external PETSC_NULL_FUNCTION
179:       PetscScalar PETSC_NULL_SCALAR(1)
180:       PetscReal   PETSC_NULL_REAL(1)
181:       PetscBool   PETSC_NULL_BOOL(1)
182: !
183: #if defined(PETSC_USE_REAL___FLOAT128)
184:       integer MPIU_REAL
185:       integer MPIU_SCALAR
186:       integer MPIU_SUM
187: #endif
188: !
189: !
190: !
191: !     Basic math constants
192: !
193:       PetscReal PETSC_PI
194:       PetscReal PETSC_MAX_REAL
195:       PetscReal PETSC_MIN_REAL
196:       PetscReal PETSC_MACHINE_EPSILON
197:       PetscReal PETSC_SQRT_MACHINE_EPSILON
198:       PetscReal PETSC_SMALL
199:       PetscReal PETSC_INFINITY
200:       PetscReal PETSC_NINFINITY

202: !
203: !     Common Block to store some of the PETSc constants.
204: !     which can be set - only at runtime.
205: !
206:       common /petscfortran1/ PETSC_NULL_CHARACTER
207:       common /petscfortran2/PETSC_NULL_INTEGER
208:       common /petscfortran4/ PETSC_NULL_SCALAR
209:       common /petscfortran5/ PETSC_NULL_DOUBLE
210:       common /petscfortran6/ PETSC_NULL_REAL
211:       common /petscfortran7/ PETSC_NULL_BOOL
212:       common /petscfortran9/ PETSC_COMM_WORLD
213:       common /petscfortran10/ PETSC_COMM_SELF
214: #if defined(PETSC_USE_REAL___FLOAT128)
215:       common /petscfortran11/ MPIU_REAL
216:       common /petscfortran12/ MPIU_SCALAR
217:       common /petscfortran13/ MPIU_SUM
218: #endif
219:       common /petscfortran14/ PETSC_PI
220:       common /petscfortran15/ PETSC_MAX_REAL
221:       common /petscfortran16/ PETSC_MIN_REAL
222:       common /petscfortran17/ PETSC_MACHINE_EPSILON
223:       common /petscfortran18/ PETSC_SQRT_MACHINE_EPSILON
224:       common /petscfortran19/ PETSC_SMALL
225:       common /petscfortran20/ PETSC_INFINITY
226:       common /petscfortran21/ PETSC_NINFINITY

228: !
229: !     Possible arguments to PetscPushErrorHandler()
230: !
231:       external PETSCTRACEBACKERRORHANDLER
232:       external PETSCABORTERRORHANDLER
233:       external PETSCEMACSCLIENTERRORHANDLER
234:       external PETSCATTACHDEBUGGERERRORHANDLER
235:       external PETSCIGNOREERRORHANDLER
236: !
237:       external  PetscIsInfOrNanScalar
238:       external  PetscIsInfOrNanReal
239:       PetscBool PetscIsInfOrNanScalar
240:       PetscBool PetscIsInfOrNanReal


243: !    END COMMON-BLOCK VARIABLES
244: ! ----------------------------------------------------------------------------
245: !
246: !     Random numbers
247: !
248:       type tPetscRandom
249:         sequence
250:         PetscFortranAddr:: v
251:       end type tPetscRandom

253:       PetscRandom, parameter :: PETSC_NULL_RANDOM                                  &
254:      &             = tPetscRandom(-1)
255: !
256: #define PETSCRAND 'rand'
257: #define PETSCRAND48 'rand48'
258: #define PETSCSPRNG 'sprng'
259: #define PETSCRANDER48 'rander48'
260: !
261: !
262: !
263:       PetscEnum PETSC_BINARY_INT_SIZE
264:       PetscEnum PETSC_BINARY_FLOAT_SIZE
265:       PetscEnum PETSC_BINARY_CHAR_SIZE
266:       PetscEnum PETSC_BINARY_SHORT_SIZE
267:       PetscEnum PETSC_BINARY_DOUBLE_SIZE
268:       PetscEnum PETSC_BINARY_SCALAR_SIZE

270:       parameter (PETSC_BINARY_INT_SIZE = 4)
271:       parameter (PETSC_BINARY_FLOAT_SIZE = 4)
272:       parameter (PETSC_BINARY_CHAR_SIZE = 1)
273:       parameter (PETSC_BINARY_SHORT_SIZE = 2)
274:       parameter (PETSC_BINARY_DOUBLE_SIZE = 8)
275: #if defined(PETSC_USE_COMPLEX)
276:       parameter (PETSC_BINARY_SCALAR_SIZE = 16)
277: #else
278:       parameter (PETSC_BINARY_SCALAR_SIZE = 8)
279: #endif

281:       PetscEnum PETSC_BINARY_SEEK_SET
282:       PetscEnum PETSC_BINARY_SEEK_CUR
283:       PetscEnum PETSC_BINARY_SEEK_END

285:       parameter (PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1)
286:       parameter (PETSC_BINARY_SEEK_END = 2)

288:       PetscEnum PETSC_BUILDTWOSIDED_ALLREDUCE
289:       PetscEnum PETSC_BUILDTWOSIDED_IBARRIER
290:       PetscEnum PETSC_BUILDTWOSIDED_REDSCATTER
291:       parameter (PETSC_BUILDTWOSIDED_ALLREDUCE = 0)
292:       parameter (PETSC_BUILDTWOSIDED_IBARRIER = 1)
293:       parameter (PETSC_BUILDTWOSIDED_REDSCATTER = 2)
294: !
295: !     PetscSubcommType
296: !
297:       PetscEnum PETSC_SUBCOMM_GENERAL
298:       PetscEnum PETSC_SUBCOMM_CONTIGUOUS
299:       PetscEnum PETSC_SUBCOMM_INTERLACED
300:       parameter(PETSC_SUBCOMM_GENERAL=0)
301:       parameter(PETSC_SUBCOMM_CONTIGUOUS=1)
302:       parameter(PETSC_SUBCOMM_INTERLACED=2)
303: !
304: ! include other sys components
305: !
306: #include "../src/sys/f90-mod/petscerror.h"
307: #include "../src/sys/f90-mod/petsclog.h"
308: #include "../src/sys/f90-mod/petscbag.h"