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