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 #define PETSC_DECIDE -1 83 84 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth; 85 86 #include "viewer.h" 87 88 /* useful Petsc routines (used often) */ 89 extern int PetscInitialize(int*,char***,char*,char*); 90 extern int PetscFinalize(); 91 92 extern int PetscDestroy(PetscObject); 93 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 94 extern int PetscObjectSetName(PetscObject,char*); 95 extern int PetscObjectGetName(PetscObject,char**); 96 97 extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*); 98 extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* ); 99 extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*); 100 extern int PetscError(int,char*,char*,char*,int); 101 extern int PetscPushErrorHandler(int 102 (*handler)(int,char*,char*,char*,int,void*),void* ); 103 extern int PetscPopErrorHandler(); 104 105 extern int PetscSetDebugger(char *,int,char *); 106 extern int PetscAttachDebugger(); 107 108 extern int PetscDefaultSignalHandler(int,void*); 109 extern int PetscPushSignalHandler(int (*)(int,void *),void*); 110 extern int PetscPopSignalHandler(); 111 extern int PetscSetFPTrap(int); 112 #define FP_TRAP_OFF 0 113 #define FP_TRAP_ON 1 114 #define FP_TRAP_ALWAYS 2 115 116 #if defined(PETSC_MALLOC) 117 extern void *Trmalloc(unsigned int,int,char*); 118 extern int Trfree(void *,int,char*); 119 extern int Trdump(FILE *); 120 #else 121 #include <malloc.h> 122 #endif 123 124 #if defined(PARCH_cray) || defined(PARCH_NCUBE) 125 #define FORTRANCAPS 126 #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_HPUX) 127 #define FORTRANUNDERSCORE 128 #endif 129 130 #include <stdio.h> /* I don't like this, but? */ 131 132 /* Global flop counter */ 133 extern double _TotalFlops; 134 #if defined(PETSC_LOG) 135 #define PLogFlops(n) {_TotalFlops += n;} 136 #else 137 #define PLogFlops(n) 138 #endif 139 140 #endif 141