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