1 2 #if !defined(__PETSC_PACKAGE) 3 #define __PETSC_PACKAGE 4 5 #include <stdio.h> 6 7 /* MPI interface */ 8 #include "mpi.h" 9 #include "mpe.h" 10 #if defined(PETSC_COMPLEX) 11 #define MPI_SCALAR MPIR_dcomplex_dte 12 #else 13 #define MPI_SCALAR MPI_DOUBLE 14 #endif 15 extern FILE *MPE_fopen(MPI_Comm,char *,char *); 16 extern int MPE_fclose(MPI_Comm,FILE*); 17 extern int MPE_fprintf(MPI_Comm,FILE*,char *,...); 18 extern int MPE_printf(MPI_Comm,char *,...); 19 extern int MPE_Set_display(MPI_Comm,char **); 20 21 22 #if defined(PETSC_COMPLEX) 23 /* work around for bug in alpha g++ compiler */ 24 #if defined(PARCH_alpha) 25 #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b)) 26 /* extern double hypot(double,double); */ 27 #endif 28 #include <complex.h> 29 #define PETSCREAL(a) real(a) 30 #define Scalar complex 31 #else 32 #define PETSCREAL(a) a 33 #define Scalar double 34 #endif 35 36 37 /* Macros for getting and freeing memory */ 38 #if defined(PETSC_MALLOC) 39 #define MALLOC(a) trmalloc(a,__LINE__,__FILE__) 40 #define FREE(a) trfree(a,__LINE__,__FILE__) 41 #else 42 #define MALLOC(a) malloc(a) 43 #define FREE(a) free(a) 44 #endif 45 #define NEW(a) (a *) MALLOC(sizeof(a)) 46 #define MEMCPY(a,b,n) memcpy((char*)(a),(char*)(b),n) 47 #define MEMSET(a,b,n) memset((char*)(a),(int)(b),n) 48 #include <memory.h> 49 50 /* Macros for error checking */ 51 #if !defined(__DIR__) 52 #define __DIR__ 0 53 #endif 54 #define SETERR(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,s,n);} 55 #define SETERRA(n,s) \ 56 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\ 57 MPI_Abort(MPI_COMM_WORLD,_ierr);} 58 #define CHKERR(n) {if (n) SETERR(n,(char *)0);} 59 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 60 #define CHKPTR(p) if (!p) SETERR(1,"No memory"); 61 #define CHKPTRA(p) if (!p) SETERRA(1,"No memory"); 62 63 64 typedef struct _PetscObject* PetscObject; 65 typedef struct _Viewer* Viewer; 66 #define ViewerPrintf (void *) 0 67 68 /* useful Petsc routines (used often) */ 69 extern int PetscInitialize(int*,char***,char*,char*); 70 extern int PetscFinalize(); 71 72 extern int PetscDestroy(PetscObject); 73 extern int PetscView(PetscObject,Viewer); 74 75 extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*); 76 extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* ); 77 extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*); 78 extern int PetscError(int,char*,char*,char*,int); 79 extern int PetscPushErrorHandler(int 80 (*handler)(int,char*,char*,char*,int,void*),void* ); 81 extern int PetscPopErrorHandler(); 82 83 extern int PetscSetDebugger(char *,int,char *); 84 extern int PetscAttachDebugger(); 85 86 extern int PetscDefaultSignalHandler(int,void*); 87 extern int PetscPushSignalHandler(int (*)(int,void *),void*); 88 extern int PetscPopSignalHandler(); 89 extern int PetscSetFPTrap(int); 90 91 extern void *trmalloc(unsigned int,int,char*); 92 extern int trfree(void *,int,char*); 93 #include <stdio.h> /* I don't like this, but? */ 94 extern int trdump(FILE *); 95 96 #if defined(PARCH_cray) || defined(PARCH_NCUBE) 97 #define FORTRANCAPS 98 #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX) 99 #define FORTRANUNDERSCORE 100 #endif 101 102 #endif 103