1 2 #if !defined(__PETSC_PACKAGE) 3 #define __PETSC_PACKAGE 4 5 #if PETSC_COMPLEX 6 #include <complex.h> 7 #define Scalar complex 8 #else 9 #define Scalar double 10 #endif 11 12 13 /* Macros for getting and freeing memory */ 14 #if defined(PETSC_MALLOC) 15 #define MALLOC(a) trmalloc(a,__LINE__,__FILE__) 16 #define FREE(a) trfree(a,__LINE__,__FILE__) 17 #else 18 #define MALLOC(a) malloc(a) 19 #define FREE(a) free(a) 20 #endif 21 #define NEW(a) (a *) MALLOC(sizeof(a)) 22 #define MEMCPY(a,b,n) memcpy((char*)(a),(char*)(b),n) 23 #define MEMSET(a,b,n) memset((char*)(a),(int)(b),n) 24 25 /* Macros for error checking */ 26 #define SETERR(n,s) {return PetscError(__LINE__,__FILE__,s,n);} 27 #define CHKERR(n) {if (n) SETERR(n,(char *)0);} 28 #define CHKPTR(p) if (!p) SETERR(1,"No memory"); 29 30 31 typedef struct _PetscObject* PetscObject; 32 typedef struct _Viewer* Viewer; 33 34 /* useful Petsc routines (used often) */ 35 extern int PetscInitialize(int*,char***,char*,char*); 36 extern int PetscFinalize(); 37 38 extern int PetscDestroy(PetscObject); 39 extern int PetscView(PetscObject,Viewer); 40 41 extern int PetscError(int,char*,char*,int); 42 extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,int,void*),void* ); 43 extern int PetscPopErrorHandler(); 44 45 extern int PetscDefaultErrorHandler(int,char*,char*,int,void*); 46 extern int PetscAbortErrorHandler(int,char*,char*,int,void* ); 47 extern int PetscAttachDebuggerErrorHandler(int, char *,char *,int,void*); 48 49 extern int PetscSetDebugger(char *,int,char *); 50 extern int PetscAttachDebugger(); 51 52 #include <signal.h> /* I don't like this, but? */ 53 extern int PetscSetSignalHandler(void (*)(int,int,struct sigcontext *,char*)); 54 55 extern void *trmalloc(unsigned int,int,char*); 56 extern int trfree(void *,int,char*); 57 58 59 #if defined(titan) || defined(cray) || defined(ncube) 60 #define FORTRANCAPS 61 #elif !defined(rs6000) && !defined(NeXT) && !defined(HPUX) 62 #define FORTRANUNDERSCORE 63 #endif 64 65 #endif 66