1 /* $Id: snes.h,v 1.17 1995/06/02 21:05:19 bsmith Exp $ */ 2 3 #if !defined(__PETSC_PACKAGE) 4 #define __PETSC_PACKAGE 5 6 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.Beta.3 Released May 29, 1995." 7 8 #include <stdio.h> 9 #if defined(PARCH_sun4) 10 int fprintf(FILE*,char*,...); 11 int printf(char*,...); 12 int fflush(FILE*); 13 int fclose(FILE*); 14 #endif 15 16 /* MPI interface */ 17 #include "mpi.h" 18 #include "mpiu.h" 19 20 #if defined(PETSC_COMPLEX) 21 /* work around for bug in alpha g++ compiler */ 22 #if defined(PARCH_alpha) 23 #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b)) 24 /* extern double hypot(double,double); */ 25 #endif 26 #include <complex.h> 27 #define PETSCREAL(a) real(a) 28 #define Scalar complex 29 #else 30 #define PETSCREAL(a) a 31 #define Scalar double 32 #endif 33 34 extern void *(*PetscMalloc)(unsigned int,int,char*); 35 extern int (*PetscFree)(void *,int,char*); 36 #define MALLOC(a) (*PetscMalloc)(a,__LINE__,__FILE__) 37 #define FREE(a) (*PetscFree)(a,__LINE__,__FILE__) 38 extern int PetscSetMalloc(void *(*)(unsigned int,int,char*), 39 int (*)(void *,int,char*)); 40 extern int Trdump(FILE *); 41 42 #define NEW(a) (a *) MALLOC(sizeof(a)) 43 #define MEMCPY(a,b,n) memcpy((char*)(a),(char*)(b),n) 44 #define MEMSET(a,b,n) memset((char*)(a),(int)(b),n) 45 #include <memory.h> 46 47 /* Macros for error checking */ 48 #if !defined(__DIR__) 49 #define __DIR__ 0 50 #endif 51 #if defined(PETSC_DEBUG) 52 #define SETERR(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,s,n);} 53 #define SETERRA(n,s) \ 54 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\ 55 MPI_Abort(MPI_COMM_WORLD,_ierr);} 56 #define CHKERR(n) {if (n) SETERR(n,(char *)0);} 57 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 58 #define CHKPTR(p) if (!p) SETERR(1,"No memory"); 59 #define CHKPTRA(p) if (!p) SETERRA(1,"No memory"); 60 #else 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 #endif 70 71 typedef struct _PetscObject* PetscObject; 72 #define PETSC_COOKIE 0x12121212 73 #define PETSC_DECIDE -1 74 75 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth; 76 77 #include "viewer.h" 78 #include "options.h" 79 80 /* useful Petsc routines (used often) */ 81 extern int PetscInitialize(int*,char***,char*,char*); 82 extern int PetscFinalize(); 83 84 extern int PetscDestroy(PetscObject); 85 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 86 extern int PetscObjectSetName(PetscObject,char*); 87 extern int PetscObjectGetName(PetscObject,char**); 88 89 extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*); 90 extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* ); 91 extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*); 92 extern int PetscError(int,char*,char*,char*,int); 93 extern int PetscPushErrorHandler(int 94 (*handler)(int,char*,char*,char*,int,void*),void* ); 95 extern int PetscPopErrorHandler(); 96 97 extern int PetscSetDebugger(char *,int,char *); 98 extern int PetscAttachDebugger(); 99 100 extern int PetscDefaultSignalHandler(int,void*); 101 extern int PetscPushSignalHandler(int (*)(int,void *),void*); 102 extern int PetscPopSignalHandler(); 103 extern int PetscSetFPTrap(int); 104 #define FP_TRAP_OFF 0 105 #define FP_TRAP_ON 1 106 #define FP_TRAP_ALWAYS 2 107 108 109 #if defined(PARCH_cray) || defined(PARCH_NCUBE) 110 #define FORTRANCAPS 111 #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_hpux) 112 #define FORTRANUNDERSCORE 113 #endif 114 115 #include <stdio.h> /* I don't like this, but? */ 116 117 /* Global flop counter */ 118 extern double _TotalFlops; 119 #if defined(PETSC_LOG) 120 #define PLogFlops(n) {_TotalFlops += n;} 121 #else 122 #define PLogFlops(n) 123 #endif 124 125 #endif 126