xref: /petsc/include/petsc.h (revision da69df5f9c22a9fc6a57aaf87f53b714a6d9ea0e)
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
82*da69df5fSBarry Smith 
83*da69df5fSBarry Smith #include "viewer.h"
842eac72dbSBarry Smith 
858ed539a5SBarry Smith /* useful Petsc routines (used often) */
86a0a59b22SBarry Smith extern int  PetscInitialize(int*,char***,char*,char*);
87a0a59b22SBarry Smith extern int  PetscFinalize();
88a0a59b22SBarry Smith 
898ed539a5SBarry Smith extern int  PetscDestroy(PetscObject);
90a5a9c739SBarry Smith extern int  PetscObjectSetName(PetscObject,char*);
91a5a9c739SBarry Smith extern int  PetscObjectGetName(PetscObject,char**);
922eac72dbSBarry Smith 
93f0479e8cSBarry Smith extern int  PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
94f0479e8cSBarry Smith extern int  PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
95f0479e8cSBarry Smith extern int  PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
96f0479e8cSBarry Smith extern int  PetscError(int,char*,char*,char*,int);
97f0479e8cSBarry Smith extern int  PetscPushErrorHandler(int
98f0479e8cSBarry Smith                          (*handler)(int,char*,char*,char*,int,void*),void* );
998ed539a5SBarry Smith extern int  PetscPopErrorHandler();
1008ed539a5SBarry Smith 
1018ed539a5SBarry Smith extern int  PetscSetDebugger(char *,int,char *);
1028ed539a5SBarry Smith extern int  PetscAttachDebugger();
1038ed539a5SBarry Smith 
104f0479e8cSBarry Smith extern int PetscDefaultSignalHandler(int,void*);
105f0479e8cSBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
106f0479e8cSBarry Smith extern int PetscPopSignalHandler();
107f0479e8cSBarry Smith extern int PetscSetFPTrap(int);
108f97c0401SBarry Smith 
109123e9dcfSBarry Smith #if defined(PETSC_MALLOC)
1108ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*);
1118ed539a5SBarry Smith extern int  trfree(void *,int,char*);
11220563c6bSBarry Smith extern int  trdump(FILE *);
113123e9dcfSBarry Smith #else
114123e9dcfSBarry Smith #include <malloc.h>
115123e9dcfSBarry Smith #endif
1168ed539a5SBarry Smith 
1171eb62cbbSBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE)
1188ed539a5SBarry Smith #define FORTRANCAPS
1191eb62cbbSBarry Smith #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX)
1208ed539a5SBarry Smith #define FORTRANUNDERSCORE
1212eac72dbSBarry Smith #endif
1222eac72dbSBarry Smith 
123123e9dcfSBarry Smith #include <stdio.h> /* I don't like this, but? */
124123e9dcfSBarry Smith 
1252eac72dbSBarry Smith #endif
126