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:    This facilitates using C version of PETSc from C++
     10: */

     15: #else
     18: #endif
     19: /* ========================================================================== */
     20: /*
     21:    Current PETSc version number and release date
     22: */
     23:  #include petscversion.h

     25: /* ========================================================================== */
     26: /*
     27:    petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h it is
     28:    found automatically by the compiler due to the -I${PETSC_DIR}/bmake/${PETSC_ARCH}
     29:    in the bmake/common_variables definition of PETSC_INCLUDE
     30: */
     31: #include "petscconf.h"

     33: /*
     34:    Currently cannot check formatting for PETSc print statements because we have our
     35:    own format %D
     36: */
     37: #undef  PETSC_PRINTF_FORMAT_CHECK
     38: #define PETSC_PRINTF_FORMAT_CHECK(a,b)
     39: #undef  PETSC_FPRINTF_FORMAT_CHECK
     40: #define PETSC_FPRINTF_FORMAT_CHECK(a,b)

     42: /*
     43:    Fixes for configure time choices which impact our interface. Currently only
     44:    calling conventions and extra compiler checking falls under this category.
     45: */
     46: #if !defined (PETSC_STDCALL)
     47: #define PETSC_STDCALL
     48: #endif
     49: #if !defined (PETSC_TEMPLATE)
     50: #define PETSC_TEMPLATE
     51: #endif

     53: /* ========================================================================== */

     55: #include <stdio.h>
     56: /*
     57:     Defines the interface to MPI allowing the use of all MPI functions.
     58: */
     59: #include "mpi.h"

     61: /*
     62:     All PETSc C functions return this error code, it is the final argument of
     63:    all Fortran subroutines
     64: */
     65: typedef int PetscErrorCode;
     66: typedef int PetscCookie;
     67: typedef int PetscEvent;
     68: typedef int PetscBLASInt;
     69: typedef int PetscMPIInt;

     71: #if defined(PETSC_USE_64BIT_INT)
     72: typedef long long PetscInt;
     73: #define MPIU_INT MPI_LONG_LONG_INT
     74: #else
     75: typedef int PetscInt;
     76: #define MPIU_INT MPI_INT
     77: #endif

     79: /*
     81: */

     85: /*
     86:     EXTERN indicates a PETSc function defined elsewhere
     87: */
     88: #if !defined(EXTERN)
     89: #define EXTERN extern
     90: #endif

     92: /*
     93:     Defines some elementary mathematics functions and constants.
     94: */
     95:  #include petscmath.h

     97: /*
     98:        Basic PETSc constants
     99: */

    101: /*E
    102:     PetscTruth - Logical variable. Actually an integer

    104:    Level: beginner

    106: E*/
    107: typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth;

    109: /*M
    110:     PETSC_FALSE - False value of PetscTruth

    112:     Level: beginner

    114:     Note: Zero integer

    116: .seealso: PetscTruth
    117: M*/

    119: /*M
    120:     PETSC_TRUE - True value of PetscTruth

    122:     Level: beginner

    124:     Note: Nonzero integer

    126: .seealso: PetscTruth
    127: M*/

    129: /*M
    130:     PETSC_YES - Alias for PETSC_TRUE

    132:     Level: beginner

    134:     Note: Zero integer

    136: .seealso: PetscTruth
    137: M*/

    139: /*M
    140:     PETSC_NO - Alias for PETSC_FALSE

    142:     Level: beginner

    144:     Note: Nonzero integer

    146: .seealso: PetscTruth
    147: M*/

    149: /*M
    150:     PETSC_NULL - standard way of passing in a null or array or pointer

    152:    Level: beginner

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

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

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

    162: M*/
    163: #define PETSC_NULL           0

    165: /*M
    166:     PETSC_DECIDE - standard way of passing in integer or floating point parameter
    167:        where you wish PETSc to use the default.

    169:    Level: beginner

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

    173: M*/
    174: #define PETSC_DECIDE         -1

    176: /*M
    177:     PETSC_DEFAULT - standard way of passing in integer or floating point parameter
    178:        where you wish PETSc to use the default.

    180:    Level: beginner

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

    184: M*/
    185: #define PETSC_DEFAULT        -2

    187: #define PETSC_YES            PETSC_TRUE
    188: #define PETSC_NO             PETSC_FALSE

    190: /*M
    191:     PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument

    193:    Level: beginner

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

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

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

    203: M*/
    204: #define PETSC_IGNORE         PETSC_NULL

    206: /*M
    207:     PETSC_DETERMINE - standard way of passing in integer or floating point parameter
    208:        where you wish PETSc to compute the required value.

    210:    Level: beginner

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

    214: M*/
    215: #define PETSC_DETERMINE      PETSC_DECIDE

    217: /*M
    218:     PETSC_COMM_WORLD - a duplicate of the MPI_COMM_WORLD communicator which represents
    219:            all the processs

    221:    Level: beginner

    223:    Notes: PETSC_COMM_WORLD and MPI_COMM_WORLD are equivalent except that passing MPI_COMM_WORLD
    224:           into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup()
    225:           will be done on it internally. We recommend always using PETSC_COMM_WORLD

    227: .seealso: PETSC_COMM_SELF

    229: M*/

    232: /*M
    233:     PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents
    234:            the current process

    236:    Level: beginner

    238:    Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent except that passint MPI_COMM_SELF
    239:           into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup()
    240:           will be done on it internally. We recommend always using PETSC_COMM_SELF

    242: .seealso: PETSC_COMM_WORLD

    244: M*/

    248: EXTERN PetscErrorCode        PetscSetCommWorld(MPI_Comm);
    249: EXTERN PetscErrorCode        PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm));
    250: EXTERN PetscErrorCode        PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*);
    251: EXTERN PetscErrorCode        PetscCommDestroy(MPI_Comm*);

    253: /*MC
    254:    PetscMalloc - Allocates memory

    256:    Input Parameter:
    257: .  m - number of bytes to allocate

    259:    Output Parameter:
    260: .  result - memory allocated

    262:    Synopsis:
    263:    PetscErrorCode PetscMalloc(size_t m,void **result)

    265:    Level: beginner

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

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

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

    274:   Concepts: memory allocation

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

    279: /*MC
    280:    PetscMalloc2 - Allocates 2 chunks of  memory

    282:    Input Parameter:
    283: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
    284: .  t1 - type of first memory elements
    285: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
    286: -  t2 - type of second memory elements

    288:    Output Parameter:
    289: +  r1 - memory allocated in first chunk
    290: -  r2 - memory allocated in second chunk

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

    295:    Level: developer

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

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

    301:   Concepts: memory allocation

    303: M*/
    304: #if defined(PETSC_USE_BOPT_g)
    305: #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2))
    306: #else
    307: #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2),r1) || (*(r2) = (t2*)(*(r1)+m1),0))
    308: #endif

    310: /*MC
    311:    PetscMalloc3 - Allocates 3 chunks of  memory

    313:    Input Parameter:
    314: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
    315: .  t1 - type of first memory elements
    316: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
    317: .  t2 - type of second memory elements
    318: .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
    319: -  t3 - type of third memory elements

    321:    Output Parameter:
    322: +  r1 - memory allocated in first chunk
    323: .  r2 - memory allocated in second chunk
    324: -  r3 - memory allocated in third chunk

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

    329:    Level: developer

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

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

    335:   Concepts: memory allocation

    337: M*/
    338: #if defined(PETSC_USE_BOPT_g)
    339: #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3))
    340: #else
    341: #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),0))
    342: #endif

    344: /*MC
    345:    PetscMalloc4 - Allocates 4 chunks of  memory

    347:    Input Parameter:
    348: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
    349: .  t1 - type of first memory elements
    350: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
    351: .  t2 - type of second memory elements
    352: .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
    353: .  t3 - type of third memory elements
    354: .  m4 - number of elements to allocate in 4th chunk  (may be zero)
    355: -  t4 - type of fourth memory elements

    357:    Output Parameter:
    358: +  r1 - memory allocated in first chunk
    359: .  r2 - memory allocated in second chunk
    360: .  r3 - memory allocated in third chunk
    361: -  r4 - memory allocated in fourth chunk

    363:    Synopsis:
    364:    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)

    366:    Level: developer

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

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

    372:   Concepts: memory allocation

    374: M*/
    375: #if defined(PETSC_USE_BOPT_g)
    376: #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4))
    377: #else
    378: #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),0))
    379: #endif

    381: /*MC
    382:    PetscMalloc5 - Allocates 5 chunks of  memory

    384:    Input Parameter:
    385: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
    386: .  t1 - type of first memory elements
    387: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
    388: .  t2 - type of second memory elements
    389: .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
    390: .  t3 - type of third memory elements
    391: .  m4 - number of elements to allocate in 4th chunk  (may be zero)
    392: .  t4 - type of fourth memory elements
    393: .  m5 - number of elements to allocate in 5th chunk  (may be zero)
    394: -  t5 - type of fifth memory elements

    396:    Output Parameter:
    397: +  r1 - memory allocated in first chunk
    398: .  r2 - memory allocated in second chunk
    399: .  r3 - memory allocated in third chunk
    400: .  r4 - memory allocated in fourth chunk
    401: -  r5 - memory allocated in fifth chunk

    403:    Synopsis:
    404:    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)

    406:    Level: developer

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

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

    412:   Concepts: memory allocation

    414: M*/
    415: #if defined(PETSC_USE_BOPT_g)
    416: #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))
    417: #else
    418: #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))
    419: #endif

    422: /*MC
    423:    PetscMalloc6 - Allocates 6 chunks of  memory

    425:    Input Parameter:
    426: +  m1 - number of elements to allocate in 1st chunk  (may be zero)
    427: .  t1 - type of first memory elements
    428: .  m2 - number of elements to allocate in 2nd chunk  (may be zero)
    429: .  t2 - type of second memory elements
    430: .  m3 - number of elements to allocate in 3rd chunk  (may be zero)
    431: .  t3 - type of third memory elements
    432: .  m4 - number of elements to allocate in 4th chunk  (may be zero)
    433: .  t4 - type of fourth memory elements
    434: .  m5 - number of elements to allocate in 5th chunk  (may be zero)
    435: .  t5 - type of fifth memory elements
    436: .  m6 - number of elements to allocate in 6th chunk  (may be zero)
    437: -  t6 - type of sixth memory elements

    439:    Output Parameter:
    440: +  r1 - memory allocated in first chunk
    441: .  r2 - memory allocated in second chunk
    442: .  r3 - memory allocated in third chunk
    443: .  r4 - memory allocated in fourth chunk
    444: .  r5 - memory allocated in fifth chunk
    445: -  r6 - memory allocated in sixth chunk

    447:    Synopsis:
    448:    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)

    450:    Level: developer

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

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

    456:   Concepts: memory allocation

    458: M*/
    459: #if defined(PETSC_USE_BOPT_g)
    460: #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))
    461: #else
    462: #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))
    463: #endif

    465: /*MC
    466:    PetscNew - Allocates memory of a particular type

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

    471:    Output Parameter:
    472: .  result - memory allocated

    474:    Synopsis:
    475:    PetscErrorCode PetscNew(struct type,((type *))result)

    477:    Level: beginner

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

    481:   Concepts: memory allocation

    483: M*/
    484: #define PetscNew(A,b)        PetscMalloc(sizeof(A),(b))

    486: /*MC
    487:    PetscFree - Frees memory

    489:    Input Parameter:
    490: .   memory - memory to free

    492:    Synopsis:
    493:    PetscErrorCode PetscFree(void *memory)

    495:    Level: beginner

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

    499: .seealso: PetscNew(), PetscMalloc()

    501:   Concepts: memory allocation

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

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

    509:    Input Parameter:
    510: +   memory1 - memory to free
    511: -   memory2 - 2nd memory to free

    514:    Synopsis:
    515:    PetscErrorCode PetscFree2(void *memory1,void *memory2)

    517:    Level: developer

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

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

    523:   Concepts: memory allocation

    525: M*/
    526: #if defined(PETSC_USE_BOPT_g)
    527: #define PetscFree2(m1,m2)   (PetscFree(m2) || PetscFree(m1))
    528: #else
    529: #define PetscFree2(m1,m2)   (PetscFree(m1))
    530: #endif

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

    535:    Input Parameter:
    536: +   memory1 - memory to free
    537: .   memory2 - 2nd memory to free
    538: -   memory3 - 3rd memory to free

    541:    Synopsis:
    542:    PetscErrorCode PetscFree3(void *memory1,void *memory2,void *memory3)

    544:    Level: developer

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

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

    550:   Concepts: memory allocation

    552: M*/
    553: #if defined(PETSC_USE_BOPT_g)
    554: #define PetscFree3(m1,m2,m3)   (PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
    555: #else
    556: #define PetscFree3(m1,m2,m3)   (PetscFree(m1))
    557: #endif

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

    562:    Input Parameter:
    563: +   m1 - memory to free
    564: .   m2 - 2nd memory to free
    565: .   m3 - 3rd memory to free
    566: -   m4 - 4th memory to free

    569:    Synopsis:
    570:    PetscErrorCode PetscFree4(void *m1,void *m2,void *m3,void *m4)

    572:    Level: developer

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

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

    578:   Concepts: memory allocation

    580: M*/
    581: #if defined(PETSC_USE_BOPT_g)
    582: #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
    583: #else
    584: #define PetscFree4(m1,m2,m3,m4)   (PetscFree(m1))
    585: #endif

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

    590:    Input Parameter:
    591: +   m1 - memory to free
    592: .   m2 - 2nd memory to free
    593: .   m3 - 3rd memory to free
    594: .   m4 - 4th memory to free
    595: -   m5 - 5th memory to free

    598:    Synopsis:
    599:    PetscErrorCode PetscFree5(void *m1,void *m2,void *m3,void *m4,void *m5)

    601:    Level: developer

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

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

    607:   Concepts: memory allocation

    609: M*/
    610: #if defined(PETSC_USE_BOPT_g)
    611: #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
    612: #else
    613: #define PetscFree5(m1,m2,m3,m4,m5)   (PetscFree(m1))
    614: #endif

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

    620:    Input Parameter:
    621: +   m1 - memory to free
    622: .   m2 - 2nd memory to free
    623: .   m3 - 3rd memory to free
    624: .   m4 - 4th memory to free
    625: .   m5 - 5th memory to free
    626: -   m6 - 6th memory to free

    629:    Synopsis:
    630:    PetscErrorCode PetscFree6(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6)

    632:    Level: developer

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

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

    638:   Concepts: memory allocation

    640: M*/
    641: #if defined(PETSC_USE_BOPT_g)
    642: #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1))
    643: #else
    644: #define PetscFree6(m1,m2,m3,m4,m5,m6)   (PetscFree(m1))
    645: #endif

    647: EXTERN PetscErrorCode  (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**);
    648: EXTERN PetscErrorCode  (*PetscTrFree)(void*,int,const char[],const char[],const char[]);
    649: EXTERN PetscErrorCode  PetscSetMalloc(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[]));
    650: EXTERN PetscErrorCode  PetscClearMalloc(void);

    652: /*
    653:    Routines for tracing memory corruption/bleeding with default PETSc
    654:    memory allocation
    655: */
    656: EXTERN PetscErrorCode   PetscTrDump(FILE *);
    657: EXTERN PetscErrorCode   PetscTrSpace(PetscLogDouble *,PetscLogDouble *,PetscLogDouble *);
    658: EXTERN PetscErrorCode   PetscTrValid(int,const char[],const char[],const char[]);
    659: EXTERN PetscErrorCode   PetscTrDebug(PetscTruth);
    660: EXTERN PetscErrorCode   PetscTrLog(void);
    661: EXTERN PetscErrorCode   PetscTrLogDump(FILE *);
    662: EXTERN PetscErrorCode   PetscGetResidentSetSize(PetscLogDouble *);

    664: /*
    665:     Variable type where we stash PETSc object pointers in Fortran.
    666:     Assumes that sizeof(long) == sizeof(void*)which is true on
    667:     all machines that we know.
    668: */
    669: #define PetscFortranAddr   long

    671: /*E
    672:     PetscDataType - Used for handling different basic data types.

    674:    Level: beginner

    676: .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(),
    677:           PetscDataTypeGetSize(), PetscDataTypeGetName()

    679: E*/
    680: typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2,
    681:               PETSC_LONG = 3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5,
    682:               PETSC_CHAR = 6,PETSC_LOGICAL = 7} PetscDataType;
    683: #if defined(PETSC_USE_COMPLEX)
    684: #define PETSC_SCALAR PETSC_COMPLEX
    685: #else
    686: #if defined(PETSC_USE_SINGLE)
    687: #define PETSC_SCALAR PETSC_FLOAT
    688: #else
    689: #define PETSC_SCALAR PETSC_DOUBLE
    690: #endif
    691: #endif
    692: #if defined(PETSC_USE_SINGLE)
    693: #define PETSC_REAL PETSC_FLOAT
    694: #else
    695: #define PETSC_REAL PETSC_DOUBLE
    696: #endif
    697: #define PETSC_FORTRANADDR PETSC_LONG

    699: EXTERN PetscErrorCode PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
    700: EXTERN PetscErrorCode PetscDataTypeGetSize(PetscDataType,PetscInt*);
    701: EXTERN PetscErrorCode PetscDataTypeGetName(PetscDataType,const char*[]);

    703: /*
    704:     Basic memory and string operations. These are usually simple wrappers
    705:    around the basic Unix system calls, but a few of them have additional
    706:    functionality and/or error checking.
    707: */
    708: EXTERN PetscErrorCode   PetscMemcpy(void*,const void *,size_t);
    709: EXTERN PetscErrorCode   PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType);
    710: EXTERN PetscErrorCode   PetscMemmove(void*,void *,size_t);
    711: EXTERN PetscErrorCode   PetscMemzero(void*,size_t);
    712: EXTERN PetscErrorCode   PetscMemcmp(const void*,const void*,size_t,PetscTruth *);
    713: EXTERN PetscErrorCode   PetscStrlen(const char[],size_t*);
    714: EXTERN PetscErrorCode   PetscStrcmp(const char[],const char[],PetscTruth *);
    715: EXTERN PetscErrorCode   PetscStrgrt(const char[],const char[],PetscTruth *);
    716: EXTERN PetscErrorCode   PetscStrcasecmp(const char[],const char[],PetscTruth*);
    717: EXTERN PetscErrorCode   PetscStrncmp(const char[],const char[],size_t,PetscTruth*);
    718: EXTERN PetscErrorCode   PetscStrcpy(char[],const char[]);
    719: EXTERN PetscErrorCode   PetscStrcat(char[],const char[]);
    720: EXTERN PetscErrorCode   PetscStrncat(char[],const char[],size_t);
    721: EXTERN PetscErrorCode   PetscStrncpy(char[],const char[],size_t);
    722: EXTERN PetscErrorCode   PetscStrchr(const char[],char,char *[]);
    723: EXTERN PetscErrorCode   PetscStrtolower(char[]);
    724: EXTERN PetscErrorCode   PetscStrrchr(const char[],char,char *[]);
    725: EXTERN PetscErrorCode   PetscStrstr(const char[],const char[],char *[]);
    726: EXTERN PetscErrorCode   PetscStrallocpy(const char[],char *[]);
    727: EXTERN PetscErrorCode   PetscStrreplace(MPI_Comm,const char[],char[],size_t);
    728: #define      PetscStrfree(a) ((a) ? PetscFree(a) : 0)
    729: /*S
    730:     PetscToken - 'Token' used for managing tokenizing strings

    732:   Level: intermediate

    734: .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy()
    735: S*/
    736: typedef struct {char token;char *array;char *current;} PetscToken;

    738: EXTERN PetscErrorCode   PetscTokenCreate(const char[],const char,PetscToken**);
    739: EXTERN PetscErrorCode   PetscTokenFind(PetscToken*,char *[]);
    740: EXTERN PetscErrorCode   PetscTokenDestroy(PetscToken*);

    742: /*
    743:    These are  MPI operations for MPI_Allreduce() etc
    744: */
    745: EXTERN MPI_Op PetscMaxSum_Op;
    746: #if defined(PETSC_USE_COMPLEX)
    747: EXTERN MPI_Op PetscSum_Op;
    748: #else
    749: #define PetscSum_Op MPI_SUM
    750: #endif
    751: EXTERN PetscErrorCode PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*);

    753: /*S
    754:      PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc

    756:    Level: beginner

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

    760: .seealso:  PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName()
    761: S*/
    762: typedef struct _p_PetscObject* PetscObject;

    764: /*S
    765:      PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed
    766:       by string name

    768:    Level: advanced

    770: .seealso:  PetscFListAdd(), PetscFListDestroy()
    771: S*/
    772: typedef struct _PetscFList *PetscFList;

    774:  #include petscviewer.h
    775:  #include petscoptions.h

    777: EXTERN PetscErrorCode PetscLogInfoAllow(PetscTruth,const char []);
    778: EXTERN PetscErrorCode PetscShowMemoryUsage(PetscViewer,const char[]);
    779: EXTERN PetscErrorCode PetscGetTime(PetscLogDouble*);
    780: EXTERN PetscErrorCode PetscGetCPUTime(PetscLogDouble*);
    781: EXTERN PetscErrorCode PetscSleep(int);

    783: /*
    784:     Initialization of PETSc
    785: */
    786: EXTERN PetscErrorCode  PetscInitialize(int*,char***,const char[],const char[]);
    787: EXTERN PetscErrorCode  PetscInitializeNoArguments(void);
    788: EXTERN PetscErrorCode  PetscInitialized(PetscTruth *);
    789: EXTERN PetscErrorCode  PetscFinalize(void);
    790: EXTERN PetscErrorCode  PetscInitializeFortran(void);
    791: EXTERN PetscErrorCode  PetscGetArgs(int*,char ***);
    792: EXTERN PetscErrorCode  PetscEnd(void);

    794: typedef void (**PetscVoidFunction)(void);

    796: /*
    797:    PetscTryMethod - Queries an object for a method, if it exists then calls it.
    798:               These are intended to be used only inside PETSc functions.
    799: */
    800: #define  PetscTryMethod(obj,A,B,C) \
    801:   0;{ PetscErrorCode (*f)B, __ierr; \
    802:     __PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \
    803:     if (f) {__(*f)C;CHKERRQ(__ierr);}\
    804:   }
    805: #define  PetscUseMethod(obj,A,B,C) \
    806:   0;{ PetscErrorCode (*f)B, __ierr; \
    807:     __PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \
    808:     if (f) {__(*f)C;CHKERRQ(__ierr);}\
    809:     else {SETERRQ1(PETSC_ERR_SUP,"Cannot locate function %s in object",A);} \
    810:   }
    811: /*
    812:     Functions that can act on any PETSc object.
    813: */
    814: EXTERN PetscErrorCode PetscObjectDestroy(PetscObject);
    815: EXTERN PetscErrorCode PetscObjectExists(PetscObject,PetscTruth*);
    816: EXTERN PetscErrorCode PetscObjectGetComm(PetscObject,MPI_Comm *);
    817: EXTERN PetscErrorCode PetscObjectGetCookie(PetscObject,int *);
    818: EXTERN PetscErrorCode PetscObjectGetType(PetscObject,int *);
    819: EXTERN PetscErrorCode PetscObjectSetName(PetscObject,const char[]);
    820: EXTERN PetscErrorCode PetscObjectGetName(PetscObject,char*[]);
    821: EXTERN PetscErrorCode PetscObjectReference(PetscObject);
    822: EXTERN PetscErrorCode PetscObjectGetReference(PetscObject,PetscInt*);
    823: EXTERN PetscErrorCode PetscObjectDereference(PetscObject);
    824: EXTERN PetscErrorCode PetscObjectGetNewTag(PetscObject,PetscMPIInt *);
    825: EXTERN PetscErrorCode PetscCommGetNewTag(MPI_Comm,PetscMPIInt *);
    826: EXTERN PetscErrorCode PetscObjectView(PetscObject,PetscViewer);
    827: EXTERN PetscErrorCode PetscObjectCompose(PetscObject,const char[],PetscObject);
    828: EXTERN PetscErrorCode PetscObjectQuery(PetscObject,const char[],PetscObject *);
    829: EXTERN PetscErrorCode PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void));

    833: /*MC
    834:    PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object.
    835:
    836:    Collective on PetscObject

    838:    Input Parameters:
    839: +  obj - the PETSc object; this must be cast with a (PetscObject), for example,
    840:          PetscObjectCompose((PetscObject)mat,...);
    841: .  name - name associated with the child function
    842: .  fname - name of the function
    843: -  ptr - function pointer (or PETSC_NULL if using dynamic libraries)

    845:    Level: advanced

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

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

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

    857:    work in C++/complex with dynamic link libraries (PETSC_USE_DYNAMIC_LIBRARIES)
    858:    enabled.

    860:    Concepts: objects^composing functions
    861:    Concepts: composing functions
    862:    Concepts: functions^querying
    863:    Concepts: objects^querying
    864:    Concepts: querying objects

    866: .seealso: PetscObjectQueryFunction()
    867: M*/
    868: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    869: #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0)
    870: #else
    871: #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(FCNVOID)(d))
    872: #endif

    874: EXTERN PetscErrorCode PetscObjectQueryFunction(PetscObject,const char[],void (**)(void));
    875: EXTERN PetscErrorCode PetscObjectSetOptionsPrefix(PetscObject,const char[]);
    876: EXTERN PetscErrorCode PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
    877: EXTERN PetscErrorCode PetscObjectPrependOptionsPrefix(PetscObject,const char[]);
    878: EXTERN PetscErrorCode PetscObjectGetOptionsPrefix(PetscObject,char*[]);
    879: EXTERN PetscErrorCode PetscObjectPublish(PetscObject);
    880: EXTERN PetscErrorCode PetscObjectChangeTypeName(PetscObject,const char[]);
    881: EXTERN PetscErrorCode PetscObjectRegisterDestroy(PetscObject);
    882: EXTERN PetscErrorCode PetscObjectRegisterDestroyAll(void);
    883: EXTERN PetscErrorCode PetscObjectName(PetscObject);
    884: EXTERN PetscErrorCode PetscTypeCompare(PetscObject,const char[],PetscTruth*);

    886: /*
    887:     Defines PETSc error handling.
    888: */
    889:  #include petscerror.h

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

    894:    Level: advanced

    896: .seealso:  PetscOListAdd(), PetscOListDestroy(), PetscOListFind()
    897: S*/
    898: typedef struct _PetscOList *PetscOList;

    900: EXTERN PetscErrorCode PetscOListDestroy(PetscOList *);
    901: EXTERN PetscErrorCode PetscOListFind(PetscOList,const char[],PetscObject*);
    902: EXTERN PetscErrorCode PetscOListReverseFind(PetscOList,PetscObject,char**);
    903: EXTERN PetscErrorCode PetscOListAdd(PetscOList *,const char[],PetscObject);
    904: EXTERN PetscErrorCode PetscOListDuplicate(PetscOList,PetscOList *);

    906: /*
    907:     Dynamic library lists. Lists of names of routines in dynamic
    908:   link libraries that will be loaded as needed.
    909: */
    910: EXTERN PetscErrorCode PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void));
    911: EXTERN PetscErrorCode PetscFListDestroy(PetscFList*);
    912: EXTERN PetscErrorCode PetscFListFind(MPI_Comm,PetscFList,const char[],void (**)(void));
    913: EXTERN PetscErrorCode PetscFListPrintTypes(MPI_Comm,FILE*,const char[],const char[],const char[],const char[],PetscFList);
    914: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    915: #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0)
    916: #else
    917: #define    PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c)
    918: #endif
    919: EXTERN PetscErrorCode PetscFListDuplicate(PetscFList,PetscFList *);
    920: EXTERN PetscErrorCode PetscFListView(PetscFList,PetscViewer);
    921: EXTERN PetscErrorCode PetscFListConcat(const char [],const char [],char []);
    922: EXTERN PetscErrorCode PetscFListGet(PetscFList,char ***,int*);

    924: /*S
    925:      PetscDLLibraryList - Linked list of dynamics libraries to search for functions

    927:    Level: advanced

    929:    PETSC_USE_DYNAMIC_LIBRARIES must be defined in petscconf.h to use dynamic libraries

    931: .seealso:  PetscDLLibraryOpen()
    932: S*/
    933: typedef struct _PetscDLLibraryList *PetscDLLibraryList;
    935: EXTERN PetscErrorCode PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *);
    936: EXTERN PetscErrorCode PetscDLLibraryOpen(MPI_Comm,const char[],void **);
    937: EXTERN PetscErrorCode PetscDLLibrarySym(MPI_Comm,PetscDLLibraryList *,const char[],const char[],void **);
    938: EXTERN PetscErrorCode PetscDLLibraryAppend(MPI_Comm,PetscDLLibraryList *,const char[]);
    939: EXTERN PetscErrorCode PetscDLLibraryPrepend(MPI_Comm,PetscDLLibraryList *,const char[]);
    940: EXTERN PetscErrorCode PetscDLLibraryClose(PetscDLLibraryList);
    941: EXTERN PetscErrorCode PetscDLLibraryPrintPath(void);
    942: EXTERN PetscErrorCode PetscDLLibraryGetInfo(void*,const char[],const char *[]);

    944: /*
    945:     Mechanism for translating PETSc object representations between languages
    946:     Not currently used.
    947: */
    948: typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage;
    949: #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C
    950: EXTERN PetscErrorCode PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *);
    951: EXTERN PetscErrorCode PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **);

    953: /*
    954:      Useful utility routines
    955: */
    956: EXTERN PetscErrorCode PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*);
    957: EXTERN PetscErrorCode PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*);
    958: EXTERN PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt);
    959: EXTERN PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt);
    960: EXTERN PetscErrorCode PetscBarrier(PetscObject);
    961: EXTERN PetscErrorCode PetscMPIDump(FILE*);

    963: #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE)
    964: /*
    965:     Defines basic graphics available from PETSc.
    966: */
    967:  #include petscdraw.h

    969: /*
    970:     Defines the base data structures for all PETSc objects
    971: */
    972:  #include petschead.h

    974: /*
    975:      Defines PETSc profiling.
    976: */
    977:  #include petsclog.h

    979: /*
    980:           For locking, unlocking and destroying AMS memories associated with
    981:     PETSc objects. Not currently used.
    982: */
    983: #define PetscPublishAll(v)           0
    984: #define PetscObjectTakeAccess(obj)   0
    985: #define PetscObjectGrantAccess(obj)  0
    986: #define PetscObjectDepublish(obj)    0

    990: /*
    991:       This code allows one to pass a MPI communicator between
    992:     C and Fortran. MPI 2.0 defines a standard API for doing this.
    993:     The code here is provided to allow PETSc to work with MPI 1.1
    994:     standard MPI libraries.
    995: */
    996: EXTERN PetscErrorCode  MPICCommToFortranComm(MPI_Comm,int *);
    997: EXTERN PetscErrorCode  MPIFortranCommToCComm(int,MPI_Comm*);

    999: /*
    1000:       Simple PETSc parallel IO for ASCII printing
    1001: */
    1002: EXTERN PetscErrorCode  PetscFixFilename(const char[],char[]);
    1003: EXTERN PetscErrorCode  PetscFOpen(MPI_Comm,const char[],const char[],FILE**);
    1004: EXTERN PetscErrorCode  PetscFClose(MPI_Comm,FILE*);
    1005: EXTERN PetscErrorCode  PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
    1006: EXTERN PetscErrorCode  PetscPrintf(MPI_Comm,const char[],...)  PETSC_PRINTF_FORMAT_CHECK(2,3);

    1008: /* These are used internally by PETSc ASCII IO routines*/
    1009: #include <stdarg.h>
    1010: EXTERN PetscErrorCode  PetscVSNPrintf(char*,size_t,const char*,va_list);
    1011: EXTERN PetscErrorCode  PetscVFPrintf(FILE*,const char*,va_list);

    1013: /*MC
    1014:     PetscErrorPrintf - Prints error messages.

    1016:     Not Collective

    1018:    Synopsis:
    1019:      PetscErrorCode (*PetscErrorPrintf)(const char format[],...);

    1021:     Input Parameters:
    1022: .   format - the usual printf() format string

    1024:    Options Database Keys:
    1025: .    -error_output_stderr - cause error messages to be printed to stderr instead of the
    1026:          (default) stdout

    1029:    Level: developer

    1031:     Fortran Note:
    1032:     This routine is not supported in Fortran.

    1034:     Concepts: error messages^printing
    1035:     Concepts: printing^error messages

    1037: .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf()
    1038: M*/
    1039: EXTERN PetscErrorCode  (*PetscErrorPrintf)(const char[],...);

    1041: /*MC
    1042:     PetscHelpPrintf - Prints help messages.

    1044:     Not Collective

    1046:    Synopsis:
    1047:      PetscErrorCode (*PetscHelpPrintf)(const char format[],...);

    1049:     Input Parameters:
    1050: .   format - the usual printf() format string

    1052:    Level: developer

    1054:     Fortran Note:
    1055:     This routine is not supported in Fortran.

    1057:     Concepts: help messages^printing
    1058:     Concepts: printing^help messages

    1060: .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf()
    1061: M*/
    1062: EXTERN PetscErrorCode  (*PetscHelpPrintf)(MPI_Comm,const char[],...);

    1064: EXTERN PetscErrorCode  PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **);
    1065: EXTERN PetscErrorCode  PetscPClose(MPI_Comm,FILE*);
    1066: EXTERN PetscErrorCode  PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
    1067: EXTERN PetscErrorCode  PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
    1068: EXTERN PetscErrorCode  PetscSynchronizedFlush(MPI_Comm);
    1069: EXTERN PetscErrorCode  PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]);
    1070: EXTERN PetscErrorCode  PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**);
    1071: EXTERN PetscErrorCode  PetscStartJava(MPI_Comm,const char[],const char[],FILE**);
    1072: EXTERN PetscErrorCode  PetscGetPetscDir(const char*[]);

    1074: EXTERN PetscErrorCode  PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*);
    1075: /*S
    1076:      PetscObjectContainer - Simple PETSc object that contains a pointer to any required data

    1078:    Level: advanced

    1080: .seealso:  PetscObject, PetscObjectContainerCreate()
    1081: S*/
    1082: typedef struct _p_PetscObjectContainer*  PetscObjectContainer;
    1083: EXTERN PetscErrorCode PetscObjectContainerGetPointer(PetscObjectContainer,void **);
    1084: EXTERN PetscErrorCode PetscObjectContainerSetPointer(PetscObjectContainer,void *);
    1085: EXTERN PetscErrorCode PetscObjectContainerDestroy(PetscObjectContainer);
    1086: EXTERN PetscErrorCode PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *);

    1088: /*
    1089:    For incremental debugging
    1090: */
    1092: EXTERN PetscErrorCode        PetscCompareDouble(double);
    1093: EXTERN PetscErrorCode        PetscCompareScalar(PetscScalar);
    1094: EXTERN PetscErrorCode        PetscCompareInt(PetscInt);

    1096: /*
    1097:    For use in debuggers
    1098: */
    1100: EXTERN PetscErrorCode PetscIntView(PetscInt,PetscInt[],PetscViewer);
    1101: EXTERN PetscErrorCode PetscRealView(PetscInt,PetscReal[],PetscViewer);
    1102: EXTERN PetscErrorCode PetscScalarView(PetscInt,PetscScalar[],PetscViewer);

    1104: /*
    1105:     Allows accessing Matlab Engine
    1106: */
    1107:  #include petscmatlab.h

    1109: /*
    1110:     C code optimization is often enhanced by telling the compiler
    1111:   that certain pointer arguments to functions are not aliased to
    1112:   to other arguments. This is not yet ANSI C standard so we define
    1113:   the macro "restrict" to indicate that the variable is not aliased
    1114:   to any other argument.
    1115: */
    1116: #if defined(PETSC_HAVE_RESTRICT) && !defined(__cplusplus)
    1117: #define restrict _Restrict
    1118: #else
    1119: #if defined(restrict)
    1120: #undef restrict
    1121: #endif
    1122: #define restrict
    1123: #endif

    1125: /*
    1126:       Determine if some of the kernel computation routines use
    1127:    Fortran (rather than C) for the numerical calculations. On some machines
    1128:    and compilers (like complex numbers) the Fortran version of the routines
    1129:    is faster than the C/C++ versions. The flag PETSC_USE_FORTRAN_KERNELS
    1130:    would be set in the petscconf.h file
    1131: */
    1132: #if defined(PETSC_USE_FORTRAN_KERNELS)

    1134: #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ)
    1135: #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ
    1136: #endif

    1138: #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ)
    1139: #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ
    1140: #endif

    1142: #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM)
    1143: #define PETSC_USE_FORTRAN_KERNEL_NORM
    1144: #endif

    1146: #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY)
    1147: #define PETSC_USE_FORTRAN_KERNEL_MAXPY
    1148: #endif

    1150: #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ)
    1151: #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ
    1152: #endif

    1154: #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ)
    1155: #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ
    1156: #endif

    1158: #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ)
    1159: #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ
    1160: #endif

    1162: #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ)
    1163: #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ
    1164: #endif

    1166: #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT)
    1167: #define PETSC_USE_FORTRAN_KERNEL_MDOT
    1168: #endif

    1170: #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY)
    1171: #define PETSC_USE_FORTRAN_KERNEL_XTIMESY
    1172: #endif

    1174: #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX)
    1175: #define PETSC_USE_FORTRAN_KERNEL_AYPX
    1176: #endif

    1178: #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY)
    1179: #define PETSC_USE_FORTRAN_KERNEL_WAXPY
    1180: #endif

    1182: #endif

    1184: /*
    1185:     Macros for indicating code that should be compiled with a C interface,
    1186:    rather than a C++ interface. Any routines that are dynamically loaded
    1187:    (such as the PCCreate_XXX() routines) must be wrapped so that the name
    1188:    mangler does not change the functions symbol name. This just hides the
    1190: */
    1191: #if defined(__cplusplus)
    1194: #else
    1197: #endif

    1199: /* --------------------------------------------------------------------*/

    1201: /*M
    1202:     size - integer variable used to contain the number of processors in
    1203:            the relevent MPI_Comm

    1205:    Level: beginner

    1207: .seealso: rank, comm
    1208: M*/

    1210: /*M
    1211:     rank - integer variable used to contain the number of this processor relative
    1212:            to all in the relevent MPI_Comm

    1214:    Level: beginner

    1216: .seealso: size, comm
    1217: M*/

    1219: /*M
    1220:     comm - MPI_Comm used in the current routine or object

    1222:    Level: beginner

    1224: .seealso: size, rank
    1225: M*/

    1227: /*M
    1228:     MPI_Comm - the basic object used by MPI to determine which processes are involved in a
    1229:         communication

    1231:    Level: beginner

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

    1235: .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF
    1236: M*/

    1238: /*M
    1239:     PetscScalar - PETSc type that represents either a double precision real number or
    1240:        a double precision complex number if the code is compiled with BOPT=g_complex or O_complex

    1242:    Level: beginner

    1244: .seealso: PetscReal, PassiveReal, PassiveScalar
    1245: M*/

    1247: /*M
    1248:     PetscReal - PETSc type that represents a double precision real number

    1250:    Level: beginner

    1252: .seealso: PetscScalar, PassiveReal, PassiveScalar
    1253: M*/

    1255: /*M
    1256:     PassiveScalar - PETSc type that represents either a double precision real number or
    1257:        a double precision complex number if the code is compiled with BOPT=g_complex or O_complex

    1259:    Level: beginner

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

    1264: .seealso: PetscReal, PassiveReal, PetscScalar
    1265: M*/

    1267: /*M
    1268:     PassiveReal - PETSc type that represents a double precision real number

    1270:    Level: beginner

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

    1275: .seealso: PetscScalar, PetscReal, PassiveScalar
    1276: M*/

    1278: /*M
    1279:     MPIU_SCALAR - MPI datatype corresponding to PetscScalar

    1281:    Level: beginner

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

    1286: .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar
    1287: M*/

    1289: /*
    1290:      The IBM include files define hz, here we hide it so that it may be used
    1291:    as a regular user variable.
    1292: */
    1293: #if defined(hz)
    1294: #undef hz
    1295: #endif

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

    1300: #if defined(PETSC_HAVE_LIMITS_H)
    1301: #include <limits.h>
    1302: #endif
    1303: #if defined(PETSC_HAVE_SYS_PARAM_H)
    1304: #include <sys/param.h>
    1305: #endif
    1306: #if defined(PETSC_HAVE_SYS_TYPES_H)
    1307: #include <sys/types.h>
    1308: #endif
    1309: #if defined(MAXPATHLEN)
    1310: #  define PETSC_MAX_PATH_LEN     MAXPATHLEN
    1311: #elif defined(MAX_PATH)
    1312: #  define PETSC_MAX_PATH_LEN     MAX_PATH
    1313: #elif defined(_MAX_PATH)
    1314: #  define PETSC_MAX_PATH_LEN     _MAX_PATH
    1315: #else
    1316: #  define PETSC_MAX_PATH_LEN     4096
    1317: #endif

    1320: #endif