xref: /petsc/include/petsc.h (revision dbb450ca0a1bd4568a196678f20f5151425d3a04)
1*dbb450caSBarry Smith /* $Id: petsc.h,v 1.57 1995/09/06 03:06:53 bsmith Exp bsmith $ */
22eac72dbSBarry Smith 
32eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE)
42eac72dbSBarry Smith #define __PETSC_PACKAGE
52eac72dbSBarry Smith 
6*dbb450caSBarry Smith #define PETSC_VERSION_NUMBER "PETSc Version 2.0.Beta.8 Released ?, 1995."
77e59f0e8SBarry Smith 
8f0479e8cSBarry Smith #include <stdio.h>
928988994SBarry Smith #if defined(PARCH_sun4)
106abc6512SBarry Smith int fprintf(FILE*,char*,...);
116abc6512SBarry Smith int printf(char*,...);
126abc6512SBarry Smith int fflush(FILE*);
136abc6512SBarry Smith int fclose(FILE*);
1428988994SBarry Smith #endif
15f0479e8cSBarry Smith 
16f0479e8cSBarry Smith /* MPI interface */
17f0479e8cSBarry Smith #include "mpi.h"
187f813858SBarry Smith #include "mpiu.h"
19f0479e8cSBarry Smith 
20c6a45a97SBarry Smith #if defined(PETSC_COMPLEX)
21c6a45a97SBarry Smith /* work around for bug in alpha g++ compiler */
22c6a45a97SBarry Smith #if defined(PARCH_alpha)
23c6a45a97SBarry Smith #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
24c6a45a97SBarry Smith /* extern double hypot(double,double); */
25c6a45a97SBarry Smith #endif
268ed539a5SBarry Smith #include <complex.h>
2720563c6bSBarry Smith #define PETSCREAL(a) real(a)
288ed539a5SBarry Smith #define Scalar       complex
298ed539a5SBarry Smith #else
3020563c6bSBarry Smith #define PETSCREAL(a) a
318ed539a5SBarry Smith #define Scalar       double
328ed539a5SBarry Smith #endif
338ed539a5SBarry Smith 
34d90ea2a1SBarry Smith extern void *(*PetscMalloc)(unsigned int,int,char*);
35d90ea2a1SBarry Smith extern int  (*PetscFree)(void *,int,char*);
3678b31e54SBarry Smith #define PETSCMALLOC(a)       (*PetscMalloc)(a,__LINE__,__FILE__)
3778b31e54SBarry Smith #define PETSCFREE(a)         (*PetscFree)(a,__LINE__,__FILE__)
387f813858SBarry Smith extern int  PetscSetMalloc(void *(*)(unsigned int,int,char*),
397f813858SBarry Smith                            int (*)(void *,int,char*));
40c7485abaSBarry Smith extern int  TrDump(FILE *);
41e9f47e53SBarry Smith extern int  TrGetMaximumAllocated(double*);
428ed539a5SBarry Smith 
4378b31e54SBarry Smith #define PETSCNEW(A)         (A*) PETSCMALLOC(sizeof(A))
4478b31e54SBarry Smith #define PETSCMEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
4578b31e54SBarry Smith #define PETSCMEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
4620563c6bSBarry Smith #include <memory.h>
472eac72dbSBarry Smith 
48145fe58dSBarry Smith #define PETSCMIN(a,b)      ( ((a)<(b)) ? (a) : (b) )
49145fe58dSBarry Smith #define PETSCMAX(a,b)      ( ((a)<(b)) ? (b) : (a) )
5081745bc7SBarry Smith #define PETSCABS(a)        ( ((a)<0)   ? -(a) : (a) )
51145fe58dSBarry Smith 
522eac72dbSBarry Smith /*  Macros for error checking */
53f0479e8cSBarry Smith #if !defined(__DIR__)
54f0479e8cSBarry Smith #define __DIR__ 0
55f0479e8cSBarry Smith #endif
56d636dbe3SBarry Smith 
57d636dbe3SBarry Smith /*
58d636dbe3SBarry Smith        Unable to malloc error and no supported function
59d636dbe3SBarry Smith */
60*dbb450caSBarry Smith #define PETSC_ERR_MEM 55   /* unalbe to allocate requested memory */
61*dbb450caSBarry Smith #define PETSC_ERR_SUP 56   /* no support yet for this operation */
62*dbb450caSBarry Smith #define PETSC_ERR_ARG 57   /* bad input argument */
63*dbb450caSBarry Smith #define PETSC_ERR_OBJ 58   /* null or corrupt PETSc object */
64d636dbe3SBarry Smith 
6528988994SBarry Smith #if defined(PETSC_DEBUG)
6678b31e54SBarry Smith #define SETERRQ(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
67d6dfbf8fSBarry Smith #define SETERRA(n,s)    \
68d6dfbf8fSBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
69d6dfbf8fSBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
7078b31e54SBarry Smith #define CHKERRQ(n)       {if (n) SETERRQ(n,(char *)0);}
71d6dfbf8fSBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
72d636dbe3SBarry Smith #define CHKPTRQ(p)       if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0);
73d636dbe3SBarry Smith #define CHKPTRA(p)       if (!p) SETERRA(PETSC_ERR_MEM,(char*)0);
7428988994SBarry Smith #else
7578b31e54SBarry Smith #define SETERRQ(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
7628988994SBarry Smith #define SETERRA(n,s)    \
7728988994SBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
7828988994SBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
7978b31e54SBarry Smith #define CHKERRQ(n)       {if (n) SETERRQ(n,(char *)0);}
8028988994SBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
81d636dbe3SBarry Smith #define CHKPTRQ(p)       if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0);
82d636dbe3SBarry Smith #define CHKPTRA(p)       if (!p) SETERRA(PETSC_ERR_MEM,(char*)0);
8328988994SBarry Smith #endif
842eac72dbSBarry Smith 
858ed539a5SBarry Smith typedef struct _PetscObject* PetscObject;
861a941147SBarry Smith #define PETSC_COOKIE         1211211
876b5873e3SBarry Smith #define PETSC_DECIDE         -1
8855b5a45fSLois Curfman McInnes #define PETSC_DEFAULT        -2
89da69df5fSBarry Smith 
90ca9b4cbeSLois Curfman McInnes typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
91ca9b4cbeSLois Curfman McInnes 
92da69df5fSBarry Smith #include "viewer.h"
938c8d4905SLois Curfman McInnes #include "options.h"
942eac72dbSBarry Smith 
95a0a59b22SBarry Smith extern int PetscInitialize(int*,char***,char*,char*);
96a0a59b22SBarry Smith extern int PetscFinalize();
97a0a59b22SBarry Smith 
98c60448a5SBarry Smith extern int PetscObjectDestroy(PetscObject);
998f4c47bcSLois Curfman McInnes extern int PetscObjectExists(PetscObject,int*);
1007f223b93SBarry Smith extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm);
101a5a9c739SBarry Smith extern int PetscObjectSetName(PetscObject,char*);
102a5a9c739SBarry Smith extern int PetscObjectGetName(PetscObject,char**);
1032eac72dbSBarry Smith 
104f0479e8cSBarry Smith extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
105f0479e8cSBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
106f0479e8cSBarry Smith extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
107f0479e8cSBarry Smith extern int PetscError(int,char*,char*,char*,int);
108f0479e8cSBarry Smith extern int PetscPushErrorHandler(int
109f0479e8cSBarry Smith                          (*handler)(int,char*,char*,char*,int,void*),void* );
1108ed539a5SBarry Smith extern int PetscPopErrorHandler();
1118ed539a5SBarry Smith 
1128ed539a5SBarry Smith extern int PetscSetDebugger(char *,int,char *);
1138ed539a5SBarry Smith extern int PetscAttachDebugger();
1148ed539a5SBarry Smith 
115f0479e8cSBarry Smith extern int PetscDefaultSignalHandler(int,void*);
116f0479e8cSBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
117f0479e8cSBarry Smith extern int PetscPopSignalHandler();
118f0479e8cSBarry Smith extern int PetscSetFPTrap(int);
1196b5873e3SBarry Smith #define FP_TRAP_OFF    0
1206b5873e3SBarry Smith #define FP_TRAP_ON     1
121fba13676SBarry Smith #define FP_TRAP_ALWAYS 2
1228ed539a5SBarry Smith 
12331b41497SLois Curfman McInnes /*
12431b41497SLois Curfman McInnes    Definitions used for the Fortran interface:
12531b41497SLois Curfman McInnes    FORTRANCAPS:       Names are uppercase, no trailing underscore
12631b41497SLois Curfman McInnes    FORTRANUNDERSCORE: Names are lowercase, trailing underscore
12731b41497SLois Curfman McInnes  */
128602c2b74SBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE) || defined(PARCH_t3d)
1298ed539a5SBarry Smith #define FORTRANCAPS
130d90ea2a1SBarry Smith #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_hpux)
1318ed539a5SBarry Smith #define FORTRANUNDERSCORE
1322eac72dbSBarry Smith #endif
1332eac72dbSBarry Smith 
13419b02663SBarry Smith #include "phead.h"
13519b02663SBarry Smith #include "plog.h"
1367857610eSBarry Smith 
1377ec12d72SBarry Smith extern void PetscSleep(int);
1387ec12d72SBarry Smith 
1392eac72dbSBarry Smith #endif
140