12eac72dbSBarry Smith 22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE) 32eac72dbSBarry Smith #define __PETSC_PACKAGE 42eac72dbSBarry Smith 5*8ed539a5SBarry Smith #if PETSC_COMPLEX 6*8ed539a5SBarry Smith #include <complex.h> 7*8ed539a5SBarry Smith #define Scalar complex 8*8ed539a5SBarry Smith #else 9*8ed539a5SBarry Smith #define Scalar double 10*8ed539a5SBarry Smith #endif 11*8ed539a5SBarry Smith 12*8ed539a5SBarry Smith 132eac72dbSBarry Smith /* Macros for getting and freeing memory */ 14*8ed539a5SBarry Smith #if defined(PETSC_MALLOC) 15*8ed539a5SBarry Smith #define MALLOC(a) trmalloc(a,__LINE__,__FILE__) 16*8ed539a5SBarry Smith #define FREE(a) trfree(a,__LINE__,__FILE__) 17*8ed539a5SBarry Smith #else 182eac72dbSBarry Smith #define MALLOC(a) malloc(a) 192eac72dbSBarry Smith #define FREE(a) free(a) 20*8ed539a5SBarry Smith #endif 21*8ed539a5SBarry Smith #define NEW(a) (a *) MALLOC(sizeof(a)) 222eac72dbSBarry Smith #define MEMCPY(a,b,n) memcpy((char*)(a),(char*)(b),n) 23*8ed539a5SBarry Smith #define MEMSET(a,b,n) memset((char*)(a),(int)(b),n) 242eac72dbSBarry Smith 252eac72dbSBarry Smith /* Macros for error checking */ 26*8ed539a5SBarry Smith #define SETERR(n,s) {return PetscError(__LINE__,__FILE__,s,n);} 272eac72dbSBarry Smith #define CHKERR(n) {if (n) SETERR(n,(char *)0);} 282eac72dbSBarry Smith #define CHKPTR(p) if (!p) SETERR(1,"No memory"); 292eac72dbSBarry Smith 302eac72dbSBarry Smith 31*8ed539a5SBarry Smith typedef struct _PetscObject* PetscObject; 32*8ed539a5SBarry Smith typedef struct _Viewer* Viewer; 332eac72dbSBarry Smith 34*8ed539a5SBarry Smith /* useful Petsc routines (used often) */ 35*8ed539a5SBarry Smith extern int PetscDestroy(PetscObject); 36*8ed539a5SBarry Smith extern int PetscView(PetscObject,Viewer); 372eac72dbSBarry Smith 38*8ed539a5SBarry Smith extern int PetscError(int,char*,char*,int); 39*8ed539a5SBarry Smith extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,int,void*),void* ); 40*8ed539a5SBarry Smith extern int PetscPopErrorHandler(); 41*8ed539a5SBarry Smith 42*8ed539a5SBarry Smith extern int PetscDefaultErrorHandler(int,char*,char*,int,void*); 43*8ed539a5SBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,int,void* ); 44*8ed539a5SBarry Smith extern int PetscAttachDebuggerErrorHandler(int, char *,char *,int,void*); 45*8ed539a5SBarry Smith 46*8ed539a5SBarry Smith extern int PetscSetDebugger(char *,int,char *); 47*8ed539a5SBarry Smith extern int PetscAttachDebugger(); 48*8ed539a5SBarry Smith 49*8ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*); 50*8ed539a5SBarry Smith extern int trfree(void *,int,char*); 51*8ed539a5SBarry Smith 52*8ed539a5SBarry Smith 53*8ed539a5SBarry Smith #if defined(titan) || defined(cray) || defined(ncube) 54*8ed539a5SBarry Smith #define FORTRANCAPS 55*8ed539a5SBarry Smith #elif !defined(rs6000) && !defined(NeXT) && !defined(HPUX) 56*8ed539a5SBarry Smith #define FORTRANUNDERSCORE 572eac72dbSBarry Smith #endif 582eac72dbSBarry Smith 592eac72dbSBarry Smith #endif 60