xref: /petsc/include/petscsystypes.h (revision 6ffe77eaecce1557e50d00ca5347a7f48e598865)
1 #if !defined(PETSCSYSTYPES_H)
2 #define PETSCSYSTYPES_H
3 
4 #include <petscconf.h>
5 #include <petscconf_poison.h>
6 #include <petscfix.h>
7 #include <stddef.h>
8 
9 /* SUBMANSEC = Sys */
10 
11 /*MC
12     PetscErrorCode - datatype used for return error code from almost all PETSc functions
13 
14     Level: beginner
15 
16 .seealso: `PetscCall()`, `SETERRQ()`
17 M*/
18 typedef int PetscErrorCode;
19 
20 /*MC
21 
22     PetscClassId - A unique id used to identify each PETSc class.
23 
24     Notes:
25     Use PetscClassIdRegister() to obtain a new value for a new class being created. Usually
26          XXXInitializePackage() calls it for each class it defines.
27 
28     Developer Notes:
29     Internal integer stored in the _p_PetscObject data structure.
30          These are all computed by an offset from the lowest one, PETSC_SMALLEST_CLASSID.
31 
32     Level: developer
33 
34 .seealso: `PetscClassIdRegister()`, `PetscLogEventRegister()`, `PetscHeaderCreate()`
35 M*/
36 typedef int PetscClassId;
37 
38 /*MC
39     PetscMPIInt - datatype used to represent 'int' parameters to MPI functions.
40 
41     Level: intermediate
42 
43     Notes:
44     usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but
45            standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt; it remains 32 bit.
46 
47     PetscMPIIntCast(a,&b) checks if the given PetscInt a will fit in a PetscMPIInt, if not it
48       generates a PETSC_ERR_ARG_OUTOFRANGE error.
49 
50 .seealso: `PetscBLASInt`, `PetscInt`, `PetscMPIIntCast()`
51 
52 M*/
53 typedef int PetscMPIInt;
54 
55 /*MC
56     PetscSizeT - datatype used to represent sizes in memory (like size_t)
57 
58     Level: intermediate
59 
60     Notes:
61     This is equivalent to size_t, but defined for consistency with Fortran, which lacks a native equivalent of size_t.
62 
63 .seealso: `PetscInt`, `PetscInt64`, `PetscCount`
64 
65 M*/
66 typedef size_t PetscSizeT;
67 
68 /*MC
69     PetscCount - signed datatype used to represent counts
70 
71     Level: intermediate
72 
73     Notes:
74     This is equivalent to ptrdiff_t, but defined for consistency with Fortran, which lacks a native equivalent of ptrdiff_t.
75 
76     Use PetscCount_FMT to format with PetscPrintf(), printf(), and related functions.
77 
78 .seealso: `PetscInt`, `PetscInt64`, `PetscSizeT`
79 
80 M*/
81 typedef ptrdiff_t PetscCount;
82 #define PetscCount_FMT "td"
83 
84 /*MC
85     PetscEnum - datatype used to pass enum types within PETSc functions.
86 
87     Level: intermediate
88 
89 .seealso: `PetscOptionsGetEnum()`, `PetscOptionsEnum()`, `PetscBagRegisterEnum()`
90 M*/
91 typedef enum { ENUM_DUMMY } PetscEnum;
92 
93 typedef short PetscShort;
94 typedef char  PetscChar;
95 typedef float PetscFloat;
96 
97 /*MC
98   PetscInt - PETSc type that represents an integer, used primarily to
99       represent size of arrays and indexing into arrays. Its size can be configured with the option --with-64-bit-indices to be either 32-bit (default) or 64-bit.
100 
101   Notes:
102   For MPI calls that require datatypes, use MPIU_INT as the datatype for PetscInt. It will automatically work correctly regardless of the size of PetscInt.
103 
104   Level: beginner
105 
106 .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`
107 M*/
108 
109 #if defined(PETSC_HAVE_STDINT_H)
110 #  include <stdint.h>
111 #endif
112 #if defined (PETSC_HAVE_INTTYPES_H)
113 #  if !defined(__STDC_FORMAT_MACROS)
114 #    define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */
115 #  endif
116 #  include <inttypes.h>
117 #  if !defined(PRId64)
118 #    define PRId64 "ld"
119 #  endif
120 #endif
121 
122 #if defined(PETSC_HAVE_STDINT_H) && defined(PETSC_HAVE_INTTYPES_H) && defined(PETSC_HAVE_MPI_INT64_T) /* MPI_INT64_T is not guaranteed to be a macro */
123    typedef int64_t PetscInt64;
124 #elif (PETSC_SIZEOF_LONG_LONG == 8)
125    typedef long long PetscInt64;
126 #elif defined(PETSC_HAVE___INT64)
127    typedef __int64 PetscInt64;
128 #else
129 #  error "cannot determine PetscInt64 type"
130 #endif
131 
132 #if defined(PETSC_USE_64BIT_INDICES)
133    typedef PetscInt64 PetscInt;
134 #else
135    typedef int PetscInt;
136 #endif
137 
138 #if defined(PETSC_HAVE_STDINT_H) && defined(PETSC_HAVE_INTTYPES_H) && defined(PETSC_HAVE_MPI_INT64_T) /* MPI_INT64_T is not guaranteed to be a macro */
139 #  define MPIU_INT64     MPI_INT64_T
140 #  define PetscInt64_FMT PRId64
141 #elif (PETSC_SIZEOF_LONG_LONG == 8)
142 #  define MPIU_INT64     MPI_LONG_LONG_INT
143 #  define PetscInt64_FMT "lld"
144 #elif defined(PETSC_HAVE___INT64)
145 #  define MPIU_INT64     MPI_INT64_T
146 #  define PetscInt64_FMT "ld"
147 #else
148 #  error "cannot determine PetscInt64 type"
149 #endif
150 
151 /*MC
152    PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions.
153 
154    Notes:
155     Usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but
156            standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt it remains 32 bit
157            (except on very rare BLAS/LAPACK implementations that support 64 bit integers see the notes below).
158 
159     PetscErrorCode PetscBLASIntCast(a,&b) checks if the given PetscInt a will fit in a PetscBLASInt, if not it
160       generates a PETSC_ERR_ARG_OUTOFRANGE error
161 
162    Installation Notes:
163     ./configure automatically determines the size of the integers used by BLAS/LAPACK except when --with-batch is used
164     in that situation one must know (by some other means) if the integers used by BLAS/LAPACK are 64 bit and if so pass the flag --known-64-bit-blas-indice
165 
166     MATLAB ships with BLAS and LAPACK that use 64 bit integers, for example if you run ./configure with, the option
167      --with-blaslapack-lib=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib]
168 
169     MKL ships with both 32 and 64 bit integer versions of the BLAS and LAPACK. If you pass the flag -with-64-bit-blas-indices PETSc will link
170     against the 64 bit version, otherwise it use the 32 bit version
171 
172     OpenBLAS can be built to use 64 bit integers. The ./configure options --download-openblas -with-64-bit-blas-indices will build a 64 bit integer version
173 
174     External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64 bit integers to BLAS/LAPACK so cannot
175     be used with PETSc when PETSc links against 64 bit integer BLAS/LAPACK. ./configure will generate an error if you attempt to link PETSc against any of
176     these external libraries while using 64 bit integer BLAS/LAPACK.
177 
178    Level: intermediate
179 
180 .seealso: `PetscMPIInt`, `PetscInt`, `PetscBLASIntCast()`
181 
182 M*/
183 #if defined(PETSC_HAVE_64BIT_BLAS_INDICES)
184 #  define PetscBLASInt_FMT PetscInt64_FMT
185    typedef PetscInt64 PetscBLASInt;
186 #else
187 #  define PetscBLASInt_FMT "d"
188    typedef int PetscBLASInt;
189 #endif
190 
191 /*MC
192    PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions.
193 
194    Notes:
195     As of this writing PetscCuBLASInt is always the system `int`.
196 
197     PetscErrorCode PetscCuBLASIntCast(a,&b) checks if the given PetscInt a will fit in a PetscCuBLASInt, if not it
198       generates a PETSC_ERR_ARG_OUTOFRANGE error
199 
200    Level: intermediate
201 
202 .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscCuBLASIntCast()`
203 
204 M*/
205 typedef int PetscCuBLASInt;
206 
207 /*E
208     PetscBool  - Logical variable. Actually an int in C and a logical in Fortran.
209 
210    Level: beginner
211 
212    Developer Note:
213    Why have PetscBool , why not use bool in C? The problem is that K and R C, C99 and C++ all have different mechanisms for
214       boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms.
215 
216 .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`
217 E*/
218 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscBool;
219 
220 /*MC
221    PetscReal - PETSc type that represents a real number version of PetscScalar
222 
223    Notes:
224    For MPI calls that require datatypes, use MPIU_REAL as the datatype for PetscScalar and MPIU_SUM, MPIU_MAX, etc. for operations.
225           They will automatically work correctly regardless of the size of PetscReal.
226 
227           See PetscScalar for details on how to ./configure the size of PetscReal.
228 
229    Level: beginner
230 
231 .seealso: `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`
232 M*/
233 
234 #if defined(PETSC_USE_REAL_SINGLE)
235    typedef float PetscReal;
236 #elif defined(PETSC_USE_REAL_DOUBLE)
237    typedef double PetscReal;
238 #elif defined(PETSC_USE_REAL___FLOAT128)
239 #  if defined(__cplusplus)
240      extern "C" {
241 #  endif
242 #  include <quadmath.h>
243 #  if defined(__cplusplus)
244      }
245 #  endif
246    typedef __float128 PetscReal;
247 #elif defined(PETSC_USE_REAL___FP16)
248    typedef __fp16 PetscReal;
249 #endif /* PETSC_USE_REAL_* */
250 
251 /*MC
252    PetscComplex - PETSc type that represents a complex number with precision matching that of PetscReal.
253 
254    Synopsis:
255    #include <petscsys.h>
256    PetscComplex number = 1. + 2.*PETSC_i;
257 
258    Notes:
259    For MPI calls that require datatypes, use MPIU_COMPLEX as the datatype for PetscComplex and MPIU_SUM etc for operations.
260           They will automatically work correctly regardless of the size of PetscComplex.
261 
262           See PetscScalar for details on how to ./configure the size of PetscReal
263 
264           Complex numbers are automatically available if PETSc was able to find a working complex implementation
265 
266     Petsc has a 'fix' for complex numbers to support expressions such as std::complex<PetscReal> + PetscInt, which are not supported by the standard
267     C++ library, but are convenient for petsc users. If the C++ compiler is able to compile code in petsccxxcomplexfix.h (This is checked by
268     configure), we include petsccxxcomplexfix.h to provide this convenience.
269 
270     If the fix causes conflicts, or one really does not want this fix for a particular C++ file, one can define PETSC_SKIP_CXX_COMPLEX_FIX
271     at the beginning of the C++ file to skip the fix.
272 
273    Level: beginner
274 
275 .seealso: `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i`
276 M*/
277 #if !defined(PETSC_SKIP_COMPLEX)
278 #  if defined(PETSC_CLANGUAGE_CXX)
279 #    if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128)
280 #      if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX)  /* enable complex for library code */
281 #        define PETSC_HAVE_COMPLEX 1
282 #      elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX)  /* User code only - conditional on libary code complex support */
283 #        define PETSC_HAVE_COMPLEX 1
284 #      endif
285 #    elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX)
286 #        define PETSC_HAVE_COMPLEX 1
287 #    endif
288 #  else /* !PETSC_CLANGUAGE_CXX */
289 #    if !defined(PETSC_USE_REAL___FP16)
290 #      if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */
291 #        define PETSC_HAVE_COMPLEX 1
292 #      elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX)  /* User code only - conditional on libary code complex support */
293 #        define PETSC_HAVE_COMPLEX 1
294 #      endif
295 #    endif
296 #  endif /* PETSC_CLANGUAGE_CXX */
297 #endif /* !PETSC_SKIP_COMPLEX */
298 
299 #if defined(PETSC_HAVE_COMPLEX)
300   #if defined(__cplusplus)  /* C++ complex support */
301     /* Locate a C++ complex template library */
302     #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */
303       #define petsccomplexlib Kokkos
304       #include <Kokkos_Complex.hpp>
305     #elif defined(__CUDACC__) || defined(__HIPCC__)
306       #define petsccomplexlib thrust
307       #include <thrust/complex.h>
308     #elif defined(PETSC_USE_REAL___FLOAT128)
309       #include <complex.h>
310     #else
311       #define petsccomplexlib std
312       #include <complex>
313     #endif
314 
315     /* Define PetscComplex based on the precision */
316     #if defined(PETSC_USE_REAL_SINGLE)
317       typedef petsccomplexlib::complex<float> PetscComplex;
318     #elif defined(PETSC_USE_REAL_DOUBLE)
319       typedef petsccomplexlib::complex<double> PetscComplex;
320     #elif defined(PETSC_USE_REAL___FLOAT128)
321       typedef __complex128 PetscComplex;
322     #endif
323 
324     /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */
325     #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX)
326       #include <petsccxxcomplexfix.h>
327     #endif
328   #else /* c99 complex support */
329     #include <complex.h>
330     #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16)
331       typedef float _Complex PetscComplex;
332     #elif defined(PETSC_USE_REAL_DOUBLE)
333       typedef double _Complex PetscComplex;
334     #elif defined(PETSC_USE_REAL___FLOAT128)
335       typedef __complex128 PetscComplex;
336     #endif /* PETSC_USE_REAL_* */
337   #endif /* !__cplusplus */
338 #endif /* PETSC_HAVE_COMPLEX */
339 
340 /*MC
341    PetscScalar - PETSc type that represents either a double precision real number, a double precision
342        complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured
343        with --with-scalar-type=real,complex --with-precision=single,double,__float128,__fp16
344 
345    Notes:
346    For MPI calls that require datatypes, use MPIU_SCALAR as the datatype for PetscScalar and MPIU_SUM, MPIU_MAX etc for operations. They will automatically work correctly regardless of the size of PetscScalar.
347 
348    Level: beginner
349 
350 .seealso: `PetscReal`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscRealPart()`, `PetscImaginaryPart()`
351 M*/
352 
353 #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX)
354    typedef PetscComplex PetscScalar;
355 #else /* PETSC_USE_COMPLEX */
356    typedef PetscReal PetscScalar;
357 #endif /* PETSC_USE_COMPLEX */
358 
359 /*E
360     PetscCopyMode  - Determines how an array or PetscObject passed to certain functions is copied or retained by the aggregate PetscObject
361 
362    Level: beginner
363 
364    For the array input:
365 $   PETSC_COPY_VALUES - the array values are copied into new space, the user is free to reuse or delete the passed in array
366 $   PETSC_OWN_POINTER - the array values are NOT copied, the object takes ownership of the array and will free it later, the user cannot change or
367 $                       delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran.
368 $   PETSC_USE_POINTER - the array values are NOT copied, the object uses the array but does NOT take ownership of the array. The user cannot use
369 $                       the array but the user must delete the array after the object is destroyed.
370 
371    For the PetscObject input:
372 $   PETSC_COPY_VALUES - the input PetscObject is cloned into the aggregate PetscObject; the user is free to reuse/modify the input PetscObject without side effects.
373 $   PETSC_OWN_POINTER - the input PetscObject is referenced by pointer (with reference count), thus should not be modified by the user. (Modification may cause errors or unintended side-effects in this or a future version of PETSc.)
374    For either case above, the input PetscObject should be destroyed by the user when no longer needed (the aggregate object increases its reference count).
375 $   PETSC_USE_POINTER - invalid for PetscObject inputs.
376 
377 E*/
378 typedef enum {PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER} PetscCopyMode;
379 
380 /*MC
381     PETSC_FALSE - False value of PetscBool
382 
383     Level: beginner
384 
385     Note:
386     Zero integer
387 
388 .seealso: `PetscBool`, `PETSC_TRUE`
389 M*/
390 
391 /*MC
392     PETSC_TRUE - True value of PetscBool
393 
394     Level: beginner
395 
396     Note:
397     Nonzero integer
398 
399 .seealso: `PetscBool`, `PETSC_FALSE`
400 M*/
401 
402 /*MC
403     PetscLogDouble - Used for logging times
404 
405   Notes:
406   Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc.
407 
408   Level: developer
409 
410 M*/
411 typedef double PetscLogDouble;
412 
413 /*E
414     PetscDataType - Used for handling different basic data types.
415 
416    Level: beginner
417 
418    Notes:
419    Use of this should be avoided if one can directly use MPI_Datatype instead.
420 
421    PETSC_INT is the datatype for a PetscInt, regardless of whether it is 4 or 8 bytes.
422    PETSC_REAL, PETSC_COMPLEX and PETSC_SCALAR are the datatypes for PetscReal, PetscComplex and PetscScalar, regardless of their sizes.
423 
424    Developer comment:
425    It would be nice if we could always just use MPI Datatypes, why can we not?
426 
427    If you change any values in PetscDatatype make sure you update their usage in
428    share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m
429 
430    TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM
431 
432 .seealso: `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`,
433           `PetscDataTypeGetSize()`
434 
435 E*/
436 typedef enum {PETSC_DATATYPE_UNKNOWN = 0,
437               PETSC_DOUBLE = 1, PETSC_COMPLEX = 2, PETSC_LONG = 3, PETSC_SHORT = 4, PETSC_FLOAT = 5,
438               PETSC_CHAR = 6, PETSC_BIT_LOGICAL = 7, PETSC_ENUM = 8, PETSC_BOOL = 9, PETSC___FLOAT128 = 10,
439               PETSC_OBJECT = 11, PETSC_FUNCTION = 12, PETSC_STRING = 13, PETSC___FP16 = 14, PETSC_STRUCT = 15,
440               PETSC_INT = 16, PETSC_INT64 = 17} PetscDataType;
441 
442 #if defined(PETSC_USE_REAL_SINGLE)
443 #  define PETSC_REAL PETSC_FLOAT
444 #elif defined(PETSC_USE_REAL_DOUBLE)
445 #  define PETSC_REAL PETSC_DOUBLE
446 #elif defined(PETSC_USE_REAL___FLOAT128)
447 #  define PETSC_REAL PETSC___FLOAT128
448 #elif defined(PETSC_USE_REAL___FP16)
449 #  define PETSC_REAL PETSC___FP16
450 #else
451 #  define PETSC_REAL PETSC_DOUBLE
452 #endif
453 
454 #if defined(PETSC_USE_COMPLEX)
455 #  define PETSC_SCALAR PETSC_COMPLEX
456 #else
457 #  define PETSC_SCALAR PETSC_REAL
458 #endif
459 
460 #define PETSC_FORTRANADDR PETSC_LONG
461 
462 /*S
463     PetscToken - 'Token' used for managing tokenizing strings
464 
465   Level: intermediate
466 
467 .seealso: `PetscTokenCreate()`, `PetscTokenFind()`, `PetscTokenDestroy()`
468 S*/
469 typedef struct _p_PetscToken* PetscToken;
470 
471 /*S
472      PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc
473 
474    Level: beginner
475 
476    Note:
477    This is the base class from which all PETSc objects are derived from.
478 
479 .seealso: `PetscObjectDestroy()`, `PetscObjectView()`, `PetscObjectGetName()`, `PetscObjectSetName()`, `PetscObjectReference()`, `PetscObjectDereference()`
480 S*/
481 typedef struct _p_PetscObject* PetscObject;
482 
483 /*MC
484     PetscObjectId - unique integer Id for a PetscObject
485 
486     Level: developer
487 
488     Notes:
489     Unlike pointer values, object ids are never reused.
490 
491 .seealso: `PetscObjectState`, `PetscObjectGetId()`
492 M*/
493 typedef PetscInt64 PetscObjectId;
494 
495 /*MC
496     PetscObjectState - integer state for a PetscObject
497 
498     Level: developer
499 
500     Notes:
501     Object state is always-increasing and (for objects that track state) can be used to determine if an object has
502     changed since the last time you interacted with it.  It is 64-bit so that it will not overflow for a very long time.
503 
504 .seealso: `PetscObjectId`, `PetscObjectStateGet()`, `PetscObjectStateIncrease()`, `PetscObjectStateSet()`
505 M*/
506 typedef PetscInt64 PetscObjectState;
507 
508 /*S
509      PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed
510       by string name
511 
512    Level: advanced
513 
514 .seealso: `PetscFunctionListAdd()`, `PetscFunctionListDestroy()`
515 S*/
516 typedef struct _n_PetscFunctionList *PetscFunctionList;
517 
518 /*E
519   PetscFileMode - Access mode for a file.
520 
521   Level: beginner
522 
523 $  FILE_MODE_UNDEFINED - initial invalid value
524 $  FILE_MODE_READ - open a file at its beginning for reading
525 $  FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist)
526 $  FILE_MODE_APPEND - open a file at end for writing
527 $  FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing
528 $  FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end
529 
530 .seealso: `PetscViewerFileSetMode()`
531 E*/
532 typedef enum {FILE_MODE_UNDEFINED=-1, FILE_MODE_READ=0, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode;
533 
534 typedef void* PetscDLHandle;
535 typedef enum {PETSC_DL_DECIDE=0,PETSC_DL_NOW=1,PETSC_DL_LOCAL=2} PetscDLMode;
536 
537 /*S
538      PetscObjectList - Linked list of PETSc objects, each accessible by string name
539 
540    Level: developer
541 
542    Notes:
543    Used by PetscObjectCompose() and PetscObjectQuery()
544 
545 .seealso: `PetscObjectListAdd()`, `PetscObjectListDestroy()`, `PetscObjectListFind()`, `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscFunctionList`
546 S*/
547 typedef struct _n_PetscObjectList *PetscObjectList;
548 
549 /*S
550      PetscDLLibrary - Linked list of dynamics libraries to search for functions
551 
552    Level: advanced
553 
554 .seealso: `PetscDLLibraryOpen()`
555 S*/
556 typedef struct _n_PetscDLLibrary *PetscDLLibrary;
557 
558 /*S
559      PetscContainer - Simple PETSc object that contains a pointer to any required data
560 
561    Level: advanced
562 
563 .seealso: `PetscObject`, `PetscContainerCreate()`
564 S*/
565 typedef struct _p_PetscContainer*  PetscContainer;
566 
567 /*S
568      PetscRandom - Abstract PETSc object that manages generating random numbers
569 
570    Level: intermediate
571 
572 .seealso: `PetscRandomCreate()`, `PetscRandomGetValue()`, `PetscRandomType`
573 S*/
574 typedef struct _p_PetscRandom*   PetscRandom;
575 
576 /*
577    In binary files variables are stored using the following lengths,
578   regardless of how they are stored in memory on any one particular
579   machine. Use these rather then sizeof() in computing sizes for
580   PetscBinarySeek().
581 */
582 #define PETSC_BINARY_INT_SIZE    (32/8)
583 #define PETSC_BINARY_FLOAT_SIZE  (32/8)
584 #define PETSC_BINARY_CHAR_SIZE   (8/8)
585 #define PETSC_BINARY_SHORT_SIZE  (16/8)
586 #define PETSC_BINARY_DOUBLE_SIZE (64/8)
587 #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar)
588 
589 /*E
590   PetscBinarySeekType - argument to PetscBinarySeek()
591 
592   Level: advanced
593 
594 .seealso: `PetscBinarySeek()`, `PetscBinarySynchronizedSeek()`
595 E*/
596 typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType;
597 
598 /*E
599     PetscBuildTwoSidedType - algorithm for setting up two-sided communication
600 
601 $  PETSC_BUILDTWOSIDED_ALLREDUCE - classical algorithm using an MPI_Allreduce with
602 $      a buffer of length equal to the communicator size. Not memory-scalable due to
603 $      the large reduction size. Requires only MPI-1.
604 $  PETSC_BUILDTWOSIDED_IBARRIER - nonblocking algorithm based on MPI_Issend and MPI_Ibarrier.
605 $      Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires MPI-3.
606 $  PETSC_BUILDTWOSIDED_REDSCATTER - similar to above, but use more optimized function
607 $      that only communicates the part of the reduction that is necessary.  Requires MPI-2.
608 
609    Level: developer
610 
611 .seealso: `PetscCommBuildTwoSided()`, `PetscCommBuildTwoSidedSetType()`, `PetscCommBuildTwoSidedGetType()`
612 E*/
613 typedef enum {
614   PETSC_BUILDTWOSIDED_NOTSET = -1,
615   PETSC_BUILDTWOSIDED_ALLREDUCE = 0,
616   PETSC_BUILDTWOSIDED_IBARRIER = 1,
617   PETSC_BUILDTWOSIDED_REDSCATTER = 2
618   /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */
619 } PetscBuildTwoSidedType;
620 
621 /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */
622 /*E
623   InsertMode - Whether entries are inserted or added into vectors or matrices
624 
625   Level: beginner
626 
627 .seealso: `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
628           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`,
629           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`
630 E*/
631  typedef enum {NOT_SET_VALUES, INSERT_VALUES, ADD_VALUES, MAX_VALUES, MIN_VALUES, INSERT_ALL_VALUES, ADD_ALL_VALUES, INSERT_BC_VALUES, ADD_BC_VALUES} InsertMode;
632 
633 /*MC
634     INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value
635 
636     Level: beginner
637 
638 .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
639           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `ADD_VALUES`,
640           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES`
641 
642 M*/
643 
644 /*MC
645     ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the
646                 value into that location
647 
648     Level: beginner
649 
650 .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
651           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `INSERT_VALUES`,
652           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES`
653 
654 M*/
655 
656 /*MC
657     MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location
658 
659     Level: beginner
660 
661 .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES`
662 
663 M*/
664 
665 /*MC
666     MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location
667 
668     Level: beginner
669 
670 .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES`
671 
672 M*/
673 
674 /*S
675    PetscSubcomm - A decomposition of an MPI communicator into subcommunicators
676 
677    Notes:
678    After a call to PetscSubcommSetType(), PetscSubcommSetTypeGeneral(), or PetscSubcommSetFromOptions() one may call
679 $     PetscSubcommChild() returns the associated subcommunicator on this process
680 $     PetscSubcommContiguousParent() returns a parent communitor but with all child of the same subcommunicator having contiguous rank
681 
682    Sample Usage:
683        PetscSubcommCreate()
684        PetscSubcommSetNumber()
685        PetscSubcommSetType(PETSC_SUBCOMM_INTERLACED);
686        ccomm = PetscSubcommChild()
687        PetscSubcommDestroy()
688 
689    Level: advanced
690 
691    Notes:
692 $   PETSC_SUBCOMM_GENERAL - similar to MPI_Comm_split() each process sets the new communicator (color) they will belong to and the order within that communicator
693 $   PETSC_SUBCOMM_CONTIGUOUS - each new communicator contains a set of process with contiguous ranks in the original MPI communicator
694 $   PETSC_SUBCOMM_INTERLACED - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator
695 
696    Example: Consider a communicator with six processes split into 3 subcommunicators.
697 $     PETSC_SUBCOMM_CONTIGUOUS - the first communicator contains rank 0,1  the second rank 2,3 and the third rank 4,5 in the original ordering of the original communicator
698 $     PETSC_SUBCOMM_INTERLACED - the first communicator contains rank 0,3, the second 1,4 and the third 2,5
699 
700    Developer Notes:
701    This is used in objects such as PCREDUNDANT to manage the subcommunicators on which the redundant computations
702       are performed.
703 
704 .seealso: `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()`
705 
706 S*/
707 typedef struct _n_PetscSubcomm* PetscSubcomm;
708 typedef enum {PETSC_SUBCOMM_GENERAL=0,PETSC_SUBCOMM_CONTIGUOUS=1,PETSC_SUBCOMM_INTERLACED=2} PetscSubcommType;
709 
710 /*S
711      PetscHeap - A simple class for managing heaps
712 
713    Level: intermediate
714 
715 .seealso: `PetscHeapCreate()`, `PetscHeapAdd()`, `PetscHeapPop()`, `PetscHeapPeek()`, `PetscHeapStash()`, `PetscHeapUnstash()`, `PetscHeapView()`, `PetscHeapDestroy()`
716 S*/
717 typedef struct _PetscHeap *PetscHeap;
718 
719 typedef struct _n_PetscShmComm* PetscShmComm;
720 typedef struct _n_PetscOmpCtrl* PetscOmpCtrl;
721 
722 /*S
723    PetscSegBuffer - a segmented extendable buffer
724 
725    Level: developer
726 
727 .seealso: `PetscSegBufferCreate()`, `PetscSegBufferGet()`, `PetscSegBufferExtract()`, `PetscSegBufferDestroy()`
728 S*/
729 typedef struct _n_PetscSegBuffer *PetscSegBuffer;
730 
731 typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted;
732 #endif
733