xref: /petsc/include/petsc.h (revision 6abc6512c105a871402f018420c4c4316bc1e68d)
12eac72dbSBarry Smith 
22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE)
32eac72dbSBarry Smith #define __PETSC_PACKAGE
42eac72dbSBarry Smith 
5f0479e8cSBarry Smith #include <stdio.h>
6*6abc6512SBarry Smith int fprintf(FILE*,char*,...);
7*6abc6512SBarry Smith int printf(char*,...);
8*6abc6512SBarry Smith int fflush(FILE*);
9*6abc6512SBarry Smith int fclose(FILE*);
10f0479e8cSBarry Smith 
11f0479e8cSBarry Smith /* MPI interface */
12f0479e8cSBarry Smith #include "mpi.h"
13f0479e8cSBarry Smith #include "mpe.h"
14f0479e8cSBarry Smith #if defined(PETSC_COMPLEX)
15f0479e8cSBarry Smith #define MPI_SCALAR MPIR_dcomplex_dte
16f0479e8cSBarry Smith #else
17f0479e8cSBarry Smith #define MPI_SCALAR MPI_DOUBLE
18f0479e8cSBarry Smith #endif
19d6dfbf8fSBarry Smith extern FILE *MPE_fopen(MPI_Comm,char *,char *);
20d6dfbf8fSBarry Smith extern int MPE_fclose(MPI_Comm,FILE*);
21d6dfbf8fSBarry Smith extern int MPE_fprintf(MPI_Comm,FILE*,char *,...);
22d6dfbf8fSBarry Smith extern int MPE_printf(MPI_Comm,char *,...);
23d6dfbf8fSBarry Smith extern int MPE_Set_display(MPI_Comm,char **);
24f0479e8cSBarry Smith 
25f0479e8cSBarry Smith 
26c6a45a97SBarry Smith #if defined(PETSC_COMPLEX)
27c6a45a97SBarry Smith /* work around for bug in alpha g++ compiler */
28c6a45a97SBarry Smith #if defined(PARCH_alpha)
29c6a45a97SBarry Smith #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
30c6a45a97SBarry Smith /* extern double hypot(double,double); */
31c6a45a97SBarry Smith #endif
328ed539a5SBarry Smith #include <complex.h>
3320563c6bSBarry Smith #define PETSCREAL(a) real(a)
348ed539a5SBarry Smith #define Scalar       complex
358ed539a5SBarry Smith #else
3620563c6bSBarry Smith #define PETSCREAL(a) a
378ed539a5SBarry Smith #define Scalar       double
388ed539a5SBarry Smith #endif
398ed539a5SBarry Smith 
408ed539a5SBarry Smith 
412eac72dbSBarry Smith /*  Macros for getting and freeing memory */
428ed539a5SBarry Smith #if defined(PETSC_MALLOC)
438ed539a5SBarry Smith #define MALLOC(a)       trmalloc(a,__LINE__,__FILE__)
448ed539a5SBarry Smith #define FREE(a)         trfree(a,__LINE__,__FILE__)
458ed539a5SBarry Smith #else
462eac72dbSBarry Smith #define MALLOC(a)       malloc(a)
472eac72dbSBarry Smith #define FREE(a)         free(a)
488ed539a5SBarry Smith #endif
498ed539a5SBarry Smith #define NEW(a)          (a *) MALLOC(sizeof(a))
502eac72dbSBarry Smith #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
518ed539a5SBarry Smith #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
5220563c6bSBarry Smith #include <memory.h>
532eac72dbSBarry Smith 
542eac72dbSBarry Smith /*  Macros for error checking */
55f0479e8cSBarry Smith #if !defined(__DIR__)
56f0479e8cSBarry Smith #define __DIR__ 0
57f0479e8cSBarry Smith #endif
58f0479e8cSBarry Smith #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
59d6dfbf8fSBarry Smith #define SETERRA(n,s)    \
60d6dfbf8fSBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
61d6dfbf8fSBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
622eac72dbSBarry Smith #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
63d6dfbf8fSBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
642eac72dbSBarry Smith #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
65d6dfbf8fSBarry Smith #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
662eac72dbSBarry Smith 
672eac72dbSBarry Smith 
688ed539a5SBarry Smith typedef struct _PetscObject* PetscObject;
69da3a660dSBarry Smith 
708ed539a5SBarry Smith typedef struct _Viewer*      Viewer;
71d6dfbf8fSBarry Smith #define ViewerPrintf         (void *) 0
72da3a660dSBarry Smith #define VIEWER_COOKIE        0x123123
73da3a660dSBarry Smith #define MATLAB_VIEWER        1
742eac72dbSBarry Smith 
758ed539a5SBarry Smith /* useful Petsc routines (used often) */
76a0a59b22SBarry Smith extern int  PetscInitialize(int*,char***,char*,char*);
77a0a59b22SBarry Smith extern int  PetscFinalize();
78a0a59b22SBarry Smith 
798ed539a5SBarry Smith extern int  PetscDestroy(PetscObject);
808ed539a5SBarry Smith extern int  PetscView(PetscObject,Viewer);
812eac72dbSBarry Smith 
82f0479e8cSBarry Smith extern int  PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
83f0479e8cSBarry Smith extern int  PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
84f0479e8cSBarry Smith extern int  PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
85f0479e8cSBarry Smith extern int  PetscError(int,char*,char*,char*,int);
86f0479e8cSBarry Smith extern int  PetscPushErrorHandler(int
87f0479e8cSBarry Smith                          (*handler)(int,char*,char*,char*,int,void*),void* );
888ed539a5SBarry Smith extern int  PetscPopErrorHandler();
898ed539a5SBarry Smith 
908ed539a5SBarry Smith extern int  PetscSetDebugger(char *,int,char *);
918ed539a5SBarry Smith extern int  PetscAttachDebugger();
928ed539a5SBarry Smith 
93f0479e8cSBarry Smith extern int PetscDefaultSignalHandler(int,void*);
94f0479e8cSBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
95f0479e8cSBarry Smith extern int PetscPopSignalHandler();
96f0479e8cSBarry Smith extern int PetscSetFPTrap(int);
97f97c0401SBarry Smith 
98123e9dcfSBarry Smith #if defined(PETSC_MALLOC)
998ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*);
1008ed539a5SBarry Smith extern int  trfree(void *,int,char*);
10120563c6bSBarry Smith extern int  trdump(FILE *);
102123e9dcfSBarry Smith #else
103123e9dcfSBarry Smith #include <malloc.h>
104123e9dcfSBarry Smith #endif
1058ed539a5SBarry Smith 
1061eb62cbbSBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE)
1078ed539a5SBarry Smith #define FORTRANCAPS
1081eb62cbbSBarry Smith #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX)
1098ed539a5SBarry Smith #define FORTRANUNDERSCORE
1102eac72dbSBarry Smith #endif
1112eac72dbSBarry Smith 
112123e9dcfSBarry Smith #include <stdio.h> /* I don't like this, but? */
113123e9dcfSBarry Smith 
1142eac72dbSBarry Smith #endif
115