xref: /petsc/include/petscsys.h (revision f3fe499b4cc4d64bf04aa4f5e4963dcc4eb56541)
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(__PETSCSYS_H)
6 #define __PETSCSYS_H
7 /* ========================================================================== */
8 /*
9    petscconf.h is contained in ${PETSC_ARCH}/include/petscconf.h it is
10    found automatically by the compiler due to the -I${PETSC_DIR}/${PETSC_ARCH}/include
11    in the conf/variables definition of PETSC_INCLUDE
12 */
13 #include "petscconf.h"
14 #include "petscfix.h"
15 
16 /* ========================================================================== */
17 /*
18    This facilitates using C version of PETSc from C++ and
19    C++ version from C. Use --with-c-support --with-clanguage=c++ with ./configure for the latter)
20 */
21 #if defined(PETSC_CLANGUAGE_CXX) && !defined(PETSC_USE_EXTERN_CXX) && !defined(__cplusplus)
22 #error "PETSc configured with --with-clanguage=c++ and NOT --with-c-support - it can be used only with a C++ compiler"
23 #endif
24 
25 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
26 #define PETSC_EXTERN_CXX_BEGIN extern "C" {
27 #define PETSC_EXTERN_CXX_END  }
28 #else
29 #define PETSC_EXTERN_CXX_BEGIN
30 #define PETSC_EXTERN_CXX_END
31 #endif
32 /* ========================================================================== */
33 /*
34    Current PETSc version number and release date. Also listed in
35     Web page
36     src/docs/tex/manual/intro.tex,
37     src/docs/tex/manual/manual.tex.
38     src/docs/website/index.html.
39 */
40 #include "petscversion.h"
41 #define PETSC_AUTHOR_INFO        "       The PETSc Team\n    petsc-maint@mcs.anl.gov\n http://www.mcs.anl.gov/petsc/\n"
42 #if (PETSC_VERSION_RELEASE == 1)
43 #define PetscGetVersion(version,len) PetscSNPrintf(version,len,"Petsc Release Version %d.%d.%d, Patch %d, %s ", \
44                                          PETSC_VERSION_MAJOR,PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, \
45 					 PETSC_VERSION_PATCH,PETSC_VERSION_PATCH_DATE)
46 #else
47 #define PetscGetVersion(version,len) PetscSNPrintf(version,len,"Petsc Development HG revision: %s  HG Date: %s", \
48                                         PETSC_VERSION_HG, PETSC_VERSION_DATE_HG)
49 #endif
50 
51 /*MC
52     PetscGetVersion - Gets the PETSc version information in a string.
53 
54     Input Parameter:
55 .   len - length of the string
56 
57     Output Parameter:
58 .   version - version string
59 
60     Level: developer
61 
62     Usage:
63     char version[256];
64     ierr = PetscGetVersion(version,256);CHKERRQ(ierr)
65 
66     Fortran Note:
67     This routine is not supported in Fortran.
68 
69 .seealso: PetscGetProgramName()
70 
71 M*/
72 
73 /* ========================================================================== */
74 
75 /*
76    Currently cannot check formatting for PETSc print statements because we have our
77    own format %D and %G
78 */
79 #undef  PETSC_PRINTF_FORMAT_CHECK
80 #define PETSC_PRINTF_FORMAT_CHECK(a,b)
81 #undef  PETSC_FPRINTF_FORMAT_CHECK
82 #define PETSC_FPRINTF_FORMAT_CHECK(a,b)
83 
84 /*
85    Fixes for ./configure time choices which impact our interface. Currently only
86    calling conventions and extra compiler checking falls under this category.
87 */
88 #if !defined(PETSC_STDCALL)
89 #define PETSC_STDCALL
90 #endif
91 #if !defined(PETSC_TEMPLATE)
92 #define PETSC_TEMPLATE
93 #endif
94 #if !defined(PETSC_HAVE_DLL_EXPORT)
95 #define PETSC_DLL_EXPORT
96 #define PETSC_DLL_IMPORT
97 #endif
98 #if !defined(PETSC_DLLEXPORT)
99 #define PETSC_DLLEXPORT
100 #endif
101 #if !defined(PETSCVEC_DLLEXPORT)
102 #define PETSCVEC_DLLEXPORT
103 #endif
104 #if !defined(PETSCMAT_DLLEXPORT)
105 #define PETSCMAT_DLLEXPORT
106 #endif
107 #if !defined(PETSCDM_DLLEXPORT)
108 #define PETSCDM_DLLEXPORT
109 #endif
110 #if !defined(PETSCKSP_DLLEXPORT)
111 #define PETSCKSP_DLLEXPORT
112 #endif
113 #if !defined(PETSCSNES_DLLEXPORT)
114 #define PETSCSNES_DLLEXPORT
115 #endif
116 #if !defined(PETSCTS_DLLEXPORT)
117 #define PETSCTS_DLLEXPORT
118 #endif
119 #if !defined(PETSCFORTRAN_DLLEXPORT)
120 #define PETSCFORTRAN_DLLEXPORT
121 #endif
122 /* ========================================================================== */
123 
124 /*
125     Defines the interface to MPI allowing the use of all MPI functions.
126 
127     PETSc does not use the C++ binding of MPI at ALL. The following flag
128     makes sure the C++ bindings are not included. The C++ bindings REQUIRE
129     putting mpi.h before ANY C++ include files, we cannot control this
130     with all PETSc users. Users who want to use the MPI C++ bindings can include
131     mpicxx.h directly in their code
132 */
133 #define MPICH_SKIP_MPICXX 1
134 #define OMPI_SKIP_MPICXX 1
135 #include "mpi.h"
136 
137 /*
138     Yuck, we need to put stdio.h AFTER mpi.h for MPICH2 with C++ compiler
139     see the top of mpicxx.h in the MPICH2 distribution.
140 
141     The MPI STANDARD HAS TO BE CHANGED to prevent this nonsense.
142 */
143 #include <stdio.h>
144 
145 /* MSMPI on 32bit windows requires this yukky hack - that breaks MPI standard compliance */
146 #if !defined(MPIAPI)
147 #define MPIAPI
148 #endif
149 
150 
151 /*MC
152     PetscErrorCode - datatype used for return error code from all PETSc functions
153 
154     Level: beginner
155 
156 .seealso: CHKERRQ, SETERRQ
157 M*/
158 typedef int PetscErrorCode;
159 
160 /*MC
161 
162     PetscClassId - A unique id used to identify each PETSc class.
163          (internal integer in the data structure used for error
164          checking). These are all defined by an offset from the lowest
165          one, PETSC_SMALLEST_CLASSID.
166 
167     Level: advanced
168 
169 .seealso: PetscClassIdRegister(), PetscLogEventRegister(), PetscHeaderCreate()
170 M*/
171 typedef int PetscClassId;
172 
173 /*MC
174     PetscLogEvent - id used to identify PETSc or user events which timed portions (blocks of executable)
175      code.
176 
177     Level: intermediate
178 
179 .seealso: PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd(), PetscLogStage
180 M*/
181 typedef int PetscLogEvent;
182 
183 /*MC
184     PetscLogStage - id used to identify user stages (phases, sections) of runs - for logging
185 
186     Level: intermediate
187 
188 .seealso: PetscLogStageRegister(), PetscLogStageBegin(), PetscLogStageEnd(), PetscLogEvent
189 M*/
190 typedef int PetscLogStage;
191 
192 /*MC
193     PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions.
194 
195     Level: intermediate
196 
197     Notes: usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but
198            standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt it remains 32 bit
199            (except on very rare BLAS/LAPACK implementations that support 64 bit integers).
200 
201     PetscBLASIntCheck(a) checks if the given PetscInt a will fit in a PetscBLASInt, if not it generates a
202       PETSC_ERR_ARG_OUTOFRANGE.
203 
204     PetscBLASInt b = PetscBLASIntCast(a) checks if the given PetscInt a will fit in a PetscBLASInt, if not it
205       generates a PETSC_ERR_ARG_OUTOFRANGE
206 
207 .seealso: PetscMPIInt, PetscInt
208 
209 M*/
210 typedef int PetscBLASInt;
211 
212 /*MC
213     PetscMPIInt - datatype used to represent 'int' parameters to MPI functions.
214 
215     Level: intermediate
216 
217     Notes: usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but
218            standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt it remains 32 bit
219 
220     PetscMPIIntCheck(a) checks if the given PetscInt a will fit in a PetscMPIInt, if not it generates a
221       PETSC_ERR_ARG_OUTOFRANGE.
222 
223     PetscMPIInt b = PetscMPIIntCast(a) checks if the given PetscInt a will fit in a PetscMPIInt, if not it
224       generates a PETSC_ERR_ARG_OUTOFRANGE
225 
226 .seealso: PetscBLASInt, PetscInt
227 
228 M*/
229 typedef int PetscMPIInt;
230 
231 /*MC
232     PetscEnum - datatype used to pass enum types within PETSc functions.
233 
234     Level: intermediate
235 
236     PetscMPIIntCheck(a) checks if the given PetscInt a will fit in a PetscMPIInt, if not it generates a
237       PETSC_ERR_ARG_OUTOFRANGE.
238 
239     PetscMPIInt b = PetscMPIIntCast(a) checks if the given PetscInt a will fit in a PetscMPIInt, if not it
240       generates a PETSC_ERR_ARG_OUTOFRANGE
241 
242 .seealso: PetscOptionsGetEnum(), PetscOptionsEnum(), PetscBagRegisterEnum()
243 M*/
244 typedef enum { ENUM_DUMMY } PetscEnum;
245 
246 /*MC
247     PetscInt - PETSc type that represents integer - used primarily to
248       represent size of arrays and indexing into arrays. Its size can be configured with the option
249       --with-64-bit-indices - to be either 32bit or 64bit [default 32 bit ints]
250 
251    Level: intermediate
252 
253 .seealso: PetscScalar, PetscBLASInt, PetscMPIInt
254 M*/
255 #if defined(PETSC_USE_64BIT_INDICES)
256 typedef long long PetscInt;
257 #define MPIU_INT MPI_LONG_LONG_INT
258 #else
259 typedef int PetscInt;
260 #define MPIU_INT MPI_INT
261 #endif
262 
263 /*
264     For the rare cases when one needs to send a size_t object with MPI
265 */
266 #if (PETSC_SIZEOF_SIZE_T) == (PETSC_SIZEOF_INT)
267 #define MPIU_SIZE_T MPI_INT
268 #elif  (PETSC_SIZEOF_SIZE_T) == (PETSC_SIZEOF_LONG)
269 #define MPIU_SIZE_T MPI_LONG
270 #elif  (PETSC_SIZEOF_SIZE_T) == (PETSC_SIZEOF_LONG_LONG)
271 #define MPIU_SIZE_T MPI_LONG_LONG_INT
272 #else
273 #error "Unknown size for size_t! Send us a bugreport at petsc-maint@mcs.anl.gov"
274 #endif
275 
276 
277 /*
278       You can use PETSC_STDOUT as a replacement of stdout. You can also change
279     the value of PETSC_STDOUT to redirect all standard output elsewhere
280 */
281 
282 extern FILE* PETSC_STDOUT;
283 
284 /*
285       You can use PETSC_STDERR as a replacement of stderr. You can also change
286     the value of PETSC_STDERR to redirect all standard error elsewhere
287 */
288 extern FILE* PETSC_STDERR;
289 
290 /*
291       PETSC_ZOPEFD is used to send data to the PETSc webpage.  It can be used
292     in conjunction with PETSC_STDOUT, or by itself.
293 */
294 extern FILE* PETSC_ZOPEFD;
295 
296 #if !defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
297 /*MC
298       PetscPolymorphicSubroutine - allows defining a C++ polymorphic version of
299             a PETSc function that remove certain optional arguments for a simplier user interface
300 
301    Synopsis:
302    PetscPolymorphicSubroutine(Functionname,(arguments of C++ function),(arguments of C function))
303 
304      Not collective
305 
306    Level: developer
307 
308     Example:
309       PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r)) generates the new routine
310            PetscErrorCode VecNorm(Vec x,PetscReal *r) = VecNorm(x,NORM_2,r)
311 
312 .seealso: PetscPolymorphicFunction()
313 
314 M*/
315 #define PetscPolymorphicSubroutine(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {return A C;}
316 
317 /*MC
318       PetscPolymorphicScalar - allows defining a C++ polymorphic version of
319             a PETSc function that replaces a PetscScalar * argument with a PetscScalar argument
320 
321    Synopsis:
322    PetscPolymorphicScalar(Functionname,(arguments of C++ function),(arguments of C function))
323 
324    Not collective
325 
326    Level: developer
327 
328     Example:
329       PetscPolymorphicScalar(VecAXPY,(PetscScalar _val,Vec x,Vec y),(&_Val,x,y)) generates the new routine
330            PetscErrorCode VecAXPY(PetscScalar _val,Vec x,Vec y) = {PetscScalar _Val = _val; return VecAXPY(&_Val,x,y);}
331 
332 .seealso: PetscPolymorphicFunction(),PetscPolymorphicSubroutine()
333 
334 M*/
335 #define PetscPolymorphicScalar(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {PetscScalar _Val = _val; return A C;}
336 
337 /*MC
338       PetscPolymorphicFunction - allows defining a C++ polymorphic version of
339             a PETSc function that remove certain optional arguments for a simplier user interface
340             and returns the computed value (istead of an error code)
341 
342    Synopsis:
343    PetscPolymorphicFunction(Functionname,(arguments of C++ function),(arguments of C function),return type,return variable name)
344 
345      Not collective
346 
347    Level: developer
348 
349     Example:
350       PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r) generates the new routine
351          PetscReal VecNorm(Vec x,NormType t) = {PetscReal r; VecNorm(x,t,&r); return r;}
352 
353 .seealso: PetscPolymorphicSubroutine()
354 
355 M*/
356 #define PetscPolymorphicFunction(A,B,C,D,E) PETSC_STATIC_INLINE D A B {D E; A C;return E;}
357 
358 #else
359 #define PetscPolymorphicSubroutine(A,B,C)
360 #define PetscPolymorphicScalar(A,B,C)
361 #define PetscPolymorphicFunction(A,B,C,D,E)
362 #endif
363 
364 /*MC
365     PetscUnlikely - hints the compiler that the given condition is usually FALSE
366 
367     Synopsis:
368     PetscTruth PetscUnlikely(PetscTruth cond)
369 
370     Not Collective
371 
372     Input Parameters:
373 .   cond - condition or expression
374 
375     Note: This returns the same truth value, it is only a hint to compilers that the resulting
376     branch is unlikely.
377 
378     Level: advanced
379 
380 .seealso: PetscLikely(), CHKERRQ
381 M*/
382 
383 /*MC
384     PetscLikely - hints the compiler that the given condition is usually TRUE
385 
386     Synopsis:
387     PetscTruth PetscUnlikely(PetscTruth cond)
388 
389     Not Collective
390 
391     Input Parameters:
392 .   cond - condition or expression
393 
394     Note: This returns the same truth value, it is only a hint to compilers that the resulting
395     branch is likely.
396 
397     Level: advanced
398 
399 .seealso: PetscUnlikely()
400 M*/
401 #if defined(PETSC_HAVE_BUILTIN_EXPECT)
402 #  define PetscUnlikely(cond)   __builtin_expect(!!(cond),0)
403 #  define PetscLikely(cond)     __builtin_expect(!!(cond),1)
404 #else
405 #  define PetscUnlikely(cond)   (cond)
406 #  define PetscLikely(cond)     (cond)
407 #endif
408 
409 /*
410     Extern indicates a PETSc function defined elsewhere
411 */
412 #if !defined(EXTERN)
413 #define EXTERN extern
414 #endif
415 
416 /*
417     Defines some elementary mathematics functions and constants.
418 */
419 #include "petscmath.h"
420 
421 /*
422     Declare extern C stuff after including external header files
423 */
424 
425 PETSC_EXTERN_CXX_BEGIN
426 
427 /*
428        Basic PETSc constants
429 */
430 
431 /*E
432     PetscTruth - Logical variable. Actually an int in C and a logical in Fortran.
433 
434    Level: beginner
435 
436 E*/
437 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth;
438 extern const char *PetscTruths[];
439 
440 /*MC
441     PETSC_FALSE - False value of PetscTruth
442 
443     Level: beginner
444 
445     Note: Zero integer
446 
447 .seealso: PetscTruth, PETSC_TRUE
448 M*/
449 
450 /*MC
451     PETSC_TRUE - True value of PetscTruth
452 
453     Level: beginner
454 
455     Note: Nonzero integer
456 
457 .seealso: PetscTruth, PETSC_FALSE
458 M*/
459 
460 /*MC
461     PETSC_YES - Alias for PETSC_TRUE
462 
463     Level: beginner
464 
465     Note: Zero integer
466 
467 .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_NO
468 M*/
469 #define PETSC_YES            PETSC_TRUE
470 
471 /*MC
472     PETSC_NO - Alias for PETSC_FALSE
473 
474     Level: beginner
475 
476     Note: Nonzero integer
477 
478 .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_YES
479 M*/
480 #define PETSC_NO             PETSC_FALSE
481 
482 /*MC
483     PETSC_NULL - standard way of passing in a null or array or pointer
484 
485    Level: beginner
486 
487    Notes: accepted by many PETSc functions to not set a parameter and instead use
488           some default
489 
490           This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
491           PETSC_NULL_DOUBLE_PRECISION, PETSC_NULL_FUNCTION, PETSC_NULL_OBJECT etc
492 
493 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
494 
495 M*/
496 #define PETSC_NULL           0
497 
498 /*MC
499     PETSC_DECIDE - standard way of passing in integer or floating point parameter
500        where you wish PETSc to use the default.
501 
502    Level: beginner
503 
504 .seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
505 
506 M*/
507 #define PETSC_DECIDE         -1
508 
509 /*MC
510     PETSC_DEFAULT - standard way of passing in integer or floating point parameter
511        where you wish PETSc to use the default.
512 
513    Level: beginner
514 
515    Fortran Notes: You need to use PETSC_DEFAULT_INTEGER or PETSC_DEFAULT_DOUBLE_PRECISION.
516 
517 .seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE
518 
519 M*/
520 #define PETSC_DEFAULT        -2
521 
522 
523 /*MC
524     PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument
525 
526    Level: beginner
527 
528    Note: accepted by many PETSc functions to not set a parameter and instead use
529           some default
530 
531    Fortran Notes: This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
532           PETSC_NULL_DOUBLE_PRECISION etc
533 
534 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE
535 
536 M*/
537 #define PETSC_IGNORE         PETSC_NULL
538 
539 /*MC
540     PETSC_DETERMINE - standard way of passing in integer or floating point parameter
541        where you wish PETSc to compute the required value.
542 
543    Level: beginner
544 
545 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes()
546 
547 M*/
548 #define PETSC_DETERMINE      PETSC_DECIDE
549 
550 /*MC
551     PETSC_COMM_WORLD - the equivalent of the MPI_COMM_WORLD communicator which represents
552            all the processs that PETSc knows about.
553 
554    Level: beginner
555 
556    Notes: By default PETSC_COMM_WORLD and MPI_COMM_WORLD are identical unless you wish to
557           run PETSc on ONLY a subset of MPI_COMM_WORLD. In that case create your new (smaller)
558           communicator, call it, say comm, and set PETSC_COMM_WORLD = comm BEFORE calling
559           PetscInitialize()
560 
561 .seealso: PETSC_COMM_SELF
562 
563 M*/
564 extern MPI_Comm PETSC_COMM_WORLD;
565 
566 /*MC
567     PETSC_COMM_SELF - This is always MPI_COMM_SELF
568 
569    Level: beginner
570 
571 .seealso: PETSC_COMM_WORLD
572 
573 M*/
574 #define PETSC_COMM_SELF MPI_COMM_SELF
575 
576 extern PETSC_DLLEXPORT PetscTruth PetscInitializeCalled;
577 extern PETSC_DLLEXPORT PetscTruth PetscFinalizeCalled;
578 
579 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm));
580 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*);
581 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommDestroy(MPI_Comm*);
582 
583 /*MC
584    PetscMalloc - Allocates memory
585 
586    Synopsis:
587    PetscErrorCode PetscMalloc(size_t m,void **result)
588 
589    Not Collective
590 
591    Input Parameter:
592 .  m - number of bytes to allocate
593 
594    Output Parameter:
595 .  result - memory allocated
596 
597    Level: beginner
598 
599    Notes: Memory is always allocated at least double aligned
600 
601           If you request memory of zero size it will allocate no space and assign the pointer to 0; PetscFree() will
602           properly handle not freeing the null pointer.
603 
604 .seealso: PetscFree(), PetscNew()
605 
606   Concepts: memory allocation
607 
608 M*/
609 #define PetscMalloc(a,b)  ((a != 0) ? (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b)) : (*(b) = 0,0) )
610 
611 /*MC
612    PetscAddrAlign - Rounds up an address to PETSC_MEMALIGN alignment
613 
614    Synopsis:
615    void *PetscAddrAlign(void *addr)
616 
617    Not Collective
618 
619    Input Parameters:
620 .  addr - address to align (any pointer type)
621 
622    Level: developer
623 
624 .seealso: PetscMallocAlign()
625 
626   Concepts: memory allocation
627 M*/
628 #if defined PETSC_UINTPTR_T
629 #  define PetscAddrAlign(a) (void*)((((PETSC_UINTPTR_T)(a))+(PETSC_MEMALIGN-1)) & ~(PETSC_MEMALIGN-1))
630 #else
631 #  define PetscAddrAlign(a) (void*)(a)
632 #endif
633 
634 /*MC
635    PetscMalloc2 - Allocates 2 chunks of  memory both aligned to PETSC_MEMALIGN
636 
637    Synopsis:
638    PetscErrorCode PetscMalloc2(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2)
639 
640    Not Collective
641 
642    Input Parameter:
643 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
644 .  t1 - type of first memory elements
645 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
646 -  t2 - type of second memory elements
647 
648    Output Parameter:
649 +  r1 - memory allocated in first chunk
650 -  r2 - memory allocated in second chunk
651 
652    Level: developer
653 
654 .seealso: PetscFree(), PetscNew(), PetscMalloc()
655 
656   Concepts: memory allocation
657 
658 M*/
659 #if defined(PETSC_USE_DEBUG)
660 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2))
661 #else
662 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) ((*(r2) = 0,PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(PETSC_MEMALIGN-1),r1)) \
663                                          || (*(r2) = (t2*)PetscAddrAlign(*(r1)+m1),0))
664 #endif
665 
666 /*MC
667    PetscMalloc3 - Allocates 3 chunks of  memory  all aligned to PETSC_MEMALIGN
668 
669    Synopsis:
670    PetscErrorCode PetscMalloc3(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3)
671 
672    Not Collective
673 
674    Input Parameter:
675 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
676 .  t1 - type of first memory elements
677 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
678 .  t2 - type of second memory elements
679 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
680 -  t3 - type of third memory elements
681 
682    Output Parameter:
683 +  r1 - memory allocated in first chunk
684 .  r2 - memory allocated in second chunk
685 -  r3 - memory allocated in third chunk
686 
687    Level: developer
688 
689 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3()
690 
691   Concepts: memory allocation
692 
693 M*/
694 #if defined(PETSC_USE_DEBUG)
695 #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))
696 #else
697 #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) ((*(r2) = 0,*(r3) = 0,PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+2*(PETSC_MEMALIGN-1),r1)) \
698                                                   || (*(r2) = (t2*)PetscAddrAlign(*(r1)+m1),*(r3) = (t3*)PetscAddrAlign(*(r2)+m2),0))
699 #endif
700 
701 /*MC
702    PetscMalloc4 - Allocates 4 chunks of  memory  all aligned to PETSC_MEMALIGN
703 
704    Synopsis:
705    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)
706 
707    Not Collective
708 
709    Input Parameter:
710 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
711 .  t1 - type of first memory elements
712 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
713 .  t2 - type of second memory elements
714 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
715 .  t3 - type of third memory elements
716 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
717 -  t4 - type of fourth memory elements
718 
719    Output Parameter:
720 +  r1 - memory allocated in first chunk
721 .  r2 - memory allocated in second chunk
722 .  r3 - memory allocated in third chunk
723 -  r4 - memory allocated in fourth chunk
724 
725    Level: developer
726 
727 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4()
728 
729   Concepts: memory allocation
730 
731 M*/
732 #if defined(PETSC_USE_DEBUG)
733 #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))
734 #else
735 #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4)               \
736   ((*(r2) = 0, *(r3) = 0, *(r4) = 0,PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+3*(PETSC_MEMALIGN-1),r1)) \
737    || (*(r2) = (t2*)PetscAddrAlign(*(r1)+m1),*(r3) = (t3*)PetscAddrAlign(*(r2)+m2),*(r4) = (t4*)PetscAddrAlign(*(r3)+m3),0))
738 #endif
739 
740 /*MC
741    PetscMalloc5 - Allocates 5 chunks of  memory all aligned to PETSC_MEMALIGN
742 
743    Synopsis:
744    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)
745 
746    Not Collective
747 
748    Input Parameter:
749 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
750 .  t1 - type of first memory elements
751 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
752 .  t2 - type of second memory elements
753 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
754 .  t3 - type of third memory elements
755 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
756 .  t4 - type of fourth memory elements
757 .  m5 - number of elements to allocate in 5th chunk  (may be zero)
758 -  t5 - type of fifth memory elements
759 
760    Output Parameter:
761 +  r1 - memory allocated in first chunk
762 .  r2 - memory allocated in second chunk
763 .  r3 - memory allocated in third chunk
764 .  r4 - memory allocated in fourth chunk
765 -  r5 - memory allocated in fifth chunk
766 
767    Level: developer
768 
769 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5()
770 
771   Concepts: memory allocation
772 
773 M*/
774 #if defined(PETSC_USE_DEBUG)
775 #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))
776 #else
777 #define PetscMalloc5(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5)      \
778   ((*(r2) = 0, *(r3) = 0, *(r4) = 0,*(r5) = 0,PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+4*(PETSC_MEMALIGN-1),r1)) \
779    || (*(r2) = (t2*)PetscAddrAlign(*(r1)+m1),*(r3) = (t3*)PetscAddrAlign(*(r2)+m2),*(r4) = (t4*)PetscAddrAlign(*(r3)+m3),*(r5) = (t5*)PetscAddrAlign(*(r4)+m4),0))
780 #endif
781 
782 
783 /*MC
784    PetscMalloc6 - Allocates 6 chunks of  memory all aligned to PETSC_MEMALIGN
785 
786    Synopsis:
787    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)
788 
789    Not Collective
790 
791    Input Parameter:
792 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
793 .  t1 - type of first memory elements
794 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
795 .  t2 - type of second memory elements
796 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
797 .  t3 - type of third memory elements
798 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
799 .  t4 - type of fourth memory elements
800 .  m5 - number of elements to allocate in 5th chunk  (may be zero)
801 .  t5 - type of fifth memory elements
802 .  m6 - number of elements to allocate in 6th chunk  (may be zero)
803 -  t6 - type of sixth memory elements
804 
805    Output Parameter:
806 +  r1 - memory allocated in first chunk
807 .  r2 - memory allocated in second chunk
808 .  r3 - memory allocated in third chunk
809 .  r4 - memory allocated in fourth chunk
810 .  r5 - memory allocated in fifth chunk
811 -  r6 - memory allocated in sixth chunk
812 
813    Level: developer
814 
815 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6()
816 
817   Concepts: memory allocation
818 
819 M*/
820 #if defined(PETSC_USE_DEBUG)
821 #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))
822 #else
823 #define PetscMalloc6(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6) \
824   ((*(r2) = 0, *(r3) = 0, *(r4) = 0,*(r5) = 0,*(r6) = 0,PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6)+5*(PETSC_MEMALIGN-1),r1)) \
825    || (*(r2) = (t2*)PetscAddrAlign(*(r1)+m1),*(r3) = (t3*)PetscAddrAlign(*(r2)+m2),*(r4) = (t4*)PetscAddrAlign(*(r3)+m3),*(r5) = (t5*)PetscAddrAlign(*(r4)+m4),*(r6) = (t6*)PetscAddrAlign(*(r5)+m5),0))
826 #endif
827 
828 /*MC
829    PetscMalloc7 - Allocates 7 chunks of  memory all aligned to PETSC_MEMALIGN
830 
831    Synopsis:
832    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)
833 
834    Not Collective
835 
836    Input Parameter:
837 +  m1 - number of elements to allocate in 1st chunk  (may be zero)
838 .  t1 - type of first memory elements
839 .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
840 .  t2 - type of second memory elements
841 .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
842 .  t3 - type of third memory elements
843 .  m4 - number of elements to allocate in 4th chunk  (may be zero)
844 .  t4 - type of fourth memory elements
845 .  m5 - number of elements to allocate in 5th chunk  (may be zero)
846 .  t5 - type of fifth memory elements
847 .  m6 - number of elements to allocate in 6th chunk  (may be zero)
848 .  t6 - type of sixth memory elements
849 .  m7 - number of elements to allocate in 7th chunk  (may be zero)
850 -  t7 - type of sixth memory elements
851 
852    Output Parameter:
853 +  r1 - memory allocated in first chunk
854 .  r2 - memory allocated in second chunk
855 .  r3 - memory allocated in third chunk
856 .  r4 - memory allocated in fourth chunk
857 .  r5 - memory allocated in fifth chunk
858 .  r6 - memory allocated in sixth chunk
859 -  r7 - memory allocated in seventh chunk
860 
861    Level: developer
862 
863 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6(), PetscFree7()
864 
865   Concepts: memory allocation
866 
867 M*/
868 #if defined(PETSC_USE_DEBUG)
869 #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))
870 #else
871 #define PetscMalloc7(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6,m7,t7,r7) \
872   ((*(r2) = 0, *(r3) = 0, *(r4) = 0,*(r5) = 0,*(r6) = 0,*(r7) = 0,PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6)+(m7)*sizeof(t7)+6*(PETSC_MEMALIGN-1),r1)) \
873    || (*(r2) = (t2*)PetscAddrAlign(*(r1)+m1),*(r3) = (t3*)PetscAddrAlign(*(r2)+m2),*(r4) = (t4*)PetscAddrAlign(*(r3)+m3),*(r5) = (t5*)PetscAddrAlign(*(r4)+m4),*(r6) = (t6*)PetscAddrAlign(*(r5)+m5),*(r7) = (t7*)PetscAddrAlign(*(r6)+m6),0))
874 #endif
875 
876 /*MC
877    PetscNew - Allocates memory of a particular type, zeros the memory! Aligned to PETSC_MEMALIGN
878 
879    Synopsis:
880    PetscErrorCode PetscNew(struct type,((type *))result)
881 
882    Not Collective
883 
884    Input Parameter:
885 .  type - structure name of space to be allocated. Memory of size sizeof(type) is allocated
886 
887    Output Parameter:
888 .  result - memory allocated
889 
890    Level: beginner
891 
892 .seealso: PetscFree(), PetscMalloc()
893 
894   Concepts: memory allocation
895 
896 M*/
897 #define PetscNew(A,b)      (PetscMalloc(sizeof(A),(b)) || PetscMemzero(*(b),sizeof(A)))
898 #define PetscNewLog(o,A,b) (PetscNew(A,b) || ((o) ? PetscLogObjectMemory(o,sizeof(A)) : 0))
899 
900 /*MC
901    PetscFree - Frees memory
902 
903    Synopsis:
904    PetscErrorCode PetscFree(void *memory)
905 
906    Not Collective
907 
908    Input Parameter:
909 .   memory - memory to free (the pointer is ALWAYS set to 0 upon sucess)
910 
911    Level: beginner
912 
913    Notes: Memory must have been obtained with PetscNew() or PetscMalloc()
914 
915 .seealso: PetscNew(), PetscMalloc(), PetscFreeVoid()
916 
917   Concepts: memory allocation
918 
919 M*/
920 #define PetscFree(a)   ((a) ? ((*PetscTrFree)((void*)(a),__LINE__,__FUNCT__,__FILE__,__SDIR__) || ((a = 0),0)) : 0)
921 
922 /*MC
923    PetscFreeVoid - Frees memory
924 
925    Synopsis:
926    void PetscFreeVoid(void *memory)
927 
928    Not Collective
929 
930    Input Parameter:
931 .   memory - memory to free
932 
933    Level: beginner
934 
935    Notes: This is different from PetscFree() in that no error code is returned
936 
937 .seealso: PetscFree(), PetscNew(), PetscMalloc()
938 
939   Concepts: memory allocation
940 
941 M*/
942 #define PetscFreeVoid(a) ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__),(a) = 0)
943 
944 
945 /*MC
946    PetscFree2 - Frees 2 chunks of memory obtained with PetscMalloc2()
947 
948    Synopsis:
949    PetscErrorCode PetscFree2(void *memory1,void *memory2)
950 
951    Not Collective
952 
953    Input Parameter:
954 +   memory1 - memory to free
955 -   memory2 - 2nd memory to free
956 
957    Level: developer
958 
959    Notes: Memory must have been obtained with PetscMalloc2()
960 
961 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree()
962 
963   Concepts: memory allocation
964 
965 M*/
966 #if defined(PETSC_USE_DEBUG)
967 #define PetscFree2(m1,m2)   (PetscFree(m2) || PetscFree(m1))
968 #else
969 #define PetscFree2(m1,m2)   (PetscFree(m1))
970 #endif
971 
972 /*MC
973    PetscFree3 - Frees 3 chunks of memory obtained with PetscMalloc3()
974 
975    Synopsis:
976    PetscErrorCode PetscFree3(void *memory1,void *memory2,void *memory3)
977 
978    Not Collective
979 
980    Input Parameter:
981 +   memory1 - memory to free
982 .   memory2 - 2nd memory to free
983 -   memory3 - 3rd memory to free
984 
985    Level: developer
986 
987    Notes: Memory must have been obtained with PetscMalloc3()
988 
989 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3()
990 
991   Concepts: memory allocation
992 
993 M*/
994 #if defined(PETSC_USE_DEBUG)
995 #define PetscFree3(m1,m2,m3)   (PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
996 #else
997 #define PetscFree3(m1,m2,m3)   (PetscFree(m1))
998 #endif
999 
1000 /*MC
1001    PetscFree4 - Frees 4 chunks of memory obtained with PetscMalloc4()
1002 
1003    Synopsis:
1004    PetscErrorCode PetscFree4(void *m1,void *m2,void *m3,void *m4)
1005 
1006    Not Collective
1007 
1008    Input Parameter:
1009 +   m1 - memory to free
1010 .   m2 - 2nd memory to free
1011 .   m3 - 3rd memory to free
1012 -   m4 - 4th memory to free
1013 
1014    Level: developer
1015 
1016    Notes: Memory must have been obtained with PetscMalloc4()
1017 
1018 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4()
1019 
1020   Concepts: memory allocation
1021 
1022 M*/
1023 #if defined(PETSC_USE_DEBUG)
1024 #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
1025 #else
1026 #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m1))
1027 #endif
1028 
1029 /*MC
1030    PetscFree5 - Frees 5 chunks of memory obtained with PetscMalloc5()
1031 
1032    Synopsis:
1033    PetscErrorCode PetscFree5(void *m1,void *m2,void *m3,void *m4,void *m5)
1034 
1035    Not Collective
1036 
1037    Input Parameter:
1038 +   m1 - memory to free
1039 .   m2 - 2nd memory to free
1040 .   m3 - 3rd memory to free
1041 .   m4 - 4th memory to free
1042 -   m5 - 5th memory to free
1043 
1044    Level: developer
1045 
1046    Notes: Memory must have been obtained with PetscMalloc5()
1047 
1048 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5()
1049 
1050   Concepts: memory allocation
1051 
1052 M*/
1053 #if defined(PETSC_USE_DEBUG)
1054 #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
1055 #else
1056 #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m1))
1057 #endif
1058 
1059 
1060 /*MC
1061    PetscFree6 - Frees 6 chunks of memory obtained with PetscMalloc6()
1062 
1063    Synopsis:
1064    PetscErrorCode PetscFree6(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6)
1065 
1066    Not Collective
1067 
1068    Input Parameter:
1069 +   m1 - memory to free
1070 .   m2 - 2nd memory to free
1071 .   m3 - 3rd memory to free
1072 .   m4 - 4th memory to free
1073 .   m5 - 5th memory to free
1074 -   m6 - 6th memory to free
1075 
1076 
1077    Level: developer
1078 
1079    Notes: Memory must have been obtained with PetscMalloc6()
1080 
1081 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6()
1082 
1083   Concepts: memory allocation
1084 
1085 M*/
1086 #if defined(PETSC_USE_DEBUG)
1087 #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
1088 #else
1089 #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m1))
1090 #endif
1091 
1092 /*MC
1093    PetscFree7 - Frees 7 chunks of memory obtained with PetscMalloc7()
1094 
1095    Synopsis:
1096    PetscErrorCode PetscFree7(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6,void *m7)
1097 
1098    Not Collective
1099 
1100    Input Parameter:
1101 +   m1 - memory to free
1102 .   m2 - 2nd memory to free
1103 .   m3 - 3rd memory to free
1104 .   m4 - 4th memory to free
1105 .   m5 - 5th memory to free
1106 .   m6 - 6th memory to free
1107 -   m7 - 7th memory to free
1108 
1109 
1110    Level: developer
1111 
1112    Notes: Memory must have been obtained with PetscMalloc7()
1113 
1114 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6(),
1115           PetscMalloc7()
1116 
1117   Concepts: memory allocation
1118 
1119 M*/
1120 #if defined(PETSC_USE_DEBUG)
1121 #define PetscFree7(m1,m2,m3,m4,m5,m6,m7)   (PetscFree(m7) || PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
1122 #else
1123 #define PetscFree7(m1,m2,m3,m4,m5,m6,m7)   (PetscFree(m1))
1124 #endif
1125 
1126 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**);
1127 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscTrFree)(void*,int,const char[],const char[],const char[]);
1128 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscMallocSet(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[]));
1129 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscMallocClear(void);
1130 
1131 /*
1132    Routines for tracing memory corruption/bleeding with default PETSc
1133    memory allocation
1134 */
1135 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocDump(FILE *);
1136 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocDumpLog(FILE *);
1137 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocGetCurrentUsage(PetscLogDouble *);
1138 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocGetMaximumUsage(PetscLogDouble *);
1139 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocDebug(PetscTruth);
1140 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocValidate(int,const char[],const char[],const char[]);
1141 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMallocSetDumpLog(void);
1142 
1143 
1144 /*
1145     Variable type where we stash PETSc object pointers in Fortran.
1146     On most machines size(pointer) == sizeof(long) - except windows
1147     where its sizeof(long long)
1148 */
1149 
1150 #if (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG)
1151 #define PetscFortranAddr   long
1152 #elif  (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG_LONG)
1153 #define PetscFortranAddr   long long
1154 #else
1155 #error "Unknown size for PetscFortranAddr! Send us a bugreport at petsc-maint@mcs.anl.gov"
1156 #endif
1157 
1158 /*E
1159     PetscDataType - Used for handling different basic data types.
1160 
1161    Level: beginner
1162 
1163    Developer comment: It would be nice if we could always just use MPI Datatypes, why can we not?
1164 
1165 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(),
1166           PetscDataTypeGetSize()
1167 
1168 E*/
1169 typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2, PETSC_LONG = 3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5,
1170               PETSC_CHAR = 6,PETSC_LOGICAL = 7,PETSC_ENUM = 8,PETSC_TRUTH=9, PETSC_LONG_DOUBLE = 10, PETSC_QD_DD = 11} PetscDataType;
1171 extern const char *PetscDataTypes[];
1172 
1173 #if defined(PETSC_USE_COMPLEX)
1174 #define PETSC_SCALAR PETSC_COMPLEX
1175 #else
1176 #if defined(PETSC_USE_SCALAR_SINGLE)
1177 #define PETSC_SCALAR PETSC_FLOAT
1178 #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
1179 #define PETSC_SCALAR PETSC_LONG_DOUBLE
1180 #elif defined(PETSC_USE_SCALAR_INT)
1181 #define PETSC_SCALAR PETSC_INT
1182 #elif defined(PETSC_USE_SCALAR_QD_DD)
1183 #define PETSC_SCALAR PETSC_QD_DD
1184 #else
1185 #define PETSC_SCALAR PETSC_DOUBLE
1186 #endif
1187 #endif
1188 #if defined(PETSC_USE_SCALAR_SINGLE)
1189 #define PETSC_REAL PETSC_FLOAT
1190 #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
1191 #define PETSC_REAL PETSC_LONG_DOUBLE
1192 #elif defined(PETSC_USE_SCALAR_INT)
1193 #define PETSC_REAL PETSC_INT
1194 #elif defined(PETSC_USE_SCALAR_QD_DD)
1195 #define PETSC_REAL PETSC_QD_DD
1196 #else
1197 #define PETSC_REAL PETSC_DOUBLE
1198 #endif
1199 #define PETSC_FORTRANADDR PETSC_LONG
1200 
1201 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
1202 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMPIDataTypeToPetscDataType(MPI_Datatype,PetscDataType*);
1203 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeGetSize(PetscDataType,size_t*);
1204 
1205 /*
1206     Basic memory and string operations. These are usually simple wrappers
1207    around the basic Unix system calls, but a few of them have additional
1208    functionality and/or error checking.
1209 */
1210 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType);
1211 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMemmove(void*,void *,size_t);
1212 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscMemcmp(const void*,const void*,size_t,PetscTruth *);
1213 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrlen(const char[],size_t*);
1214 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrToArray(const char[],int*,char ***);
1215 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrToArrayDestroy(int,char **);
1216 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrcmp(const char[],const char[],PetscTruth *);
1217 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrgrt(const char[],const char[],PetscTruth *);
1218 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrcasecmp(const char[],const char[],PetscTruth*);
1219 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrncmp(const char[],const char[],size_t,PetscTruth*);
1220 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrcpy(char[],const char[]);
1221 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrcat(char[],const char[]);
1222 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrncat(char[],const char[],size_t);
1223 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrncpy(char[],const char[],size_t);
1224 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrchr(const char[],char,char *[]);
1225 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrtolower(char[]);
1226 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrrchr(const char[],char,char *[]);
1227 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrstr(const char[],const char[],char *[]);
1228 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrrstr(const char[],const char[],char *[]);
1229 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrallocpy(const char[],char *[]);
1230 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscStrreplace(MPI_Comm,const char[],char[],size_t);
1231 
1232 /*S
1233     PetscToken - 'Token' used for managing tokenizing strings
1234 
1235   Level: intermediate
1236 
1237 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy()
1238 S*/
1239 typedef struct _p_PetscToken* PetscToken;
1240 
1241 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscTokenCreate(const char[],const char,PetscToken*);
1242 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscTokenFind(PetscToken,char *[]);
1243 EXTERN PetscErrorCode PETSC_DLLEXPORT   PetscTokenDestroy(PetscToken);
1244 
1245 /*
1246    These are  MPI operations for MPI_Allreduce() etc
1247 */
1248 EXTERN PETSC_DLLEXPORT MPI_Op PetscMaxSum_Op;
1249 #if defined(PETSC_USE_COMPLEX) && !defined(PETSC_HAVE_MPI_C_DOUBLE_COMPLEX)
1250 EXTERN PETSC_DLLEXPORT MPI_Op MPIU_SUM;
1251 #else
1252 #define MPIU_SUM MPI_SUM
1253 #endif
1254 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*);
1255 
1256 /*S
1257      PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc
1258 
1259    Level: beginner
1260 
1261    Note: This is the base class from which all objects appear.
1262 
1263 .seealso:  PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName(), PetscObjectReference(), PetscObjectDereferenc()
1264 S*/
1265 typedef struct _p_PetscObject* PetscObject;
1266 
1267 /*S
1268      PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed
1269       by string name
1270 
1271    Level: advanced
1272 
1273 .seealso:  PetscFListAdd(), PetscFListDestroy()
1274 S*/
1275 typedef struct _n_PetscFList *PetscFList;
1276 
1277 /*E
1278   PetscFileMode - Access mode for a file.
1279 
1280   Level: beginner
1281 
1282   FILE_MODE_READ - open a file at its beginning for reading
1283 
1284   FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist)
1285 
1286   FILE_MODE_APPEND - open a file at end for writing
1287 
1288   FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing
1289 
1290   FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end
1291 
1292 .seealso: PetscViewerFileSetMode()
1293 E*/
1294 typedef enum {FILE_MODE_READ, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode;
1295 
1296 #include "petscviewer.h"
1297 #include "petscoptions.h"
1298 
1299 #define PETSC_SMALLEST_CLASSID 1211211
1300 extern PETSC_DLLEXPORT PetscClassId PETSC_LARGEST_CLASSID;
1301 extern PETSC_DLLEXPORT PetscClassId PETSC_OBJECT_CLASSID;
1302 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscClassIdRegister(const char[],PetscClassId *);
1303 
1304 /*
1305    Routines that get memory usage information from the OS
1306 */
1307 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryGetCurrentUsage(PetscLogDouble *);
1308 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryGetMaximumUsage(PetscLogDouble *);
1309 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemorySetGetMaximumUsage(void);
1310 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryShowUsage(PetscViewer,const char[]);
1311 
1312 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInfoAllow(PetscTruth,const char []);
1313 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetTime(PetscLogDouble*);
1314 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetCPUTime(PetscLogDouble*);
1315 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSleep(PetscReal);
1316 
1317 /*
1318    Initialization of PETSc
1319 */
1320 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitialize(int*,char***,const char[],const char[]);
1321 PetscPolymorphicSubroutine(PetscInitialize,(int *argc,char ***args),(argc,args,PETSC_NULL,PETSC_NULL))
1322 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitializeNoArguments(void);
1323 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitialized(PetscTruth *);
1324 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFinalized(PetscTruth *);
1325 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFinalize(void);
1326 EXTERN PetscErrorCode PetscInitializeFortran(void);
1327 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetArgs(int*,char ***);
1328 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetArguments(char ***);
1329 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFreeArguments(char **);
1330 
1331 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscEnd(void);
1332 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSysInitializePackage(const char[]);
1333 
1334 extern MPI_Comm PETSC_COMM_LOCAL_WORLD;
1335 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPMerge(PetscMPIInt,PetscErrorCode (*)(void*),void*);
1336 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPSpawn(PetscMPIInt);
1337 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPFinalize(void);
1338 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPRun(MPI_Comm,PetscErrorCode (*)(MPI_Comm,void *),void*);
1339 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPRunCtx(MPI_Comm,PetscErrorCode (*)(MPI_Comm,void*,void *),void*);
1340 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPFree(MPI_Comm,void*);
1341 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPMalloc(MPI_Comm,size_t,void**);
1342 
1343 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPythonInitialize(const char[],const char[]);
1344 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPythonFinalize(void);
1345 
1346 /*
1347      These are so that in extern C code we can caste function pointers to non-extern C
1348    function pointers. Since the regular C++ code expects its function pointers to be
1349    C++.
1350 */
1351 typedef void (**PetscVoidStarFunction)(void);
1352 typedef void (*PetscVoidFunction)(void);
1353 typedef PetscErrorCode (*PetscErrorCodeFunction)(void);
1354 
1355 /*
1356    PetscTryMethod - Queries an object for a method, if it exists then calls it.
1357               These are intended to be used only inside PETSc functions.
1358 
1359    Level: developer
1360 
1361 .seealso: PetscUseMethod()
1362 */
1363 #define  PetscTryMethod(obj,A,B,C) \
1364   0;{ PetscErrorCode (*f)B, __ierr; \
1365     __ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \
1366     if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
1367   }
1368 
1369 /*
1370    PetscUseMethod - Queries an object for a method, if it exists then calls it, otherwise generates an error.
1371               These are intended to be used only inside PETSc functions.
1372 
1373    Level: developer
1374 
1375 .seealso: PetscTryMethod()
1376 */
1377 #define  PetscUseMethod(obj,A,B,C) \
1378   0;{ PetscErrorCode (*f)B, __ierr; \
1379     __ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \
1380     if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
1381     else SETERRQ1(((PetscObject)A)->comm,PETSC_ERR_SUP,"Cannot locate function %s in object",A); \
1382   }
1383 
1384 /*
1385     Functions that can act on any PETSc object.
1386 */
1387 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCreate(MPI_Comm,PetscObject*);
1388 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCreateGeneric(MPI_Comm, PetscClassId, const char [], PetscObject *);
1389 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectDestroy(PetscObject);
1390 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetComm(PetscObject,MPI_Comm *);
1391 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetClassId(PetscObject,PetscClassId *);
1392 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetType(PetscObject,const char []);
1393 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetType(PetscObject,const char *[]);
1394 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetName(PetscObject,const char[]);
1395 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetName(PetscObject,const char*[]);
1396 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetTabLevel(PetscObject,PetscInt);
1397 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetTabLevel(PetscObject,PetscInt*);
1398 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectIncrementTabLevel(PetscObject,PetscObject,PetscInt);
1399 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectReference(PetscObject);
1400 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetReference(PetscObject,PetscInt*);
1401 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectDereference(PetscObject);
1402 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetNewTag(PetscObject,PetscMPIInt *);
1403 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectView(PetscObject,PetscViewer);
1404 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCompose(PetscObject,const char[],PetscObject);
1405 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectQuery(PetscObject,const char[],PetscObject *);
1406 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void));
1407 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetFromOptions(PetscObject);
1408 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetUp(PetscObject);
1409 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommGetNewTag(MPI_Comm,PetscMPIInt *);
1410 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectAddOptionsHandler(PetscObject,PetscErrorCode (*)(PetscObject,void*),PetscErrorCode (*)(PetscObject,void*),void*);
1411 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectProcessOptionsHandlers(PetscObject);
1412 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectDestroyOptionsHandlers(PetscObject);
1413 
1414 /*MC
1415    PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object.
1416 
1417     Synopsis:
1418     PetscErrorCode PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr)
1419 
1420    Logically Collective on PetscObject
1421 
1422    Input Parameters:
1423 +  obj - the PETSc object; this must be cast with a (PetscObject), for example,
1424          PetscObjectCompose((PetscObject)mat,...);
1425 .  name - name associated with the child function
1426 .  fname - name of the function
1427 -  ptr - function pointer (or PETSC_NULL if using dynamic libraries)
1428 
1429    Level: advanced
1430 
1431 
1432    Notes:
1433    To remove a registered routine, pass in a PETSC_NULL rname and fnc().
1434 
1435    PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as
1436    Mat, Vec, KSP, SNES, etc.) or any user-provided object.
1437 
1438    The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to
1439    work in C++/complex with dynamic link libraries (./configure options --with-shared-libraries --with-dynamic-loading)
1440    enabled.
1441 
1442    Concepts: objects^composing functions
1443    Concepts: composing functions
1444    Concepts: functions^querying
1445    Concepts: objects^querying
1446    Concepts: querying objects
1447 
1448 .seealso: PetscObjectQueryFunction()
1449 M*/
1450 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1451 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0)
1452 #else
1453 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(PetscVoidFunction)(d))
1454 #endif
1455 
1456 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectQueryFunction(PetscObject,const char[],void (**)(void));
1457 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetOptionsPrefix(PetscObject,const char[]);
1458 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
1459 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPrependOptionsPrefix(PetscObject,const char[]);
1460 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetOptionsPrefix(PetscObject,const char*[]);
1461 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPublish(PetscObject);
1462 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectChangeTypeName(PetscObject,const char[]);
1463 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectRegisterDestroy(PetscObject);
1464 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectRegisterDestroyAll(void);
1465 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectName(PetscObject);
1466 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTypeCompare(PetscObject,const char[],PetscTruth*);
1467 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRegisterFinalize(PetscErrorCode (*)(void));
1468 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRegisterFinalizeAll(void);
1469 
1470 /*
1471     Defines PETSc error handling.
1472 */
1473 #include "petscerror.h"
1474 
1475 /*S
1476      PetscOList - Linked list of PETSc objects, each accessable by string name
1477 
1478    Level: developer
1479 
1480    Notes: Used by PetscObjectCompose() and PetscObjectQuery()
1481 
1482 .seealso:  PetscOListAdd(), PetscOListDestroy(), PetscOListFind(), PetscObjectCompose(), PetscObjectQuery()
1483 S*/
1484 typedef struct _n_PetscOList *PetscOList;
1485 
1486 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListDestroy(PetscOList);
1487 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListFind(PetscOList,const char[],PetscObject*);
1488 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListReverseFind(PetscOList,PetscObject,char**);
1489 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListAdd(PetscOList *,const char[],PetscObject);
1490 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListDuplicate(PetscOList,PetscOList *);
1491 
1492 /*
1493     Dynamic library lists. Lists of names of routines in objects or in dynamic
1494   link libraries that will be loaded as needed.
1495 */
1496 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void));
1497 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListDestroy(PetscFList*);
1498 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListFind(PetscFList,MPI_Comm,const char[],void (**)(void));
1499 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListPrintTypes(MPI_Comm,FILE*,const char[],const char[],const char[],const char[],PetscFList,const char[]);
1500 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1501 #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0)
1502 #else
1503 #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c)
1504 #endif
1505 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListDuplicate(PetscFList,PetscFList *);
1506 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListView(PetscFList,PetscViewer);
1507 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListConcat(const char [],const char [],char []);
1508 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListGet(PetscFList,char ***,int*);
1509 
1510 /*S
1511      PetscDLLibrary - Linked list of dynamics libraries to search for functions
1512 
1513    Level: advanced
1514 
1515    --with-shared-libraries --with-dynamic-loading must be used with ./configure to use dynamic libraries
1516 
1517 .seealso:  PetscDLLibraryOpen()
1518 S*/
1519 typedef struct _n_PetscDLLibrary *PetscDLLibrary;
1520 extern PETSC_DLLEXPORT PetscDLLibrary DLLibrariesLoaded;
1521 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryAppend(MPI_Comm,PetscDLLibrary *,const char[]);
1522 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryPrepend(MPI_Comm,PetscDLLibrary *,const char[]);
1523 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibrarySym(MPI_Comm,PetscDLLibrary *,const char[],const char[],void **);
1524 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryPrintPath(PetscDLLibrary);
1525 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,size_t,PetscTruth *);
1526 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryOpen(MPI_Comm,const char[],PetscDLLibrary *);
1527 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryClose(PetscDLLibrary);
1528 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryCCAAppend(MPI_Comm,PetscDLLibrary *,const char[]);
1529 
1530 /*
1531   PetscFwk support.  Needs to be documented.
1532   Logically it is an extension of PetscDLLXXX, PetscObjectCompose, etc.
1533 */
1534 #include "petscfwk.h"
1535 
1536 /*
1537      Useful utility routines
1538 */
1539 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*);
1540 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*);
1541 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt);
1542 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(MPI_Comm comm),(comm,1))
1543 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(void),(PETSC_COMM_WORLD,1))
1544 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt);
1545 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(MPI_Comm comm),(comm,1))
1546 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(void),(PETSC_COMM_WORLD,1))
1547 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBarrier(PetscObject);
1548 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMPIDump(FILE*);
1549 
1550 /*
1551     PetscNot - negates a logical type value and returns result as a PetscTruth
1552 
1553     Notes: This is useful in cases like
1554 $     int        *a;
1555 $     PetscTruth flag = PetscNot(a)
1556      where !a does not return a PetscTruth because we cannot provide a cast from int to PetscTruth in C.
1557 */
1558  #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE)
1559 
1560 /*
1561     Defines basic graphics available from PETSc.
1562 */
1563 #include "petscdraw.h"
1564 
1565 /*
1566     Defines the base data structures for all PETSc objects
1567 */
1568 #include "private/petscimpl.h"
1569 
1570 /*
1571      Defines PETSc profiling.
1572 */
1573 #include "petsclog.h"
1574 
1575 /*
1576           For locking, unlocking and destroying AMS memories associated with  PETSc objects. ams.h is included in petscviewer.h
1577 */
1578 #if defined(PETSC_HAVE_AMS)
1579 extern PetscTruth PetscAMSPublishAll;
1580 #define PetscPublishAll(v) (PetscAMSPublishAll ? PetscObjectPublish((PetscObject)v) : 0)
1581 #define PetscObjectTakeAccess(obj)  ((((PetscObject)(obj))->amem == -1) ? 0 : AMS_Memory_take_access(((PetscObject)(obj))->amem))
1582 #define PetscObjectGrantAccess(obj) ((((PetscObject)(obj))->amem == -1) ? 0 : AMS_Memory_grant_access(((PetscObject)(obj))->amem))
1583 #define PetscObjectDepublish(obj)   ((((PetscObject)(obj))->amem == -1) ? 0 : AMS_Memory_destroy(((PetscObject)(obj))->amem));((PetscObject)(obj))->amem = -1;
1584 #else
1585 #define PetscPublishAll(v)           0
1586 #define PetscObjectTakeAccess(obj)   0
1587 #define PetscObjectGrantAccess(obj)  0
1588 #define PetscObjectDepublish(obj)      0
1589 #endif
1590 
1591 /*
1592       Simple PETSc parallel IO for ASCII printing
1593 */
1594 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscFixFilename(const char[],char[]);
1595 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscFOpen(MPI_Comm,const char[],const char[],FILE**);
1596 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscFClose(MPI_Comm,FILE*);
1597 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
1598 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscPrintf(MPI_Comm,const char[],...)  PETSC_PRINTF_FORMAT_CHECK(2,3);
1599 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSNPrintf(char*,size_t,const char [],...);
1600 
1601 /* These are used internally by PETSc ASCII IO routines*/
1602 #include <stdarg.h>
1603 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscVSNPrintf(char*,size_t,const char[],int*,va_list);
1604 EXTERN PetscErrorCode PETSC_DLLEXPORT  (*PetscVFPrintf)(FILE*,const char[],va_list);
1605 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscVFPrintfDefault(FILE*,const char[],va_list);
1606 
1607 /*MC
1608     PetscErrorPrintf - Prints error messages.
1609 
1610    Synopsis:
1611      PetscErrorCode (*PetscErrorPrintf)(const char format[],...);
1612 
1613     Not Collective
1614 
1615     Input Parameters:
1616 .   format - the usual printf() format string
1617 
1618    Options Database Keys:
1619 +    -error_output_stdout - cause error messages to be printed to stdout instead of the
1620          (default) stderr
1621 -    -error_output_none to turn off all printing of error messages (does not change the way the
1622           error is handled.)
1623 
1624    Notes: Use
1625 $     PetscErrorPrintf = PetscErrorPrintfNone; to turn off all printing of error messages (does not change the way the
1626 $                        error is handled.) and
1627 $     PetscErrorPrintf = PetscErrorPrintfDefault; to turn it back on
1628 
1629           Use
1630      PETSC_STDERR = FILE* obtained from a file open etc. to have stderr printed to the file.
1631      PETSC_STDOUT = FILE* obtained from a file open etc. to have stdout printed to the file.
1632 
1633           Use
1634       PetscPushErrorHandler() to provide your own error handler that determines what kind of messages to print
1635 
1636    Level: developer
1637 
1638     Fortran Note:
1639     This routine is not supported in Fortran.
1640 
1641     Concepts: error messages^printing
1642     Concepts: printing^error messages
1643 
1644 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf(), PetscPrintf(), PetscErrorHandlerPush()
1645 M*/
1646 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscErrorPrintf)(const char[],...);
1647 
1648 /*MC
1649     PetscHelpPrintf - Prints help messages.
1650 
1651    Synopsis:
1652      PetscErrorCode (*PetscHelpPrintf)(const char format[],...);
1653 
1654     Not Collective
1655 
1656     Input Parameters:
1657 .   format - the usual printf() format string
1658 
1659    Level: developer
1660 
1661     Fortran Note:
1662     This routine is not supported in Fortran.
1663 
1664     Concepts: help messages^printing
1665     Concepts: printing^help messages
1666 
1667 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf()
1668 M*/
1669 EXTERN PETSC_DLLEXPORT PetscErrorCode  (*PetscHelpPrintf)(MPI_Comm,const char[],...);
1670 
1671 EXTERN PetscErrorCode  PetscErrorPrintfDefault(const char [],...);
1672 EXTERN PetscErrorCode  PetscErrorPrintfNone(const char [],...);
1673 EXTERN PetscErrorCode  PetscHelpPrintfDefault(MPI_Comm,const char [],...);
1674 
1675 #if defined(PETSC_HAVE_POPEN)
1676 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **);
1677 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscPClose(MPI_Comm,FILE*);
1678 #endif
1679 
1680 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
1681 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
1682 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSynchronizedFlush(MPI_Comm);
1683 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]);
1684 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**);
1685 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscStartJava(MPI_Comm,const char[],const char[],FILE**);
1686 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscGetPetscDir(const char*[]);
1687 
1688 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscPopUpSelect(MPI_Comm,const char*,const char*,int,const char**,int*);
1689 
1690 /*S
1691      PetscContainer - Simple PETSc object that contains a pointer to any required data
1692 
1693    Level: advanced
1694 
1695 .seealso:  PetscObject, PetscContainerCreate()
1696 S*/
1697 extern PetscClassId PETSC_DLLEXPORT PETSC_CONTAINER_CLASSID;
1698 typedef struct _p_PetscContainer*  PetscContainer;
1699 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerGetPointer(PetscContainer,void **);
1700 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerSetPointer(PetscContainer,void *);
1701 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerDestroy(PetscContainer);
1702 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerCreate(MPI_Comm,PetscContainer *);
1703 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerSetUserDestroy(PetscContainer, PetscErrorCode (*)(void*));
1704 
1705 /*
1706    For use in debuggers
1707 */
1708 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalRank;
1709 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalSize;
1710 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscIntView(PetscInt,const PetscInt[],PetscViewer);
1711 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRealView(PetscInt,const PetscReal[],PetscViewer);
1712 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscScalarView(PetscInt,const PetscScalar[],PetscViewer);
1713 
1714 #if defined(PETSC_HAVE_MEMORY_H)
1715 #include <memory.h>
1716 #endif
1717 #if defined(PETSC_HAVE_STDLIB_H)
1718 #include <stdlib.h>
1719 #endif
1720 #if defined(PETSC_HAVE_STRINGS_H)
1721 #include <strings.h>
1722 #endif
1723 #if defined(PETSC_HAVE_STRING_H)
1724 #include <string.h>
1725 #endif
1726 
1727 
1728 #if defined(PETSC_HAVE_XMMINTRIN_H)
1729 #include <xmmintrin.h>
1730 #endif
1731 #if defined(PETSC_HAVE_STDINT_H)
1732 #include <stdint.h>
1733 #endif
1734 
1735 /*@C
1736    PetscMemcpy - Copies n bytes, beginning at location b, to the space
1737    beginning at location a. The two memory regions CANNOT overlap, use
1738    PetscMemmove() in that case.
1739 
1740    Not Collective
1741 
1742    Input Parameters:
1743 +  b - pointer to initial memory space
1744 -  n - length (in bytes) of space to copy
1745 
1746    Output Parameter:
1747 .  a - pointer to copy space
1748 
1749    Level: intermediate
1750 
1751    Compile Option:
1752     PETSC_PREFER_DCOPY_FOR_MEMCPY will cause the BLAS dcopy() routine to be used
1753                                   for memory copies on double precision values.
1754     PETSC_PREFER_COPY_FOR_MEMCPY will cause C code to be used
1755                                   for memory copies on double precision values.
1756     PETSC_PREFER_FORTRAN_FORMEMCPY will cause Fortran code to be used
1757                                   for memory copies on double precision values.
1758 
1759    Note:
1760    This routine is analogous to memcpy().
1761 
1762    Developer Note: this is inlined for fastest performance
1763 
1764   Concepts: memory^copying
1765   Concepts: copying^memory
1766 
1767 .seealso: PetscMemmove()
1768 
1769 @*/
1770 PETSC_STATIC_INLINE PetscErrorCode PETSC_DLLEXPORT PetscMemcpy(void *a,const void *b,size_t n)
1771 {
1772 #if defined(PETSC_USE_DEBUG)
1773   unsigned long al = (unsigned long) a,bl = (unsigned long) b;
1774   unsigned long nl = (unsigned long) n;
1775   if (n > 0 && !b) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Trying to copy from a null pointer");
1776   if (n > 0 && !a) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Trying to copy to a null pointer");
1777 #endif
1778   PetscFunctionBegin;
1779   if (a != b) {
1780 #if defined(PETSC_USE_DEBUG)
1781     if ((al > bl && (al - bl) < nl) || (bl - al) < nl) {
1782       SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Memory regions overlap: either use PetscMemmov()\n\
1783               or make sure your copy regions and lengths are correct. \n\
1784               Length (bytes) %ld first address %ld second address %ld",nl,al,bl);
1785     }
1786 #endif
1787 #if (defined(PETSC_PREFER_DCOPY_FOR_MEMCPY) || defined(PETSC_PREFER_COPY_FOR_MEMCPY) || defined(PETSC_PREFER_FORTRAN_FORMEMCPY))
1788    if (!(((long) a) % sizeof(PetscScalar)) && !(n % sizeof(PetscScalar))) {
1789       size_t len = n/sizeof(PetscScalar);
1790 #if defined(PETSC_PREFER_DCOPY_FOR_MEMCPY)
1791       PetscBLASInt one = 1,blen = PetscBLASIntCast(len);
1792       BLAScopy_(&blen,(PetscScalar *)b,&one,(PetscScalar *)a,&one);
1793 #elif defined(PETSC_PREFER_FORTRAN_FORMEMCPY)
1794       fortrancopy_(&len,(PetscScalar*)b,(PetscScalar*)a);
1795 #else
1796       size_t      i;
1797       PetscScalar *x = (PetscScalar*)b, *y = (PetscScalar*)a;
1798       for (i=0; i<len; i++) y[i] = x[i];
1799 #endif
1800     } else {
1801       memcpy((char*)(a),(char*)(b),n);
1802     }
1803 #elif defined(PETSC_HAVE__INTEL_FAST_MEMCPY)
1804     _intel_fast_memcpy((char*)(a),(char*)(b),n);
1805 #else
1806     memcpy((char*)(a),(char*)(b),n);
1807 #endif
1808   }
1809   PetscFunctionReturn(0);
1810 }
1811 
1812 /*@C
1813    PetscMemzero - Zeros the specified memory.
1814 
1815    Not Collective
1816 
1817    Input Parameters:
1818 +  a - pointer to beginning memory location
1819 -  n - length (in bytes) of memory to initialize
1820 
1821    Level: intermediate
1822 
1823    Compile Option:
1824    PETSC_PREFER_BZERO - on certain machines (the IBM RS6000) the bzero() routine happens
1825   to be faster than the memset() routine. This flag causes the bzero() routine to be used.
1826 
1827    Developer Note: this is inlined for fastest performance
1828 
1829    Concepts: memory^zeroing
1830    Concepts: zeroing^memory
1831 
1832 .seealso: PetscMemcpy()
1833 @*/
1834 PETSC_STATIC_INLINE PetscErrorCode PETSC_DLLEXPORT PetscMemzero(void *a,size_t n)
1835 {
1836   if (n > 0) {
1837 #if defined(PETSC_USE_DEBUG)
1838     if (!a) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Trying to zero at a null pointer");
1839 #endif
1840 #if defined(PETSC_PREFER_ZERO_FOR_MEMZERO)
1841     if (!(((long) a) % sizeof(PetscScalar)) && !(n % sizeof(PetscScalar))) {
1842       size_t      i,len = n/sizeof(PetscScalar);
1843       PetscScalar *x = (PetscScalar*)a;
1844       for (i=0; i<len; i++) x[i] = 0.0;
1845     } else {
1846 #elif defined(PETSC_PREFER_FORTRAN_FOR_MEMZERO)
1847     if (!(((long) a) % sizeof(PetscScalar)) && !(n % sizeof(PetscScalar))) {
1848       PetscInt len = n/sizeof(PetscScalar);
1849       fortranzero_(&len,(PetscScalar*)a);
1850     } else {
1851 #endif
1852 #if defined(PETSC_PREFER_BZERO)
1853       bzero((char *)a,n);
1854 #elif defined (PETSC_HAVE__INTEL_FAST_MEMSET)
1855       _intel_fast_memset((char*)a,0,n);
1856 #else
1857       memset((char*)a,0,n);
1858 #endif
1859 #if defined(PETSC_PREFER_ZERO_FOR_MEMZERO) || defined(PETSC_PREFER_FORTRAN_FOR_MEMZERO)
1860     }
1861 #endif
1862   }
1863   return 0;
1864 }
1865 
1866 /*MC
1867    PetscPrefetchBlock - Prefetches a block of memory
1868 
1869    Synopsis:
1870     void PetscPrefetchBlock(const anytype *a,size_t n,int rw,int t)
1871 
1872    Not Collective
1873 
1874    Input Parameters:
1875 +  a - pointer to first element to fetch (any type but usually PetscInt or PetscScalar)
1876 .  n - number of elements to fetch
1877 .  rw - 1 if the memory will be written to, otherwise 0 (ignored by many processors)
1878 -  t - temporal locality (0,1,2,3), see note
1879 
1880    Level: developer
1881 
1882    Notes:
1883    The last two arguments (rw and t) must be compile-time constants.
1884 
1885    There are four levels of temporal locality (not all architectures distinguish)
1886 +  0 - Non-temporal.  Prefetches directly to L1, evicts to memory (skips higher level cache unless it was already there when prefetched).
1887 .  1 - Temporal with respect to high-level cache only.  Only prefetches to high-level cache (not L1), kept at high levels after eviction from L1.
1888 .  2 - Same as 1, but keep in mid-level cache.  (On most systems, 1 and 2 are equivalent.)
1889 -  3 - Fetch to all levels of cache and evict to the closest level.  Use this when the memory will be reused regularly despite necessary eviction from L1.
1890 
1891    This function does nothing on architectures that do not support prefetch and never errors (even if passed an invalid
1892    address).
1893 
1894    Concepts: memory
1895 M*/
1896 #define PetscPrefetchBlock(a,n,rw,t) do {                               \
1897     const char *_p = (const char*)(a),*_end = (const char*)((a)+(n));   \
1898     for ( ; _p < _end; _p += PETSC_LEVEL1_DCACHE_LINESIZE) PETSC_Prefetch(_p,(rw),(t)); \
1899   } while (0)
1900 
1901 /*
1902     Allows accessing Matlab Engine
1903 */
1904 #include "petscmatlab.h"
1905 
1906 /*
1907       Determine if some of the kernel computation routines use
1908    Fortran (rather than C) for the numerical calculations. On some machines
1909    and compilers (like complex numbers) the Fortran version of the routines
1910    is faster than the C/C++ versions. The flag --with-fortran-kernels
1911    should be used with ./configure to turn these on.
1912 */
1913 #if defined(PETSC_USE_FORTRAN_KERNELS)
1914 
1915 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCRL)
1916 #define PETSC_USE_FORTRAN_KERNEL_MULTCRL
1917 #endif
1918 
1919 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM)
1920 #define PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM
1921 #endif
1922 
1923 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ)
1924 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ
1925 #endif
1926 
1927 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ)
1928 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ
1929 #endif
1930 
1931 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM)
1932 #define PETSC_USE_FORTRAN_KERNEL_NORM
1933 #endif
1934 
1935 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY)
1936 #define PETSC_USE_FORTRAN_KERNEL_MAXPY
1937 #endif
1938 
1939 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ)
1940 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ
1941 #endif
1942 
1943 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ)
1944 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ
1945 #endif
1946 
1947 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ)
1948 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ
1949 #endif
1950 
1951 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ)
1952 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ
1953 #endif
1954 
1955 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT)
1956 #define PETSC_USE_FORTRAN_KERNEL_MDOT
1957 #endif
1958 
1959 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY)
1960 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY
1961 #endif
1962 
1963 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX)
1964 #define PETSC_USE_FORTRAN_KERNEL_AYPX
1965 #endif
1966 
1967 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY)
1968 #define PETSC_USE_FORTRAN_KERNEL_WAXPY
1969 #endif
1970 
1971 #endif
1972 
1973 /*
1974     Macros for indicating code that should be compiled with a C interface,
1975    rather than a C++ interface. Any routines that are dynamically loaded
1976    (such as the PCCreate_XXX() routines) must be wrapped so that the name
1977    mangler does not change the functions symbol name. This just hides the
1978    ugly extern "C" {} wrappers.
1979 */
1980 #if defined(__cplusplus)
1981 #define EXTERN_C_BEGIN extern "C" {
1982 #define EXTERN_C_END }
1983 #else
1984 #define EXTERN_C_BEGIN
1985 #define EXTERN_C_END
1986 #endif
1987 
1988 /* --------------------------------------------------------------------*/
1989 
1990 /*MC
1991     MPI_Comm - the basic object used by MPI to determine which processes are involved in a
1992         communication
1993 
1994    Level: beginner
1995 
1996    Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm
1997 
1998 .seealso: PETSC_COMM_WORLD, PETSC_COMM_SELF
1999 M*/
2000 
2001 /*MC
2002     PetscScalar - PETSc type that represents either a double precision real number, a double precision
2003        complex number, a single precision real number, a long double or an int - if the code is configured
2004        with --with-scalar-type=real,complex --with-precision=single,double,longdouble,int,matsingle
2005 
2006 
2007    Level: beginner
2008 
2009 .seealso: PetscReal, PassiveReal, PassiveScalar, MPIU_SCALAR, PetscInt
2010 M*/
2011 
2012 /*MC
2013     PetscReal - PETSc type that represents a real number version of PetscScalar
2014 
2015    Level: beginner
2016 
2017 .seealso: PetscScalar, PassiveReal, PassiveScalar
2018 M*/
2019 
2020 /*MC
2021     PassiveScalar - PETSc type that represents a PetscScalar
2022    Level: beginner
2023 
2024     This is the same as a PetscScalar except in code that is automatically differentiated it is
2025    treated as a constant (not an indendent or dependent variable)
2026 
2027 .seealso: PetscReal, PassiveReal, PetscScalar
2028 M*/
2029 
2030 /*MC
2031     PassiveReal - PETSc type that represents a PetscReal
2032 
2033    Level: beginner
2034 
2035     This is the same as a PetscReal except in code that is automatically differentiated it is
2036    treated as a constant (not an indendent or dependent variable)
2037 
2038 .seealso: PetscScalar, PetscReal, PassiveScalar
2039 M*/
2040 
2041 /*MC
2042     MPIU_SCALAR - MPI datatype corresponding to PetscScalar
2043 
2044    Level: beginner
2045 
2046     Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars
2047           pass this value
2048 
2049 .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar, MPIU_INT
2050 M*/
2051 
2052 #if defined(PETSC_HAVE_MPIIO)
2053 #if !defined(PETSC_WORDS_BIGENDIAN)
2054 extern PetscErrorCode MPIU_File_write_all(MPI_File,void*,PetscMPIInt,MPI_Datatype,MPI_Status*);
2055 extern PetscErrorCode MPIU_File_read_all(MPI_File,void*,PetscMPIInt,MPI_Datatype,MPI_Status*);
2056 #else
2057 #define MPIU_File_write_all(a,b,c,d,e) MPI_File_write_all(a,b,c,d,e)
2058 #define MPIU_File_read_all(a,b,c,d,e) MPI_File_read_all(a,b,c,d,e)
2059 #endif
2060 #endif
2061 
2062 /* the following petsc_static_inline require petscerror.h */
2063 
2064 /* Limit MPI to 32-bits */
2065 #define PETSC_MPI_INT_MAX  2147483647
2066 #define PETSC_MPI_INT_MIN -2147483647
2067 /* Limit BLAS to 32-bits */
2068 #define PETSC_BLAS_INT_MAX  2147483647
2069 #define PETSC_BLAS_INT_MIN -2147483647
2070 /* On 32 bit systems HDF5 is limited by size of integer, because hsize_t is defined as size_t */
2071 #define PETSC_HDF5_INT_MAX  2147483647
2072 #define PETSC_HDF5_INT_MIN -2147483647
2073 
2074 #if defined(PETSC_USE_64BIT_INDICES)
2075 #define PetscMPIIntCheck(a)  if ((a) > PETSC_MPI_INT_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Message too long for MPI")
2076 #define PetscBLASIntCheck(a)  if ((a) > PETSC_BLAS_INT_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for BLAS/LAPACK")
2077 #define PetscMPIIntCast(a) (a);PetscMPIIntCheck(a)
2078 #define PetscBLASIntCast(a) (a);PetscBLASIntCheck(a)
2079 
2080 #if (PETSC_SIZEOF_SIZE_T == 4)
2081 #define PetscHDF5IntCheck(a)  if ((a) > PETSC_HDF5_INT_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for HDF5")
2082 #define PetscHDF5IntCast(a) (a);PetscHDF5IntCheck(a)
2083 #else
2084 #define PetscHDF5IntCheck(a)
2085 #define PetscHDF5IntCast(a) a
2086 #endif
2087 
2088 #else
2089 #define PetscMPIIntCheck(a)
2090 #define PetscBLASIntCheck(a)
2091 #define PetscHDF5IntCheck(a)
2092 #define PetscMPIIntCast(a) a
2093 #define PetscBLASIntCast(a) a
2094 #define PetscHDF5IntCast(a) a
2095 #endif
2096 
2097 
2098 /*
2099      The IBM include files define hz, here we hide it so that it may be used
2100    as a regular user variable.
2101 */
2102 #if defined(hz)
2103 #undef hz
2104 #endif
2105 
2106 /*  For arrays that contain filenames or paths */
2107 
2108 
2109 #if defined(PETSC_HAVE_LIMITS_H)
2110 #include <limits.h>
2111 #endif
2112 #if defined(PETSC_HAVE_SYS_PARAM_H)
2113 #include <sys/param.h>
2114 #endif
2115 #if defined(PETSC_HAVE_SYS_TYPES_H)
2116 #include <sys/types.h>
2117 #endif
2118 #if defined(MAXPATHLEN)
2119 #  define PETSC_MAX_PATH_LEN     MAXPATHLEN
2120 #elif defined(MAX_PATH)
2121 #  define PETSC_MAX_PATH_LEN     MAX_PATH
2122 #elif defined(_MAX_PATH)
2123 #  define PETSC_MAX_PATH_LEN     _MAX_PATH
2124 #else
2125 #  define PETSC_MAX_PATH_LEN     4096
2126 #endif
2127 
2128 /* Special support for C++ */
2129 #include "petscsys.hh"
2130 
2131 
2132 /*MC
2133 
2134     UsingFortran - Fortran can be used with PETSc in four distinct approaches
2135 
2136 $    1) classic Fortran 77 style
2137 $#include "finclude/petscXXX.h" to work with material from the XXX component of PETSc
2138 $       XXX variablename
2139 $      You cannot use this approach if you wish to use the Fortran 90 specific PETSc routines
2140 $      which end in F90; such as VecGetArrayF90()
2141 $
2142 $    2) classic Fortran 90 style
2143 $#include "finclude/petscXXX.h"
2144 $#include "finclude/petscXXX.h90" to work with material from the XXX component of PETSc
2145 $       XXX variablename
2146 $
2147 $    3) Using Fortran modules
2148 $#include "finclude/petscXXXdef.h"
2149 $         use petscXXXX
2150 $       XXX variablename
2151 $
2152 $    4) Use Fortran modules and Fortran data types for PETSc types
2153 $#include "finclude/petscXXXdef.h"
2154 $         use petscXXXX
2155 $       type(XXX) variablename
2156 $      To use this approach you must ./configure PETSc with the additional
2157 $      option --with-fortran-datatypes You cannot use the type(XXX) declaration approach without using Fortran modules
2158 
2159     Finally if you absolutely do not want to use any #include you can use either
2160 
2161 $    3a) skip the #include BUT you cannot use any PETSc data type names like Vec, Mat, PetscInt, PetscErrorCode etc
2162 $        and you must declare the variables as integer, for example
2163 $        integer variablename
2164 $
2165 $    4a) skip the #include, you use the object types like type(Vec) type(Mat) but cannot use the data type
2166 $        names like PetscErrorCode, PetscInt etc. again for those you must use integer
2167 
2168    We recommend either 2 or 3. Approaches 2 and 3 provide type checking for most PETSc function calls; 4 has type checking
2169 for only a few PETSc functions.
2170 
2171    Fortran type checking with interfaces is strick, this means you cannot pass a scalar value when an array value
2172 is expected (even though it is legal Fortran). For example when setting a single value in a matrix with MatSetValues()
2173 you cannot have something like
2174 $      PetscInt row,col
2175 $      PetscScalar val
2176 $        ...
2177 $      call MatSetValues(mat,1,row,1,col,val,INSERT_VALUES,ierr)
2178 You must instead have
2179 $      PetscInt row(1),col(1)
2180 $      PetscScalar val(1)
2181 $        ...
2182 $      call MatSetValues(mat,1,row,1,col,val,INSERT_VALUES,ierr)
2183 
2184 
2185     See the example src/vec/vec/examples/tutorials/ex20f90.F90 for an example that can use all four approaches
2186 
2187     Developer Notes: The finclude/petscXXXdef.h contain all the #defines (would be typedefs in C code) these
2188      automatically include their predecessors; for example finclude/petscvecdef.h includes finclude/petscisdef.h
2189 
2190      The finclude/petscXXXX.h contain all the parameter statements for that package. These automatically include
2191      their finclude/petscXXXdef.h file but DO NOT automatically include their predecessors;  for example
2192      finclude/petscvec.h does NOT automatically include finclude/petscis.h
2193 
2194      The finclude/ftn-custom/petscXXXdef.h90 are not intended to be used directly in code, they define the
2195      Fortran data type type(XXX) (for example type(Vec)) when PETSc is ./configure with the --with-fortran-datatypes option.
2196 
2197      The finclude/ftn-custom/petscXXX.h90 (not included directly by code) contain interface definitions for
2198      the PETSc Fortran stubs that have different bindings then their C version (for example VecGetArrayF90).
2199 
2200      The finclude/ftn-auto/petscXXX.h90 (not included directly by code) contain interface definitions generated
2201      automatically by "make allfortranstubs".
2202 
2203      The finclude/petscXXX.h90 includes the custom finclude/ftn-custom/petscXXX.h90 and if ./configure
2204      was run with --with-fortran-interfaces it also includes the finclude/ftn-auto/petscXXX.h90 These DO NOT automatically
2205      include their predecessors
2206 
2207     Level: beginner
2208 
2209 M*/
2210 
2211 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetArchType(char[],size_t);
2212 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetHostName(char[],size_t);
2213 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetUserName(char[],size_t);
2214 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetProgramName(char[],size_t);
2215 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetProgramName(const char[]);
2216 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetDate(char[],size_t);
2217 
2218 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortInt(PetscInt,PetscInt[]);
2219 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortIntWithPermutation(PetscInt,const PetscInt[],PetscInt[]);
2220 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortStrWithPermutation(PetscInt,const char*[],PetscInt[]);
2221 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortIntWithArray(PetscInt,PetscInt[],PetscInt[]);
2222 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortMPIIntWithArray(PetscMPIInt,PetscMPIInt[],PetscMPIInt[]);
2223 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortIntWithScalarArray(PetscInt,PetscInt[],PetscScalar[]);
2224 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortReal(PetscInt,PetscReal[]);
2225 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortRealWithPermutation(PetscInt,const PetscReal[],PetscInt[]);
2226 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortSplit(PetscInt,PetscInt,PetscScalar[],PetscInt[]);
2227 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSortSplitReal(PetscInt,PetscInt,PetscReal[],PetscInt[]);
2228 
2229 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDisplay(void);
2230 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetDisplay(char[],size_t);
2231 
2232 /*E
2233     PetscRandomType - String with the name of a PETSc randomizer
2234        with an optional dynamic library name, for example
2235        http://www.mcs.anl.gov/petsc/lib.a:myrandcreate()
2236 
2237    Level: beginner
2238 
2239    Notes: to use the SPRNG you must have ./configure PETSc
2240    with the option --download-sprng
2241 
2242 .seealso: PetscRandomSetType(), PetscRandom
2243 E*/
2244 #define PetscRandomType char*
2245 #define PETSCRAND       "rand"
2246 #define PETSCRAND48     "rand48"
2247 #define PETSCSPRNG      "sprng"
2248 
2249 /* Logging support */
2250 extern PETSC_DLLEXPORT PetscClassId PETSC_RANDOM_CLASSID;
2251 
2252 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomInitializePackage(const char[]);
2253 
2254 /*S
2255      PetscRandom - Abstract PETSc object that manages generating random numbers
2256 
2257    Level: intermediate
2258 
2259   Concepts: random numbers
2260 
2261 .seealso:  PetscRandomCreate(), PetscRandomGetValue(), PetscRandomType
2262 S*/
2263 typedef struct _p_PetscRandom*   PetscRandom;
2264 
2265 /* Dynamic creation and loading functions */
2266 extern PetscFList PetscRandomList;
2267 extern PetscTruth PetscRandomRegisterAllCalled;
2268 
2269 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomRegisterAll(const char []);
2270 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomRegister(const char[],const char[],const char[],PetscErrorCode (*)(PetscRandom));
2271 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomRegisterDestroy(void);
2272 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetType(PetscRandom, const PetscRandomType);
2273 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetFromOptions(PetscRandom);
2274 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetType(PetscRandom, const PetscRandomType*);
2275 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomViewFromOptions(PetscRandom,char*);
2276 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomView(PetscRandom,PetscViewer);
2277 
2278 /*MC
2279   PetscRandomRegisterDynamic - Adds a new PetscRandom component implementation
2280 
2281   Synopsis:
2282   PetscErrorCode PetscRandomRegisterDynamic(const char *name, const char *path, const char *func_name, PetscErrorCode (*create_func)(PetscRandom))
2283 
2284   Not Collective
2285 
2286   Input Parameters:
2287 + name        - The name of a new user-defined creation routine
2288 . path        - The path (either absolute or relative) of the library containing this routine
2289 . func_name   - The name of routine to create method context
2290 - create_func - The creation routine itself
2291 
2292   Notes:
2293   PetscRandomRegisterDynamic() may be called multiple times to add several user-defined randome number generators
2294 
2295   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
2296 
2297   Sample usage:
2298 .vb
2299     PetscRandomRegisterDynamic("my_rand","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyPetscRandomtorCreate", MyPetscRandomtorCreate);
2300 .ve
2301 
2302   Then, your random type can be chosen with the procedural interface via
2303 .vb
2304     PetscRandomCreate(MPI_Comm, PetscRandom *);
2305     PetscRandomSetType(PetscRandom,"my_random_name");
2306 .ve
2307    or at runtime via the option
2308 .vb
2309     -random_type my_random_name
2310 .ve
2311 
2312   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
2313 
2314          For an example of the code needed to interface your own random number generator see
2315          src/sys/random/impls/rand/rand.c
2316 
2317   Level: advanced
2318 
2319 .keywords: PetscRandom, register
2320 .seealso: PetscRandomRegisterAll(), PetscRandomRegisterDestroy(), PetscRandomRegister()
2321 M*/
2322 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
2323 #define PetscRandomRegisterDynamic(a,b,c,d) PetscRandomRegister(a,b,c,0)
2324 #else
2325 #define PetscRandomRegisterDynamic(a,b,c,d) PetscRandomRegister(a,b,c,d)
2326 #endif
2327 
2328 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomCreate(MPI_Comm,PetscRandom*);
2329 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetValue(PetscRandom,PetscScalar*);
2330 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetValueReal(PetscRandom,PetscReal*);
2331 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetInterval(PetscRandom,PetscScalar*,PetscScalar*);
2332 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetInterval(PetscRandom,PetscScalar,PetscScalar);
2333 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetSeed(PetscRandom,unsigned long);
2334 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetSeed(PetscRandom,unsigned long *);
2335 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSeed(PetscRandom);
2336 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomDestroy(PetscRandom);
2337 
2338 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetFullPath(const char[],char[],size_t);
2339 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetRelativePath(const char[],char[],size_t);
2340 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetWorkingDirectory(char[],size_t);
2341 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetRealPath(const char[],char[]);
2342 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetHomeDirectory(char[],size_t);
2343 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTestFile(const char[],char,PetscTruth*);
2344 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTestDirectory(const char[],char,PetscTruth*);
2345 
2346 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryRead(int,void*,PetscInt,PetscDataType);
2347 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinarySynchronizedRead(MPI_Comm,int,void*,PetscInt,PetscDataType);
2348 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinarySynchronizedWrite(MPI_Comm,int,void*,PetscInt,PetscDataType,PetscTruth);
2349 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryWrite(int,void*,PetscInt,PetscDataType,PetscTruth);
2350 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryOpen(const char[],PetscFileMode,int *);
2351 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryClose(int);
2352 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSharedTmp(MPI_Comm,PetscTruth *);
2353 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSharedWorkingDirectory(MPI_Comm,PetscTruth *);
2354 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetTmp(MPI_Comm,char[],size_t);
2355 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFileRetrieve(MPI_Comm,const char[],char[],size_t,PetscTruth*);
2356 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLs(MPI_Comm,const char[],char[],size_t,PetscTruth*);
2357 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenSocket(char*,int,int*);
2358 
2359 /*
2360    In binary files variables are stored using the following lengths,
2361   regardless of how they are stored in memory on any one particular
2362   machine. Use these rather then sizeof() in computing sizes for
2363   PetscBinarySeek().
2364 */
2365 #define PETSC_BINARY_INT_SIZE    (32/8)
2366 #define PETSC_BINARY_FLOAT_SIZE  (32/8)
2367 #define PETSC_BINARY_CHAR_SIZE    (8/8)
2368 #define PETSC_BINARY_SHORT_SIZE  (16/8)
2369 #define PETSC_BINARY_DOUBLE_SIZE (64/8)
2370 #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar)
2371 
2372 /*E
2373   PetscBinarySeekType - argument to PetscBinarySeek()
2374 
2375   Level: advanced
2376 
2377 .seealso: PetscBinarySeek(), PetscBinarySynchronizedSeek()
2378 E*/
2379 typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType;
2380 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinarySeek(int,off_t,PetscBinarySeekType,off_t*);
2381 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinarySynchronizedSeek(MPI_Comm,int,off_t,PetscBinarySeekType,off_t*);
2382 
2383 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDebugTerminal(const char[]);
2384 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDebugger(const char[],PetscTruth);
2385 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDefaultDebugger(void);
2386 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDebuggerFromString(char*);
2387 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscAttachDebugger(void);
2388 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStopForDebugger(void);
2389 
2390 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGatherNumberOfMessages(MPI_Comm,const PetscMPIInt[],const PetscMPIInt[],PetscMPIInt*);
2391 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGatherMessageLengths(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],PetscMPIInt**,PetscMPIInt**);
2392 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGatherMessageLengths2(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],const PetscMPIInt[],PetscMPIInt**,PetscMPIInt**,PetscMPIInt**);
2393 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPostIrecvInt(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],const PetscMPIInt[],PetscInt***,MPI_Request**);
2394 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPostIrecvScalar(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],const PetscMPIInt[],PetscScalar***,MPI_Request**);
2395 
2396 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSSEIsEnabled(MPI_Comm,PetscTruth *,PetscTruth *);
2397 
2398 /*E
2399   InsertMode - Whether entries are inserted or added into vectors or matrices
2400 
2401   Level: beginner
2402 
2403 .seealso: VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(),
2404           VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(),
2405           MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd()
2406 E*/
2407 typedef enum {NOT_SET_VALUES, INSERT_VALUES, ADD_VALUES, MAX_VALUES} InsertMode;
2408 
2409 /*MC
2410     INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value
2411 
2412     Level: beginner
2413 
2414 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(),
2415           VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES,
2416           MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd(), MAX_VALUES
2417 
2418 M*/
2419 
2420 /*MC
2421     ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the
2422                 value into that location
2423 
2424     Level: beginner
2425 
2426 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(),
2427           VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), INSERT_VALUES,
2428           MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd(), MAX_VALUES
2429 
2430 M*/
2431 
2432 /*MC
2433     MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location
2434 
2435     Level: beginner
2436 
2437 .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES
2438 
2439 M*/
2440 
2441 /*S
2442    PetscSubcomm - Context of MPI subcommunicators, used by PCREDUNDANT
2443 
2444    Level: advanced
2445 
2446    Concepts: communicator, create
2447 S*/
2448 typedef struct _n_PetscSubcomm* PetscSubcomm;
2449 
2450 struct _n_PetscSubcomm {
2451   MPI_Comm   parent;      /* parent communicator */
2452   MPI_Comm   dupparent;   /* duplicate parent communicator, under which the processors of this subcomm have contiguous rank */
2453   MPI_Comm   comm;        /* this communicator */
2454   PetscInt   n;           /* num of subcommunicators under the parent communicator */
2455   PetscInt   color;       /* color of processors belong to this communicator */
2456 };
2457 
2458 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscSubcommCreate(MPI_Comm,PetscInt,PetscSubcomm*);
2459 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscSubcommDestroy(PetscSubcomm);
2460 
2461 PETSC_EXTERN_CXX_END
2462 
2463 #endif
2464