xref: /petsc/include/petsc.h (revision 77431f27ef6a796c710ee53da3b02f01a7247aeb)
1 /*
2    This is the main PETSc include file (for C and C++).  It is included by all
3    other PETSc include files, so it almost never has to be specifically included.
4 */
5 #if !defined(__PETSC_H)
6 #define __PETSC_H
7 /* ========================================================================== */
8 /*
9    This facilitates using C version of PETSc from C++
10 */
11 
12 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
13 #define PETSC_EXTERN_CXX_BEGIN extern "C" {
14 #define PETSC_EXTERN_CXX_END  }
15 #else
16 #define PETSC_EXTERN_CXX_BEGIN
17 #define PETSC_EXTERN_CXX_END
18 #endif
19 /* ========================================================================== */
20 /*
21    Current PETSc version number and release date
22 */
23 #include "petscversion.h"
24 
25 /* ========================================================================== */
26 /*
27    petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h it is
28    found automatically by the compiler due to the -I${PETSC_DIR}/bmake/${PETSC_ARCH}
29    in the bmake/common_variables definition of PETSC_INCLUDE
30 */
31 #include "petscconf.h"
32 
33 /*
34    Currently cannot check formatting for PETSc print statements because we have our
35    own format %D
36 */
37 #undef  PETSC_PRINTF_FORMAT_CHECK
38 #define PETSC_PRINTF_FORMAT_CHECK(a,b)
39 #undef  PETSC_FPRINTF_FORMAT_CHECK
40 #define PETSC_FPRINTF_FORMAT_CHECK(a,b)
41 
42 /*
43    Fixes for configure time choices which impact our interface. Currently only
44    calling conventions and extra compiler checking falls under this category.
45 */
46 #if !defined (PETSC_STDCALL)
47 #define PETSC_STDCALL
48 #endif
49 #if !defined (PETSC_TEMPLATE)
50 #define PETSC_TEMPLATE
51 #endif
52 
53 /* ========================================================================== */
54 
55 #include <stdio.h>
56 /*
57     Defines the interface to MPI allowing the use of all MPI functions.
58 */
59 #include "mpi.h"
60 
61 /*
62     All PETSc C functions return this error code, it is the final argument of
63    all Fortran subroutines
64 */
65 typedef int PetscErrorCode;
66 typedef int PetscCookie;
67 typedef int PetscEvent;
68 typedef int PetscBLASInt;
69 typedef int PetscMPIInt;
70 
71 #if defined(PETSC_USE_64BIT_INT)
72 typedef long long PetscInt;
73 #define MPIU_INT MPI_LONG_LONG_INT
74 #else
75 typedef int PetscInt;
76 #define MPIU_INT MPI_INT
77 #endif
78 
79 /*
80     Declare extern C stuff after incuding external header files
81 */
82 
83 PETSC_EXTERN_CXX_BEGIN
84 
85 /*
86     EXTERN indicates a PETSc function defined elsewhere
87 */
88 #if !defined(EXTERN)
89 #define EXTERN extern
90 #endif
91 
92 /*
93     Defines some elementary mathematics functions and constants.
94 */
95 #include "petscmath.h"
96 
97 /*
98        Basic PETSc constants
99 */
100 
101 /*E
102     PetscTruth - Logical variable. Actually an integer
103 
104    Level: beginner
105 
106 E*/
107 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth;
108 
109 /*M
110     PETSC_FALSE - False value of PetscTruth
111 
112     Level: beginner
113 
114     Note: Zero integer
115 
116 .seealso: PetscTruth
117 M*/
118 
119 /*M
120     PETSC_TRUE - True value of PetscTruth
121 
122     Level: beginner
123 
124     Note: Nonzero integer
125 
126 .seealso: PetscTruth
127 M*/
128 
129 /*M
130     PETSC_YES - Alias for PETSC_TRUE
131 
132     Level: beginner
133 
134     Note: Zero integer
135 
136 .seealso: PetscTruth
137 M*/
138 
139 /*M
140     PETSC_NO - Alias for PETSC_FALSE
141 
142     Level: beginner
143 
144     Note: Nonzero integer
145 
146 .seealso: PetscTruth
147 M*/
148 
149 /*M
150     PETSC_NULL - standard way of passing in a null or array or pointer
151 
152    Level: beginner
153 
154    Notes: accepted by many PETSc functions to not set a parameter and instead use
155           some default
156 
157           This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
158           PETSC_NULL_DOUBLE_PRECISION etc
159 
160 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
161 
162 M*/
163 #define PETSC_NULL           0
164 
165 /*M
166     PETSC_DECIDE - standard way of passing in integer or floating point parameter
167        where you wish PETSc to use the default.
168 
169    Level: beginner
170 
171 .seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
172 
173 M*/
174 #define PETSC_DECIDE         -1
175 
176 /*M
177     PETSC_DEFAULT - standard way of passing in integer or floating point parameter
178        where you wish PETSc to use the default.
179 
180    Level: beginner
181 
182 .seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE
183 
184 M*/
185 #define PETSC_DEFAULT        -2
186 
187 #define PETSC_YES            PETSC_TRUE
188 #define PETSC_NO             PETSC_FALSE
189 
190 /*M
191     PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument
192 
193    Level: beginner
194 
195    Notes: accepted by many PETSc functions to not set a parameter and instead use
196           some default
197 
198           This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
199           PETSC_NULL_DOUBLE_PRECISION etc
200 
201 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE
202 
203 M*/
204 #define PETSC_IGNORE         PETSC_NULL
205 
206 /*M
207     PETSC_DETERMINE - standard way of passing in integer or floating point parameter
208        where you wish PETSc to compute the required value.
209 
210    Level: beginner
211 
212 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes()
213 
214 M*/
215 #define PETSC_DETERMINE      PETSC_DECIDE
216 
217 /*M
218     PETSC_COMM_WORLD - a duplicate of the MPI_COMM_WORLD communicator which represents
219            all the processs
220 
221    Level: beginner
222 
223    Notes: PETSC_COMM_WORLD and MPI_COMM_WORLD are equivalent except that passing MPI_COMM_WORLD
224           into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup()
225           will be done on it internally. We recommend always using PETSC_COMM_WORLD
226 
227 .seealso: PETSC_COMM_SELF
228 
229 M*/
230 extern MPI_Comm   PETSC_COMM_WORLD;
231 
232 /*M
233     PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents
234            the current process
235 
236    Level: beginner
237 
238    Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent except that passint MPI_COMM_SELF
239           into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup()
240           will be done on it internally. We recommend always using PETSC_COMM_SELF
241 
242 .seealso: PETSC_COMM_WORLD
243 
244 M*/
245 extern MPI_Comm   PETSC_COMM_SELF;
246 
247 extern PetscTruth PetscInitializeCalled;
248 EXTERN PetscErrorCode        PetscSetCommWorld(MPI_Comm);
249 EXTERN PetscErrorCode        PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm));
250 EXTERN PetscErrorCode        PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*);
251 EXTERN PetscErrorCode        PetscCommDestroy(MPI_Comm*);
252 
253 /*MC
254    PetscMalloc - Allocates memory
255 
256    Input Parameter:
257 .  m - number of bytes to allocate
258 
259    Output Parameter:
260 .  result - memory allocated
261 
262    Synopsis:
263    PetscErrorCode PetscMalloc(size_t m,void **result)
264 
265    Level: beginner
266 
267    Notes: Memory is always allocated at least double aligned
268 
269 .seealso: PetscFree(), PetscNew()
270 
271   Concepts: memory allocation
272 
273 M*/
274 #define PetscMalloc(a,b)     (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b))
275 /*MC
276    PetscNew - Allocates memory of a particular type
277 
278    Input Parameter:
279 . type - structure name of space to be allocated. Memory of size sizeof(type) is allocated
280 
281    Output Parameter:
282 .  result - memory allocated
283 
284    Synopsis:
285    PetscErrorCode PetscNew(struct type,((type *))result)
286 
287    Level: beginner
288 
289 .seealso: PetscFree(), PetscMalloc()
290 
291   Concepts: memory allocation
292 
293 M*/
294 #define PetscNew(A,b)        PetscMalloc(sizeof(A),(b))
295 /*MC
296    PetscFree - Frees memory
297 
298    Input Parameter:
299 .   memory - memory to free
300 
301    Synopsis:
302    PetscErrorCode PetscFree(void *memory)
303 
304    Level: beginner
305 
306    Notes: Memory must have been obtained with PetscNew() or PetscMalloc()
307 
308 .seealso: PetscNew(), PetscMalloc()
309 
310   Concepts: memory allocation
311 
312 M*/
313 #define PetscFree(a)   ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__) || ((a = 0),0))
314 EXTERN PetscErrorCode  (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**);
315 EXTERN PetscErrorCode  (*PetscTrFree)(void*,int,const char[],const char[],const char[]);
316 EXTERN PetscErrorCode  PetscSetMalloc(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[]));
317 EXTERN PetscErrorCode  PetscClearMalloc(void);
318 
319 /*
320    Routines for tracing memory corruption/bleeding with default PETSc
321    memory allocation
322 */
323 EXTERN PetscErrorCode   PetscTrDump(FILE *);
324 EXTERN PetscErrorCode   PetscTrSpace(PetscLogDouble *,PetscLogDouble *,PetscLogDouble *);
325 EXTERN PetscErrorCode   PetscTrValid(int,const char[],const char[],const char[]);
326 EXTERN PetscErrorCode   PetscTrDebug(PetscTruth);
327 EXTERN PetscErrorCode   PetscTrLog(void);
328 EXTERN PetscErrorCode   PetscTrLogDump(FILE *);
329 EXTERN PetscErrorCode   PetscGetResidentSetSize(PetscLogDouble *);
330 
331 /*
332     Variable type where we stash PETSc object pointers in Fortran.
333     Assumes that sizeof(long) == sizeof(void*)which is true on
334     all machines that we know.
335 */
336 #define PetscFortranAddr   long
337 
338 /*E
339     PetscDataType - Used for handling different basic data types.
340 
341    Level: beginner
342 
343 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(),
344           PetscDataTypeGetSize(), PetscDataTypeGetName()
345 
346 E*/
347 typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2,
348               PETSC_LONG =3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5,
349               PETSC_CHAR = 6,PETSC_LOGICAL = 7} PetscDataType;
350 #if defined(PETSC_USE_COMPLEX)
351 #define PETSC_SCALAR PETSC_COMPLEX
352 #else
353 #if defined(PETSC_USE_SINGLE)
354 #define PETSC_SCALAR PETSC_FLOAT
355 #else
356 #define PETSC_SCALAR PETSC_DOUBLE
357 #endif
358 #endif
359 #if defined(PETSC_USE_SINGLE)
360 #define PETSC_REAL PETSC_FLOAT
361 #else
362 #define PETSC_REAL PETSC_DOUBLE
363 #endif
364 #define PETSC_FORTRANADDR PETSC_LONG
365 
366 EXTERN PetscErrorCode PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
367 EXTERN PetscErrorCode PetscDataTypeGetSize(PetscDataType,int*);
368 EXTERN PetscErrorCode PetscDataTypeGetName(PetscDataType,const char*[]);
369 
370 /*
371     Basic memory and string operations. These are usually simple wrappers
372    around the basic Unix system calls, but a few of them have additional
373    functionality and/or error checking.
374 */
375 EXTERN PetscErrorCode   PetscMemcpy(void*,const void *,size_t);
376 EXTERN PetscErrorCode   PetscBitMemcpy(void*,int,const void*,int,int,PetscDataType);
377 EXTERN PetscErrorCode   PetscMemmove(void*,void *,size_t);
378 EXTERN PetscErrorCode   PetscMemzero(void*,size_t);
379 EXTERN PetscErrorCode   PetscMemcmp(const void*,const void*,size_t,PetscTruth *);
380 EXTERN PetscErrorCode   PetscStrlen(const char[],size_t*);
381 EXTERN PetscErrorCode   PetscStrcmp(const char[],const char[],PetscTruth *);
382 EXTERN PetscErrorCode   PetscStrgrt(const char[],const char[],PetscTruth *);
383 EXTERN PetscErrorCode   PetscStrcasecmp(const char[],const char[],PetscTruth*);
384 EXTERN PetscErrorCode   PetscStrncmp(const char[],const char[],size_t,PetscTruth*);
385 EXTERN PetscErrorCode   PetscStrcpy(char[],const char[]);
386 EXTERN PetscErrorCode   PetscStrcat(char[],const char[]);
387 EXTERN PetscErrorCode   PetscStrncat(char[],const char[],size_t);
388 EXTERN PetscErrorCode   PetscStrncpy(char[],const char[],size_t);
389 EXTERN PetscErrorCode   PetscStrchr(const char[],char,char *[]);
390 EXTERN PetscErrorCode   PetscStrtolower(char[]);
391 EXTERN PetscErrorCode   PetscStrrchr(const char[],char,char *[]);
392 EXTERN PetscErrorCode   PetscStrstr(const char[],const char[],char *[]);
393 EXTERN PetscErrorCode   PetscStrallocpy(const char[],char *[]);
394 EXTERN PetscErrorCode   PetscStrreplace(MPI_Comm,const char[],char[],size_t);
395 #define      PetscStrfree(a) ((a) ? PetscFree(a) : 0)
396 /*S
397     PetscToken - 'Token' used for managing tokenizing strings
398 
399   Level: intermediate
400 
401 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy()
402 S*/
403 typedef struct {char token;char *array;char *current;} PetscToken;
404 
405 EXTERN PetscErrorCode   PetscTokenCreate(const char[],const char,PetscToken**);
406 EXTERN PetscErrorCode   PetscTokenFind(PetscToken*,char *[]);
407 EXTERN PetscErrorCode   PetscTokenDestroy(PetscToken*);
408 
409 /*
410    These are  MPI operations for MPI_Allreduce() etc
411 */
412 EXTERN MPI_Op PetscMaxSum_Op;
413 #if defined(PETSC_USE_COMPLEX)
414 EXTERN MPI_Op PetscSum_Op;
415 #else
416 #define PetscSum_Op MPI_SUM
417 #endif
418 EXTERN PetscErrorCode PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*);
419 
420 /*S
421      PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc
422 
423    Level: beginner
424 
425    Note: This is the base class from which all objects appear.
426 
427 .seealso:  PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName()
428 S*/
429 typedef struct _p_PetscObject* PetscObject;
430 
431 /*S
432      PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed
433       by string name
434 
435    Level: advanced
436 
437 .seealso:  PetscFListAdd(), PetscFListDestroy()
438 S*/
439 typedef struct _PetscFList *PetscFList;
440 
441 #include "petscviewer.h"
442 #include "petscoptions.h"
443 
444 EXTERN PetscErrorCode PetscShowMemoryUsage(PetscViewer,const char[]);
445 EXTERN PetscErrorCode PetscGetTime(PetscLogDouble*);
446 EXTERN PetscErrorCode PetscGetCPUTime(PetscLogDouble*);
447 EXTERN PetscErrorCode PetscSleep(int);
448 
449 /*
450     Initialization of PETSc
451 */
452 EXTERN PetscErrorCode  PetscInitialize(int*,char***,const char[],const char[]);
453 EXTERN PetscErrorCode  PetscInitializeNoArguments(void);
454 EXTERN PetscErrorCode  PetscInitialized(PetscTruth *);
455 EXTERN PetscErrorCode  PetscFinalize(void);
456 EXTERN PetscErrorCode  PetscInitializeFortran(void);
457 EXTERN PetscErrorCode  PetscGetArgs(int*,char ***);
458 EXTERN PetscErrorCode  PetscEnd(void);
459 
460 typedef void (**PetscVoidFunction)(void);
461 
462 /*
463    PetscTryMethod - Queries an object for a method, if it exists then calls it.
464               These are intended to be used only inside PETSc functions.
465 */
466 #define  PetscTryMethod(obj,A,B,C) \
467   0;{ PetscErrorCode (*f)B, __ierr; \
468     __ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \
469     if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
470   }
471 #define  PetscUseMethod(obj,A,B,C) \
472   0;{ PetscErrorCode (*f)B, __ierr; \
473     __ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \
474     if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
475     else {SETERRQ1(PETSC_ERR_SUP,"Cannot locate function %s in object",A);} \
476   }
477 /*
478     Functions that can act on any PETSc object.
479 */
480 EXTERN PetscErrorCode PetscObjectDestroy(PetscObject);
481 EXTERN PetscErrorCode PetscObjectExists(PetscObject,PetscTruth*);
482 EXTERN PetscErrorCode PetscObjectGetComm(PetscObject,MPI_Comm *);
483 EXTERN PetscErrorCode PetscObjectGetCookie(PetscObject,int *);
484 EXTERN PetscErrorCode PetscObjectGetType(PetscObject,int *);
485 EXTERN PetscErrorCode PetscObjectSetName(PetscObject,const char[]);
486 EXTERN PetscErrorCode PetscObjectGetName(PetscObject,char*[]);
487 EXTERN PetscErrorCode PetscObjectReference(PetscObject);
488 EXTERN PetscErrorCode PetscObjectGetReference(PetscObject,int*);
489 EXTERN PetscErrorCode PetscObjectDereference(PetscObject);
490 EXTERN PetscErrorCode PetscObjectGetNewTag(PetscObject,PetscMPIInt *);
491 EXTERN PetscErrorCode PetscCommGetNewTag(MPI_Comm,PetscMPIInt *);
492 EXTERN PetscErrorCode PetscObjectView(PetscObject,PetscViewer);
493 EXTERN PetscErrorCode PetscObjectCompose(PetscObject,const char[],PetscObject);
494 EXTERN PetscErrorCode PetscObjectQuery(PetscObject,const char[],PetscObject *);
495 EXTERN PetscErrorCode PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void));
496 
497 typedef void (*FCNVOID)(void); /* cast in next macro should never be extern C */
498 typedef PetscErrorCode (*FCNINTVOID)(void); /* used in casts to make sure they are not extern C */
499 /*MC
500    PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object.
501 
502    Collective on PetscObject
503 
504    Input Parameters:
505 +  obj - the PETSc object; this must be cast with a (PetscObject), for example,
506          PetscObjectCompose((PetscObject)mat,...);
507 .  name - name associated with the child function
508 .  fname - name of the function
509 -  ptr - function pointer (or PETSC_NULL if using dynamic libraries)
510 
511    Level: advanced
512 
513     Synopsis:
514     int PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr)
515 
516    Notes:
517    To remove a registered routine, pass in a PETSC_NULL rname and fnc().
518 
519    PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as
520    Mat, Vec, KSP, SNES, etc.) or any user-provided object.
521 
522    The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to
523    work in C++/complex with dynamic link libraries (PETSC_USE_DYNAMIC_LIBRARIES)
524    enabled.
525 
526    Concepts: objects^composing functions
527    Concepts: composing functions
528    Concepts: functions^querying
529    Concepts: objects^querying
530    Concepts: querying objects
531 
532 .seealso: PetscObjectQueryFunction()
533 M*/
534 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
535 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0)
536 #else
537 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(FCNVOID)(d))
538 #endif
539 
540 EXTERN PetscErrorCode PetscObjectQueryFunction(PetscObject,const char[],void (**)(void));
541 EXTERN PetscErrorCode PetscObjectSetOptionsPrefix(PetscObject,const char[]);
542 EXTERN PetscErrorCode PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
543 EXTERN PetscErrorCode PetscObjectPrependOptionsPrefix(PetscObject,const char[]);
544 EXTERN PetscErrorCode PetscObjectGetOptionsPrefix(PetscObject,char*[]);
545 EXTERN PetscErrorCode PetscObjectPublish(PetscObject);
546 EXTERN PetscErrorCode PetscObjectChangeTypeName(PetscObject,const char[]);
547 EXTERN PetscErrorCode PetscObjectRegisterDestroy(PetscObject);
548 EXTERN PetscErrorCode PetscObjectRegisterDestroyAll(void);
549 EXTERN PetscErrorCode PetscObjectName(PetscObject);
550 EXTERN PetscErrorCode PetscTypeCompare(PetscObject,const char[],PetscTruth*);
551 
552 /*
553     Defines PETSc error handling.
554 */
555 #include "petscerror.h"
556 
557 /*S
558      PetscOList - Linked list of PETSc objects, accessable by string name
559 
560    Level: advanced
561 
562 .seealso:  PetscOListAdd(), PetscOListDestroy(), PetscOListFind()
563 S*/
564 typedef struct _PetscOList *PetscOList;
565 
566 EXTERN PetscErrorCode PetscOListDestroy(PetscOList *);
567 EXTERN PetscErrorCode PetscOListFind(PetscOList,const char[],PetscObject*);
568 EXTERN PetscErrorCode PetscOListReverseFind(PetscOList,PetscObject,char**);
569 EXTERN PetscErrorCode PetscOListAdd(PetscOList *,const char[],PetscObject);
570 EXTERN PetscErrorCode PetscOListDuplicate(PetscOList,PetscOList *);
571 
572 /*
573     Dynamic library lists. Lists of names of routines in dynamic
574   link libraries that will be loaded as needed.
575 */
576 EXTERN PetscErrorCode PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void));
577 EXTERN PetscErrorCode PetscFListDestroy(PetscFList*);
578 EXTERN PetscErrorCode PetscFListFind(MPI_Comm,PetscFList,const char[],void (**)(void));
579 EXTERN PetscErrorCode PetscFListPrintTypes(MPI_Comm,FILE*,const char[],const char[],const char[],const char[],PetscFList);
580 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
581 #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0)
582 #else
583 #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c)
584 #endif
585 EXTERN PetscErrorCode PetscFListDuplicate(PetscFList,PetscFList *);
586 EXTERN PetscErrorCode PetscFListView(PetscFList,PetscViewer);
587 EXTERN PetscErrorCode PetscFListConcat(const char [],const char [],char []);
588 EXTERN PetscErrorCode PetscFListGet(PetscFList,char ***,int*);
589 
590 /*S
591      PetscDLLibraryList - Linked list of dynamics libraries to search for functions
592 
593    Level: advanced
594 
595    PETSC_USE_DYNAMIC_LIBRARIES must be defined in petscconf.h to use dynamic libraries
596 
597 .seealso:  PetscDLLibraryOpen()
598 S*/
599 typedef struct _PetscDLLibraryList *PetscDLLibraryList;
600 extern PetscDLLibraryList DLLibrariesLoaded;
601 EXTERN PetscErrorCode PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *);
602 EXTERN PetscErrorCode PetscDLLibraryOpen(MPI_Comm,const char[],void **);
603 EXTERN PetscErrorCode PetscDLLibrarySym(MPI_Comm,PetscDLLibraryList *,const char[],const char[],void **);
604 EXTERN PetscErrorCode PetscDLLibraryAppend(MPI_Comm,PetscDLLibraryList *,const char[]);
605 EXTERN PetscErrorCode PetscDLLibraryPrepend(MPI_Comm,PetscDLLibraryList *,const char[]);
606 EXTERN PetscErrorCode PetscDLLibraryClose(PetscDLLibraryList);
607 EXTERN PetscErrorCode PetscDLLibraryPrintPath(void);
608 EXTERN PetscErrorCode PetscDLLibraryGetInfo(void*,const char[],const char *[]);
609 
610 /*
611     Mechanism for translating PETSc object representations between languages
612     Not currently used.
613 */
614 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage;
615 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C
616 EXTERN PetscErrorCode PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *);
617 EXTERN PetscErrorCode PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **);
618 
619 /*
620      Useful utility routines
621 */
622 EXTERN PetscErrorCode PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*);
623 EXTERN PetscErrorCode PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*);
624 EXTERN PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt);
625 EXTERN PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt);
626 EXTERN PetscErrorCode PetscBarrier(PetscObject);
627 EXTERN PetscErrorCode PetscMPIDump(FILE*);
628 
629 #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE)
630 /*
631     Defines basic graphics available from PETSc.
632 */
633 #include "petscdraw.h"
634 
635 /*
636     Defines the base data structures for all PETSc objects
637 */
638 #include "petschead.h"
639 
640 /*
641      Defines PETSc profiling.
642 */
643 #include "petsclog.h"
644 
645 /*
646           For locking, unlocking and destroying AMS memories associated with
647     PETSc objects. Not currently used.
648 */
649 #define PetscPublishAll(v)           0
650 #define PetscObjectTakeAccess(obj)   0
651 #define PetscObjectGrantAccess(obj)  0
652 #define PetscObjectDepublish(obj)    0
653 
654 
655 
656 /*
657       This code allows one to pass a MPI communicator between
658     C and Fortran. MPI 2.0 defines a standard API for doing this.
659     The code here is provided to allow PETSc to work with MPI 1.1
660     standard MPI libraries.
661 */
662 EXTERN PetscErrorCode  MPICCommToFortranComm(MPI_Comm,int *);
663 EXTERN PetscErrorCode  MPIFortranCommToCComm(int,MPI_Comm*);
664 
665 /*
666       Simple PETSc parallel IO for ASCII printing
667 */
668 EXTERN PetscErrorCode  PetscFixFilename(const char[],char[]);
669 EXTERN PetscErrorCode  PetscFOpen(MPI_Comm,const char[],const char[],FILE**);
670 EXTERN PetscErrorCode  PetscFClose(MPI_Comm,FILE*);
671 EXTERN PetscErrorCode  PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
672 EXTERN PetscErrorCode  PetscPrintf(MPI_Comm,const char[],...)  PETSC_PRINTF_FORMAT_CHECK(2,3);
673 
674 /* These are used internally by PETSc ASCII IO routines*/
675 #include <stdarg.h>
676 EXTERN PetscErrorCode  PetscVSNPrintf(char*,size_t,const char*,va_list);
677 EXTERN PetscErrorCode  PetscVFPrintf(FILE*,const char*,va_list);
678 
679 /*MC
680     PetscErrorPrintf - Prints error messages.
681 
682     Not Collective
683 
684    Synopsis:
685      PetscErrorCode (*PetscErrorPrintf)(const char format[],...);
686 
687     Input Parameters:
688 .   format - the usual printf() format string
689 
690    Options Database Keys:
691 .    -error_output_stderr - cause error messages to be printed to stderr instead of the
692          (default) stdout
693 
694 
695    Level: developer
696 
697     Fortran Note:
698     This routine is not supported in Fortran.
699 
700     Concepts: error messages^printing
701     Concepts: printing^error messages
702 
703 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf()
704 M*/
705 EXTERN PetscErrorCode  (*PetscErrorPrintf)(const char[],...);
706 
707 /*MC
708     PetscHelpPrintf - Prints help messages.
709 
710     Not Collective
711 
712    Synopsis:
713      PetscErrorCode (*PetscHelpPrintf)(const char format[],...);
714 
715     Input Parameters:
716 .   format - the usual printf() format string
717 
718    Level: developer
719 
720     Fortran Note:
721     This routine is not supported in Fortran.
722 
723     Concepts: help messages^printing
724     Concepts: printing^help messages
725 
726 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf()
727 M*/
728 EXTERN PetscErrorCode  (*PetscHelpPrintf)(MPI_Comm,const char[],...);
729 
730 EXTERN PetscErrorCode  PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **);
731 EXTERN PetscErrorCode  PetscPClose(MPI_Comm,FILE*);
732 EXTERN PetscErrorCode  PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
733 EXTERN PetscErrorCode  PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
734 EXTERN PetscErrorCode  PetscSynchronizedFlush(MPI_Comm);
735 EXTERN PetscErrorCode  PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]);
736 EXTERN PetscErrorCode  PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**);
737 EXTERN PetscErrorCode  PetscStartJava(MPI_Comm,const char[],const char[],FILE**);
738 EXTERN PetscErrorCode  PetscGetPetscDir(const char*[]);
739 
740 EXTERN PetscErrorCode  PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*);
741 /*S
742      PetscObjectContainer - Simple PETSc object that contains a pointer to any required data
743 
744    Level: advanced
745 
746 .seealso:  PetscObject, PetscObjectContainerCreate()
747 S*/
748 typedef struct _p_PetscObjectContainer*  PetscObjectContainer;
749 EXTERN PetscErrorCode PetscObjectContainerGetPointer(PetscObjectContainer,void **);
750 EXTERN PetscErrorCode PetscObjectContainerSetPointer(PetscObjectContainer,void *);
751 EXTERN PetscErrorCode PetscObjectContainerDestroy(PetscObjectContainer);
752 EXTERN PetscErrorCode PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *);
753 
754 /*
755    For incremental debugging
756 */
757 extern PetscTruth PetscCompare;
758 EXTERN PetscErrorCode        PetscCompareDouble(double);
759 EXTERN PetscErrorCode        PetscCompareScalar(PetscScalar);
760 EXTERN PetscErrorCode        PetscCompareInt(PetscInt);
761 
762 /*
763    For use in debuggers
764 */
765 extern int PetscGlobalRank,PetscGlobalSize;
766 EXTERN PetscErrorCode PetscIntView(PetscInt,PetscInt[],PetscViewer);
767 EXTERN PetscErrorCode PetscRealView(PetscInt,PetscReal[],PetscViewer);
768 EXTERN PetscErrorCode PetscScalarView(PetscInt,PetscScalar[],PetscViewer);
769 
770 /*
771     Allows accessing Matlab Engine
772 */
773 #include "petscmatlab.h"
774 
775 /*
776     C code optimization is often enhanced by telling the compiler
777   that certain pointer arguments to functions are not aliased to
778   to other arguments. This is not yet ANSI C standard so we define
779   the macro "restrict" to indicate that the variable is not aliased
780   to any other argument.
781 */
782 #if defined(PETSC_HAVE_RESTRICT) && !defined(__cplusplus)
783 #define restrict _Restrict
784 #else
785 #if defined(restrict)
786 #undef restrict
787 #endif
788 #define restrict
789 #endif
790 
791 /*
792       Determine if some of the kernel computation routines use
793    Fortran (rather than C) for the numerical calculations. On some machines
794    and compilers (like complex numbers) the Fortran version of the routines
795    is faster than the C/C++ versions. The flag PETSC_USE_FORTRAN_KERNELS
796    would be set in the petscconf.h file
797 */
798 #if defined(PETSC_USE_FORTRAN_KERNELS)
799 
800 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ)
801 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ
802 #endif
803 
804 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ)
805 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ
806 #endif
807 
808 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM)
809 #define PETSC_USE_FORTRAN_KERNEL_NORM
810 #endif
811 
812 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY)
813 #define PETSC_USE_FORTRAN_KERNEL_MAXPY
814 #endif
815 
816 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ)
817 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ
818 #endif
819 
820 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ)
821 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ
822 #endif
823 
824 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ)
825 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ
826 #endif
827 
828 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ)
829 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ
830 #endif
831 
832 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT)
833 #define PETSC_USE_FORTRAN_KERNEL_MDOT
834 #endif
835 
836 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY)
837 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY
838 #endif
839 
840 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX)
841 #define PETSC_USE_FORTRAN_KERNEL_AYPX
842 #endif
843 
844 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY)
845 #define PETSC_USE_FORTRAN_KERNEL_WAXPY
846 #endif
847 
848 #endif
849 
850 /*
851     Macros for indicating code that should be compiled with a C interface,
852    rather than a C++ interface. Any routines that are dynamically loaded
853    (such as the PCCreate_XXX() routines) must be wrapped so that the name
854    mangler does not change the functions symbol name. This just hides the
855    ugly extern "C" {} wrappers.
856 */
857 #if defined(__cplusplus)
858 #define EXTERN_C_BEGIN extern "C" {
859 #define EXTERN_C_END }
860 #else
861 #define EXTERN_C_BEGIN
862 #define EXTERN_C_END
863 #endif
864 
865 /* --------------------------------------------------------------------*/
866 
867 /*M
868     size - integer variable used to contain the number of processors in
869            the relevent MPI_Comm
870 
871    Level: beginner
872 
873 .seealso: rank, comm
874 M*/
875 
876 /*M
877     rank - integer variable used to contain the number of this processor relative
878            to all in the relevent MPI_Comm
879 
880    Level: beginner
881 
882 .seealso: size, comm
883 M*/
884 
885 /*M
886     comm - MPI_Comm used in the current routine or object
887 
888    Level: beginner
889 
890 .seealso: size, rank
891 M*/
892 
893 /*M
894     MPI_Comm - the basic object used by MPI to determine which processes are involved in a
895         communication
896 
897    Level: beginner
898 
899    Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm
900 
901 .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF
902 M*/
903 
904 /*M
905     PetscScalar - PETSc type that represents either a double precision real number or
906        a double precision complex number if the code is compiled with BOPT=g_complex or O_complex
907 
908    Level: beginner
909 
910 .seealso: PetscReal, PassiveReal, PassiveScalar
911 M*/
912 
913 /*M
914     PetscReal - PETSc type that represents a double precision real number
915 
916    Level: beginner
917 
918 .seealso: PetscScalar, PassiveReal, PassiveScalar
919 M*/
920 
921 /*M
922     PassiveScalar - PETSc type that represents either a double precision real number or
923        a double precision complex number if the code is compiled with BOPT=g_complex or O_complex
924 
925    Level: beginner
926 
927     This is the same as a PetscScalar except in code that is automatically differentiated it is
928    treated as a constant (not an indendent or dependent variable)
929 
930 .seealso: PetscReal, PassiveReal, PetscScalar
931 M*/
932 
933 /*M
934     PassiveReal - PETSc type that represents a double precision real number
935 
936    Level: beginner
937 
938     This is the same as a PetscReal except in code that is automatically differentiated it is
939    treated as a constant (not an indendent or dependent variable)
940 
941 .seealso: PetscScalar, PetscReal, PassiveScalar
942 M*/
943 
944 /*M
945     MPIU_SCALAR - MPI datatype corresponding to PetscScalar
946 
947    Level: beginner
948 
949     Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars
950           pass this value
951 
952 .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar
953 M*/
954 
955 /*
956      The IBM include files define hz, here we hide it so that it may be used
957    as a regular user variable.
958 */
959 #if defined(hz)
960 #undef hz
961 #endif
962 
963 /*  For arrays that contain filenames or paths */
964 
965 
966 #if defined(PETSC_HAVE_LIMITS_H)
967 #include <limits.h>
968 #endif
969 #if defined(PETSC_HAVE_SYS_PARAM_H)
970 #include <sys/param.h>
971 #endif
972 
973 #if defined(MAXPATHLEN)
974 #  define PETSC_MAX_PATH_LEN     MAXPATHLEN
975 #elif defined(MAX_PATH)
976 #  define PETSC_MAX_PATH_LEN     MAX_PATH
977 #elif defined(_MAX_PATH)
978 #  define PETSC_MAX_PATH_LEN     _MAX_PATH
979 #else
980 #  define PETSC_MAX_PATH_LEN     4096
981 #endif
982 
983 PETSC_EXTERN_CXX_END
984 #endif
985 
986 
987