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