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