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