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