xref: /petsc/include/petsc.h (revision d6dfbf8f6aa26f18ad3ebf3c96fa582aa9714225)
12eac72dbSBarry Smith 
22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE)
32eac72dbSBarry Smith #define __PETSC_PACKAGE
42eac72dbSBarry Smith 
5f0479e8cSBarry Smith #include <stdio.h>
6f0479e8cSBarry Smith 
7f0479e8cSBarry Smith /* MPI interface */
8f0479e8cSBarry Smith #include "mpi.h"
9f0479e8cSBarry Smith #include "mpe.h"
10f0479e8cSBarry Smith #if defined(PETSC_COMPLEX)
11f0479e8cSBarry Smith #define MPI_SCALAR MPIR_dcomplex_dte
12f0479e8cSBarry Smith #else
13f0479e8cSBarry Smith #define MPI_SCALAR MPI_DOUBLE
14f0479e8cSBarry Smith #endif
15*d6dfbf8fSBarry Smith extern FILE *MPE_fopen(MPI_Comm,char *,char *);
16*d6dfbf8fSBarry Smith extern int MPE_fclose(MPI_Comm,FILE*);
17*d6dfbf8fSBarry Smith extern int MPE_fprintf(MPI_Comm,FILE*,char *,...);
18*d6dfbf8fSBarry Smith extern int MPE_printf(MPI_Comm,char *,...);
19*d6dfbf8fSBarry Smith extern int MPE_Set_display(MPI_Comm,char **);
20f0479e8cSBarry Smith 
21f0479e8cSBarry Smith 
22c6a45a97SBarry Smith #if defined(PETSC_COMPLEX)
23c6a45a97SBarry Smith /* work around for bug in alpha g++ compiler */
24c6a45a97SBarry Smith #if defined(PARCH_alpha)
25c6a45a97SBarry Smith #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
26c6a45a97SBarry Smith /* extern double hypot(double,double); */
27c6a45a97SBarry Smith #endif
288ed539a5SBarry Smith #include <complex.h>
2920563c6bSBarry Smith #define PETSCREAL(a) real(a)
308ed539a5SBarry Smith #define Scalar       complex
318ed539a5SBarry Smith #else
3220563c6bSBarry Smith #define PETSCREAL(a) a
338ed539a5SBarry Smith #define Scalar       double
348ed539a5SBarry Smith #endif
358ed539a5SBarry Smith 
368ed539a5SBarry Smith 
372eac72dbSBarry Smith /*  Macros for getting and freeing memory */
388ed539a5SBarry Smith #if defined(PETSC_MALLOC)
398ed539a5SBarry Smith #define MALLOC(a)       trmalloc(a,__LINE__,__FILE__)
408ed539a5SBarry Smith #define FREE(a)         trfree(a,__LINE__,__FILE__)
418ed539a5SBarry Smith #else
422eac72dbSBarry Smith #define MALLOC(a)       malloc(a)
432eac72dbSBarry Smith #define FREE(a)         free(a)
448ed539a5SBarry Smith #endif
458ed539a5SBarry Smith #define NEW(a)          (a *) MALLOC(sizeof(a))
462eac72dbSBarry Smith #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
478ed539a5SBarry Smith #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
4820563c6bSBarry Smith #include <memory.h>
492eac72dbSBarry Smith 
502eac72dbSBarry Smith /*  Macros for error checking */
51f0479e8cSBarry Smith #if !defined(__DIR__)
52f0479e8cSBarry Smith #define __DIR__ 0
53f0479e8cSBarry Smith #endif
54f0479e8cSBarry Smith #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
55*d6dfbf8fSBarry Smith #define SETERRA(n,s)    \
56*d6dfbf8fSBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
57*d6dfbf8fSBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
582eac72dbSBarry Smith #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
59*d6dfbf8fSBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
602eac72dbSBarry Smith #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
61*d6dfbf8fSBarry Smith #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
622eac72dbSBarry Smith 
632eac72dbSBarry Smith 
648ed539a5SBarry Smith typedef struct _PetscObject* PetscObject;
658ed539a5SBarry Smith typedef struct _Viewer*      Viewer;
66*d6dfbf8fSBarry Smith #define ViewerPrintf    (void *) 0
672eac72dbSBarry Smith 
688ed539a5SBarry Smith /* useful Petsc routines (used often) */
69a0a59b22SBarry Smith extern int  PetscInitialize(int*,char***,char*,char*);
70a0a59b22SBarry Smith extern int  PetscFinalize();
71a0a59b22SBarry Smith 
728ed539a5SBarry Smith extern int  PetscDestroy(PetscObject);
738ed539a5SBarry Smith extern int  PetscView(PetscObject,Viewer);
742eac72dbSBarry Smith 
75f0479e8cSBarry Smith extern int  PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
76f0479e8cSBarry Smith extern int  PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
77f0479e8cSBarry Smith extern int  PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
78f0479e8cSBarry Smith extern int  PetscError(int,char*,char*,char*,int);
79f0479e8cSBarry Smith extern int  PetscPushErrorHandler(int
80f0479e8cSBarry Smith                          (*handler)(int,char*,char*,char*,int,void*),void* );
818ed539a5SBarry Smith extern int  PetscPopErrorHandler();
828ed539a5SBarry Smith 
838ed539a5SBarry Smith extern int  PetscSetDebugger(char *,int,char *);
848ed539a5SBarry Smith extern int  PetscAttachDebugger();
858ed539a5SBarry Smith 
86f0479e8cSBarry Smith extern int PetscDefaultSignalHandler(int,void*);
87f0479e8cSBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
88f0479e8cSBarry Smith extern int PetscPopSignalHandler();
89f0479e8cSBarry Smith extern int PetscSetFPTrap(int);
90f97c0401SBarry Smith 
918ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*);
928ed539a5SBarry Smith extern int  trfree(void *,int,char*);
9320563c6bSBarry Smith #include <stdio.h> /* I don't like this, but? */
9420563c6bSBarry Smith extern int  trdump(FILE *);
958ed539a5SBarry Smith 
961eb62cbbSBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE)
978ed539a5SBarry Smith #define FORTRANCAPS
981eb62cbbSBarry Smith #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX)
998ed539a5SBarry Smith #define FORTRANUNDERSCORE
1002eac72dbSBarry Smith #endif
1012eac72dbSBarry Smith 
1022eac72dbSBarry Smith #endif
103