12eac72dbSBarry Smith 22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE) 32eac72dbSBarry Smith #define __PETSC_PACKAGE 42eac72dbSBarry Smith 58ed539a5SBarry Smith #if PETSC_COMPLEX 68ed539a5SBarry Smith #include <complex.h> 7*20563c6bSBarry Smith #define PETSCREAL(a) real(a) 88ed539a5SBarry Smith #define Scalar complex 98ed539a5SBarry Smith #else 10*20563c6bSBarry Smith #define PETSCREAL(a) a 118ed539a5SBarry Smith #define Scalar double 128ed539a5SBarry Smith #endif 138ed539a5SBarry Smith 148ed539a5SBarry Smith 152eac72dbSBarry Smith /* Macros for getting and freeing memory */ 168ed539a5SBarry Smith #if defined(PETSC_MALLOC) 178ed539a5SBarry Smith #define MALLOC(a) trmalloc(a,__LINE__,__FILE__) 188ed539a5SBarry Smith #define FREE(a) trfree(a,__LINE__,__FILE__) 198ed539a5SBarry Smith #else 202eac72dbSBarry Smith #define MALLOC(a) malloc(a) 212eac72dbSBarry Smith #define FREE(a) free(a) 228ed539a5SBarry Smith #endif 238ed539a5SBarry Smith #define NEW(a) (a *) MALLOC(sizeof(a)) 242eac72dbSBarry Smith #define MEMCPY(a,b,n) memcpy((char*)(a),(char*)(b),n) 258ed539a5SBarry Smith #define MEMSET(a,b,n) memset((char*)(a),(int)(b),n) 26*20563c6bSBarry Smith #include <memory.h> 272eac72dbSBarry Smith 282eac72dbSBarry Smith /* Macros for error checking */ 298ed539a5SBarry Smith #define SETERR(n,s) {return PetscError(__LINE__,__FILE__,s,n);} 302eac72dbSBarry Smith #define CHKERR(n) {if (n) SETERR(n,(char *)0);} 312eac72dbSBarry Smith #define CHKPTR(p) if (!p) SETERR(1,"No memory"); 322eac72dbSBarry Smith 332eac72dbSBarry Smith 348ed539a5SBarry Smith typedef struct _PetscObject* PetscObject; 358ed539a5SBarry Smith typedef struct _Viewer* Viewer; 362eac72dbSBarry Smith 378ed539a5SBarry Smith /* useful Petsc routines (used often) */ 38a0a59b22SBarry Smith extern int PetscInitialize(int*,char***,char*,char*); 39a0a59b22SBarry Smith extern int PetscFinalize(); 40a0a59b22SBarry Smith 418ed539a5SBarry Smith extern int PetscDestroy(PetscObject); 428ed539a5SBarry Smith extern int PetscView(PetscObject,Viewer); 432eac72dbSBarry Smith 448ed539a5SBarry Smith extern int PetscError(int,char*,char*,int); 458ed539a5SBarry Smith extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,int,void*),void* ); 468ed539a5SBarry Smith extern int PetscPopErrorHandler(); 478ed539a5SBarry Smith 488ed539a5SBarry Smith extern int PetscDefaultErrorHandler(int,char*,char*,int,void*); 498ed539a5SBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,int,void* ); 508ed539a5SBarry Smith extern int PetscAttachDebuggerErrorHandler(int, char *,char *,int,void*); 518ed539a5SBarry Smith 528ed539a5SBarry Smith extern int PetscSetDebugger(char *,int,char *); 538ed539a5SBarry Smith extern int PetscAttachDebugger(); 548ed539a5SBarry Smith 55f97c0401SBarry Smith #include <signal.h> /* I don't like this, but? */ 56f97c0401SBarry Smith extern int PetscSetSignalHandler(void (*)(int,int,struct sigcontext *,char*)); 57f97c0401SBarry Smith 588ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*); 598ed539a5SBarry Smith extern int trfree(void *,int,char*); 60*20563c6bSBarry Smith #include <stdio.h> /* I don't like this, but? */ 61*20563c6bSBarry Smith extern int trdump(FILE *); 628ed539a5SBarry Smith 638ed539a5SBarry Smith #if defined(titan) || defined(cray) || defined(ncube) 648ed539a5SBarry Smith #define FORTRANCAPS 658ed539a5SBarry Smith #elif !defined(rs6000) && !defined(NeXT) && !defined(HPUX) 668ed539a5SBarry Smith #define FORTRANUNDERSCORE 672eac72dbSBarry Smith #endif 682eac72dbSBarry Smith 692eac72dbSBarry Smith #endif 70