Actual source code: petsc.h

  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: */
  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"

 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 config/configure.py for the latter)
 20: */
 22: #error "PETSc configured with --with-clanguage=c++ and NOT --with-c-support - it can be used only with a C++ compiler"
 23: #endif      

 28: #else
 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        "\
 42:        The PETSc Team\n\
 43:     petsc-maint@mcs.anl.gov\n\
 44:  http://www.mcs.anl.gov/petsc/\n"
 45: #if (PETSC_VERSION_RELEASE == 1)
 46: #define PetscGetVersion(version,len) (PetscSNPrintf(version,len,"Petsc Release Version %d.%d.%d, Patch %d, ", \
 47:                                          PETSC_VERSION_MAJOR,PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, \
 48:                                          PETSC_VERSION_PATCH),PetscStrcat(version,PETSC_VERSION_PATCH_DATE), \
 49:                                          PetscStrcat(version," HG revision: "),PetscStrcat(version,PETSC_VERSION_HG))
 50: #else
 51: #define PetscGetVersion(version,len) (PetscSNPrintf(version,len,"Petsc Development Version %d.%d.%d, Patch %d, ", \
 52:                                          PETSC_VERSION_MAJOR,PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, \
 53:                                          PETSC_VERSION_PATCH),PetscStrcat(version,PETSC_VERSION_PATCH_DATE), \
 54:                                          PetscStrcat(version," HG revision: "),PetscStrcat(version,PETSC_VERSION_HG))
 55: #endif

 57: /*MC
 58:     PetscGetVersion - Gets the PETSc version information in a string.

 60:     Input Parameter:
 61: .   len - length of the string

 63:     Output Parameter:
 64: .   version - version string

 66:     Level: developer

 68:     Usage:
 69:     char version[256];
 70:     PetscGetVersion(version,256);CHKERRQ(ierr)

 72:     Fortran Note:
 73:     This routine is not supported in Fortran.

 75: .seealso: PetscGetProgramName()

 77: M*/

 79: /* ========================================================================== */

 81: /*
 82:    Currently cannot check formatting for PETSc print statements because we have our
 83:    own format %D and %G
 84: */
 85: #undef  PETSC_PRINTF_FORMAT_CHECK
 86: #define PETSC_PRINTF_FORMAT_CHECK(a,b)
 87: #undef  PETSC_FPRINTF_FORMAT_CHECK
 88: #define PETSC_FPRINTF_FORMAT_CHECK(a,b)

 90: /*
 91:    Fixes for config/configure.py time choices which impact our interface. Currently only
 92:    calling conventions and extra compiler checking falls under this category.
 93: */
 94: #if !defined(PETSC_STDCALL)
 95: #define PETSC_STDCALL
 96: #endif
 97: #if !defined(PETSC_TEMPLATE)
 98: #define PETSC_TEMPLATE
 99: #endif
100: #if !defined(PETSC_HAVE_DLL_EXPORT)
101: #define PETSC_DLL_EXPORT
102: #define PETSC_DLL_IMPORT
103: #endif
104: #if !defined()
105: #define 
106: #endif
107: #if !defined()
108: #define 
109: #endif
110: #if !defined()
111: #define 
112: #endif
113: #if !defined()
114: #define 
115: #endif
116: #if !defined()
117: #define 
118: #endif
119: #if !defined()
120: #define 
121: #endif
122: #if !defined()
123: #define 
124: #endif
125: #if !defined()
126: #define 
127: #endif
128: /* ========================================================================== */

130: /*
131:     Defines the interface to MPI allowing the use of all MPI functions.

133:     PETSc does not use the C++ binding of MPI at ALL. The following flag
134:     makes sure the C++ bindings are not included. The C++ bindings REQUIRE
135:     putting mpi.h before ANY C++ include files, we cannot control this
136:     with all PETSc users.
137: */
138: #define MPICH_SKIP_MPICXX 1
139: #include "mpi.h"
140: /*
141:     Yuck, we need to put stdio.h AFTER mpi.h for MPICH2 with C++ compiler 
142:     see the top of mpicxx.h in the MPICH2 distribution.

144:     The MPI STANDARD HAS TO BE CHANGED to prevent this nonsense.
145: */
146: #include <stdio.h>

148: /*MC
149:     PetscErrorCode - datatype used for return error code from all PETSc functions

151:     Level: beginner

153: .seealso: CHKERRQ, SETERRQ
154: M*/
155: typedef int PetscErrorCode;

157: /*MC

159:     PetscCookie - A unique id used to identify each PETSc object.
160:          (internal integer in the data structure used for error
161:          checking). These are all defined by an offset from the lowest
162:          one, PETSC_SMALLEST_COOKIE. 

164:     Level: advanced

167: M*/
168: typedef int PetscCookie;

170: /*MC
171:     PetscEvent - id used to identify PETSc or user events - primarily for logging

173:     Level: intermediate

176: M*/
177: typedef int PetscEvent;

179: /*MC
180:     PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions.

182:     Level: intermediate

184:     Notes: usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but 
185:            standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt

187: .seealso: PetscMPIInt, PetscInt

189: M*/
190: typedef int PetscBLASInt;

192: /*MC
193:     PetscMPIInt - datatype used to represent 'int' parameters to MPI functions.

195:     Level: intermediate

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

200: .seealso: PetscBLASInt, PetscInt

202: M*/
203: typedef int PetscMPIInt;

205: /*MC
206:     PetscEnum - datatype used to pass enum types within PETSc functions.

208:     Level: intermediate

210: .seealso: PetscOptionsGetEnum(), PetscOptionsEnum(), PetscBagRegisterEnum()
211: M*/
212: typedef enum { ENUM_DUMMY } PetscEnum;

214: /*MC
215:     PetscInt - PETSc type that represents integer - used primarily to
216:       represent size of objects. Its size can be configured with the option
217:       --with-64-bit-indices - to be either 32bit or 64bit [default 32 bit ints]

219:    Level: intermediate

221: .seealso: PetscScalar, PetscBLASInt, PetscMPIInt
222: M*/
223: #if defined(PETSC_USE_64BIT_INDICES)
224: typedef long long PetscInt;
225: #define MPIU_INT MPI_LONG_LONG_INT
226: #else
227: typedef int PetscInt;
228: #define MPIU_INT MPI_INT
229: #endif  

231: /*
232:       You can use PETSC_STDOUT as a replacement of stdout. You can also change
233:     the value of PETSC_STDOUT to redirect all standard output elsewhere
234: */


238: /*
239:       You can use PETSC_STDERR as a replacement of stderr. You can also change
240:     the value of PETSC_STDERR to redirect all standard error elsewhere
241: */

244: /*
245:       PETSC_ZOPEFD is used to send data to the PETSc webpage.  It can be used
246:     in conjunction with PETSC_STDOUT, or by itself.
247: */

251: /*MC
252:       PetscPolymorphicSubroutine - allows defining a C++ polymorphic version of 
253:             a PETSc function that remove certain optional arguments for a simplier user interface

255:      Not collective

257:    Synopsis:
258:    PetscPolymorphicSubroutine(Functionname,(arguments of C++ function),(arguments of C function))
259:  
260:    Level: developer

262:     Example:
263:       PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r)) generates the new routine
264:            PetscErrorCode VecNorm(Vec x,PetscReal *r) = VecNorm(x,NORM_2,r)

266: .seealso: PetscPolymorphicFunction()

268: M*/
269: #define PetscPolymorphicSubroutine(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {return A C;}

271: /*MC
272:       PetscPolymorphicScalar - allows defining a C++ polymorphic version of 
273:             a PETSc function that replaces a PetscScalar * argument with a PetscScalar argument

275:      Not collective

277:    Synopsis:
278:    PetscPolymorphicScalar(Functionname,(arguments of C++ function),(arguments of C function))
279:  
280:    Level: developer

282:     Example:
283:       PetscPolymorphicScalar(VecAXPY,(PetscScalar _val,Vec x,Vec y),(&_Val,x,y)) generates the new routine
284:            PetscErrorCode VecAXPY(PetscScalar _val,Vec x,Vec y) = {PetscScalar _Val = _val; return VecAXPY(&_Val,x,y);}

286: .seealso: PetscPolymorphicFunction(),PetscPolymorphicSubroutine()

288: M*/
289: #define PetscPolymorphicScalar(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {PetscScalar _Val = _val; return A C;}

291: /*MC
292:       PetscPolymorphicFunction - allows defining a C++ polymorphic version of 
293:             a PETSc function that remove certain optional arguments for a simplier user interface
294:             and returns the computed value (istead of an error code)

296:      Not collective

298:    Synopsis:
299:    PetscPolymorphicFunction(Functionname,(arguments of C++ function),(arguments of C function),return type,return variable name)
300:  
301:    Level: developer

303:     Example:
304:       PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r) generates the new routine
305:          PetscReal VecNorm(Vec x,NormType t) = {PetscReal r; VecNorm(x,t,&r); return r;}

307: .seealso: PetscPolymorphicSubroutine()

309: M*/
310: #define PetscPolymorphicFunction(A,B,C,D,E) PETSC_STATIC_INLINE D A B {D E; A C;return E;}

312: #else
313: #define PetscPolymorphicSubroutine(A,B,C)
314: #define PetscPolymorphicScalar(A,B,C)
315: #define PetscPolymorphicFunction(A,B,C,D,E)
316: #endif

318: /*
319:     Extern indicates a PETSc function defined elsewhere
320: */
321: #if !defined(EXTERN)
322: #define EXTERN extern
323: #endif

325: /*
326:     Defines some elementary mathematics functions and constants.
327: */
328:  #include petscmath.h

330: /*
332: */


336: /*
337:        Basic PETSc constants
338: */

340: /*E
341:     PetscTruth - Logical variable. Actually an integer

343:    Level: beginner

345: E*/
346: typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth;

349: /*MC
350:     PETSC_FALSE - False value of PetscTruth

352:     Level: beginner

354:     Note: Zero integer

356: .seealso: PetscTruth, PETSC_TRUE
357: M*/

359: /*MC
360:     PETSC_TRUE - True value of PetscTruth

362:     Level: beginner

364:     Note: Nonzero integer

366: .seealso: PetscTruth, PETSC_FALSE
367: M*/

369: /*MC
370:     PETSC_YES - Alias for PETSC_TRUE

372:     Level: beginner

374:     Note: Zero integer

376: .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_NO
377: M*/
378: #define PETSC_YES            PETSC_TRUE

380: /*MC
381:     PETSC_NO - Alias for PETSC_FALSE

383:     Level: beginner

385:     Note: Nonzero integer

387: .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_YES
388: M*/
389: #define PETSC_NO             PETSC_FALSE

391: /*MC
392:     PETSC_NULL - standard way of passing in a null or array or pointer

394:    Level: beginner

396:    Notes: accepted by many PETSc functions to not set a parameter and instead use
397:           some default

399:           This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 
400:           PETSC_NULL_DOUBLE_PRECISION etc

402: .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE

404: M*/
405: #define PETSC_NULL           0

407: /*MC
408:     PETSC_DECIDE - standard way of passing in integer or floating point parameter
409:        where you wish PETSc to use the default.

411:    Level: beginner

413: .seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE

415: M*/
416: #define PETSC_DECIDE         -1

418: /*MC
419:     PETSC_DEFAULT - standard way of passing in integer or floating point parameter
420:        where you wish PETSc to use the default.

422:    Level: beginner

424: .seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE

426: M*/
427: #define PETSC_DEFAULT        -2


430: /*MC
431:     PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument

433:    Level: beginner

435:    Notes: accepted by many PETSc functions to not set a parameter and instead use
436:           some default

438:           This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 
439:           PETSC_NULL_DOUBLE_PRECISION etc

441: .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE

443: M*/
444: #define PETSC_IGNORE         PETSC_NULL

446: /*MC
447:     PETSC_DETERMINE - standard way of passing in integer or floating point parameter
448:        where you wish PETSc to compute the required value.

450:    Level: beginner

452: .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes()

454: M*/
455: #define PETSC_DETERMINE      PETSC_DECIDE

457: /*MC
458:     PETSC_COMM_WORLD - the equivalent of the MPI_COMM_WORLD communicator which represents
459:            all the processs that PETSc knows about. 

461:    Level: beginner

463:    Notes: By default PETSC_COMM_WORLD and MPI_COMM_WORLD are identical unless you wish to 
464:           run PETSc on ONLY a subset of MPI_COMM_WORLD. In that case create your new (smaller)
465:           communicator, call it, say comm, and set PETSC_COMM_WORLD = comm BEFORE calling
466:           PetscInitialize()

468: .seealso: PETSC_COMM_SELF

470: M*/

473: /*MC
474:     PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents
475:            the current process

477:    Level: beginner

479:    Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent.

481: .seealso: PETSC_COMM_WORLD

483: M*/
484: #define PETSC_COMM_SELF MPI_COMM_SELF


489: EXTERN PetscErrorCode  PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm));
490: EXTERN PetscErrorCode  PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*);
491: EXTERN PetscErrorCode  PetscCommDestroy(MPI_Comm*);

493: /*MC
494:    PetscMalloc - Allocates memory

496:    Input Parameter:
497: .  m - number of bytes to allocate

499:    Output Parameter:
500: .  result - memory allocated

502:    Synopsis:
503:    PetscErrorCode PetscMalloc(size_t m,void **result)

505:    Level: beginner

507:    Notes: Memory is always allocated at least double aligned

509:           If you request memory of zero size it will allocate no space and assign the pointer to 0; PetscFree() will 
510:           properly handle not freeing the null pointer.

512: .seealso: PetscFree(), PetscNew()

514:   Concepts: memory allocation

516: M*/
517: #define PetscMalloc(a,b)  ((a != 0) ? (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b)) : (*(b) = 0,0) )

519: /*MC
520:    PetscMalloc2 - Allocates 2 chunks of  memory

522:    Input Parameter:
523: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
524: .  t1 - type of first memory elements 
525: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
526: -  t2 - type of second memory elements

528:    Output Parameter:
529: +  r1 - memory allocated in first chunk
530: -  r2 - memory allocated in second chunk

532:    Synopsis:
533:    PetscErrorCode PetscMalloc2(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2)

535:    Level: developer

537:    Notes: Memory of first chunk is always allocated at least double aligned

539: .seealso: PetscFree(), PetscNew(), PetscMalloc()

541:   Concepts: memory allocation

543: M*/
544: #if defined(PETSC_USE_DEBUG)
545: #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2))
546: #else
547: #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2),r1) || (*(r2) = (t2*)(*(r1)+m1),0))
548: #endif

550: /*MC
551:    PetscMalloc3 - Allocates 3 chunks of  memory

553:    Input Parameter:
554: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
555: .  t1 - type of first memory elements 
556: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
557: .  t2 - type of second memory elements
558: .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
559: -  t3 - type of third memory elements

561:    Output Parameter:
562: +  r1 - memory allocated in first chunk
563: .  r2 - memory allocated in second chunk
564: -  r3 - memory allocated in third chunk

566:    Synopsis:
567:    PetscErrorCode PetscMalloc3(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3)

569:    Level: developer

571:    Notes: Memory of first chunk is always allocated at least double aligned

573: .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3()

575:   Concepts: memory allocation

577: M*/
578: #if defined(PETSC_USE_DEBUG)
579: #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))
580: #else
581: #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),0))
582: #endif

584: /*MC
585:    PetscMalloc4 - Allocates 4 chunks of  memory

587:    Input Parameter:
588: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
589: .  t1 - type of first memory elements 
590: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
591: .  t2 - type of second memory elements
592: .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
593: .  t3 - type of third memory elements
594: .  m4 - number of elements to allocate in 4th chunk  (may be zero)
595: -  t4 - type of fourth memory elements

597:    Output Parameter:
598: +  r1 - memory allocated in first chunk
599: .  r2 - memory allocated in second chunk
600: .  r3 - memory allocated in third chunk
601: -  r4 - memory allocated in fourth chunk

603:    Synopsis:
604:    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)

606:    Level: developer

608:    Notes: Memory of first chunk is always allocated at least double aligned

610: .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4()

612:   Concepts: memory allocation

614: M*/
615: #if defined(PETSC_USE_DEBUG)
616: #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))
617: #else
618: #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),0))
619: #endif

621: /*MC
622:    PetscMalloc5 - Allocates 5 chunks of  memory

624:    Input Parameter:
625: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
626: .  t1 - type of first memory elements 
627: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
628: .  t2 - type of second memory elements
629: .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
630: .  t3 - type of third memory elements
631: .  m4 - number of elements to allocate in 4th chunk  (may be zero)
632: .  t4 - type of fourth memory elements
633: .  m5 - number of elements to allocate in 5th chunk  (may be zero)
634: -  t5 - type of fifth memory elements

636:    Output Parameter:
637: +  r1 - memory allocated in first chunk
638: .  r2 - memory allocated in second chunk
639: .  r3 - memory allocated in third chunk
640: .  r4 - memory allocated in fourth chunk
641: -  r5 - memory allocated in fifth chunk

643:    Synopsis:
644:    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)

646:    Level: developer

648:    Notes: Memory of first chunk is always allocated at least double aligned

650: .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5()

652:   Concepts: memory allocation

654: M*/
655: #if defined(PETSC_USE_DEBUG)
656: #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))
657: #else
658: #define PetscMalloc5(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),0))
659: #endif


662: /*MC
663:    PetscMalloc6 - Allocates 6 chunks of  memory

665:    Input Parameter:
666: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
667: .  t1 - type of first memory elements 
668: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
669: .  t2 - type of second memory elements
670: .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
671: .  t3 - type of third memory elements
672: .  m4 - number of elements to allocate in 4th chunk  (may be zero)
673: .  t4 - type of fourth memory elements
674: .  m5 - number of elements to allocate in 5th chunk  (may be zero)
675: .  t5 - type of fifth memory elements
676: .  m6 - number of elements to allocate in 6th chunk  (may be zero)
677: -  t6 - type of sixth memory elements

679:    Output Parameter:
680: +  r1 - memory allocated in first chunk
681: .  r2 - memory allocated in second chunk
682: .  r3 - memory allocated in third chunk
683: .  r4 - memory allocated in fourth chunk
684: .  r5 - memory allocated in fifth chunk
685: -  r6 - memory allocated in sixth chunk

687:    Synopsis:
688:    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)

690:    Level: developer

692:    Notes: Memory of first chunk is always allocated at least double aligned

694: .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6()

696:   Concepts: memory allocation

698: M*/
699: #if defined(PETSC_USE_DEBUG)
700: #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))
701: #else
702: #define PetscMalloc6(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),*(r6) = (t6*)(*(r5)+m5),0))
703: #endif

705: /*MC
706:    PetscMalloc7 - Allocates 7 chunks of  memory

708:    Input Parameter:
709: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
710: .  t1 - type of first memory elements 
711: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
712: .  t2 - type of second memory elements
713: .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
714: .  t3 - type of third memory elements
715: .  m4 - number of elements to allocate in 4th chunk  (may be zero)
716: .  t4 - type of fourth memory elements
717: .  m5 - number of elements to allocate in 5th chunk  (may be zero)
718: .  t5 - type of fifth memory elements
719: .  m6 - number of elements to allocate in 6th chunk  (may be zero)
720: .  t6 - type of sixth memory elements
721: .  m7 - number of elements to allocate in 7th chunk  (may be zero)
722: -  t7 - type of sixth memory elements

724:    Output Parameter:
725: +  r1 - memory allocated in first chunk
726: .  r2 - memory allocated in second chunk
727: .  r3 - memory allocated in third chunk
728: .  r4 - memory allocated in fourth chunk
729: .  r5 - memory allocated in fifth chunk
730: .  r6 - memory allocated in sixth chunk
731: -  r7 - memory allocated in sixth chunk

733:    Synopsis:
734:    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)

736:    Level: developer

738:    Notes: Memory of first chunk is always allocated at least double aligned

740: .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6(), PetscFree7()

742:   Concepts: memory allocation

744: M*/
745: #if defined(PETSC_USE_DEBUG)
746: #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))
747: #else
748: #define PetscMalloc7(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6,m7,t7,r7) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6)+(m7)*sizeof(t7),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),*(r6) = (t6*)(*(r5)+m5),*(r7) = (t7*)(*(r6)+m6),0))
749: #endif

751: /*MC
752:    PetscNew - Allocates memory of a particular type, zeros the memory!

754:    Input Parameter:
755: .  type - structure name of space to be allocated. Memory of size sizeof(type) is allocated

757:    Output Parameter:
758: .  result - memory allocated

760:    Synopsis:
761:    PetscErrorCode PetscNew(struct type,((type *))result)

763:    Level: beginner

765: .seealso: PetscFree(), PetscMalloc()

767:   Concepts: memory allocation

769: M*/
770: #define PetscNew(A,b)      (PetscMalloc(sizeof(A),(b)) || PetscMemzero(*(b),sizeof(A)))
771: #define PetscNewLog(o,A,b) (PetscNew(A,b) || ((o) ? PetscLogObjectMemory(o,sizeof(A)) : 0))

773: /*MC
774:    PetscFree - Frees memory

776:    Input Parameter:
777: .   memory - memory to free (the pointer is ALWAYS set to 0 upon sucess)

779:    Synopsis:
780:    PetscErrorCode PetscFree(void *memory)

782:    Level: beginner

784:    Notes: Memory must have been obtained with PetscNew() or PetscMalloc()

786: .seealso: PetscNew(), PetscMalloc(), PetscFreeVoid()

788:   Concepts: memory allocation

790: M*/
791: #define PetscFree(a)   ((a) ? ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__) || ((a = 0),0)) : 0)

793: /*MC
794:    PetscFreeVoid - Frees memory

796:    Input Parameter:
797: .   memory - memory to free

799:    Synopsis:
800:    void PetscFreeVoid(void *memory)

802:    Level: beginner

804:    Notes: This is different from PetscFree() in that no error code is returned

806: .seealso: PetscFree(), PetscNew(), PetscMalloc()

808:   Concepts: memory allocation

810: M*/
811: #define PetscFreeVoid(a) ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__),(a) = 0)


814: /*MC
815:    PetscFree2 - Frees 2 chunks of memory obtained with PetscMalloc2()

817:    Input Parameter:
818: +   memory1 - memory to free
819: -   memory2 - 2nd memory to free


822:    Synopsis:
823:    PetscErrorCode PetscFree2(void *memory1,void *memory2)

825:    Level: developer

827:    Notes: Memory must have been obtained with PetscMalloc2()

829: .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree()

831:   Concepts: memory allocation

833: M*/
834: #if defined(PETSC_USE_DEBUG)
835: #define PetscFree2(m1,m2)   (PetscFree(m2) || PetscFree(m1))
836: #else
837: #define PetscFree2(m1,m2)   (PetscFree(m1))
838: #endif

840: /*MC
841:    PetscFree3 - Frees 3 chunks of memory obtained with PetscMalloc3()

843:    Input Parameter:
844: +   memory1 - memory to free
845: .   memory2 - 2nd memory to free
846: -   memory3 - 3rd memory to free


849:    Synopsis:
850:    PetscErrorCode PetscFree3(void *memory1,void *memory2,void *memory3)

852:    Level: developer

854:    Notes: Memory must have been obtained with PetscMalloc3()

856: .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3()

858:   Concepts: memory allocation

860: M*/
861: #if defined(PETSC_USE_DEBUG)
862: #define PetscFree3(m1,m2,m3)   (PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
863: #else
864: #define PetscFree3(m1,m2,m3)   (PetscFree(m1))
865: #endif

867: /*MC
868:    PetscFree4 - Frees 4 chunks of memory obtained with PetscMalloc4()

870:    Input Parameter:
871: +   m1 - memory to free
872: .   m2 - 2nd memory to free
873: .   m3 - 3rd memory to free
874: -   m4 - 4th memory to free


877:    Synopsis:
878:    PetscErrorCode PetscFree4(void *m1,void *m2,void *m3,void *m4)

880:    Level: developer

882:    Notes: Memory must have been obtained with PetscMalloc4()

884: .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4()

886:   Concepts: memory allocation

888: M*/
889: #if defined(PETSC_USE_DEBUG)
890: #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
891: #else
892: #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m1))
893: #endif

895: /*MC
896:    PetscFree5 - Frees 5 chunks of memory obtained with PetscMalloc5()

898:    Input Parameter:
899: +   m1 - memory to free
900: .   m2 - 2nd memory to free
901: .   m3 - 3rd memory to free
902: .   m4 - 4th memory to free
903: -   m5 - 5th memory to free


906:    Synopsis:
907:    PetscErrorCode PetscFree5(void *m1,void *m2,void *m3,void *m4,void *m5)

909:    Level: developer

911:    Notes: Memory must have been obtained with PetscMalloc5()

913: .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5()

915:   Concepts: memory allocation

917: M*/
918: #if defined(PETSC_USE_DEBUG)
919: #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
920: #else
921: #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m1))
922: #endif


925: /*MC
926:    PetscFree6 - Frees 6 chunks of memory obtained with PetscMalloc6()

928:    Input Parameter:
929: +   m1 - memory to free
930: .   m2 - 2nd memory to free
931: .   m3 - 3rd memory to free
932: .   m4 - 4th memory to free
933: .   m5 - 5th memory to free
934: -   m6 - 6th memory to free


937:    Synopsis:
938:    PetscErrorCode PetscFree6(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6)

940:    Level: developer

942:    Notes: Memory must have been obtained with PetscMalloc6()

944: .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6()

946:   Concepts: memory allocation

948: M*/
949: #if defined(PETSC_USE_DEBUG)
950: #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
951: #else
952: #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m1))
953: #endif

955: /*MC
956:    PetscFree7 - Frees 7 chunks of memory obtained with PetscMalloc7()

958:    Input Parameter:
959: +   m1 - memory to free
960: .   m2 - 2nd memory to free
961: .   m3 - 3rd memory to free
962: .   m4 - 4th memory to free
963: .   m5 - 5th memory to free
964: .   m6 - 6th memory to free
965: -   m7 - 7th memory to free


968:    Synopsis:
969:    PetscErrorCode PetscFree7(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6,void *m7)

971:    Level: developer

973:    Notes: Memory must have been obtained with PetscMalloc7()

975: .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6(),
976:           PetscMalloc7()

978:   Concepts: memory allocation

980: M*/
981: #if defined(PETSC_USE_DEBUG)
982: #define PetscFree7(m1,m2,m3,m4,m5,m6,m7)   (PetscFree(m7) || PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
983: #else
984: #define PetscFree7(m1,m2,m3,m4,m5,m6,m7)   (PetscFree(m1))
985: #endif

987: EXTERN  PetscErrorCode (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**);
988: EXTERN  PetscErrorCode (*PetscTrFree)(void*,int,const char[],const char[],const char[]);
989: EXTERN PetscErrorCode   PetscMallocSet(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[]));
990: EXTERN PetscErrorCode   PetscMallocClear(void);

992: /*
993:    Routines for tracing memory corruption/bleeding with default PETSc 
994:    memory allocation
995: */
996: EXTERN PetscErrorCode    PetscMallocDump(FILE *);
997: EXTERN PetscErrorCode    PetscMallocDumpLog(FILE *);
998: EXTERN PetscErrorCode    PetscMallocGetCurrentUsage(PetscLogDouble *);
999: EXTERN PetscErrorCode    PetscMallocGetMaximumUsage(PetscLogDouble *);
1000: EXTERN PetscErrorCode    PetscMallocDebug(PetscTruth);
1001: EXTERN PetscErrorCode    PetscMallocValidate(int,const char[],const char[],const char[]);
1002: EXTERN PetscErrorCode    PetscMallocSetDumpLog(void);


1005: /*
1006:     Variable type where we stash PETSc object pointers in Fortran.
1007:     On most machines size(pointer) == sizeof(long) - except windows
1008:     where its sizeof(long long)
1009: */

1011: #if (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG)
1012: #define PetscFortranAddr   long
1013: #elif  (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG_LONG)
1014: #define PetscFortranAddr   long long
1015: #else
1016: #error "Unknown size for PetscFortranAddr! Send us a bugreport at petsc-maint@mcs.anl.gov"
1017: #endif

1019: /*E
1020:     PetscDataType - Used for handling different basic data types.

1022:    Level: beginner

1024: .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(),
1025:           PetscDataTypeGetSize()

1027: E*/
1028: typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2, PETSC_LONG = 3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5,
1029:               PETSC_CHAR = 6,PETSC_LOGICAL = 7,PETSC_ENUM = 8,PETSC_TRUTH=9, PETSC_LONG_DOUBLE = 10} PetscDataType;

1032: #if defined(PETSC_USE_COMPLEX)
1033: #define PETSC_SCALAR PETSC_COMPLEX
1034: #else
1035: #if defined(PETSC_USE_SINGLE)
1036: #define PETSC_SCALAR PETSC_FLOAT
1037: #elif defined(PETSC_USE_LONG_DOUBLE)
1038: #define PETSC_SCALAR PETSC_LONG_DOUBLE
1039: #elif defined(PETSC_USE_INT)
1040: #define PETSC_SCALAR PETSC_INT
1041: #else
1042: #define PETSC_SCALAR PETSC_DOUBLE
1043: #endif
1044: #endif
1045: #if defined(PETSC_USE_SINGLE)
1046: #define PETSC_REAL PETSC_FLOAT
1047: #elif defined(PETSC_USE_LONG_DOUBLE)
1048: #define PETSC_REAL PETSC_LONG_DOUBLE
1049: #elif defined(PETSC_USE_INT)
1050: #define PETSC_REAL PETSC_INT
1051: #else
1052: #define PETSC_REAL PETSC_DOUBLE
1053: #endif
1054: #define PETSC_FORTRANADDR PETSC_LONG

1056: EXTERN PetscErrorCode  PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
1057: EXTERN PetscErrorCode  PetscDataTypeGetSize(PetscDataType,size_t*);

1059: /*
1060:     Basic memory and string operations. These are usually simple wrappers
1061:    around the basic Unix system calls, but a few of them have additional
1062:    functionality and/or error checking.
1063: */
1064: EXTERN PetscErrorCode    PetscMemcpy(void*,const void *,size_t);
1065: EXTERN PetscErrorCode    PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType);
1066: EXTERN PetscErrorCode    PetscMemmove(void*,void *,size_t);
1067: EXTERN PetscErrorCode    PetscMemzero(void*,size_t);
1068: EXTERN PetscErrorCode    PetscMemcmp(const void*,const void*,size_t,PetscTruth *);
1069: EXTERN PetscErrorCode    PetscStrlen(const char[],size_t*);
1070: EXTERN PetscErrorCode    PetscStrcmp(const char[],const char[],PetscTruth *);
1071: EXTERN PetscErrorCode    PetscStrgrt(const char[],const char[],PetscTruth *);
1072: EXTERN PetscErrorCode    PetscStrcasecmp(const char[],const char[],PetscTruth*);
1073: EXTERN PetscErrorCode    PetscStrncmp(const char[],const char[],size_t,PetscTruth*);
1074: EXTERN PetscErrorCode    PetscStrcpy(char[],const char[]);
1075: EXTERN PetscErrorCode    PetscStrcat(char[],const char[]);
1076: EXTERN PetscErrorCode    PetscStrncat(char[],const char[],size_t);
1077: EXTERN PetscErrorCode    PetscStrncpy(char[],const char[],size_t);
1078: EXTERN PetscErrorCode    PetscStrchr(const char[],char,char *[]);
1079: EXTERN PetscErrorCode    PetscStrtolower(char[]);
1080: EXTERN PetscErrorCode    PetscStrrchr(const char[],char,char *[]);
1081: EXTERN PetscErrorCode    PetscStrstr(const char[],const char[],char *[]);
1082: EXTERN PetscErrorCode    PetscStrrstr(const char[],const char[],char *[]);
1083: EXTERN PetscErrorCode    PetscStrallocpy(const char[],char *[]);
1084: EXTERN PetscErrorCode    PetscStrreplace(MPI_Comm,const char[],char[],size_t);
1085: #define      PetscStrfree(a) ((a) ? PetscFree(a) : 0) 

1087: /*S
1088:     PetscToken - 'Token' used for managing tokenizing strings

1090:   Level: intermediate

1092: .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy()
1093: S*/
1094: typedef struct _p_PetscToken* PetscToken;

1096: EXTERN PetscErrorCode    PetscTokenCreate(const char[],const char,PetscToken*);
1097: EXTERN PetscErrorCode    PetscTokenFind(PetscToken,char *[]);
1098: EXTERN PetscErrorCode    PetscTokenDestroy(PetscToken);

1100: /*
1101:    These are  MPI operations for MPI_Allreduce() etc
1102: */
1103: EXTERN  MPI_Op PetscMaxSum_Op;
1104: #if defined(PETSC_USE_COMPLEX)
1105: EXTERN  MPI_Op PetscSum_Op;
1106: #else
1107: #define PetscSum_Op MPI_SUM
1108: #endif
1109: EXTERN PetscErrorCode  PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*);

1111: /*S
1112:      PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc

1114:    Level: beginner

1116:    Note: This is the base class from which all objects appear.

1118: .seealso:  PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName()
1119: S*/
1120: typedef struct _p_PetscObject* PetscObject;

1122: /*S
1123:      PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed
1124:       by string name

1126:    Level: advanced

1128: .seealso:  PetscFListAdd(), PetscFListDestroy()
1129: S*/
1130: typedef struct _n_PetscFList *PetscFList;

1132: /*E
1133:   PetscFileMode - Access mode for a file.

1135:   Level: beginner

1137:   FILE_MODE_READ - open a file at its beginning for reading

1139:   FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist)

1141:   FILE_MODE_APPEND - open a file at end for writing

1143:   FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing

1145:   FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end

1147: .seealso: PetscViewerFileSetMode()
1148: E*/
1149: typedef enum {FILE_MODE_READ, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode;

1151:  #include petscviewer.h
1152:  #include petscoptions.h

1154: #define PETSC_SMALLEST_COOKIE 1211211
1157: EXTERN PetscErrorCode  PetscCookieRegister(PetscCookie *);

1159: /*
1160:    Routines that get memory usage information from the OS
1161: */
1162: EXTERN PetscErrorCode  PetscMemoryGetCurrentUsage(PetscLogDouble *);
1163: EXTERN PetscErrorCode  PetscMemoryGetMaximumUsage(PetscLogDouble *);
1164: EXTERN PetscErrorCode  PetscMemorySetGetMaximumUsage(void);
1165: EXTERN PetscErrorCode  PetscMemoryShowUsage(PetscViewer,const char[]);

1167: EXTERN PetscErrorCode  PetscInfoAllow(PetscTruth,const char []);
1168: EXTERN PetscErrorCode  PetscGetTime(PetscLogDouble*);
1169: EXTERN PetscErrorCode  PetscGetCPUTime(PetscLogDouble*);
1170: EXTERN PetscErrorCode  PetscSleep(int);

1172: /*
1173:     Initialization of PETSc
1174: */
1175: EXTERN PetscErrorCode  PetscInitialize(int*,char***,const char[],const char[]);
1176: PetscPolymorphicSubroutine(PetscInitialize,(int *argc,char ***args),(argc,args,PETSC_NULL,PETSC_NULL))
1177: EXTERN PetscErrorCode  PetscInitializeNoArguments(void);
1178: EXTERN PetscErrorCode  PetscInitialized(PetscTruth *);
1179: EXTERN PetscErrorCode  PetscFinalized(PetscTruth *);
1180: EXTERN PetscErrorCode  PetscFinalize(void);
1181: EXTERN PetscErrorCode PetscInitializeFortran(void);
1182: EXTERN PetscErrorCode  PetscGetArgs(int*,char ***);
1183: EXTERN PetscErrorCode  PetscGetArguments(char ***);
1184: EXTERN PetscErrorCode  PetscFreeArguments(char **);

1186: EXTERN PetscErrorCode  PetscEnd(void);
1187: EXTERN PetscErrorCode  PetscInitializePackage(const char[]);

1189: EXTERN PetscErrorCode  PetscOpenMPMerge(PetscMPIInt);
1190: EXTERN PetscErrorCode  PetscOpenMPSpawn(PetscMPIInt);
1191: EXTERN PetscErrorCode  PetscOpenMPFinalize(void);
1192: EXTERN PetscErrorCode  PetscOpenMPRun(MPI_Comm,PetscErrorCode (*)(MPI_Comm,void *),void*);
1193: EXTERN PetscErrorCode  PetscOpenMPFree(MPI_Comm,void*);
1194: EXTERN PetscErrorCode  PetscOpenMPNew(MPI_Comm,PetscInt,void**);

1196: /*
1198:    function pointers. Since the regular C++ code expects its function pointers to be 
1199:    C++.
1200: */
1201: typedef void (**PetscVoidStarFunction)(void);
1202: typedef void (*PetscVoidFunction)(void);
1203: typedef PetscErrorCode (*PetscErrorCodeFunction)(void);

1205: /*
1206:    PetscTryMethod - Queries an object for a method, if it exists then calls it.
1207:               These are intended to be used only inside PETSc functions.
1208: */
1209: #define  PetscTryMethod(obj,A,B,C) \
1210:   0;{ PetscErrorCode (*f)B, __ierr; \
1211:     __PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \
1212:     if (f) {__(*f)C;CHKERRQ(__ierr);}\
1213:   }
1214: #define  PetscUseMethod(obj,A,B,C) \
1215:   0;{ PetscErrorCode (*f)B, __ierr; \
1216:     __PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \
1217:     if (f) {__(*f)C;CHKERRQ(__ierr);}\
1218:     else {SETERRQ1(PETSC_ERR_SUP,"Cannot locate function %s in object",A);} \
1219:   }
1220: /*
1221:     Functions that can act on any PETSc object.
1222: */
1223: EXTERN PetscErrorCode  PetscObjectCreate(MPI_Comm,PetscObject*);
1224: EXTERN PetscErrorCode  PetscObjectCreateGeneric(MPI_Comm, PetscCookie, const char [], PetscObject *);
1225: EXTERN PetscErrorCode  PetscObjectDestroy(PetscObject);
1226: EXTERN PetscErrorCode  PetscObjectExists(PetscObject,PetscTruth*);
1227: EXTERN PetscErrorCode  PetscObjectGetComm(PetscObject,MPI_Comm *);
1228: EXTERN PetscErrorCode  PetscObjectGetCookie(PetscObject,PetscCookie *);
1229: EXTERN PetscErrorCode  PetscObjectSetType(PetscObject,const char []);
1230: EXTERN PetscErrorCode  PetscObjectGetType(PetscObject,const char *[]);
1231: EXTERN PetscErrorCode  PetscObjectSetName(PetscObject,const char[]);
1232: EXTERN PetscErrorCode  PetscObjectGetName(PetscObject,const char*[]);
1233: EXTERN PetscErrorCode  PetscObjectReference(PetscObject);
1234: EXTERN PetscErrorCode  PetscObjectGetReference(PetscObject,PetscInt*);
1235: EXTERN PetscErrorCode  PetscObjectDereference(PetscObject);
1236: EXTERN PetscErrorCode  PetscObjectGetNewTag(PetscObject,PetscMPIInt *);
1237: EXTERN PetscErrorCode  PetscObjectView(PetscObject,PetscViewer);
1238: EXTERN PetscErrorCode  PetscObjectCompose(PetscObject,const char[],PetscObject);
1239: EXTERN PetscErrorCode  PetscObjectQuery(PetscObject,const char[],PetscObject *);
1240: EXTERN PetscErrorCode  PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void));
1241: EXTERN PetscErrorCode  PetscObjectSetFromOptions(PetscObject);
1242: EXTERN PetscErrorCode  PetscObjectSetUp(PetscObject);
1243: EXTERN PetscErrorCode  PetscCommGetNewTag(MPI_Comm,PetscMPIInt *);

1245: /*MC
1246:    PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object. 
1247:                        
1248:    Collective on PetscObject

1250:    Input Parameters:
1251: +  obj - the PETSc object; this must be cast with a (PetscObject), for example, 
1252:          PetscObjectCompose((PetscObject)mat,...);
1253: .  name - name associated with the child function
1254: .  fname - name of the function
1255: -  ptr - function pointer (or PETSC_NULL if using dynamic libraries)

1257:    Level: advanced

1259:     Synopsis:
1260:     PetscErrorCode PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr)

1262:    Notes:
1263:    To remove a registered routine, pass in a PETSC_NULL rname and fnc().

1265:    PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as
1266:    Mat, Vec, KSP, SNES, etc.) or any user-provided object. 

1269:    work in C++/complex with dynamic link libraries (config/configure.py options --with-shared --with-dynamic)
1270:    enabled.

1272:    Concepts: objects^composing functions
1273:    Concepts: composing functions
1274:    Concepts: functions^querying
1275:    Concepts: objects^querying
1276:    Concepts: querying objects

1278: .seealso: PetscObjectQueryFunction()
1279: M*/
1280: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1281: #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0)
1282: #else
1283: #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(PetscVoidFunction)(d))
1284: #endif

1286: EXTERN PetscErrorCode  PetscObjectQueryFunction(PetscObject,const char[],void (**)(void));
1287: EXTERN PetscErrorCode  PetscObjectSetOptionsPrefix(PetscObject,const char[]);
1288: EXTERN PetscErrorCode  PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
1289: EXTERN PetscErrorCode  PetscObjectPrependOptionsPrefix(PetscObject,const char[]);
1290: EXTERN PetscErrorCode  PetscObjectGetOptionsPrefix(PetscObject,const char*[]);
1291: EXTERN PetscErrorCode  PetscObjectPublish(PetscObject);
1292: EXTERN PetscErrorCode  PetscObjectChangeTypeName(PetscObject,const char[]);
1293: EXTERN PetscErrorCode  PetscObjectRegisterDestroy(PetscObject);
1294: EXTERN PetscErrorCode  PetscObjectRegisterDestroyAll(void);
1295: EXTERN PetscErrorCode  PetscObjectName(PetscObject);
1296: EXTERN PetscErrorCode  PetscTypeCompare(PetscObject,const char[],PetscTruth*);
1297: EXTERN PetscErrorCode  PetscRegisterFinalize(PetscErrorCode (*)(void));
1298: EXTERN PetscErrorCode  PetscRegisterFinalizeAll(void);

1300: /*
1301:     Defines PETSc error handling.
1302: */
1303:  #include petscerror.h

1305: /*S
1306:      PetscOList - Linked list of PETSc objects, accessable by string name

1308:    Level: advanced

1310: .seealso:  PetscOListAdd(), PetscOListDestroy(), PetscOListFind()
1311: S*/
1312: typedef struct _n_PetscOList *PetscOList;

1314: EXTERN PetscErrorCode  PetscOListDestroy(PetscOList);
1315: EXTERN PetscErrorCode  PetscOListFind(PetscOList,const char[],PetscObject*);
1316: EXTERN PetscErrorCode  PetscOListReverseFind(PetscOList,PetscObject,char**);
1317: EXTERN PetscErrorCode  PetscOListAdd(PetscOList *,const char[],PetscObject);
1318: EXTERN PetscErrorCode  PetscOListDuplicate(PetscOList,PetscOList *);

1320: /*
1321:     Dynamic library lists. Lists of names of routines in dynamic 
1322:   link libraries that will be loaded as needed.
1323: */
1324: EXTERN PetscErrorCode  PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void));
1325: EXTERN PetscErrorCode  PetscFListDestroy(PetscFList*);
1326: EXTERN PetscErrorCode  PetscFListFind(PetscFList,MPI_Comm,const char[],void (**)(void));
1327: EXTERN PetscErrorCode  PetscFListPrintTypes(PetscFList,MPI_Comm,FILE*,const char[],const char[],const char[],const char[]);
1328: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1329: #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0)
1330: #else
1331: #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c)
1332: #endif
1333: EXTERN PetscErrorCode  PetscFListDuplicate(PetscFList,PetscFList *);
1334: EXTERN PetscErrorCode  PetscFListView(PetscFList,PetscViewer);
1335: EXTERN PetscErrorCode  PetscFListConcat(const char [],const char [],char []);
1336: EXTERN PetscErrorCode  PetscFListGet(PetscFList,char ***,int*);

1338: /*S
1339:      PetscDLLibrary - Linked list of dynamics libraries to search for functions

1341:    Level: advanced

1343:    --with-shared --with-dynamic must be used with config/configure.py to use dynamic libraries

1345: .seealso:  PetscDLLibraryOpen()
1346: S*/
1347: typedef struct _n_PetscDLLibrary *PetscDLLibrary;
1349: EXTERN PetscErrorCode  PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *);
1350: EXTERN PetscErrorCode  PetscDLLibraryOpen(MPI_Comm,const char[],void **);
1351: EXTERN PetscErrorCode  PetscDLLibrarySym(MPI_Comm,PetscDLLibrary *,const char[],const char[],void **);
1352: EXTERN PetscErrorCode  PetscDLLibraryAppend(MPI_Comm,PetscDLLibrary *,const char[]);
1353: EXTERN PetscErrorCode  PetscDLLibraryPrepend(MPI_Comm,PetscDLLibrary *,const char[]);
1354: EXTERN PetscErrorCode  PetscDLLibraryClose(PetscDLLibrary);
1355: EXTERN PetscErrorCode  PetscDLLibraryPrintPath(void);
1356: EXTERN PetscErrorCode  PetscDLLibraryGetInfo(void*,const char[],const char *[]);
1357: EXTERN PetscErrorCode  PetscDLLibraryCCAAppend(MPI_Comm,PetscDLLibrary *,const char[]);

1359: /*
1360:      Useful utility routines
1361: */
1362: EXTERN PetscErrorCode  PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*);
1363: EXTERN PetscErrorCode  PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*);
1364: EXTERN PetscErrorCode  PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt);
1365: PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(MPI_Comm comm),(comm,1))
1366: PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(void),(PETSC_COMM_WORLD,1))
1367: EXTERN PetscErrorCode  PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt);
1368: PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(MPI_Comm comm),(comm,1))
1369: PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(void),(PETSC_COMM_WORLD,1))
1370: EXTERN PetscErrorCode  PetscBarrier(PetscObject);
1371: EXTERN PetscErrorCode  PetscMPIDump(FILE*);

1373: #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE)
1374: /*
1375:     Defines basic graphics available from PETSc.
1376: */
1377:  #include petscdraw.h

1379: /*
1380:     Defines the base data structures for all PETSc objects
1381: */
1382:  #include private/petscimpl.h
1383: /*
1384:      Defines PETSc profiling.
1385: */
1386:  #include petsclog.h

1388: /*
1389:           For locking, unlocking and destroying AMS memories associated with 
1390:     PETSc objects. Not currently used.
1391: */
1392: #define PetscPublishAll(v)           0
1393: #define PetscObjectTakeAccess(obj)   0
1394: #define PetscObjectGrantAccess(obj)  0
1395: #define PetscObjectDepublish(obj)    0

1397: /*
1398:       This code allows one to pass a MPI communicator between 
1399:     C and Fortran. MPI 2.0 defines a standard API for doing this.
1400:     The code here is provided to allow PETSc to work with MPI 1.1
1401:     standard MPI libraries.
1402: */
1403: EXTERN PetscErrorCode MPICCommToFortranComm(MPI_Comm,int *);
1404: EXTERN PetscErrorCode MPIFortranCommToCComm(int,MPI_Comm*);

1406: /*
1407:       Simple PETSc parallel IO for ASCII printing
1408: */
1409: EXTERN PetscErrorCode   PetscFixFilename(const char[],char[]);
1410: EXTERN PetscErrorCode   PetscFOpen(MPI_Comm,const char[],const char[],FILE**);
1411: EXTERN PetscErrorCode   PetscFClose(MPI_Comm,FILE*);
1412: EXTERN PetscErrorCode   PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
1413: EXTERN PetscErrorCode   PetscPrintf(MPI_Comm,const char[],...)  PETSC_PRINTF_FORMAT_CHECK(2,3);
1414: EXTERN PetscErrorCode   PetscSNPrintf(char*,size_t,const char [],...);

1416: /* These are used internally by PETSc ASCII IO routines*/
1417: #include <stdarg.h>
1418: EXTERN PetscErrorCode   PetscVSNPrintf(char*,size_t,const char[],va_list);
1419: EXTERN PetscErrorCode   (*PetscVFPrintf)(FILE*,const char[],va_list);
1420: EXTERN PetscErrorCode   PetscVFPrintfDefault(FILE*,const char[],va_list);

1422: /*MC
1423:     PetscErrorPrintf - Prints error messages.

1425:     Not Collective

1427:    Synopsis:
1428:      PetscErrorCode (*PetscErrorPrintf)(const char format[],...);

1430:     Input Parameters:
1431: .   format - the usual printf() format string 

1433:    Options Database Keys:
1434: +    -error_output_stdout - cause error messages to be printed to stdout instead of the
1435:          (default) stderr
1436: -    -error_output_none to turn off all printing of error messages (does not change the way the 
1437:           error is handled.)

1439:    Notes: Use
1440: $     PetscErrorPrintf = PetscErrorPrintfNone; to turn off all printing of error messages (does not change the way the 
1441: $                        error is handled.) and
1442: $     PetscErrorPrintf = PetscErrorPrintfDefault; to turn it back on

1444:           Use
1445:      PETSC_STDERR = FILE* obtained from a file open etc. to have stderr printed to the file. 
1446:      PETSC_STDOUT = FILE* obtained from a file open etc. to have stdout printed to the file. 

1448:           Use
1449:       PetscPushErrorHandler() to provide your own error handler that determines what kind of messages to print

1451:    Level: developer

1453:     Fortran Note:
1454:     This routine is not supported in Fortran.

1456:     Concepts: error messages^printing
1457:     Concepts: printing^error messages

1459: .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf(), PetscPrintf(), PetscErrorHandlerPush()
1460: M*/
1461: EXTERN  PetscErrorCode (*PetscErrorPrintf)(const char[],...);

1463: /*MC
1464:     PetscHelpPrintf - Prints help messages.

1466:     Not Collective

1468:    Synopsis:
1469:      PetscErrorCode (*PetscHelpPrintf)(const char format[],...);

1471:     Input Parameters:
1472: .   format - the usual printf() format string 

1474:    Level: developer

1476:     Fortran Note:
1477:     This routine is not supported in Fortran.

1479:     Concepts: help messages^printing
1480:     Concepts: printing^help messages

1482: .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf()
1483: M*/
1484: EXTERN  PetscErrorCode  (*PetscHelpPrintf)(MPI_Comm,const char[],...);

1486: EXTERN PetscErrorCode  PetscErrorPrintfDefault(const char [],...);
1487: EXTERN PetscErrorCode  PetscErrorPrintfNone(const char [],...);
1488: EXTERN PetscErrorCode  PetscHelpPrintfDefault(MPI_Comm,const char [],...);

1490: EXTERN PetscErrorCode   PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **);
1491: EXTERN PetscErrorCode   PetscPClose(MPI_Comm,FILE*);
1492: EXTERN PetscErrorCode   PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
1493: EXTERN PetscErrorCode   PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
1494: EXTERN PetscErrorCode   PetscSynchronizedFlush(MPI_Comm);
1495: EXTERN PetscErrorCode   PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]);
1496: EXTERN PetscErrorCode   PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**);
1497: EXTERN PetscErrorCode   PetscStartJava(MPI_Comm,const char[],const char[],FILE**);
1498: EXTERN PetscErrorCode   PetscGetPetscDir(const char*[]);

1500: EXTERN PetscErrorCode   PetscPopUpSelect(MPI_Comm,const char*,const char*,int,const char**,int*);

1502: /*S
1503:      PetscContainer - Simple PETSc object that contains a pointer to any required data

1505:    Level: advanced

1507: .seealso:  PetscObject, PetscContainerCreate()
1508: S*/
1510: typedef struct _p_PetscContainer*  PetscContainer;
1511: EXTERN PetscErrorCode  PetscContainerGetPointer(PetscContainer,void **);
1512: EXTERN PetscErrorCode  PetscContainerSetPointer(PetscContainer,void *);
1513: EXTERN PetscErrorCode  PetscContainerDestroy(PetscContainer);
1514: EXTERN PetscErrorCode  PetscContainerCreate(MPI_Comm,PetscContainer *);
1515: EXTERN PetscErrorCode  PetscContainerSetUserDestroy(PetscContainer, PetscErrorCode (*)(void*));

1517: /*
1518:    For use in debuggers 
1519: */

1523: EXTERN PetscErrorCode  PetscIntView(PetscInt,PetscInt[],PetscViewer);
1524: EXTERN PetscErrorCode  PetscRealView(PetscInt,PetscReal[],PetscViewer);
1525: EXTERN PetscErrorCode  PetscScalarView(PetscInt,PetscScalar[],PetscViewer);

1527: /*
1528:     Allows accessing Matlab Engine
1529: */
1530:  #include petscmatlab.h

1532: /*
1533:       Determine if some of the kernel computation routines use
1534:    Fortran (rather than C) for the numerical calculations. On some machines
1535:    and compilers (like complex numbers) the Fortran version of the routines
1536:    is faster than the C/C++ versions. The flag --with-fortran-kernels
1537:    should be used with config/configure.py to turn these on.
1538: */
1539: #if defined(PETSC_USE_FORTRAN_KERNELS)

1541: #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCRL)
1542: #define PETSC_USE_FORTRAN_KERNEL_MULTCRL
1543: #endif

1545: #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM)
1546: #define PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM
1547: #endif

1549: #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ)
1550: #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ
1551: #endif

1553: #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ)
1554: #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ
1555: #endif

1557: #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM)
1558: #define PETSC_USE_FORTRAN_KERNEL_NORM
1559: #endif

1561: #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY)
1562: #define PETSC_USE_FORTRAN_KERNEL_MAXPY
1563: #endif

1565: #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ)
1566: #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ
1567: #endif

1569: #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ)
1570: #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ
1571: #endif

1573: #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ)
1574: #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ
1575: #endif

1577: #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ)
1578: #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ
1579: #endif

1581: #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT)
1582: #define PETSC_USE_FORTRAN_KERNEL_MDOT
1583: #endif

1585: #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY)
1586: #define PETSC_USE_FORTRAN_KERNEL_XTIMESY
1587: #endif

1589: #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX)
1590: #define PETSC_USE_FORTRAN_KERNEL_AYPX
1591: #endif

1593: #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY)
1594: #define PETSC_USE_FORTRAN_KERNEL_WAXPY
1595: #endif

1597: #endif

1599: /*
1600:     Macros for indicating code that should be compiled with a C interface,
1601:    rather than a C++ interface. Any routines that are dynamically loaded
1602:    (such as the PCCreate_XXX() routines) must be wrapped so that the name
1603:    mangler does not change the functions symbol name. This just hides the 
1605: */
1606: #if defined(__cplusplus)
1609: #else
1612: #endif

1614: /* --------------------------------------------------------------------*/

1616: /*MC
1617:     size - integer variable used to contain the number of processors in
1618:            the relevent MPI_Comm

1620:    Level: beginner

1622: .seealso: rank, comm
1623: M*/

1625: /*MC
1626:     rank - integer variable used to contain the number of this processor relative
1627:            to all in the relevent MPI_Comm

1629:    Level: beginner

1631: .seealso: size, comm
1632: M*/

1634: /*MC
1635:     comm - MPI_Comm used in the current routine or object

1637:    Level: beginner

1639: .seealso: size, rank
1640: M*/

1642: /*MC
1643:     MPI_Comm - the basic object used by MPI to determine which processes are involved in a 
1644:         communication

1646:    Level: beginner

1648:    Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm

1650: .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF
1651: M*/

1653: /*MC
1654:     PetscScalar - PETSc type that represents either a double precision real number, a double precision
1655:        complex number, a single precision real number, a long double or an int - if the code is configured 
1656:        with --with-scalar-type=real,complex --with-precision=single,double,longdouble,int,matsingle


1659:    Level: beginner

1661: .seealso: PetscReal, PassiveReal, PassiveScalar, MPIU_SCALAR, PetscInt
1662: M*/

1664: /*MC
1665:     PetscReal - PETSc type that represents a real number version of PetscScalar

1667:    Level: beginner

1669: .seealso: PetscScalar, PassiveReal, PassiveScalar
1670: M*/

1672: /*MC
1673:     PassiveScalar - PETSc type that represents a PetscScalar
1674:    Level: beginner

1676:     This is the same as a PetscScalar except in code that is automatically differentiated it is
1677:    treated as a constant (not an indendent or dependent variable)

1679: .seealso: PetscReal, PassiveReal, PetscScalar
1680: M*/

1682: /*MC
1683:     PassiveReal - PETSc type that represents a PetscReal

1685:    Level: beginner

1687:     This is the same as a PetscReal except in code that is automatically differentiated it is
1688:    treated as a constant (not an indendent or dependent variable)

1690: .seealso: PetscScalar, PetscReal, PassiveScalar
1691: M*/

1693: /*MC
1694:     MPIU_SCALAR - MPI datatype corresponding to PetscScalar

1696:    Level: beginner

1698:     Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars
1699:           pass this value

1701: .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar, MPIU_INT
1702: M*/

1704: /*
1705:      The IBM include files define hz, here we hide it so that it may be used
1706:    as a regular user variable.
1707: */
1708: #if defined(hz)
1709: #undef hz
1710: #endif

1712: /*  For arrays that contain filenames or paths */


1715: #if defined(PETSC_HAVE_LIMITS_H)
1716: #include <limits.h>
1717: #endif
1718: #if defined(PETSC_HAVE_SYS_PARAM_H)
1719: #include <sys/param.h>
1720: #endif
1721: #if defined(PETSC_HAVE_SYS_TYPES_H)
1722: #include <sys/types.h>
1723: #endif
1724: #if defined(MAXPATHLEN)
1725: #  define PETSC_MAX_PATH_LEN     MAXPATHLEN
1726: #elif defined(MAX_PATH)
1727: #  define PETSC_MAX_PATH_LEN     MAX_PATH
1728: #elif defined(_MAX_PATH)
1729: #  define PETSC_MAX_PATH_LEN     _MAX_PATH
1730: #else
1731: #  define PETSC_MAX_PATH_LEN     4096
1732: #endif

1734: /* Special support for C++ */
1735:  #include petsc.hh

1738: #endif