xref: /petsc/include/petsc.h (revision da9f1d6b25924a16baf1fafcd5e58fa8eaafd3cf)
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    petscconf.h is contained in ${PETSC_ARCH}/conf/petscconf.h it is
10    found automatically by the compiler due to the -I${PETSC_DIR}/${PETSC_ARCH}/include
11    in the bmake/common/variables definition of PETSC_INCLUDE
12 */
13 #include "petscconf.h"
14 
15 /* ========================================================================== */
16 /*
17    This facilitates using C version of PETSc from C++ and
18    C++ version from C. Use --with-c-support --with-clanguage=c++ with config/configure.py for the latter)
19 */
20 #if defined(PETSC_CLANGUAGE_CXX) && !defined(PETSC_USE_EXTERN_CXX) && !defined(__cplusplus)
21 #error "PETSc configured with --with-clanguage=c++ and NOT --with-c-support - it can be used only with a C++ compiler"
22 #endif
23 
24 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
25 #define PETSC_EXTERN_CXX_BEGIN extern "C" {
26 #define PETSC_EXTERN_CXX_END  }
27 #else
28 #define PETSC_EXTERN_CXX_BEGIN
29 #define PETSC_EXTERN_CXX_END
30 #endif
31 /* ========================================================================== */
32 /*
33    Current PETSc version number and release date. Also listed in
34     Web page
35     src/docs/tex/manual/intro.tex,
36     src/docs/tex/manual/manual.tex.
37     src/docs/website/index.html.
38 */
39 #include "petscversion.h"
40 #define PETSC_AUTHOR_INFO        "\
41        The PETSc Team\n\
42     petsc-maint@mcs.anl.gov\n\
43  http://www.mcs.anl.gov/petsc/\n"
44 #if (PETSC_VERSION_RELEASE == 1)
45 #define PetscGetVersion(version,len) (PetscSNPrintf(*(version),len,"Petsc Release Version %d.%d.%d, Patch %d, ", \
46                                          PETSC_VERSION_MAJOR,PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, \
47                                          PETSC_VERSION_PATCH),PetscStrcat(*(version),PETSC_VERSION_PATCH_DATE), \
48                                          PetscStrcat(*(version)," HG revision: "),PetscStrcat(*(version),PETSC_VERSION_HG),0)
49 #else
50 #define PetscGetVersion(version,len) (PetscSNPrintf(*(version),len,"Petsc Development Version %d.%d.%d, Patch %d, ", \
51                                          PETSC_VERSION_MAJOR,PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, \
52                                          PETSC_VERSION_PATCH),PetscStrcat(*(version),PETSC_VERSION_PATCH_DATE), \
53                                          PetscStrcat(*(version)," HG revision: "),PetscStrcat(*(version),PETSC_VERSION_HG),0)
54 #endif
55 
56 /*MC
57     PetscGetVersion - Gets the Petsc Version information in a string.
58 
59     Output Parameter:
60 .   version - version string
61 
62     Input Parameter:
63 .   len - length of the string
64 
65     Level: developer
66 
67     Usage:
68     char version[256];
69     PetscGetVersion(&version,256);
70 
71     Fortran Note:
72     This routine is not supported in Fortran.
73 
74 .seealso: PetscGetProgramName()
75 
76 M*/
77 
78 /* ========================================================================== */
79 
80 /*
81    Currently cannot check formatting for PETSc print statements because we have our
82    own format %D and %G
83 */
84 #undef  PETSC_PRINTF_FORMAT_CHECK
85 #define PETSC_PRINTF_FORMAT_CHECK(a,b)
86 #undef  PETSC_FPRINTF_FORMAT_CHECK
87 #define PETSC_FPRINTF_FORMAT_CHECK(a,b)
88 
89 /*
90    Fixes for configure time choices which impact our interface. Currently only
91    calling conventions and extra compiler checking falls under this category.
92 */
93 #if !defined(PETSC_STDCALL)
94 #define PETSC_STDCALL
95 #endif
96 #if !defined(PETSC_TEMPLATE)
97 #define PETSC_TEMPLATE
98 #endif
99 #if !defined(PETSC_HAVE_DLL_EXPORT)
100 #define PETSC_DLL_EXPORT
101 #define PETSC_DLL_IMPORT
102 #endif
103 #if !defined(PETSC_DLLEXPORT)
104 #define PETSC_DLLEXPORT
105 #endif
106 #if !defined(PETSCVEC_DLLEXPORT)
107 #define PETSCVEC_DLLEXPORT
108 #endif
109 #if !defined(PETSCMAT_DLLEXPORT)
110 #define PETSCMAT_DLLEXPORT
111 #endif
112 #if !defined(PETSCDM_DLLEXPORT)
113 #define PETSCDM_DLLEXPORT
114 #endif
115 #if !defined(PETSCKSP_DLLEXPORT)
116 #define PETSCKSP_DLLEXPORT
117 #endif
118 #if !defined(PETSCSNES_DLLEXPORT)
119 #define PETSCSNES_DLLEXPORT
120 #endif
121 #if !defined(PETSCTS_DLLEXPORT)
122 #define PETSCTS_DLLEXPORT
123 #endif
124 #if !defined(PETSCFORTRAN_DLLEXPORT)
125 #define PETSCFORTRAN_DLLEXPORT
126 #endif
127 /* ========================================================================== */
128 
129 /*
130     Defines the interface to MPI allowing the use of all MPI functions.
131 
132     PETSc does not use the C++ binding of MPI at ALL. The following flag
133     makes sure the C++ bindings are not included. The C++ bindings REQUIRE
134     putting mpi.h before ANY C++ include files, we cannot control this
135     with all PETSc users.
136 */
137 #define MPICH_SKIP_MPICXX 1
138 #include "mpi.h"
139 /*
140     Yuck, we need to put stdio.h AFTER mpi.h for MPICH2 with C++ compiler
141     see the top of mpicxx.h
142 
143     The MPI STANDARD HAS TO BE CHANGED to prevent this nonsense.
144 */
145 #include <stdio.h>
146 
147 /*MC
148     PetscErrorCode - datatype used for return error code from all PETSc functions
149 
150     Level: beginner
151 
152 .seealso: CHKERRQ, SETERRQ
153 M*/
154 typedef int PetscErrorCode;
155 
156 /*MC
157 
158     PetscCookie - A unique id used to identify each PETSc object.
159          (internal integer in the data structure used for error
160          checking). These are all defined by an offset from the lowest
161          one, PETSC_SMALLEST_COOKIE.
162 
163     Level: advanced
164 
165 .seealso: PetscLogClassRegister(), PetscLogEventRegister(), PetscHeaderCreate()
166 M*/
167 typedef int PetscCookie;
168 
169 /*MC
170     PetscEvent - id used to identify PETSc or user events - primarily for logging
171 
172     Level: intermediate
173 
174 .seealso: PetscLogEventRegister(), PetscLogEventBegin() PetscLogEventEnd()
175 M*/
176 typedef int PetscEvent;
177 
178 /*MC
179     PetscBLASInt - datatype used to represent 'int' parameters to blas functions.
180 
181     Level: intermediate
182 M*/
183 typedef int PetscBLASInt;
184 
185 /*MC
186     PetscMPIInt - datatype used to represent 'int' parameters to MPI functions.
187 
188     Level: intermediate
189 M*/
190 typedef int PetscMPIInt;
191 
192 /*MC
193     PetscEnum - datatype used to pass enum types within PETSc functions.
194 
195     Level: intermediate
196 
197 .seealso: PetscOptionsGetEnum(), PetscOptionsEnum(), PetscBagRegisterEnum()
198 M*/
199 typedef enum { ENUM_DUMMY } PetscEnum;
200 
201 /*MC
202     PetscInt - PETSc type that represents integer - used primarily to
203       represent size of objects. Its size can be configured with the option
204       --with-64-bit-indices - to be either 32bit or 64bit [default 32 bit ints]
205 
206    Level: intermediate
207 
208 .seealso: PetscScalar
209 M*/
210 #if defined(PETSC_USE_64BIT_INDICES)
211 typedef long long PetscInt;
212 #define MPIU_INT MPI_LONG_LONG_INT
213 #else
214 typedef int PetscInt;
215 #define MPIU_INT MPI_INT
216 #endif
217 
218 /*
219       You can use PETSC_STDOUT as a replacement of stdout. You can also change
220     the value of PETSC_STDOUT to redirect all standard output elsewhere
221 */
222 extern FILE* PETSC_STDOUT;
223 
224 /*
225       You can use PETSC_STDERR as a replacement of stderr. You can also change
226     the value of PETSC_STDERR to redirect all standard error elsewhere
227 */
228 extern FILE* PETSC_STDERR;
229 
230 #if !defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
231 /*MC
232       PetscPolymorphicSubroutine - allows defining a C++ polymorphic version of
233             a PETSc function that remove certain optional arguments for a simplier user interface
234 
235      Not collective
236 
237    Synopsis:
238    PetscPolymorphicSubroutine(Functionname,(arguments of C++ function),(arguments of C function))
239 
240    Level: developer
241 
242     Example:
243       PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r)) generates the new routine
244            PetscErrorCode VecNorm(Vec x,PetscReal *r) = VecNorm(x,NORM_2,r)
245 
246 .seealso: PetscPolymorphicFunction()
247 
248 M*/
249 #define PetscPolymorphicSubroutine(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {return A C;}
250 
251 /*MC
252       PetscPolymorphicScalar - allows defining a C++ polymorphic version of
253             a PETSc function that replaces a PetscScalar * argument with a PetscScalar argument
254 
255      Not collective
256 
257    Synopsis:
258    PetscPolymorphicScalar(Functionname,(arguments of C++ function),(arguments of C function))
259 
260    Level: developer
261 
262     Example:
263       PetscPolymorphicScalar(VecAXPY,(PetscScalar _val,Vec x,Vec y),(&_Val,x,y)) generates the new routine
264            PetscErrorCode VecAXPY(PetscScalar _val,Vec x,Vec y) = {PetscScalar _Val = _val; return VecAXPY(&_Val,x,y);}
265 
266 .seealso: PetscPolymorphicFunction(),PetscPolymorphicSubroutine()
267 
268 M*/
269 #define PetscPolymorphicScalar(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {PetscScalar _Val = _val; return A C;}
270 
271 /*MC
272       PetscPolymorphicFunction - allows defining a C++ polymorphic version of
273             a PETSc function that remove certain optional arguments for a simplier user interface
274             and returns the computed value (istead of an error code)
275 
276      Not collective
277 
278    Synopsis:
279    PetscPolymorphicFunction(Functionname,(arguments of C++ function),(arguments of C function),return type,return variable name)
280 
281    Level: developer
282 
283     Example:
284       PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r) generates the new routine
285          PetscReal VecNorm(Vec x,NormType t) = {PetscReal r; VecNorm(x,t,&r); return r;}
286 
287 .seealso: PetscPolymorphicSubroutine()
288 
289 M*/
290 #define PetscPolymorphicFunction(A,B,C,D,E) PETSC_STATIC_INLINE D A B {D E; A C;return E;}
291 
292 #else
293 #define PetscPolymorphicSubroutine(A,B,C)
294 #define PetscPolymorphicScalar(A,B,C)
295 #define PetscPolymorphicFunction(A,B,C,D,E)
296 #endif
297 
298 /*
299     Extern indicates a PETSc function defined elsewhere
300 */
301 #if !defined(EXTERN)
302 #define EXTERN extern
303 #endif
304 
305 /*
306     Defines some elementary mathematics functions and constants.
307 */
308 #include "petscmath.h"
309 
310 /*
311     Declare extern C stuff after including external header files
312 */
313 
314 PETSC_EXTERN_CXX_BEGIN
315 
316 /*
317        Basic PETSc constants
318 */
319 
320 /*E
321     PetscTruth - Logical variable. Actually an integer
322 
323    Level: beginner
324 
325 E*/
326 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth;
327 extern const char *PetscTruths[];
328 
329 /*MC
330     PETSC_FALSE - False value of PetscTruth
331 
332     Level: beginner
333 
334     Note: Zero integer
335 
336 .seealso: PetscTruth, PETSC_TRUE
337 M*/
338 
339 /*MC
340     PETSC_TRUE - True value of PetscTruth
341 
342     Level: beginner
343 
344     Note: Nonzero integer
345 
346 .seealso: PetscTruth, PETSC_FALSE
347 M*/
348 
349 /*MC
350     PETSC_YES - Alias for PETSC_TRUE
351 
352     Level: beginner
353 
354     Note: Zero integer
355 
356 .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_NO
357 M*/
358 #define PETSC_YES            PETSC_TRUE
359 
360 /*MC
361     PETSC_NO - Alias for PETSC_FALSE
362 
363     Level: beginner
364 
365     Note: Nonzero integer
366 
367 .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_YES
368 M*/
369 #define PETSC_NO             PETSC_FALSE
370 
371 /*MC
372     PETSC_NULL - standard way of passing in a null or array or pointer
373 
374    Level: beginner
375 
376    Notes: accepted by many PETSc functions to not set a parameter and instead use
377           some default
378 
379           This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
380           PETSC_NULL_DOUBLE_PRECISION etc
381 
382 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
383 
384 M*/
385 #define PETSC_NULL           0
386 
387 /*MC
388     PETSC_DECIDE - standard way of passing in integer or floating point parameter
389        where you wish PETSc to use the default.
390 
391    Level: beginner
392 
393 .seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
394 
395 M*/
396 #define PETSC_DECIDE         -1
397 
398 /*MC
399     PETSC_DEFAULT - standard way of passing in integer or floating point parameter
400        where you wish PETSc to use the default.
401 
402    Level: beginner
403 
404 .seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE
405 
406 M*/
407 #define PETSC_DEFAULT        -2
408 
409 
410 /*MC
411     PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument
412 
413    Level: beginner
414 
415    Notes: accepted by many PETSc functions to not set a parameter and instead use
416           some default
417 
418           This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
419           PETSC_NULL_DOUBLE_PRECISION etc
420 
421 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE
422 
423 M*/
424 #define PETSC_IGNORE         PETSC_NULL
425 
426 /*MC
427     PETSC_DETERMINE - standard way of passing in integer or floating point parameter
428        where you wish PETSc to compute the required value.
429 
430    Level: beginner
431 
432 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes()
433 
434 M*/
435 #define PETSC_DETERMINE      PETSC_DECIDE
436 
437 /*MC
438     PETSC_COMM_WORLD - the equivalent of the MPI_COMM_WORLD communicator which represents
439            all the processs that PETSc knows about.
440 
441    Level: beginner
442 
443    Notes: By default PETSC_COMM_WORLD and MPI_COMM_WORLD are identical unless you wish to
444           run PETSc on ONLY a subset of MPI_COMM_WORLD. In that case create your new (smaller)
445           communicator, call it, say comm, and set PETSC_COMM_WORLD = comm BEFORE calling
446           PetscInitialize()
447 
448 .seealso: PETSC_COMM_SELF
449 
450 M*/
451 extern MPI_Comm PETSC_COMM_WORLD;
452 
453 /*MC
454     PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents
455            the current process
456 
457    Level: beginner
458 
459    Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent.
460 
461 .seealso: PETSC_COMM_WORLD
462 
463 M*/
464 #define PETSC_COMM_SELF MPI_COMM_SELF
465 
466 extern PETSC_DLLEXPORT PetscTruth PetscInitializeCalled;
467 extern PETSC_DLLEXPORT PetscTruth PetscFinalizeCalled;
468 
469 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm));
470 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*);
471 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommDestroy(MPI_Comm*);
472 
473 /*MC
474    PetscMalloc - Allocates memory
475 
476    Input Parameter:
477 .  m - number of bytes to allocate
478 
479    Output Parameter:
480 .  result - memory allocated
481 
482    Synopsis:
483    PetscErrorCode PetscMalloc(size_t m,void **result)
484 
485    Level: beginner
486 
487    Notes: Memory is always allocated at least double aligned
488 
489           If you request memory of zero size it will allocate no space and assign the pointer to 0; PetscFree() will
490           properly handle not freeing the null pointer.
491 
492 .seealso: PetscFree(), PetscNew()
493 
494   Concepts: memory allocation
495 
496 M*/
497 #define PetscMalloc(a,b)  ((a != 0) ? (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b)) : (*(b) = 0,0) )
498 
499 /*MC
500    PetscMalloc2 - Allocates 2 chunks of  memory
501 
502    Input Parameter:
503 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
504 .  t1 - type of first memory elements
505 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
506 -  t2 - type of second memory elements
507 
508    Output Parameter:
509 +  r1 - memory allocated in first chunk
510 -  r2 - memory allocated in second chunk
511 
512    Synopsis:
513    PetscErrorCode PetscMalloc2(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2)
514 
515    Level: developer
516 
517    Notes: Memory of first chunk is always allocated at least double aligned
518 
519 .seealso: PetscFree(), PetscNew(), PetscMalloc()
520 
521   Concepts: memory allocation
522 
523 M*/
524 #if defined(PETSC_USE_DEBUG)
525 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2))
526 #else
527 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2),r1) || (*(r2) = (t2*)(*(r1)+m1),0))
528 #endif
529 
530 /*MC
531    PetscMalloc3 - Allocates 3 chunks of  memory
532 
533    Input Parameter:
534 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
535 .  t1 - type of first memory elements
536 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
537 .  t2 - type of second memory elements
538 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
539 -  t3 - type of third memory elements
540 
541    Output Parameter:
542 +  r1 - memory allocated in first chunk
543 .  r2 - memory allocated in second chunk
544 -  r3 - memory allocated in third chunk
545 
546    Synopsis:
547    PetscErrorCode PetscMalloc3(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3)
548 
549    Level: developer
550 
551    Notes: Memory of first chunk is always allocated at least double aligned
552 
553 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3()
554 
555   Concepts: memory allocation
556 
557 M*/
558 #if defined(PETSC_USE_DEBUG)
559 #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3))
560 #else
561 #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),0))
562 #endif
563 
564 /*MC
565    PetscMalloc4 - Allocates 4 chunks of  memory
566 
567    Input Parameter:
568 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
569 .  t1 - type of first memory elements
570 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
571 .  t2 - type of second memory elements
572 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
573 .  t3 - type of third memory elements
574 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
575 -  t4 - type of fourth memory elements
576 
577    Output Parameter:
578 +  r1 - memory allocated in first chunk
579 .  r2 - memory allocated in second chunk
580 .  r3 - memory allocated in third chunk
581 -  r4 - memory allocated in fourth chunk
582 
583    Synopsis:
584    PetscErrorCode PetscMalloc4(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4)
585 
586    Level: developer
587 
588    Notes: Memory of first chunk is always allocated at least double aligned
589 
590 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4()
591 
592   Concepts: memory allocation
593 
594 M*/
595 #if defined(PETSC_USE_DEBUG)
596 #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4))
597 #else
598 #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),0))
599 #endif
600 
601 /*MC
602    PetscMalloc5 - Allocates 5 chunks of  memory
603 
604    Input Parameter:
605 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
606 .  t1 - type of first memory elements
607 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
608 .  t2 - type of second memory elements
609 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
610 .  t3 - type of third memory elements
611 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
612 .  t4 - type of fourth memory elements
613 .  m5 - number of elements to allocate in 5th chunk  (may be zero)
614 -  t5 - type of fifth memory elements
615 
616    Output Parameter:
617 +  r1 - memory allocated in first chunk
618 .  r2 - memory allocated in second chunk
619 .  r3 - memory allocated in third chunk
620 .  r4 - memory allocated in fourth chunk
621 -  r5 - memory allocated in fifth chunk
622 
623    Synopsis:
624    PetscErrorCode PetscMalloc5(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4,size_t m5,type t5,void **r5)
625 
626    Level: developer
627 
628    Notes: Memory of first chunk is always allocated at least double aligned
629 
630 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5()
631 
632   Concepts: memory allocation
633 
634 M*/
635 #if defined(PETSC_USE_DEBUG)
636 #define PetscMalloc5(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4) || PetscMalloc((m5)*sizeof(t5),r5))
637 #else
638 #define PetscMalloc5(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),0))
639 #endif
640 
641 
642 /*MC
643    PetscMalloc6 - Allocates 6 chunks of  memory
644 
645    Input Parameter:
646 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
647 .  t1 - type of first memory elements
648 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
649 .  t2 - type of second memory elements
650 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
651 .  t3 - type of third memory elements
652 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
653 .  t4 - type of fourth memory elements
654 .  m5 - number of elements to allocate in 5th chunk  (may be zero)
655 .  t5 - type of fifth memory elements
656 .  m6 - number of elements to allocate in 6th chunk  (may be zero)
657 -  t6 - type of sixth memory elements
658 
659    Output Parameter:
660 +  r1 - memory allocated in first chunk
661 .  r2 - memory allocated in second chunk
662 .  r3 - memory allocated in third chunk
663 .  r4 - memory allocated in fourth chunk
664 .  r5 - memory allocated in fifth chunk
665 -  r6 - memory allocated in sixth chunk
666 
667    Synopsis:
668    PetscErrorCode PetscMalloc6(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4,size_t m5,type t5,void **r5,size_t m6,type t6,void **r6)
669 
670    Level: developer
671 
672    Notes: Memory of first chunk is always allocated at least double aligned
673 
674 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6()
675 
676   Concepts: memory allocation
677 
678 M*/
679 #if defined(PETSC_USE_DEBUG)
680 #define PetscMalloc6(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4) || PetscMalloc((m5)*sizeof(t5),r5) || PetscMalloc((m6)*sizeof(t6),r6))
681 #else
682 #define PetscMalloc6(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),*(r6) = (t6*)(*(r5)+m5),0))
683 #endif
684 
685 /*MC
686    PetscMalloc7 - Allocates 7 chunks of  memory
687 
688    Input Parameter:
689 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
690 .  t1 - type of first memory elements
691 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
692 .  t2 - type of second memory elements
693 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
694 .  t3 - type of third memory elements
695 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
696 .  t4 - type of fourth memory elements
697 .  m5 - number of elements to allocate in 5th chunk  (may be zero)
698 .  t5 - type of fifth memory elements
699 .  m6 - number of elements to allocate in 6th chunk  (may be zero)
700 .  t6 - type of sixth memory elements
701 .  m7 - number of elements to allocate in 7th chunk  (may be zero)
702 -  t7 - type of sixth memory elements
703 
704    Output Parameter:
705 +  r1 - memory allocated in first chunk
706 .  r2 - memory allocated in second chunk
707 .  r3 - memory allocated in third chunk
708 .  r4 - memory allocated in fourth chunk
709 .  r5 - memory allocated in fifth chunk
710 .  r6 - memory allocated in sixth chunk
711 -  r7 - memory allocated in sixth chunk
712 
713    Synopsis:
714    PetscErrorCode PetscMalloc7(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4,size_t m5,type t5,void **r5,size_t m6,type t6,void **r6,size_t m7,type t7,void **r7)
715 
716    Level: developer
717 
718    Notes: Memory of first chunk is always allocated at least double aligned
719 
720 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6(), PetscFree7()
721 
722   Concepts: memory allocation
723 
724 M*/
725 #if defined(PETSC_USE_DEBUG)
726 #define PetscMalloc7(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6,m7,t7,r7) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4) || PetscMalloc((m5)*sizeof(t5),r5) || PetscMalloc((m6)*sizeof(t6),r6) || PetscMalloc((m7)*sizeof(t7),r7))
727 #else
728 #define PetscMalloc7(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6,m7,t7,r7) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6)+(m7)*sizeof(t7),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),*(r6) = (t6*)(*(r5)+m5),*(r7) = (t7*)(*(r6)+m6),0))
729 #endif
730 
731 /*MC
732    PetscNew - Allocates memory of a particular type, zeros the memory!
733 
734    Input Parameter:
735 .  type - structure name of space to be allocated. Memory of size sizeof(type) is allocated
736 
737    Output Parameter:
738 .  result - memory allocated
739 
740    Synopsis:
741    PetscErrorCode PetscNew(struct type,((type *))result)
742 
743    Level: beginner
744 
745 .seealso: PetscFree(), PetscMalloc()
746 
747   Concepts: memory allocation
748 
749 M*/
750 #define PetscNew(A,b)      (PetscMalloc(sizeof(A),(b)) || PetscMemzero(*(b),sizeof(A)))
751 #define PetscNewLog(o,A,b) (PetscNew(A,b) || ((o) ? PetscLogObjectMemory(o,sizeof(A)) : 0))
752 
753 /*MC
754    PetscFree - Frees memory
755 
756    Input Parameter:
757 .   memory - memory to free (the pointer is ALWAYS set to 0 upon sucess)
758 
759    Synopsis:
760    PetscErrorCode PetscFree(void *memory)
761 
762    Level: beginner
763 
764    Notes: Memory must have been obtained with PetscNew() or PetscMalloc()
765 
766 .seealso: PetscNew(), PetscMalloc(), PetscFreeVoid()
767 
768   Concepts: memory allocation
769 
770 M*/
771 #define PetscFree(a)   ((a) ? ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__) || ((a = 0),0)) : 0)
772 
773 /*MC
774    PetscFreeVoid - Frees memory
775 
776    Input Parameter:
777 .   memory - memory to free
778 
779    Synopsis:
780    void PetscFreeVoid(void *memory)
781 
782    Level: beginner
783 
784    Notes: This is different from PetscFree() in that no error code is returned
785 
786 .seealso: PetscFree(), PetscNew(), PetscMalloc()
787 
788   Concepts: memory allocation
789 
790 M*/
791 #define PetscFreeVoid(a) ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__),(a) = 0)
792 
793 
794 /*MC
795    PetscFree2 - Frees 2 chunks of memory obtained with PetscMalloc2()
796 
797    Input Parameter:
798 +   memory1 - memory to free
799 -   memory2 - 2nd memory to free
800 
801 
802    Synopsis:
803    PetscErrorCode PetscFree2(void *memory1,void *memory2)
804 
805    Level: developer
806 
807    Notes: Memory must have been obtained with PetscMalloc2()
808 
809 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree()
810 
811   Concepts: memory allocation
812 
813 M*/
814 #if defined(PETSC_USE_DEBUG)
815 #define PetscFree2(m1,m2)   (PetscFree(m2) || PetscFree(m1))
816 #else
817 #define PetscFree2(m1,m2)   (PetscFree(m1))
818 #endif
819 
820 /*MC
821    PetscFree3 - Frees 3 chunks of memory obtained with PetscMalloc3()
822 
823    Input Parameter:
824 +   memory1 - memory to free
825 .   memory2 - 2nd memory to free
826 -   memory3 - 3rd memory to free
827 
828 
829    Synopsis:
830    PetscErrorCode PetscFree3(void *memory1,void *memory2,void *memory3)
831 
832    Level: developer
833 
834    Notes: Memory must have been obtained with PetscMalloc3()
835 
836 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3()
837 
838   Concepts: memory allocation
839 
840 M*/
841 #if defined(PETSC_USE_DEBUG)
842 #define PetscFree3(m1,m2,m3)   (PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
843 #else
844 #define PetscFree3(m1,m2,m3)   (PetscFree(m1))
845 #endif
846 
847 /*MC
848    PetscFree4 - Frees 4 chunks of memory obtained with PetscMalloc4()
849 
850    Input Parameter:
851 +   m1 - memory to free
852 .   m2 - 2nd memory to free
853 .   m3 - 3rd memory to free
854 -   m4 - 4th memory to free
855 
856 
857    Synopsis:
858    PetscErrorCode PetscFree4(void *m1,void *m2,void *m3,void *m4)
859 
860    Level: developer
861 
862    Notes: Memory must have been obtained with PetscMalloc4()
863 
864 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4()
865 
866   Concepts: memory allocation
867 
868 M*/
869 #if defined(PETSC_USE_DEBUG)
870 #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
871 #else
872 #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m1))
873 #endif
874 
875 /*MC
876    PetscFree5 - Frees 5 chunks of memory obtained with PetscMalloc5()
877 
878    Input Parameter:
879 +   m1 - memory to free
880 .   m2 - 2nd memory to free
881 .   m3 - 3rd memory to free
882 .   m4 - 4th memory to free
883 -   m5 - 5th memory to free
884 
885 
886    Synopsis:
887    PetscErrorCode PetscFree5(void *m1,void *m2,void *m3,void *m4,void *m5)
888 
889    Level: developer
890 
891    Notes: Memory must have been obtained with PetscMalloc5()
892 
893 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5()
894 
895   Concepts: memory allocation
896 
897 M*/
898 #if defined(PETSC_USE_DEBUG)
899 #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
900 #else
901 #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m1))
902 #endif
903 
904 
905 /*MC
906    PetscFree6 - Frees 6 chunks of memory obtained with PetscMalloc6()
907 
908    Input Parameter:
909 +   m1 - memory to free
910 .   m2 - 2nd memory to free
911 .   m3 - 3rd memory to free
912 .   m4 - 4th memory to free
913 .   m5 - 5th memory to free
914 -   m6 - 6th memory to free
915 
916 
917    Synopsis:
918    PetscErrorCode PetscFree6(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6)
919 
920    Level: developer
921 
922    Notes: Memory must have been obtained with PetscMalloc6()
923 
924 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6()
925 
926   Concepts: memory allocation
927 
928 M*/
929 #if defined(PETSC_USE_DEBUG)
930 #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
931 #else
932 #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m1))
933 #endif
934 
935 /*MC
936    PetscFree7 - Frees 7 chunks of memory obtained with PetscMalloc7()
937 
938    Input Parameter:
939 +   m1 - memory to free
940 .   m2 - 2nd memory to free
941 .   m3 - 3rd memory to free
942 .   m4 - 4th memory to free
943 .   m5 - 5th memory to free
944 .   m6 - 6th memory to free
945 -   m7 - 7th memory to free
946 
947 
948    Synopsis:
949    PetscErrorCode PetscFree7(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6,void *m7)
950 
951    Level: developer
952 
953    Notes: Memory must have been obtained with PetscMalloc7()
954 
955 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6(),
956           PetscMalloc7()
957 
958   Concepts: memory allocation
959 
960 M*/
961 #if defined(PETSC_USE_DEBUG)
962 #define PetscFree7(m1,m2,m3,m4,m5,m6,m7)   (PetscFree(m7) || PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
963 #else
964 #define PetscFree7(m1,m2,m3,m4,m5,m6,m7)   (PetscFree(m1))
965 #endif
966 
967 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**);
968 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscTrFree)(void*,int,const char[],const char[],const char[]);
969 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSetMalloc(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[]));
970 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscClearMalloc(void);
971 
972 /*
973    Routines for tracing memory corruption/bleeding with default PETSc
974    memory allocation
975 */
976 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocDump(FILE *);
977 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocDumpLog(FILE *);
978 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocGetCurrentUsage(PetscLogDouble *);
979 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocGetMaximumUsage(PetscLogDouble *);
980 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocDebug(PetscTruth);
981 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocValidate(int,const char[],const char[],const char[]);
982 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocSetDumpLog(void);
983 
984 
985 /*
986     Variable type where we stash PETSc object pointers in Fortran.
987     On most machines size(pointer) == sizeof(long) - except windows
988     where its sizeof(long long)
989 */
990 
991 #if (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG)
992 #define PetscFortranAddr   long
993 #elif  (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG_LONG)
994 #define PetscFortranAddr   long long
995 #else
996 #error "Unknown size for PetscFortranAddr! Send us a bugreport at petsc-maint@mcs.anl.gov"
997 #endif
998 
999 /*E
1000     PetscDataType - Used for handling different basic data types.
1001 
1002    Level: beginner
1003 
1004 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(),
1005           PetscDataTypeGetSize()
1006 
1007 E*/
1008 typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2, PETSC_LONG = 3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5,
1009               PETSC_CHAR = 6,PETSC_LOGICAL = 7,PETSC_ENUM = 8,PETSC_TRUTH=9, PETSC_LONG_DOUBLE = 10} PetscDataType;
1010 extern const char *PetscDataTypes[];
1011 
1012 #if defined(PETSC_USE_COMPLEX)
1013 #define PETSC_SCALAR PETSC_COMPLEX
1014 #else
1015 #if defined(PETSC_USE_SINGLE)
1016 #define PETSC_SCALAR PETSC_FLOAT
1017 #elif defined(PETSC_USE_LONG_DOUBLE)
1018 #define PETSC_SCALAR PETSC_LONG_DOUBLE
1019 #elif defined(PETSC_USE_INT)
1020 #define PETSC_SCALAR PETSC_INT
1021 #else
1022 #define PETSC_SCALAR PETSC_DOUBLE
1023 #endif
1024 #endif
1025 #if defined(PETSC_USE_SINGLE)
1026 #define PETSC_REAL PETSC_FLOAT
1027 #elif defined(PETSC_USE_LONG_DOUBLE)
1028 #define PETSC_REAL PETSC_LONG_DOUBLE
1029 #elif defined(PETSC_USE_INT)
1030 #define PETSC_REAL PETSC_INT
1031 #else
1032 #define PETSC_REAL PETSC_DOUBLE
1033 #endif
1034 #define PETSC_FORTRANADDR PETSC_LONG
1035 
1036 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
1037 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeGetSize(PetscDataType,PetscInt*);
1038 
1039 /*
1040     Basic memory and string operations. These are usually simple wrappers
1041    around the basic Unix system calls, but a few of them have additional
1042    functionality and/or error checking.
1043 */
1044 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMemcpy(void*,const void *,size_t);
1045 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType);
1046 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMemmove(void*,void *,size_t);
1047 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMemzero(void*,size_t);
1048 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMemcmp(const void*,const void*,size_t,PetscTruth *);
1049 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrlen(const char[],size_t*);
1050 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrcmp(const char[],const char[],PetscTruth *);
1051 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrgrt(const char[],const char[],PetscTruth *);
1052 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrcasecmp(const char[],const char[],PetscTruth*);
1053 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrncmp(const char[],const char[],size_t,PetscTruth*);
1054 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrcpy(char[],const char[]);
1055 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrcat(char[],const char[]);
1056 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrncat(char[],const char[],size_t);
1057 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrncpy(char[],const char[],size_t);
1058 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrchr(const char[],char,char *[]);
1059 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrtolower(char[]);
1060 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrrchr(const char[],char,char *[]);
1061 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrstr(const char[],const char[],char *[]);
1062 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrrstr(const char[],const char[],char *[]);
1063 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrallocpy(const char[],char *[]);
1064 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrreplace(MPI_Comm,const char[],char[],size_t);
1065 #define      PetscStrfree(a) ((a) ? PetscFree(a) : 0)
1066 
1067 /*S
1068     PetscToken - 'Token' used for managing tokenizing strings
1069 
1070   Level: intermediate
1071 
1072 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy()
1073 S*/
1074 typedef struct {char token;char *array;char *current;} PetscToken;
1075 
1076 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscTokenCreate(const char[],const char,PetscToken**);
1077 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscTokenFind(PetscToken*,char *[]);
1078 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscTokenDestroy(PetscToken*);
1079 
1080 /*
1081    These are  MPI operations for MPI_Allreduce() etc
1082 */
1083 EXTERN PETSC_DLLEXPORT MPI_Op PetscMaxSum_Op;
1084 #if defined(PETSC_USE_COMPLEX)
1085 EXTERN PETSC_DLLEXPORT MPI_Op PetscSum_Op;
1086 #else
1087 #define PetscSum_Op MPI_SUM
1088 #endif
1089 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*);
1090 
1091 /*S
1092      PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc
1093 
1094    Level: beginner
1095 
1096    Note: This is the base class from which all objects appear.
1097 
1098 .seealso:  PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName()
1099 S*/
1100 typedef struct _p_PetscObject* PetscObject;
1101 
1102 /*S
1103      PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed
1104       by string name
1105 
1106    Level: advanced
1107 
1108 .seealso:  PetscFListAdd(), PetscFListDestroy()
1109 S*/
1110 typedef struct _n_PetscFList *PetscFList;
1111 
1112 /*E
1113   PetscFileMode - Access mode for a file.
1114 
1115   Level: beginner
1116 
1117   FILE_MODE_READ - open a file at its beginning for reading
1118 
1119   FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist)
1120 
1121   FILE_MODE_APPEND - open a file at end for writing
1122 
1123   FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing
1124 
1125   FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end
1126 
1127 .seealso: PetscViewerFileSetMode()
1128 E*/
1129 typedef enum {FILE_MODE_READ, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode;
1130 
1131 #include "petscviewer.h"
1132 #include "petscoptions.h"
1133 
1134 #define PETSC_SMALLEST_COOKIE 1211211
1135 extern PETSC_DLLEXPORT PetscCookie PETSC_LARGEST_COOKIE;
1136 extern PETSC_DLLEXPORT PetscCookie PETSC_OBJECT_COOKIE;
1137 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCookieRegister(PetscCookie *);
1138 
1139 /*
1140    Routines that get memory usage information from the OS
1141 */
1142 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryGetCurrentUsage(PetscLogDouble *);
1143 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryGetMaximumUsage(PetscLogDouble *);
1144 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemorySetGetMaximumUsage(void);
1145 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryShowUsage(PetscViewer,const char[]);
1146 
1147 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInfoAllow(PetscTruth,const char []);
1148 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetTime(PetscLogDouble*);
1149 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetCPUTime(PetscLogDouble*);
1150 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSleep(int);
1151 
1152 /*
1153     Initialization of PETSc
1154 */
1155 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitialize(int*,char***,const char[],const char[]);
1156 PetscPolymorphicSubroutine(PetscInitialize,(int *argc,char ***args),(argc,args,PETSC_NULL,PETSC_NULL))
1157 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitializeNoArguments(void);
1158 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitialized(PetscTruth *);
1159 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFinalized(PetscTruth *);
1160 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFinalize(void);
1161 EXTERN PetscErrorCode PetscInitializeFortran(void);
1162 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetArgs(int*,char ***);
1163 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetArguments(char ***args);
1164 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFreeArguments(char **args);
1165 
1166 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscEnd(void);
1167 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitializePackage(const char[]);
1168 
1169 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPMerge(PetscMPIInt);
1170 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPSpawn(PetscMPIInt);
1171 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPFinalize(void);
1172 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPRun(MPI_Comm,PetscErrorCode (*)(MPI_Comm,void *),void*);
1173 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPFree(MPI_Comm,void*);
1174 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPNew(MPI_Comm,PetscInt,void**);
1175 
1176 /*
1177      These are so that in extern C code we can caste function pointers to non-extern C
1178    function pointers. Since the regular C++ code expects its function pointers to be
1179    C++.
1180 */
1181 typedef void (**PetscVoidStarFunction)(void);
1182 typedef void (*PetscVoidFunction)(void);
1183 typedef PetscErrorCode (*PetscErrorCodeFunction)(void);
1184 
1185 /*
1186    PetscTryMethod - Queries an object for a method, if it exists then calls it.
1187               These are intended to be used only inside PETSc functions.
1188 */
1189 #define  PetscTryMethod(obj,A,B,C) \
1190   0;{ PetscErrorCode (*f)B, __ierr; \
1191     __ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \
1192     if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
1193   }
1194 #define  PetscUseMethod(obj,A,B,C) \
1195   0;{ PetscErrorCode (*f)B, __ierr; \
1196     __ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \
1197     if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
1198     else {SETERRQ1(PETSC_ERR_SUP,"Cannot locate function %s in object",A);} \
1199   }
1200 /*
1201     Functions that can act on any PETSc object.
1202 */
1203 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCreate(MPI_Comm,PetscObject*);
1204 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCreateGeneric(MPI_Comm, PetscCookie, const char [], PetscObject *);
1205 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectDestroy(PetscObject);
1206 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectExists(PetscObject,PetscTruth*);
1207 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetComm(PetscObject,MPI_Comm *);
1208 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetCookie(PetscObject,PetscCookie *);
1209 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetType(PetscObject,const char []);
1210 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetType(PetscObject,const char *[]);
1211 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetName(PetscObject,const char[]);
1212 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetName(PetscObject,const char*[]);
1213 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectReference(PetscObject);
1214 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetReference(PetscObject,PetscInt*);
1215 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectDereference(PetscObject);
1216 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetNewTag(PetscObject,PetscMPIInt *);
1217 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectView(PetscObject,PetscViewer);
1218 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCompose(PetscObject,const char[],PetscObject);
1219 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectQuery(PetscObject,const char[],PetscObject *);
1220 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void));
1221 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetFromOptions(PetscObject);
1222 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetUp(PetscObject);
1223 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommGetNewTag(MPI_Comm,PetscMPIInt *);
1224 
1225 /*MC
1226    PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object.
1227 
1228    Collective on PetscObject
1229 
1230    Input Parameters:
1231 +  obj - the PETSc object; this must be cast with a (PetscObject), for example,
1232          PetscObjectCompose((PetscObject)mat,...);
1233 .  name - name associated with the child function
1234 .  fname - name of the function
1235 -  ptr - function pointer (or PETSC_NULL if using dynamic libraries)
1236 
1237    Level: advanced
1238 
1239     Synopsis:
1240     PetscErrorCode PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr)
1241 
1242    Notes:
1243    To remove a registered routine, pass in a PETSC_NULL rname and fnc().
1244 
1245    PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as
1246    Mat, Vec, KSP, SNES, etc.) or any user-provided object.
1247 
1248    The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to
1249    work in C++/complex with dynamic link libraries (config/configure.py options --with-shared --with-dynamic)
1250    enabled.
1251 
1252    Concepts: objects^composing functions
1253    Concepts: composing functions
1254    Concepts: functions^querying
1255    Concepts: objects^querying
1256    Concepts: querying objects
1257 
1258 .seealso: PetscObjectQueryFunction()
1259 M*/
1260 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1261 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0)
1262 #else
1263 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(PetscVoidFunction)(d))
1264 #endif
1265 
1266 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectQueryFunction(PetscObject,const char[],void (**)(void));
1267 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetOptionsPrefix(PetscObject,const char[]);
1268 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
1269 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPrependOptionsPrefix(PetscObject,const char[]);
1270 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetOptionsPrefix(PetscObject,const char*[]);
1271 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPublish(PetscObject);
1272 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectChangeTypeName(PetscObject,const char[]);
1273 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectRegisterDestroy(PetscObject);
1274 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectRegisterDestroyAll(void);
1275 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectName(PetscObject);
1276 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTypeCompare(PetscObject,const char[],PetscTruth*);
1277 
1278 /*
1279     Defines PETSc error handling.
1280 */
1281 #include "petscerror.h"
1282 
1283 /*S
1284      PetscOList - Linked list of PETSc objects, accessable by string name
1285 
1286    Level: advanced
1287 
1288 .seealso:  PetscOListAdd(), PetscOListDestroy(), PetscOListFind()
1289 S*/
1290 typedef struct _n_PetscOList *PetscOList;
1291 
1292 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListDestroy(PetscOList);
1293 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListFind(PetscOList,const char[],PetscObject*);
1294 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListReverseFind(PetscOList,PetscObject,char**);
1295 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListAdd(PetscOList *,const char[],PetscObject);
1296 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListDuplicate(PetscOList,PetscOList *);
1297 
1298 /*
1299     Dynamic library lists. Lists of names of routines in dynamic
1300   link libraries that will be loaded as needed.
1301 */
1302 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void));
1303 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListDestroy(PetscFList*);
1304 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListFind(PetscFList,MPI_Comm,const char[],void (**)(void));
1305 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListPrintTypes(PetscFList,MPI_Comm,FILE*,const char[],const char[],const char[],const char[]);
1306 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1307 #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0)
1308 #else
1309 #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c)
1310 #endif
1311 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListDuplicate(PetscFList,PetscFList *);
1312 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListView(PetscFList,PetscViewer);
1313 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListConcat(const char [],const char [],char []);
1314 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListGet(PetscFList,char ***,int*);
1315 
1316 /*S
1317      PetscDLLibrary - Linked list of dynamics libraries to search for functions
1318 
1319    Level: advanced
1320 
1321    --with-shared --with-dynamic must be used with config/configure.py to use dynamic libraries
1322 
1323 .seealso:  PetscDLLibraryOpen()
1324 S*/
1325 typedef struct _n_PetscDLLibrary *PetscDLLibrary;
1326 extern PetscDLLibrary DLLibrariesLoaded;
1327 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *);
1328 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryOpen(MPI_Comm,const char[],void **);
1329 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibrarySym(MPI_Comm,PetscDLLibrary *,const char[],const char[],void **);
1330 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryAppend(MPI_Comm,PetscDLLibrary *,const char[]);
1331 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryPrepend(MPI_Comm,PetscDLLibrary *,const char[]);
1332 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryClose(PetscDLLibrary);
1333 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryPrintPath(void);
1334 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryGetInfo(void*,const char[],const char *[]);
1335 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryCCAAppend(MPI_Comm,PetscDLLibrary *,const char[]);
1336 
1337 /*
1338      Useful utility routines
1339 */
1340 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*);
1341 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*);
1342 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt);
1343 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(MPI_Comm comm),(comm,1))
1344 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(void),(PETSC_COMM_WORLD,1))
1345 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt);
1346 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(MPI_Comm comm),(comm,1))
1347 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(void),(PETSC_COMM_WORLD,1))
1348 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBarrier(PetscObject);
1349 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMPIDump(FILE*);
1350 
1351 #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE)
1352 /*
1353     Defines basic graphics available from PETSc.
1354 */
1355 #include "petscdraw.h"
1356 
1357 /*
1358     Defines the base data structures for all PETSc objects
1359 */
1360 #include "private/petscimpl.h"
1361 /*
1362      Defines PETSc profiling.
1363 */
1364 #include "petsclog.h"
1365 
1366 /*
1367           For locking, unlocking and destroying AMS memories associated with
1368     PETSc objects. Not currently used.
1369 */
1370 #define PetscPublishAll(v)           0
1371 #define PetscObjectTakeAccess(obj)   0
1372 #define PetscObjectGrantAccess(obj)  0
1373 #define PetscObjectDepublish(obj)    0
1374 
1375 
1376 
1377 /*
1378       This code allows one to pass a MPI communicator between
1379     C and Fortran. MPI 2.0 defines a standard API for doing this.
1380     The code here is provided to allow PETSc to work with MPI 1.1
1381     standard MPI libraries.
1382 */
1383 EXTERN PetscErrorCode MPICCommToFortranComm(MPI_Comm,int *);
1384 EXTERN PetscErrorCode MPIFortranCommToCComm(int,MPI_Comm*);
1385 
1386 /*
1387       Simple PETSc parallel IO for ASCII printing
1388 */
1389 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscFixFilename(const char[],char[]);
1390 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscFOpen(MPI_Comm,const char[],const char[],FILE**);
1391 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscFClose(MPI_Comm,FILE*);
1392 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
1393 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscPrintf(MPI_Comm,const char[],...)  PETSC_PRINTF_FORMAT_CHECK(2,3);
1394 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSNPrintf(char*,size_t,const char [],...);
1395 
1396 /* These are used internally by PETSc ASCII IO routines*/
1397 #include <stdarg.h>
1398 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscVSNPrintf(char*,size_t,const char[],va_list);
1399 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscVFPrintf(FILE*,const char[],va_list);
1400 
1401 /*MC
1402     PetscErrorPrintf - Prints error messages.
1403 
1404     Not Collective
1405 
1406    Synopsis:
1407      PetscErrorCode (*PetscErrorPrintf)(const char format[],...);
1408 
1409     Input Parameters:
1410 .   format - the usual printf() format string
1411 
1412    Options Database Keys:
1413 +    -error_output_stderr - cause error messages to be printed to stderr instead of the
1414          (default) stdout
1415 -    -error_output_none to turn off all printing of error messages (does not change the way the
1416           error is handled.)
1417 
1418    Notes: Use
1419      PetscErrorPrintf = PetscErrorPrintfNone; to turn off all printing of error messages (does not change the way the
1420            error is handled.) and
1421      PetscErrorPrintf = PetscErrorPrintfDefault; to turn it back on
1422 
1423 
1424 
1425 
1426    Level: developer
1427 
1428     Fortran Note:
1429     This routine is not supported in Fortran.
1430 
1431     Concepts: error messages^printing
1432     Concepts: printing^error messages
1433 
1434 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf()
1435 M*/
1436 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscErrorPrintf)(const char[],...);
1437 
1438 /*MC
1439     PetscHelpPrintf - Prints help messages.
1440 
1441     Not Collective
1442 
1443    Synopsis:
1444      PetscErrorCode (*PetscHelpPrintf)(const char format[],...);
1445 
1446     Input Parameters:
1447 .   format - the usual printf() format string
1448 
1449    Level: developer
1450 
1451     Fortran Note:
1452     This routine is not supported in Fortran.
1453 
1454     Concepts: help messages^printing
1455     Concepts: printing^help messages
1456 
1457 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf()
1458 M*/
1459 EXTERN PETSC_DLLEXPORT PetscErrorCode  (*PetscHelpPrintf)(MPI_Comm,const char[],...);
1460 
1461 EXTERN PetscErrorCode  PetscErrorPrintfDefault(const char [],...);
1462 EXTERN PetscErrorCode  PetscErrorPrintfNone(const char [],...);
1463 EXTERN PetscErrorCode  PetscHelpPrintfDefault(MPI_Comm,const char [],...);
1464 
1465 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **);
1466 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscPClose(MPI_Comm,FILE*);
1467 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
1468 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
1469 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSynchronizedFlush(MPI_Comm);
1470 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]);
1471 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**);
1472 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscStartJava(MPI_Comm,const char[],const char[],FILE**);
1473 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscGetPetscDir(const char*[]);
1474 
1475 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*);
1476 
1477 /*S
1478      PetscContainer - Simple PETSc object that contains a pointer to any required data
1479 
1480    Level: advanced
1481 
1482 .seealso:  PetscObject, PetscContainerCreate()
1483 S*/
1484 extern PetscCookie PETSC_DLLEXPORT PETSC_CONTAINER_COOKIE;
1485 typedef struct _p_PetscContainer*  PetscContainer;
1486 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerGetPointer(PetscContainer,void **);
1487 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerSetPointer(PetscContainer,void *);
1488 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerDestroy(PetscContainer);
1489 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerCreate(MPI_Comm,PetscContainer *);
1490 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerSetUserDestroy(PetscContainer, PetscErrorCode (*)(void*));
1491 
1492 /*
1493    For use in debuggers
1494 */
1495 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalRank;
1496 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalSize;
1497 
1498 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscIntView(PetscInt,PetscInt[],PetscViewer);
1499 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRealView(PetscInt,PetscReal[],PetscViewer);
1500 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscScalarView(PetscInt,PetscScalar[],PetscViewer);
1501 
1502 /*
1503     Allows accessing Matlab Engine
1504 */
1505 #include "petscmatlab.h"
1506 
1507 /*
1508       Determine if some of the kernel computation routines use
1509    Fortran (rather than C) for the numerical calculations. On some machines
1510    and compilers (like complex numbers) the Fortran version of the routines
1511    is faster than the C/C++ versions. The flag --with-fortran-kernels
1512    should be used with config/configure.py to turn these on.
1513 */
1514 #if defined(PETSC_USE_FORTRAN_KERNELS)
1515 
1516 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCRL)
1517 #define PETSC_USE_FORTRAN_KERNEL_MULTCRL
1518 #endif
1519 
1520 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM)
1521 #define PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM
1522 #endif
1523 
1524 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ)
1525 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ
1526 #endif
1527 
1528 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ)
1529 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ
1530 #endif
1531 
1532 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM)
1533 #define PETSC_USE_FORTRAN_KERNEL_NORM
1534 #endif
1535 
1536 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY)
1537 #define PETSC_USE_FORTRAN_KERNEL_MAXPY
1538 #endif
1539 
1540 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ)
1541 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ
1542 #endif
1543 
1544 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ)
1545 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ
1546 #endif
1547 
1548 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ)
1549 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ
1550 #endif
1551 
1552 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ)
1553 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ
1554 #endif
1555 
1556 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT)
1557 #define PETSC_USE_FORTRAN_KERNEL_MDOT
1558 #endif
1559 
1560 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY)
1561 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY
1562 #endif
1563 
1564 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX)
1565 #define PETSC_USE_FORTRAN_KERNEL_AYPX
1566 #endif
1567 
1568 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY)
1569 #define PETSC_USE_FORTRAN_KERNEL_WAXPY
1570 #endif
1571 
1572 #endif
1573 
1574 /*
1575     Macros for indicating code that should be compiled with a C interface,
1576    rather than a C++ interface. Any routines that are dynamically loaded
1577    (such as the PCCreate_XXX() routines) must be wrapped so that the name
1578    mangler does not change the functions symbol name. This just hides the
1579    ugly extern "C" {} wrappers.
1580 */
1581 #if defined(__cplusplus)
1582 #define EXTERN_C_BEGIN extern "C" {
1583 #define EXTERN_C_END }
1584 #else
1585 #define EXTERN_C_BEGIN
1586 #define EXTERN_C_END
1587 #endif
1588 
1589 /* --------------------------------------------------------------------*/
1590 
1591 /*MC
1592     size - integer variable used to contain the number of processors in
1593            the relevent MPI_Comm
1594 
1595    Level: beginner
1596 
1597 .seealso: rank, comm
1598 M*/
1599 
1600 /*MC
1601     rank - integer variable used to contain the number of this processor relative
1602            to all in the relevent MPI_Comm
1603 
1604    Level: beginner
1605 
1606 .seealso: size, comm
1607 M*/
1608 
1609 /*MC
1610     comm - MPI_Comm used in the current routine or object
1611 
1612    Level: beginner
1613 
1614 .seealso: size, rank
1615 M*/
1616 
1617 /*MC
1618     MPI_Comm - the basic object used by MPI to determine which processes are involved in a
1619         communication
1620 
1621    Level: beginner
1622 
1623    Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm
1624 
1625 .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF
1626 M*/
1627 
1628 /*MC
1629     PetscScalar - PETSc type that represents either a double precision real number,
1630        a double precision complex number, a single precision real number, a long double or an int
1631        if the code is configured with --with-scalar-type=complex,float,longdouble,int
1632 
1633    Level: beginner
1634 
1635 .seealso: PetscReal, PassiveReal, PassiveScalar
1636 M*/
1637 
1638 /*MC
1639     PetscReal - PETSc type that represents a real number version of PetscScalar
1640 
1641    Level: beginner
1642 
1643 .seealso: PetscScalar, PassiveReal, PassiveScalar
1644 M*/
1645 
1646 /*MC
1647     PassiveScalar - PETSc type that represents a PetscScalar
1648    Level: beginner
1649 
1650     This is the same as a PetscScalar except in code that is automatically differentiated it is
1651    treated as a constant (not an indendent or dependent variable)
1652 
1653 .seealso: PetscReal, PassiveReal, PetscScalar
1654 M*/
1655 
1656 /*MC
1657     PassiveReal - PETSc type that represents a PetscReal
1658 
1659    Level: beginner
1660 
1661     This is the same as a PetscReal except in code that is automatically differentiated it is
1662    treated as a constant (not an indendent or dependent variable)
1663 
1664 .seealso: PetscScalar, PetscReal, PassiveScalar
1665 M*/
1666 
1667 /*MC
1668     MPIU_SCALAR - MPI datatype corresponding to PetscScalar
1669 
1670    Level: beginner
1671 
1672     Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars
1673           pass this value
1674 
1675 .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar
1676 M*/
1677 
1678 /*
1679      The IBM include files define hz, here we hide it so that it may be used
1680    as a regular user variable.
1681 */
1682 #if defined(hz)
1683 #undef hz
1684 #endif
1685 
1686 /*  For arrays that contain filenames or paths */
1687 
1688 
1689 #if defined(PETSC_HAVE_LIMITS_H)
1690 #include <limits.h>
1691 #endif
1692 #if defined(PETSC_HAVE_SYS_PARAM_H)
1693 #include <sys/param.h>
1694 #endif
1695 #if defined(PETSC_HAVE_SYS_TYPES_H)
1696 #include <sys/types.h>
1697 #endif
1698 #if defined(MAXPATHLEN)
1699 #  define PETSC_MAX_PATH_LEN     MAXPATHLEN
1700 #elif defined(MAX_PATH)
1701 #  define PETSC_MAX_PATH_LEN     MAX_PATH
1702 #elif defined(_MAX_PATH)
1703 #  define PETSC_MAX_PATH_LEN     _MAX_PATH
1704 #else
1705 #  define PETSC_MAX_PATH_LEN     4096
1706 #endif
1707 
1708 PETSC_EXTERN_CXX_END
1709 #endif
1710