xref: /petsc/include/petsc.h (revision c6a45a9732aaf0679b0f4eb4ddc75ce99ee9558a)
12eac72dbSBarry Smith 
22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE)
32eac72dbSBarry Smith #define __PETSC_PACKAGE
42eac72dbSBarry Smith 
5*c6a45a97SBarry Smith #if defined(PETSC_COMPLEX)
6*c6a45a97SBarry Smith /* work around for bug in alpha g++ compiler */
7*c6a45a97SBarry Smith #if defined(PARCH_alpha)
8*c6a45a97SBarry Smith #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
9*c6a45a97SBarry Smith /* extern double hypot(double,double); */
10*c6a45a97SBarry Smith #endif
118ed539a5SBarry Smith #include <complex.h>
1220563c6bSBarry Smith #define PETSCREAL(a) real(a)
138ed539a5SBarry Smith #define Scalar       complex
148ed539a5SBarry Smith #else
1520563c6bSBarry Smith #define PETSCREAL(a) a
168ed539a5SBarry Smith #define Scalar       double
178ed539a5SBarry Smith #endif
188ed539a5SBarry Smith 
198ed539a5SBarry Smith 
202eac72dbSBarry Smith /*  Macros for getting and freeing memory */
218ed539a5SBarry Smith #if defined(PETSC_MALLOC)
228ed539a5SBarry Smith #define MALLOC(a)       trmalloc(a,__LINE__,__FILE__)
238ed539a5SBarry Smith #define FREE(a)         trfree(a,__LINE__,__FILE__)
248ed539a5SBarry Smith #else
252eac72dbSBarry Smith #define MALLOC(a)       malloc(a)
262eac72dbSBarry Smith #define FREE(a)         free(a)
278ed539a5SBarry Smith #endif
288ed539a5SBarry Smith #define NEW(a)          (a *) MALLOC(sizeof(a))
292eac72dbSBarry Smith #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
308ed539a5SBarry Smith #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
3120563c6bSBarry Smith #include <memory.h>
322eac72dbSBarry Smith 
332eac72dbSBarry Smith /*  Macros for error checking */
348ed539a5SBarry Smith #define SETERR(n,s)     {return PetscError(__LINE__,__FILE__,s,n);}
352eac72dbSBarry Smith #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
362eac72dbSBarry Smith #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
372eac72dbSBarry Smith 
382eac72dbSBarry Smith 
398ed539a5SBarry Smith typedef struct _PetscObject* PetscObject;
408ed539a5SBarry Smith typedef struct _Viewer*      Viewer;
412eac72dbSBarry Smith 
428ed539a5SBarry Smith /* useful Petsc routines (used often) */
43a0a59b22SBarry Smith extern int  PetscInitialize(int*,char***,char*,char*);
44a0a59b22SBarry Smith extern int  PetscFinalize();
45a0a59b22SBarry Smith 
468ed539a5SBarry Smith extern int  PetscDestroy(PetscObject);
478ed539a5SBarry Smith extern int  PetscView(PetscObject,Viewer);
482eac72dbSBarry Smith 
498ed539a5SBarry Smith extern int  PetscError(int,char*,char*,int);
508ed539a5SBarry Smith extern int  PetscPushErrorHandler(int (*handler)(int,char*,char*,int,void*),void* );
518ed539a5SBarry Smith extern int  PetscPopErrorHandler();
528ed539a5SBarry Smith 
538ed539a5SBarry Smith extern int  PetscDefaultErrorHandler(int,char*,char*,int,void*);
548ed539a5SBarry Smith extern int  PetscAbortErrorHandler(int,char*,char*,int,void* );
558ed539a5SBarry Smith extern int  PetscAttachDebuggerErrorHandler(int, char *,char *,int,void*);
568ed539a5SBarry Smith 
578ed539a5SBarry Smith extern int  PetscSetDebugger(char *,int,char *);
588ed539a5SBarry Smith extern int  PetscAttachDebugger();
598ed539a5SBarry Smith 
60f97c0401SBarry Smith #include <signal.h> /* I don't like this, but? */
611eb62cbbSBarry Smith #if !defined(PARCH_rs6000) && !defined(PARCH_freebsd) && !defined(PARCH_alpha)
62f97c0401SBarry Smith extern int PetscSetSignalHandler(void (*)(int,int,struct sigcontext *,char*));
631eb62cbbSBarry Smith #else
641eb62cbbSBarry Smith extern int PetscSetSignalHandler(void (*)(int));
651eb62cbbSBarry Smith #endif
66f97c0401SBarry Smith 
678ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*);
688ed539a5SBarry Smith extern int  trfree(void *,int,char*);
6920563c6bSBarry Smith #include <stdio.h> /* I don't like this, but? */
7020563c6bSBarry Smith extern int  trdump(FILE *);
718ed539a5SBarry Smith 
721eb62cbbSBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE)
738ed539a5SBarry Smith #define FORTRANCAPS
741eb62cbbSBarry Smith #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX)
758ed539a5SBarry Smith #define FORTRANUNDERSCORE
762eac72dbSBarry Smith #endif
772eac72dbSBarry Smith 
782eac72dbSBarry Smith #endif
79