xref: /petsc/include/petsc.h (revision a5a9c7395dc5f08d0dbb7ed05e148334692018e2)
12eac72dbSBarry Smith 
22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE)
32eac72dbSBarry Smith #define __PETSC_PACKAGE
42eac72dbSBarry Smith 
5f0479e8cSBarry Smith #include <stdio.h>
628988994SBarry Smith #if defined(PARCH_sun4)
76abc6512SBarry Smith int fprintf(FILE*,char*,...);
86abc6512SBarry Smith int printf(char*,...);
96abc6512SBarry Smith int fflush(FILE*);
106abc6512SBarry Smith int fclose(FILE*);
1128988994SBarry Smith #endif
12f0479e8cSBarry Smith 
13f0479e8cSBarry Smith /* MPI interface */
14f0479e8cSBarry Smith #include "mpi.h"
15f0479e8cSBarry Smith #include "mpe.h"
16f0479e8cSBarry Smith #if defined(PETSC_COMPLEX)
17f0479e8cSBarry Smith #define MPI_SCALAR MPIR_dcomplex_dte
18f0479e8cSBarry Smith #else
19f0479e8cSBarry Smith #define MPI_SCALAR MPI_DOUBLE
20f0479e8cSBarry Smith #endif
21d6dfbf8fSBarry Smith extern FILE *MPE_fopen(MPI_Comm,char *,char *);
22d6dfbf8fSBarry Smith extern int MPE_fclose(MPI_Comm,FILE*);
23d6dfbf8fSBarry Smith extern int MPE_fprintf(MPI_Comm,FILE*,char *,...);
24d6dfbf8fSBarry Smith extern int MPE_printf(MPI_Comm,char *,...);
25d6dfbf8fSBarry Smith extern int MPE_Set_display(MPI_Comm,char **);
26f0479e8cSBarry Smith 
27f0479e8cSBarry Smith 
28c6a45a97SBarry Smith #if defined(PETSC_COMPLEX)
29c6a45a97SBarry Smith /* work around for bug in alpha g++ compiler */
30c6a45a97SBarry Smith #if defined(PARCH_alpha)
31c6a45a97SBarry Smith #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
32c6a45a97SBarry Smith /* extern double hypot(double,double); */
33c6a45a97SBarry Smith #endif
348ed539a5SBarry Smith #include <complex.h>
3520563c6bSBarry Smith #define PETSCREAL(a) real(a)
368ed539a5SBarry Smith #define Scalar       complex
378ed539a5SBarry Smith #else
3820563c6bSBarry Smith #define PETSCREAL(a) a
398ed539a5SBarry Smith #define Scalar       double
408ed539a5SBarry Smith #endif
418ed539a5SBarry Smith 
428ed539a5SBarry Smith 
432eac72dbSBarry Smith /*  Macros for getting and freeing memory */
448ed539a5SBarry Smith #if defined(PETSC_MALLOC)
458ed539a5SBarry Smith #define MALLOC(a)       trmalloc(a,__LINE__,__FILE__)
468ed539a5SBarry Smith #define FREE(a)         trfree(a,__LINE__,__FILE__)
478ed539a5SBarry Smith #else
482eac72dbSBarry Smith #define MALLOC(a)       malloc(a)
492eac72dbSBarry Smith #define FREE(a)         free(a)
508ed539a5SBarry Smith #endif
518ed539a5SBarry Smith #define NEW(a)          (a *) MALLOC(sizeof(a))
522eac72dbSBarry Smith #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
538ed539a5SBarry Smith #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
5420563c6bSBarry Smith #include <memory.h>
552eac72dbSBarry Smith 
562eac72dbSBarry Smith /*  Macros for error checking */
57f0479e8cSBarry Smith #if !defined(__DIR__)
58f0479e8cSBarry Smith #define __DIR__ 0
59f0479e8cSBarry Smith #endif
6028988994SBarry Smith #if defined(PETSC_DEBUG)
61f0479e8cSBarry Smith #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
62d6dfbf8fSBarry Smith #define SETERRA(n,s)    \
63d6dfbf8fSBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
64d6dfbf8fSBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
652eac72dbSBarry Smith #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
66d6dfbf8fSBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
672eac72dbSBarry Smith #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
68d6dfbf8fSBarry Smith #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
6928988994SBarry Smith #else
7028988994SBarry Smith #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
7128988994SBarry Smith #define SETERRA(n,s)    \
7228988994SBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
7328988994SBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
7428988994SBarry Smith #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
7528988994SBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
7628988994SBarry Smith #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
7728988994SBarry Smith #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
7828988994SBarry Smith #endif
792eac72dbSBarry Smith 
808ed539a5SBarry Smith typedef struct _PetscObject* PetscObject;
819e25ed09SBarry Smith #define PETSC_COOKIE         0x12121212
828ed539a5SBarry Smith typedef struct _Viewer*      Viewer;
83d6dfbf8fSBarry Smith #define ViewerPrintf         (void *) 0
849e25ed09SBarry Smith #define VIEWER_COOKIE        PETSC_COOKIE+1
859e25ed09SBarry Smith #define MATLAB_VIEWER        0
8628988994SBarry Smith extern int ViewerMatlabOpen(char*,int,Viewer *);
872eac72dbSBarry Smith 
888ed539a5SBarry Smith /* useful Petsc routines (used often) */
89a0a59b22SBarry Smith extern int  PetscInitialize(int*,char***,char*,char*);
90a0a59b22SBarry Smith extern int  PetscFinalize();
91a0a59b22SBarry Smith 
928ed539a5SBarry Smith extern int  PetscDestroy(PetscObject);
938ed539a5SBarry Smith extern int  PetscView(PetscObject,Viewer);
94*a5a9c739SBarry Smith extern int  PetscObjectSetName(PetscObject,char*);
95*a5a9c739SBarry Smith extern int  PetscObjectGetName(PetscObject,char**);
962eac72dbSBarry Smith 
97f0479e8cSBarry Smith extern int  PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
98f0479e8cSBarry Smith extern int  PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
99f0479e8cSBarry Smith extern int  PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
100f0479e8cSBarry Smith extern int  PetscError(int,char*,char*,char*,int);
101f0479e8cSBarry Smith extern int  PetscPushErrorHandler(int
102f0479e8cSBarry Smith                          (*handler)(int,char*,char*,char*,int,void*),void* );
1038ed539a5SBarry Smith extern int  PetscPopErrorHandler();
1048ed539a5SBarry Smith 
1058ed539a5SBarry Smith extern int  PetscSetDebugger(char *,int,char *);
1068ed539a5SBarry Smith extern int  PetscAttachDebugger();
1078ed539a5SBarry Smith 
108f0479e8cSBarry Smith extern int PetscDefaultSignalHandler(int,void*);
109f0479e8cSBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
110f0479e8cSBarry Smith extern int PetscPopSignalHandler();
111f0479e8cSBarry Smith extern int PetscSetFPTrap(int);
112f97c0401SBarry Smith 
113123e9dcfSBarry Smith #if defined(PETSC_MALLOC)
1148ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*);
1158ed539a5SBarry Smith extern int  trfree(void *,int,char*);
11620563c6bSBarry Smith extern int  trdump(FILE *);
117123e9dcfSBarry Smith #else
118123e9dcfSBarry Smith #include <malloc.h>
119123e9dcfSBarry Smith #endif
1208ed539a5SBarry Smith 
1211eb62cbbSBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE)
1228ed539a5SBarry Smith #define FORTRANCAPS
1231eb62cbbSBarry Smith #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX)
1248ed539a5SBarry Smith #define FORTRANUNDERSCORE
1252eac72dbSBarry Smith #endif
1262eac72dbSBarry Smith 
127123e9dcfSBarry Smith #include <stdio.h> /* I don't like this, but? */
128123e9dcfSBarry Smith 
1292eac72dbSBarry Smith #endif
130