xref: /petsc/include/petsc.h (revision 779eefb8f9c1a628a33cb66ed6c57583a424602f)
1*779eefb8SBarry Smith /* $Id: petsc.h,v 1.34 1995/06/21 20:34:21 bsmith Exp bsmith $ */
22eac72dbSBarry Smith 
32eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE)
42eac72dbSBarry Smith #define __PETSC_PACKAGE
52eac72dbSBarry Smith 
6*779eefb8SBarry Smith #define PETSC_VERSION_NUMBER "PETSc Version 2.0.Beta.5 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*));
407f813858SBarry Smith extern int  Trdump(FILE *);
418ed539a5SBarry Smith 
4278b31e54SBarry Smith #define PETSCNEW(A)         (A*) PETSCMALLOC(sizeof(A))
4378b31e54SBarry Smith #define PETSCMEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
4478b31e54SBarry Smith #define PETSCMEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
4520563c6bSBarry Smith #include <memory.h>
462eac72dbSBarry Smith 
472eac72dbSBarry Smith /*  Macros for error checking */
48f0479e8cSBarry Smith #if !defined(__DIR__)
49f0479e8cSBarry Smith #define __DIR__ 0
50f0479e8cSBarry Smith #endif
5128988994SBarry Smith #if defined(PETSC_DEBUG)
5278b31e54SBarry Smith #define SETERRQ(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
53d6dfbf8fSBarry Smith #define SETERRA(n,s)    \
54d6dfbf8fSBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
55d6dfbf8fSBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
5678b31e54SBarry Smith #define CHKERRQ(n)       {if (n) SETERRQ(n,(char *)0);}
57d6dfbf8fSBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
5878b31e54SBarry Smith #define CHKPTRQ(p)       if (!p) SETERRQ(1,"No memory");
59d6dfbf8fSBarry Smith #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
6028988994SBarry Smith #else
6178b31e54SBarry Smith #define SETERRQ(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
6228988994SBarry Smith #define SETERRA(n,s)    \
6328988994SBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
6428988994SBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
6578b31e54SBarry Smith #define CHKERRQ(n)       {if (n) SETERRQ(n,(char *)0);}
6628988994SBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
6778b31e54SBarry Smith #define CHKPTRQ(p)       if (!p) SETERRQ(1,"No memory");
6828988994SBarry Smith #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
6928988994SBarry Smith #endif
702eac72dbSBarry Smith 
718ed539a5SBarry Smith typedef struct _PetscObject* PetscObject;
729e25ed09SBarry Smith #define PETSC_COOKIE         0x12121212
736b5873e3SBarry Smith #define PETSC_DECIDE         -1
74da69df5fSBarry Smith 
75ca9b4cbeSLois Curfman McInnes typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
76ca9b4cbeSLois Curfman McInnes 
77da69df5fSBarry Smith #include "viewer.h"
788c8d4905SLois Curfman McInnes #include "options.h"
792eac72dbSBarry Smith 
80a0a59b22SBarry Smith extern int PetscInitialize(int*,char***,char*,char*);
81a0a59b22SBarry Smith extern int PetscFinalize();
82a0a59b22SBarry Smith 
83c60448a5SBarry Smith extern int PetscObjectDestroy(PetscObject);
847f223b93SBarry Smith extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm);
85a5a9c739SBarry Smith extern int PetscObjectSetName(PetscObject,char*);
86a5a9c739SBarry Smith extern int PetscObjectGetName(PetscObject,char**);
872eac72dbSBarry Smith 
88f0479e8cSBarry Smith extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
89f0479e8cSBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
90f0479e8cSBarry Smith extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
91f0479e8cSBarry Smith extern int PetscError(int,char*,char*,char*,int);
92f0479e8cSBarry Smith extern int PetscPushErrorHandler(int
93f0479e8cSBarry Smith                          (*handler)(int,char*,char*,char*,int,void*),void* );
948ed539a5SBarry Smith extern int PetscPopErrorHandler();
958ed539a5SBarry Smith 
968ed539a5SBarry Smith extern int PetscSetDebugger(char *,int,char *);
978ed539a5SBarry Smith extern int PetscAttachDebugger();
988ed539a5SBarry Smith 
99f0479e8cSBarry Smith extern int PetscDefaultSignalHandler(int,void*);
100f0479e8cSBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
101f0479e8cSBarry Smith extern int PetscPopSignalHandler();
102f0479e8cSBarry Smith extern int PetscSetFPTrap(int);
1036b5873e3SBarry Smith #define FP_TRAP_OFF    0
1046b5873e3SBarry Smith #define FP_TRAP_ON     1
1056b5873e3SBarry Smith #define FP_TRAP_ALWAYS 2
106f97c0401SBarry Smith 
1078ed539a5SBarry Smith 
108602c2b74SBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE) || defined(PARCH_t3d)
1098ed539a5SBarry Smith #define FORTRANCAPS
110d90ea2a1SBarry Smith #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_hpux)
1118ed539a5SBarry Smith #define FORTRANUNDERSCORE
1122eac72dbSBarry Smith #endif
1132eac72dbSBarry Smith 
1147857610eSBarry Smith /* Global flop counter */
1157857610eSBarry Smith extern double _TotalFlops;
1167857610eSBarry Smith #if defined(PETSC_LOG)
1177857610eSBarry Smith #define PLogFlops(n) {_TotalFlops += n;}
1187857610eSBarry Smith #else
1197857610eSBarry Smith #define PLogFlops(n)
1207857610eSBarry Smith #endif
12106259719SBarry Smith extern int PLogPrint(MPI_Comm,FILE *);
12206259719SBarry Smith extern int PLogBegin();
12306259719SBarry Smith extern int PLogAllBegin();
12406259719SBarry Smith extern int PLogDump(char*);
1257857610eSBarry Smith 
1262eac72dbSBarry Smith #endif
127