xref: /petsc/include/petsc.h (revision 52e6d16ba989af9362d0fcebb12e73dd7c9666ed)
1 /*
2    This is the main PETSc include file (for C and C++).  It is included by all
3    other PETSc include files, so it almost never has to be specifically included.
4 */
5 #if !defined(__PETSC_H)
6 #define __PETSC_H
7 /* ========================================================================== */
8 /*
9    This facilitates using C version of PETSc from C++
10 */
11 
12 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
13 #define PETSC_EXTERN_CXX_BEGIN extern "C" {
14 #define PETSC_EXTERN_CXX_END  }
15 #else
16 #define PETSC_EXTERN_CXX_BEGIN
17 #define PETSC_EXTERN_CXX_END
18 #endif
19 /* ========================================================================== */
20 /*
21    Current PETSc version number and release date
22 */
23 #include "petscversion.h"
24 
25 /* ========================================================================== */
26 /*
27    petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h it is
28    found automatically by the compiler due to the -I${PETSC_DIR}/bmake/${PETSC_ARCH}
29    in the bmake/common_variables definition of PETSC_INCLUDE
30 */
31 #include "petscconf.h"
32 
33 /*
34    Currently cannot check formatting for PETSc print statements because we have our
35    own format %D
36 */
37 #undef  PETSC_PRINTF_FORMAT_CHECK
38 #define PETSC_PRINTF_FORMAT_CHECK(a,b)
39 #undef  PETSC_FPRINTF_FORMAT_CHECK
40 #define PETSC_FPRINTF_FORMAT_CHECK(a,b)
41 
42 /*
43    Fixes for configure time choices which impact our interface. Currently only
44    calling conventions and extra compiler checking falls under this category.
45 */
46 #if !defined (PETSC_STDCALL)
47 #define PETSC_STDCALL
48 #endif
49 #if !defined (PETSC_TEMPLATE)
50 #define PETSC_TEMPLATE
51 #endif
52 
53 /* ========================================================================== */
54 
55 /*
56     Defines the interface to MPI allowing the use of all MPI functions.
57 */
58 #include "mpi.h"
59 /*
60     Yuck, we need to put stdio.h AFTER mpi.h for MPICH2 with C++ compiler
61     see the top of mpicxx.h
62 
63     The MPI STANDARD HAS TO BE CHANGED to prevent this nonsense.
64 */
65 #include <stdio.h>
66 
67 /*
68     All PETSc C functions return this error code, it is the final argument of
69    all Fortran subroutines
70 */
71 typedef int PetscErrorCode;
72 typedef int PetscCookie;
73 typedef int PetscEvent;
74 typedef int PetscBLASInt;
75 typedef int PetscMPIInt;
76 
77 #if defined(PETSC_USE_64BIT_INT)
78 typedef long long PetscInt;
79 #define MPIU_INT MPI_LONG_LONG_INT
80 #else
81 typedef int PetscInt;
82 #define MPIU_INT MPI_INT
83 #endif
84 
85 /*
86     Declare extern C stuff after incuding external header files
87 */
88 
89 PETSC_EXTERN_CXX_BEGIN
90 
91 /*
92     EXTERN indicates a PETSc function defined elsewhere
93 */
94 #if !defined(EXTERN)
95 #define EXTERN extern
96 #endif
97 
98 /*
99     Defines some elementary mathematics functions and constants.
100 */
101 #include "petscmath.h"
102 
103 /*
104        Basic PETSc constants
105 */
106 
107 /*E
108     PetscTruth - Logical variable. Actually an integer
109 
110    Level: beginner
111 
112 E*/
113 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth;
114 
115 /*M
116     PETSC_FALSE - False value of PetscTruth
117 
118     Level: beginner
119 
120     Note: Zero integer
121 
122 .seealso: PetscTruth
123 M*/
124 
125 /*M
126     PETSC_TRUE - True value of PetscTruth
127 
128     Level: beginner
129 
130     Note: Nonzero integer
131 
132 .seealso: PetscTruth
133 M*/
134 
135 /*M
136     PETSC_YES - Alias for PETSC_TRUE
137 
138     Level: beginner
139 
140     Note: Zero integer
141 
142 .seealso: PetscTruth
143 M*/
144 
145 /*M
146     PETSC_NO - Alias for PETSC_FALSE
147 
148     Level: beginner
149 
150     Note: Nonzero integer
151 
152 .seealso: PetscTruth
153 M*/
154 
155 /*M
156     PETSC_NULL - standard way of passing in a null or array or pointer
157 
158    Level: beginner
159 
160    Notes: accepted by many PETSc functions to not set a parameter and instead use
161           some default
162 
163           This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
164           PETSC_NULL_DOUBLE_PRECISION etc
165 
166 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
167 
168 M*/
169 #define PETSC_NULL           0
170 
171 /*M
172     PETSC_DECIDE - standard way of passing in integer or floating point parameter
173        where you wish PETSc to use the default.
174 
175    Level: beginner
176 
177 .seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
178 
179 M*/
180 #define PETSC_DECIDE         -1
181 
182 /*M
183     PETSC_DEFAULT - standard way of passing in integer or floating point parameter
184        where you wish PETSc to use the default.
185 
186    Level: beginner
187 
188 .seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE
189 
190 M*/
191 #define PETSC_DEFAULT        -2
192 
193 #define PETSC_YES            PETSC_TRUE
194 #define PETSC_NO             PETSC_FALSE
195 
196 /*M
197     PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument
198 
199    Level: beginner
200 
201    Notes: accepted by many PETSc functions to not set a parameter and instead use
202           some default
203 
204           This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
205           PETSC_NULL_DOUBLE_PRECISION etc
206 
207 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE
208 
209 M*/
210 #define PETSC_IGNORE         PETSC_NULL
211 
212 /*M
213     PETSC_DETERMINE - standard way of passing in integer or floating point parameter
214        where you wish PETSc to compute the required value.
215 
216    Level: beginner
217 
218 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes()
219 
220 M*/
221 #define PETSC_DETERMINE      PETSC_DECIDE
222 
223 /*M
224     PETSC_COMM_WORLD - a duplicate of the MPI_COMM_WORLD communicator which represents
225            all the processs
226 
227    Level: beginner
228 
229    Notes: PETSC_COMM_WORLD and MPI_COMM_WORLD are equivalent except that passing MPI_COMM_WORLD
230           into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup()
231           will be done on it internally. We recommend always using PETSC_COMM_WORLD
232 
233 .seealso: PETSC_COMM_SELF
234 
235 M*/
236 extern MPI_Comm   PETSC_COMM_WORLD;
237 
238 /*M
239     PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents
240            the current process
241 
242    Level: beginner
243 
244    Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent except that passint MPI_COMM_SELF
245           into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup()
246           will be done on it internally. We recommend always using PETSC_COMM_SELF
247 
248 .seealso: PETSC_COMM_WORLD
249 
250 M*/
251 extern MPI_Comm   PETSC_COMM_SELF;
252 
253 extern PetscTruth PetscInitializeCalled;
254 extern PetscTruth PetscFinalizeCalled;
255 EXTERN PetscErrorCode        PetscSetCommWorld(MPI_Comm);
256 EXTERN PetscErrorCode        PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm));
257 EXTERN PetscErrorCode        PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*);
258 EXTERN PetscErrorCode        PetscCommDestroy(MPI_Comm*);
259 
260 /*MC
261    PetscMalloc - Allocates memory
262 
263    Input Parameter:
264 .  m - number of bytes to allocate
265 
266    Output Parameter:
267 .  result - memory allocated
268 
269    Synopsis:
270    PetscErrorCode PetscMalloc(size_t m,void **result)
271 
272    Level: beginner
273 
274    Notes: Memory is always allocated at least double aligned
275 
276           If you request memory of zero size it will allocate no space and assign the pointer to 0; PetscFree() will
277           properly handle not freeing the null pointer.
278 
279 .seealso: PetscFree(), PetscNew()
280 
281   Concepts: memory allocation
282 
283 M*/
284 #define PetscMalloc(a,b)  ((a != 0) ? (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b)) : (*(b) = 0,0) )
285 
286 /*MC
287    PetscMalloc2 - Allocates 2 chunks of  memory
288 
289    Input Parameter:
290 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
291 .  t1 - type of first memory elements
292 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
293 -  t2 - type of second memory elements
294 
295    Output Parameter:
296 +  r1 - memory allocated in first chunk
297 -  r2 - memory allocated in second chunk
298 
299    Synopsis:
300    PetscErrorCode PetscMalloc2(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2)
301 
302    Level: developer
303 
304    Notes: Memory of first chunk is always allocated at least double aligned
305 
306 .seealso: PetscFree(), PetscNew(), PetscMalloc()
307 
308   Concepts: memory allocation
309 
310 M*/
311 #if defined(PETSC_USE_DEBUG)
312 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2))
313 #else
314 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2),r1) || (*(r2) = (t2*)(*(r1)+m1),0))
315 #endif
316 
317 /*MC
318    PetscMalloc3 - Allocates 3 chunks of  memory
319 
320    Input Parameter:
321 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
322 .  t1 - type of first memory elements
323 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
324 .  t2 - type of second memory elements
325 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
326 -  t3 - type of third memory elements
327 
328    Output Parameter:
329 +  r1 - memory allocated in first chunk
330 .  r2 - memory allocated in second chunk
331 -  r3 - memory allocated in third chunk
332 
333    Synopsis:
334    PetscErrorCode PetscMalloc3(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3)
335 
336    Level: developer
337 
338    Notes: Memory of first chunk is always allocated at least double aligned
339 
340 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3()
341 
342   Concepts: memory allocation
343 
344 M*/
345 #if defined(PETSC_USE_DEBUG)
346 #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))
347 #else
348 #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))
349 #endif
350 
351 /*MC
352    PetscMalloc4 - Allocates 4 chunks of  memory
353 
354    Input Parameter:
355 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
356 .  t1 - type of first memory elements
357 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
358 .  t2 - type of second memory elements
359 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
360 .  t3 - type of third memory elements
361 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
362 -  t4 - type of fourth memory elements
363 
364    Output Parameter:
365 +  r1 - memory allocated in first chunk
366 .  r2 - memory allocated in second chunk
367 .  r3 - memory allocated in third chunk
368 -  r4 - memory allocated in fourth chunk
369 
370    Synopsis:
371    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)
372 
373    Level: developer
374 
375    Notes: Memory of first chunk is always allocated at least double aligned
376 
377 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4()
378 
379   Concepts: memory allocation
380 
381 M*/
382 #if defined(PETSC_USE_DEBUG)
383 #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))
384 #else
385 #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))
386 #endif
387 
388 /*MC
389    PetscMalloc5 - Allocates 5 chunks of  memory
390 
391    Input Parameter:
392 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
393 .  t1 - type of first memory elements
394 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
395 .  t2 - type of second memory elements
396 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
397 .  t3 - type of third memory elements
398 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
399 .  t4 - type of fourth memory elements
400 .  m5 - number of elements to allocate in 5th chunk  (may be zero)
401 -  t5 - type of fifth memory elements
402 
403    Output Parameter:
404 +  r1 - memory allocated in first chunk
405 .  r2 - memory allocated in second chunk
406 .  r3 - memory allocated in third chunk
407 .  r4 - memory allocated in fourth chunk
408 -  r5 - memory allocated in fifth chunk
409 
410    Synopsis:
411    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)
412 
413    Level: developer
414 
415    Notes: Memory of first chunk is always allocated at least double aligned
416 
417 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5()
418 
419   Concepts: memory allocation
420 
421 M*/
422 #if defined(PETSC_USE_DEBUG)
423 #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))
424 #else
425 #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))
426 #endif
427 
428 
429 /*MC
430    PetscMalloc6 - Allocates 6 chunks of  memory
431 
432    Input Parameter:
433 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
434 .  t1 - type of first memory elements
435 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
436 .  t2 - type of second memory elements
437 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
438 .  t3 - type of third memory elements
439 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
440 .  t4 - type of fourth memory elements
441 .  m5 - number of elements to allocate in 5th chunk  (may be zero)
442 .  t5 - type of fifth memory elements
443 .  m6 - number of elements to allocate in 6th chunk  (may be zero)
444 -  t6 - type of sixth memory elements
445 
446    Output Parameter:
447 +  r1 - memory allocated in first chunk
448 .  r2 - memory allocated in second chunk
449 .  r3 - memory allocated in third chunk
450 .  r4 - memory allocated in fourth chunk
451 .  r5 - memory allocated in fifth chunk
452 -  r6 - memory allocated in sixth chunk
453 
454    Synopsis:
455    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)
456 
457    Level: developer
458 
459    Notes: Memory of first chunk is always allocated at least double aligned
460 
461 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6()
462 
463   Concepts: memory allocation
464 
465 M*/
466 #if defined(PETSC_USE_DEBUG)
467 #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))
468 #else
469 #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))
470 #endif
471 
472 /*MC
473    PetscNew - Allocates memory of a particular type, Zeros the memory!
474 
475    Input Parameter:
476 . type - structure name of space to be allocated. Memory of size sizeof(type) is allocated
477 
478    Output Parameter:
479 .  result - memory allocated
480 
481    Synopsis:
482    PetscErrorCode PetscNew(struct type,((type *))result)
483 
484    Level: beginner
485 
486 .seealso: PetscFree(), PetscMalloc()
487 
488   Concepts: memory allocation
489 
490 M*/
491 #define PetscNew(A,b)        (PetscMalloc(sizeof(A),(b)) || PetscMemzero(*(b),sizeof(A)))
492 
493 /*MC
494    PetscFree - Frees memory
495 
496    Input Parameter:
497 .   memory - memory to free
498 
499    Synopsis:
500    PetscErrorCode PetscFree(void *memory)
501 
502    Level: beginner
503 
504    Notes: Memory must have been obtained with PetscNew() or PetscMalloc()
505 
506 .seealso: PetscNew(), PetscMalloc()
507 
508   Concepts: memory allocation
509 
510 M*/
511 #define PetscFree(a)   ((a) ? ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__) || ((a = 0),0)) : 0)
512 
513 /*MC
514    PetscFree2 - Frees 2 chunks of memory obtained with PetscMalloc2()
515 
516    Input Parameter:
517 +   memory1 - memory to free
518 -   memory2 - 2nd memory to free
519 
520 
521    Synopsis:
522    PetscErrorCode PetscFree2(void *memory1,void *memory2)
523 
524    Level: developer
525 
526    Notes: Memory must have been obtained with PetscMalloc2()
527 
528 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree()
529 
530   Concepts: memory allocation
531 
532 M*/
533 #if defined(PETSC_USE_DEBUG)
534 #define PetscFree2(m1,m2)   (PetscFree(m2) || PetscFree(m1))
535 #else
536 #define PetscFree2(m1,m2)   (PetscFree(m1))
537 #endif
538 
539 /*MC
540    PetscFree3 - Frees 3 chunks of memory obtained with PetscMalloc3()
541 
542    Input Parameter:
543 +   memory1 - memory to free
544 .   memory2 - 2nd memory to free
545 -   memory3 - 3rd memory to free
546 
547 
548    Synopsis:
549    PetscErrorCode PetscFree3(void *memory1,void *memory2,void *memory3)
550 
551    Level: developer
552 
553    Notes: Memory must have been obtained with PetscMalloc3()
554 
555 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3()
556 
557   Concepts: memory allocation
558 
559 M*/
560 #if defined(PETSC_USE_DEBUG)
561 #define PetscFree3(m1,m2,m3)   (PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
562 #else
563 #define PetscFree3(m1,m2,m3)   (PetscFree(m1))
564 #endif
565 
566 /*MC
567    PetscFree4 - Frees 4 chunks of memory obtained with PetscMalloc4()
568 
569    Input Parameter:
570 +   m1 - memory to free
571 .   m2 - 2nd memory to free
572 .   m3 - 3rd memory to free
573 -   m4 - 4th memory to free
574 
575 
576    Synopsis:
577    PetscErrorCode PetscFree4(void *m1,void *m2,void *m3,void *m4)
578 
579    Level: developer
580 
581    Notes: Memory must have been obtained with PetscMalloc4()
582 
583 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4()
584 
585   Concepts: memory allocation
586 
587 M*/
588 #if defined(PETSC_USE_DEBUG)
589 #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
590 #else
591 #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m1))
592 #endif
593 
594 /*MC
595    PetscFree5 - Frees 5 chunks of memory obtained with PetscMalloc5()
596 
597    Input Parameter:
598 +   m1 - memory to free
599 .   m2 - 2nd memory to free
600 .   m3 - 3rd memory to free
601 .   m4 - 4th memory to free
602 -   m5 - 5th memory to free
603 
604 
605    Synopsis:
606    PetscErrorCode PetscFree5(void *m1,void *m2,void *m3,void *m4,void *m5)
607 
608    Level: developer
609 
610    Notes: Memory must have been obtained with PetscMalloc5()
611 
612 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5()
613 
614   Concepts: memory allocation
615 
616 M*/
617 #if defined(PETSC_USE_DEBUG)
618 #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
619 #else
620 #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m1))
621 #endif
622 
623 
624 /*MC
625    PetscFree6 - Frees 6 chunks of memory obtained with PetscMalloc6()
626 
627    Input Parameter:
628 +   m1 - memory to free
629 .   m2 - 2nd memory to free
630 .   m3 - 3rd memory to free
631 .   m4 - 4th memory to free
632 .   m5 - 5th memory to free
633 -   m6 - 6th memory to free
634 
635 
636    Synopsis:
637    PetscErrorCode PetscFree6(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6)
638 
639    Level: developer
640 
641    Notes: Memory must have been obtained with PetscMalloc6()
642 
643 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6()
644 
645   Concepts: memory allocation
646 
647 M*/
648 #if defined(PETSC_USE_DEBUG)
649 #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
650 #else
651 #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m1))
652 #endif
653 
654 EXTERN PetscErrorCode  (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**);
655 EXTERN PetscErrorCode  (*PetscTrFree)(void*,int,const char[],const char[],const char[]);
656 EXTERN PetscErrorCode  PetscSetMalloc(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[]));
657 EXTERN PetscErrorCode  PetscClearMalloc(void);
658 
659 /*
660    Routines for tracing memory corruption/bleeding with default PETSc
661    memory allocation
662 */
663 EXTERN PetscErrorCode   PetscMallocDump(FILE *);
664 EXTERN PetscErrorCode   PetscMallocDumpLog(FILE *);
665 EXTERN PetscErrorCode   PetscMallocGetCurrentUsage(PetscLogDouble *);
666 EXTERN PetscErrorCode   PetscMallocGetMaximumUsage(PetscLogDouble *);
667 EXTERN PetscErrorCode   PetscMallocDebug(PetscTruth);
668 EXTERN PetscErrorCode   PetscMallocValidate(int,const char[],const char[],const char[]);
669 EXTERN PetscErrorCode   PetscMallocSetDumpLog(void);
670 
671 
672 /*
673     Variable type where we stash PETSc object pointers in Fortran.
674     Assumes that sizeof(long) == sizeof(void*)which is true on
675     all machines that we know.
676 */
677 #define PetscFortranAddr   long
678 
679 /*E
680     PetscDataType - Used for handling different basic data types.
681 
682    Level: beginner
683 
684 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(),
685           PetscDataTypeGetSize(), PetscDataTypeGetName()
686 
687 E*/
688 typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2,
689               PETSC_LONG = 3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5,
690               PETSC_CHAR = 6,PETSC_LOGICAL = 7} PetscDataType;
691 #if defined(PETSC_USE_COMPLEX)
692 #define PETSC_SCALAR PETSC_COMPLEX
693 #else
694 #if defined(PETSC_USE_SINGLE)
695 #define PETSC_SCALAR PETSC_FLOAT
696 #else
697 #define PETSC_SCALAR PETSC_DOUBLE
698 #endif
699 #endif
700 #if defined(PETSC_USE_SINGLE)
701 #define PETSC_REAL PETSC_FLOAT
702 #else
703 #define PETSC_REAL PETSC_DOUBLE
704 #endif
705 #define PETSC_FORTRANADDR PETSC_LONG
706 
707 EXTERN PetscErrorCode PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
708 EXTERN PetscErrorCode PetscDataTypeGetSize(PetscDataType,PetscInt*);
709 EXTERN PetscErrorCode PetscDataTypeGetName(PetscDataType,const char*[]);
710 
711 /*
712     Basic memory and string operations. These are usually simple wrappers
713    around the basic Unix system calls, but a few of them have additional
714    functionality and/or error checking.
715 */
716 EXTERN PetscErrorCode   PetscMemcpy(void*,const void *,size_t);
717 EXTERN PetscErrorCode   PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType);
718 EXTERN PetscErrorCode   PetscMemmove(void*,void *,size_t);
719 EXTERN PetscErrorCode   PetscMemzero(void*,size_t);
720 EXTERN PetscErrorCode   PetscMemcmp(const void*,const void*,size_t,PetscTruth *);
721 EXTERN PetscErrorCode   PetscStrlen(const char[],size_t*);
722 EXTERN PetscErrorCode   PetscStrcmp(const char[],const char[],PetscTruth *);
723 EXTERN PetscErrorCode   PetscStrgrt(const char[],const char[],PetscTruth *);
724 EXTERN PetscErrorCode   PetscStrcasecmp(const char[],const char[],PetscTruth*);
725 EXTERN PetscErrorCode   PetscStrncmp(const char[],const char[],size_t,PetscTruth*);
726 EXTERN PetscErrorCode   PetscStrcpy(char[],const char[]);
727 EXTERN PetscErrorCode   PetscStrcat(char[],const char[]);
728 EXTERN PetscErrorCode   PetscStrncat(char[],const char[],size_t);
729 EXTERN PetscErrorCode   PetscStrncpy(char[],const char[],size_t);
730 EXTERN PetscErrorCode   PetscStrchr(const char[],char,char *[]);
731 EXTERN PetscErrorCode   PetscStrtolower(char[]);
732 EXTERN PetscErrorCode   PetscStrrchr(const char[],char,char *[]);
733 EXTERN PetscErrorCode   PetscStrstr(const char[],const char[],char *[]);
734 EXTERN PetscErrorCode   PetscStrallocpy(const char[],char *[]);
735 EXTERN PetscErrorCode   PetscStrreplace(MPI_Comm,const char[],char[],size_t);
736 #define      PetscStrfree(a) ((a) ? PetscFree(a) : 0)
737 /*S
738     PetscToken - 'Token' used for managing tokenizing strings
739 
740   Level: intermediate
741 
742 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy()
743 S*/
744 typedef struct {char token;char *array;char *current;} PetscToken;
745 
746 EXTERN PetscErrorCode   PetscTokenCreate(const char[],const char,PetscToken**);
747 EXTERN PetscErrorCode   PetscTokenFind(PetscToken*,char *[]);
748 EXTERN PetscErrorCode   PetscTokenDestroy(PetscToken*);
749 
750 /*
751    These are  MPI operations for MPI_Allreduce() etc
752 */
753 EXTERN MPI_Op PetscMaxSum_Op;
754 #if defined(PETSC_USE_COMPLEX)
755 EXTERN MPI_Op PetscSum_Op;
756 #else
757 #define PetscSum_Op MPI_SUM
758 #endif
759 EXTERN PetscErrorCode PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*);
760 
761 /*S
762      PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc
763 
764    Level: beginner
765 
766    Note: This is the base class from which all objects appear.
767 
768 .seealso:  PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName()
769 S*/
770 typedef struct _p_PetscObject* PetscObject;
771 
772 /*S
773      PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed
774       by string name
775 
776    Level: advanced
777 
778 .seealso:  PetscFListAdd(), PetscFListDestroy()
779 S*/
780 typedef struct _PetscFList *PetscFList;
781 
782 #include "petscviewer.h"
783 #include "petscoptions.h"
784 
785 /*
786    Routines that get memory usage information from the OS
787 */
788 EXTERN PetscErrorCode PetscMemoryGetCurrentUsage(PetscLogDouble *);
789 EXTERN PetscErrorCode PetscMemoryGetMaximumUsage(PetscLogDouble *);
790 EXTERN PetscErrorCode PetscMemorySetGetMaximumUsage(void);
791 EXTERN PetscErrorCode PetscMemoryShowUsage(PetscViewer,const char[]);
792 
793 EXTERN PetscErrorCode PetscLogInfoAllow(PetscTruth,const char []);
794 EXTERN PetscErrorCode PetscGetTime(PetscLogDouble*);
795 EXTERN PetscErrorCode PetscGetCPUTime(PetscLogDouble*);
796 EXTERN PetscErrorCode PetscSleep(int);
797 
798 /*
799     Initialization of PETSc
800 */
801 EXTERN PetscErrorCode  PetscInitialize(int*,char***,const char[],const char[]);
802 EXTERN PetscErrorCode  PetscInitializeNoArguments(void);
803 EXTERN PetscErrorCode  PetscInitialized(PetscTruth *);
804 EXTERN PetscErrorCode  PetscFinalized(PetscTruth *);
805 EXTERN PetscErrorCode  PetscFinalize(void);
806 EXTERN PetscErrorCode  PetscInitializeFortran(void);
807 EXTERN PetscErrorCode  PetscGetArgs(int*,char ***);
808 EXTERN PetscErrorCode  PetscEnd(void);
809 
810 typedef void (**PetscVoidFunction)(void);
811 
812 /*
813    PetscTryMethod - Queries an object for a method, if it exists then calls it.
814               These are intended to be used only inside PETSc functions.
815 */
816 #define  PetscTryMethod(obj,A,B,C) \
817   0;{ PetscErrorCode (*f)B, __ierr; \
818     __ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \
819     if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
820   }
821 #define  PetscUseMethod(obj,A,B,C) \
822   0;{ PetscErrorCode (*f)B, __ierr; \
823     __ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \
824     if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
825     else {SETERRQ1(PETSC_ERR_SUP,"Cannot locate function %s in object",A);} \
826   }
827 /*
828     Functions that can act on any PETSc object.
829 */
830 EXTERN PetscErrorCode PetscObjectDestroy(PetscObject);
831 EXTERN PetscErrorCode PetscObjectExists(PetscObject,PetscTruth*);
832 EXTERN PetscErrorCode PetscObjectGetComm(PetscObject,MPI_Comm *);
833 EXTERN PetscErrorCode PetscObjectGetCookie(PetscObject,int *);
834 EXTERN PetscErrorCode PetscObjectGetType(PetscObject,int *);
835 EXTERN PetscErrorCode PetscObjectSetName(PetscObject,const char[]);
836 EXTERN PetscErrorCode PetscObjectGetName(PetscObject,char*[]);
837 EXTERN PetscErrorCode PetscObjectReference(PetscObject);
838 EXTERN PetscErrorCode PetscObjectGetReference(PetscObject,PetscInt*);
839 EXTERN PetscErrorCode PetscObjectDereference(PetscObject);
840 EXTERN PetscErrorCode PetscObjectGetNewTag(PetscObject,PetscMPIInt *);
841 EXTERN PetscErrorCode PetscCommGetNewTag(MPI_Comm,PetscMPIInt *);
842 EXTERN PetscErrorCode PetscObjectView(PetscObject,PetscViewer);
843 EXTERN PetscErrorCode PetscObjectCompose(PetscObject,const char[],PetscObject);
844 EXTERN PetscErrorCode PetscObjectQuery(PetscObject,const char[],PetscObject *);
845 EXTERN PetscErrorCode PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void));
846 
847 typedef void (*FCNVOID)(void); /* cast in next macro should never be extern C */
848 typedef PetscErrorCode (*FCNINTVOID)(void); /* used in casts to make sure they are not extern C */
849 /*MC
850    PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object.
851 
852    Collective on PetscObject
853 
854    Input Parameters:
855 +  obj - the PETSc object; this must be cast with a (PetscObject), for example,
856          PetscObjectCompose((PetscObject)mat,...);
857 .  name - name associated with the child function
858 .  fname - name of the function
859 -  ptr - function pointer (or PETSC_NULL if using dynamic libraries)
860 
861    Level: advanced
862 
863     Synopsis:
864     PetscErrorCode PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr)
865 
866    Notes:
867    To remove a registered routine, pass in a PETSC_NULL rname and fnc().
868 
869    PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as
870    Mat, Vec, KSP, SNES, etc.) or any user-provided object.
871 
872    The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to
873    work in C++/complex with dynamic link libraries (PETSC_USE_DYNAMIC_LIBRARIES)
874    enabled.
875 
876    Concepts: objects^composing functions
877    Concepts: composing functions
878    Concepts: functions^querying
879    Concepts: objects^querying
880    Concepts: querying objects
881 
882 .seealso: PetscObjectQueryFunction()
883 M*/
884 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
885 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0)
886 #else
887 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(FCNVOID)(d))
888 #endif
889 
890 EXTERN PetscErrorCode PetscObjectQueryFunction(PetscObject,const char[],void (**)(void));
891 EXTERN PetscErrorCode PetscObjectSetOptionsPrefix(PetscObject,const char[]);
892 EXTERN PetscErrorCode PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
893 EXTERN PetscErrorCode PetscObjectPrependOptionsPrefix(PetscObject,const char[]);
894 EXTERN PetscErrorCode PetscObjectGetOptionsPrefix(PetscObject,char*[]);
895 EXTERN PetscErrorCode PetscObjectPublish(PetscObject);
896 EXTERN PetscErrorCode PetscObjectChangeTypeName(PetscObject,const char[]);
897 EXTERN PetscErrorCode PetscObjectRegisterDestroy(PetscObject);
898 EXTERN PetscErrorCode PetscObjectRegisterDestroyAll(void);
899 EXTERN PetscErrorCode PetscObjectName(PetscObject);
900 EXTERN PetscErrorCode PetscTypeCompare(PetscObject,const char[],PetscTruth*);
901 
902 /*
903     Defines PETSc error handling.
904 */
905 #include "petscerror.h"
906 
907 /*S
908      PetscOList - Linked list of PETSc objects, accessable by string name
909 
910    Level: advanced
911 
912 .seealso:  PetscOListAdd(), PetscOListDestroy(), PetscOListFind()
913 S*/
914 typedef struct _PetscOList *PetscOList;
915 
916 EXTERN PetscErrorCode PetscOListDestroy(PetscOList *);
917 EXTERN PetscErrorCode PetscOListFind(PetscOList,const char[],PetscObject*);
918 EXTERN PetscErrorCode PetscOListReverseFind(PetscOList,PetscObject,char**);
919 EXTERN PetscErrorCode PetscOListAdd(PetscOList *,const char[],PetscObject);
920 EXTERN PetscErrorCode PetscOListDuplicate(PetscOList,PetscOList *);
921 
922 /*
923     Dynamic library lists. Lists of names of routines in dynamic
924   link libraries that will be loaded as needed.
925 */
926 EXTERN PetscErrorCode PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void));
927 EXTERN PetscErrorCode PetscFListDestroy(PetscFList*);
928 EXTERN PetscErrorCode PetscFListFind(MPI_Comm,PetscFList,const char[],void (**)(void));
929 EXTERN PetscErrorCode PetscFListPrintTypes(MPI_Comm,FILE*,const char[],const char[],const char[],const char[],PetscFList);
930 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
931 #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0)
932 #else
933 #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c)
934 #endif
935 EXTERN PetscErrorCode PetscFListDuplicate(PetscFList,PetscFList *);
936 EXTERN PetscErrorCode PetscFListView(PetscFList,PetscViewer);
937 EXTERN PetscErrorCode PetscFListConcat(const char [],const char [],char []);
938 EXTERN PetscErrorCode PetscFListGet(PetscFList,char ***,int*);
939 
940 /*S
941      PetscDLLibraryList - Linked list of dynamics libraries to search for functions
942 
943    Level: advanced
944 
945    PETSC_USE_DYNAMIC_LIBRARIES must be defined in petscconf.h to use dynamic libraries
946 
947 .seealso:  PetscDLLibraryOpen()
948 S*/
949 typedef struct _PetscDLLibraryList *PetscDLLibraryList;
950 extern PetscDLLibraryList DLLibrariesLoaded;
951 EXTERN PetscErrorCode PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *);
952 EXTERN PetscErrorCode PetscDLLibraryOpen(MPI_Comm,const char[],void **);
953 EXTERN PetscErrorCode PetscDLLibrarySym(MPI_Comm,PetscDLLibraryList *,const char[],const char[],void **);
954 EXTERN PetscErrorCode PetscDLLibraryAppend(MPI_Comm,PetscDLLibraryList *,const char[]);
955 EXTERN PetscErrorCode PetscDLLibraryPrepend(MPI_Comm,PetscDLLibraryList *,const char[]);
956 EXTERN PetscErrorCode PetscDLLibraryClose(PetscDLLibraryList);
957 EXTERN PetscErrorCode PetscDLLibraryPrintPath(void);
958 EXTERN PetscErrorCode PetscDLLibraryGetInfo(void*,const char[],const char *[]);
959 
960 /*
961     Mechanism for translating PETSc object representations between languages
962     Not currently used.
963 */
964 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CXX} PetscLanguage;
965 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C
966 EXTERN PetscErrorCode PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *);
967 EXTERN PetscErrorCode PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **);
968 
969 /*
970      Useful utility routines
971 */
972 EXTERN PetscErrorCode PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*);
973 EXTERN PetscErrorCode PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*);
974 EXTERN PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt);
975 EXTERN PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt);
976 EXTERN PetscErrorCode PetscBarrier(PetscObject);
977 EXTERN PetscErrorCode PetscMPIDump(FILE*);
978 
979 #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE)
980 /*
981     Defines basic graphics available from PETSc.
982 */
983 #include "petscdraw.h"
984 
985 /*
986     Defines the base data structures for all PETSc objects
987 */
988 #include "petschead.h"
989 
990 /*
991      Defines PETSc profiling.
992 */
993 #include "petsclog.h"
994 
995 /*
996           For locking, unlocking and destroying AMS memories associated with
997     PETSc objects. Not currently used.
998 */
999 #define PetscPublishAll(v)           0
1000 #define PetscObjectTakeAccess(obj)   0
1001 #define PetscObjectGrantAccess(obj)  0
1002 #define PetscObjectDepublish(obj)    0
1003 
1004 
1005 
1006 /*
1007       This code allows one to pass a MPI communicator between
1008     C and Fortran. MPI 2.0 defines a standard API for doing this.
1009     The code here is provided to allow PETSc to work with MPI 1.1
1010     standard MPI libraries.
1011 */
1012 EXTERN PetscErrorCode  MPICCommToFortranComm(MPI_Comm,int *);
1013 EXTERN PetscErrorCode  MPIFortranCommToCComm(int,MPI_Comm*);
1014 
1015 /*
1016       Simple PETSc parallel IO for ASCII printing
1017 */
1018 EXTERN PetscErrorCode  PetscFixFilename(const char[],char[]);
1019 EXTERN PetscErrorCode  PetscFOpen(MPI_Comm,const char[],const char[],FILE**);
1020 EXTERN PetscErrorCode  PetscFClose(MPI_Comm,FILE*);
1021 EXTERN PetscErrorCode  PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
1022 EXTERN PetscErrorCode  PetscPrintf(MPI_Comm,const char[],...)  PETSC_PRINTF_FORMAT_CHECK(2,3);
1023 
1024 /* These are used internally by PETSc ASCII IO routines*/
1025 #include <stdarg.h>
1026 EXTERN PetscErrorCode  PetscVSNPrintf(char*,size_t,const char*,va_list);
1027 EXTERN PetscErrorCode  PetscVFPrintf(FILE*,const char*,va_list);
1028 
1029 /*MC
1030     PetscErrorPrintf - Prints error messages.
1031 
1032     Not Collective
1033 
1034    Synopsis:
1035      PetscErrorCode (*PetscErrorPrintf)(const char format[],...);
1036 
1037     Input Parameters:
1038 .   format - the usual printf() format string
1039 
1040    Options Database Keys:
1041 .    -error_output_stderr - cause error messages to be printed to stderr instead of the
1042          (default) stdout
1043 
1044 
1045    Level: developer
1046 
1047     Fortran Note:
1048     This routine is not supported in Fortran.
1049 
1050     Concepts: error messages^printing
1051     Concepts: printing^error messages
1052 
1053 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf()
1054 M*/
1055 EXTERN PetscErrorCode  (*PetscErrorPrintf)(const char[],...);
1056 
1057 /*MC
1058     PetscHelpPrintf - Prints help messages.
1059 
1060     Not Collective
1061 
1062    Synopsis:
1063      PetscErrorCode (*PetscHelpPrintf)(const char format[],...);
1064 
1065     Input Parameters:
1066 .   format - the usual printf() format string
1067 
1068    Level: developer
1069 
1070     Fortran Note:
1071     This routine is not supported in Fortran.
1072 
1073     Concepts: help messages^printing
1074     Concepts: printing^help messages
1075 
1076 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf()
1077 M*/
1078 EXTERN PetscErrorCode  (*PetscHelpPrintf)(MPI_Comm,const char[],...);
1079 
1080 EXTERN PetscErrorCode  PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **);
1081 EXTERN PetscErrorCode  PetscPClose(MPI_Comm,FILE*);
1082 EXTERN PetscErrorCode  PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
1083 EXTERN PetscErrorCode  PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
1084 EXTERN PetscErrorCode  PetscSynchronizedFlush(MPI_Comm);
1085 EXTERN PetscErrorCode  PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]);
1086 EXTERN PetscErrorCode  PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**);
1087 EXTERN PetscErrorCode  PetscStartJava(MPI_Comm,const char[],const char[],FILE**);
1088 EXTERN PetscErrorCode  PetscGetPetscDir(const char*[]);
1089 
1090 EXTERN PetscErrorCode  PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*);
1091 /*S
1092      PetscObjectContainer - Simple PETSc object that contains a pointer to any required data
1093 
1094    Level: advanced
1095 
1096 .seealso:  PetscObject, PetscObjectContainerCreate()
1097 S*/
1098 typedef struct _p_PetscObjectContainer*  PetscObjectContainer;
1099 EXTERN PetscErrorCode PetscObjectContainerGetPointer(PetscObjectContainer,void **);
1100 EXTERN PetscErrorCode PetscObjectContainerSetPointer(PetscObjectContainer,void *);
1101 EXTERN PetscErrorCode PetscObjectContainerDestroy(PetscObjectContainer);
1102 EXTERN PetscErrorCode PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *);
1103 EXTERN PetscErrorCode PetscObjectContainerSetUserDestroy(PetscObjectContainer, PetscErrorCode (*)(void*));
1104 
1105 /*
1106    For incremental debugging
1107 */
1108 extern PetscTruth PetscCompare;
1109 EXTERN PetscErrorCode        PetscCompareDouble(double);
1110 EXTERN PetscErrorCode        PetscCompareScalar(PetscScalar);
1111 EXTERN PetscErrorCode        PetscCompareInt(PetscInt);
1112 
1113 /*
1114    For use in debuggers
1115 */
1116 extern int PetscGlobalRank,PetscGlobalSize;
1117 EXTERN PetscErrorCode PetscIntView(PetscInt,PetscInt[],PetscViewer);
1118 EXTERN PetscErrorCode PetscRealView(PetscInt,PetscReal[],PetscViewer);
1119 EXTERN PetscErrorCode PetscScalarView(PetscInt,PetscScalar[],PetscViewer);
1120 
1121 /*
1122     Allows accessing Matlab Engine
1123 */
1124 #include "petscmatlab.h"
1125 
1126 /*
1127     C code optimization is often enhanced by telling the compiler
1128   that certain pointer arguments to functions are not aliased to
1129   to other arguments. This is not yet ANSI C standard so we define
1130   the macro "restrict" to indicate that the variable is not aliased
1131   to any other argument.
1132 */
1133 #if defined(PETSC_HAVE_RESTRICT) && !defined(__cplusplus)
1134 #define restrict _Restrict
1135 #else
1136 #if defined(restrict)
1137 #undef restrict
1138 #endif
1139 #define restrict
1140 #endif
1141 
1142 /*
1143       Determine if some of the kernel computation routines use
1144    Fortran (rather than C) for the numerical calculations. On some machines
1145    and compilers (like complex numbers) the Fortran version of the routines
1146    is faster than the C/C++ versions. The flag PETSC_USE_FORTRAN_KERNELS
1147    would be set in the petscconf.h file
1148 */
1149 #if defined(PETSC_USE_FORTRAN_KERNELS)
1150 
1151 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ)
1152 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ
1153 #endif
1154 
1155 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ)
1156 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ
1157 #endif
1158 
1159 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM)
1160 #define PETSC_USE_FORTRAN_KERNEL_NORM
1161 #endif
1162 
1163 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY)
1164 #define PETSC_USE_FORTRAN_KERNEL_MAXPY
1165 #endif
1166 
1167 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ)
1168 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ
1169 #endif
1170 
1171 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ)
1172 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ
1173 #endif
1174 
1175 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ)
1176 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ
1177 #endif
1178 
1179 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ)
1180 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ
1181 #endif
1182 
1183 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT)
1184 #define PETSC_USE_FORTRAN_KERNEL_MDOT
1185 #endif
1186 
1187 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY)
1188 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY
1189 #endif
1190 
1191 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX)
1192 #define PETSC_USE_FORTRAN_KERNEL_AYPX
1193 #endif
1194 
1195 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY)
1196 #define PETSC_USE_FORTRAN_KERNEL_WAXPY
1197 #endif
1198 
1199 #endif
1200 
1201 /*
1202     Macros for indicating code that should be compiled with a C interface,
1203    rather than a C++ interface. Any routines that are dynamically loaded
1204    (such as the PCCreate_XXX() routines) must be wrapped so that the name
1205    mangler does not change the functions symbol name. This just hides the
1206    ugly extern "C" {} wrappers.
1207 */
1208 #if defined(__cplusplus)
1209 #define EXTERN_C_BEGIN extern "C" {
1210 #define EXTERN_C_END }
1211 #else
1212 #define EXTERN_C_BEGIN
1213 #define EXTERN_C_END
1214 #endif
1215 
1216 /* --------------------------------------------------------------------*/
1217 
1218 /*M
1219     size - integer variable used to contain the number of processors in
1220            the relevent MPI_Comm
1221 
1222    Level: beginner
1223 
1224 .seealso: rank, comm
1225 M*/
1226 
1227 /*M
1228     rank - integer variable used to contain the number of this processor relative
1229            to all in the relevent MPI_Comm
1230 
1231    Level: beginner
1232 
1233 .seealso: size, comm
1234 M*/
1235 
1236 /*M
1237     comm - MPI_Comm used in the current routine or object
1238 
1239    Level: beginner
1240 
1241 .seealso: size, rank
1242 M*/
1243 
1244 /*M
1245     MPI_Comm - the basic object used by MPI to determine which processes are involved in a
1246         communication
1247 
1248    Level: beginner
1249 
1250    Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm
1251 
1252 .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF
1253 M*/
1254 
1255 /*M
1256     PetscScalar - PETSc type that represents either a double precision real number or
1257        a double precision complex number if the code is configured with --with-scalar-type=complex
1258 
1259    Level: beginner
1260 
1261 .seealso: PetscReal, PassiveReal, PassiveScalar
1262 M*/
1263 
1264 /*M
1265     PetscReal - PETSc type that represents a double precision real number
1266 
1267    Level: beginner
1268 
1269 .seealso: PetscScalar, PassiveReal, PassiveScalar
1270 M*/
1271 
1272 /*M
1273     PassiveScalar - PETSc type that represents either a double precision real number or
1274        a double precision complex number if the code is  code is configured with --with-scalar-type=complex
1275 
1276    Level: beginner
1277 
1278     This is the same as a PetscScalar except in code that is automatically differentiated it is
1279    treated as a constant (not an indendent or dependent variable)
1280 
1281 .seealso: PetscReal, PassiveReal, PetscScalar
1282 M*/
1283 
1284 /*M
1285     PassiveReal - PETSc type that represents a double precision real number
1286 
1287    Level: beginner
1288 
1289     This is the same as a PetscReal except in code that is automatically differentiated it is
1290    treated as a constant (not an indendent or dependent variable)
1291 
1292 .seealso: PetscScalar, PetscReal, PassiveScalar
1293 M*/
1294 
1295 /*M
1296     MPIU_SCALAR - MPI datatype corresponding to PetscScalar
1297 
1298    Level: beginner
1299 
1300     Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars
1301           pass this value
1302 
1303 .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar
1304 M*/
1305 
1306 /*
1307      The IBM include files define hz, here we hide it so that it may be used
1308    as a regular user variable.
1309 */
1310 #if defined(hz)
1311 #undef hz
1312 #endif
1313 
1314 /*  For arrays that contain filenames or paths */
1315 
1316 
1317 #if defined(PETSC_HAVE_LIMITS_H)
1318 #include <limits.h>
1319 #endif
1320 #if defined(PETSC_HAVE_SYS_PARAM_H)
1321 #include <sys/param.h>
1322 #endif
1323 #if defined(PETSC_HAVE_SYS_TYPES_H)
1324 #include <sys/types.h>
1325 #endif
1326 #if defined(MAXPATHLEN)
1327 #  define PETSC_MAX_PATH_LEN     MAXPATHLEN
1328 #elif defined(MAX_PATH)
1329 #  define PETSC_MAX_PATH_LEN     MAX_PATH
1330 #elif defined(_MAX_PATH)
1331 #  define PETSC_MAX_PATH_LEN     _MAX_PATH
1332 #else
1333 #  define PETSC_MAX_PATH_LEN     4096
1334 #endif
1335 
1336 PETSC_EXTERN_CXX_END
1337 #endif
1338 
1339 
1340