1 /* $Id: petsc.h,v 1.45 1995/07/25 02:44:01 curfman Exp bsmith $ */ 2 3 #if !defined(__PETSC_PACKAGE) 4 #define __PETSC_PACKAGE 5 6 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.Beta.6 Released ?, 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 PETSCMALLOC(a) (*PetscMalloc)(a,__LINE__,__FILE__) 37 #define PETSCFREE(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 extern int TrGetMaximumAllocated(double*); 42 43 #define PETSCNEW(A) (A*) PETSCMALLOC(sizeof(A)) 44 #define PETSCMEMCPY(a,b,n) memcpy((char*)(a),(char*)(b),n) 45 #define PETSCMEMSET(a,b,n) memset((char*)(a),(int)(b),n) 46 #include <memory.h> 47 48 #define PETSCMIN(a,b) ( ((a)<(b)) ? (a) : (b) ) 49 #define PETSCMAX(a,b) ( ((a)<(b)) ? (b) : (a) ) 50 51 /* Macros for error checking */ 52 #if !defined(__DIR__) 53 #define __DIR__ 0 54 #endif 55 #if defined(PETSC_DEBUG) 56 #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,s,n);} 57 #define SETERRA(n,s) \ 58 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\ 59 MPI_Abort(MPI_COMM_WORLD,_ierr);} 60 #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 61 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 62 #define CHKPTRQ(p) if (!p) SETERRQ(1,"PETSC ERROR: No memory"); 63 #define CHKPTRA(p) if (!p) SETERRA(1,"PETSC ERROR: No memory"); 64 #else 65 #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,s,n);} 66 #define SETERRA(n,s) \ 67 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\ 68 MPI_Abort(MPI_COMM_WORLD,_ierr);} 69 #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 70 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 71 #define CHKPTRQ(p) if (!p) SETERRQ(1,"PETSC ERROR: No memory"); 72 #define CHKPTRA(p) if (!p) SETERRA(1,"PETSC ERROR: No memory"); 73 #endif 74 75 typedef struct _PetscObject* PetscObject; 76 #define PETSC_COOKIE 0x12121212 77 #define PETSC_DECIDE -1 78 #define PETSC_DEFAULT 0 79 80 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth; 81 82 #include "viewer.h" 83 #include "options.h" 84 85 extern int PetscInitialize(int*,char***,char*,char*); 86 extern int PetscFinalize(); 87 88 extern int PetscObjectDestroy(PetscObject); 89 extern int PetscObjectExists(PetscObject,int*); 90 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 91 extern int PetscObjectSetName(PetscObject,char*); 92 extern int PetscObjectGetName(PetscObject,char**); 93 94 extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*); 95 extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* ); 96 extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*); 97 extern int PetscError(int,char*,char*,char*,int); 98 extern int PetscPushErrorHandler(int 99 (*handler)(int,char*,char*,char*,int,void*),void* ); 100 extern int PetscPopErrorHandler(); 101 102 extern int PetscSetDebugger(char *,int,char *); 103 extern int PetscAttachDebugger(); 104 105 extern int PetscDefaultSignalHandler(int,void*); 106 extern int PetscPushSignalHandler(int (*)(int,void *),void*); 107 extern int PetscPopSignalHandler(); 108 extern int PetscSetFPTrap(int); 109 #define FP_TRAP_OFF 0 110 #define FP_TRAP_ON 1 111 #define FP_TRAP_ALWAYS 2 112 113 /* 114 Definitions used for the Fortran interface: 115 FORTRANCAPS: Names are uppercase, no trailing underscore 116 FORTRANUNDERSCORE: Names are lowercase, trailing underscore 117 */ 118 #if defined(PARCH_cray) || defined(PARCH_NCUBE) || defined(PARCH_t3d) 119 #define FORTRANCAPS 120 #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_hpux) 121 #define FORTRANUNDERSCORE 122 #endif 123 124 /* Global flop counter */ 125 extern double _TotalFlops; 126 #if defined(PETSC_LOG) 127 #define PLogFlops(n) {_TotalFlops += n;} 128 #else 129 #define PLogFlops(n) 130 #endif 131 132 /*M 133 PLogFlops - Adds floating point operations to the global counter. 134 135 Input Parameter: 136 . f - flop counter 137 138 Synopsis: 139 PLogFlops(int f) 140 141 Notes: 142 A global counter logs all PETSc flop counts. The user can use 143 PLogFlops() to increment this counter to include flops for the 144 application code. 145 146 PETSc automatically logs library events if the code has been 147 compiled with -DPETSC_LOG (which is the default), and -log, 148 -log_summary, or -log_all are specified. PLogFlops() is 149 intended for logging user flops to supplement this PETSc 150 information. 151 152 Example of Usage: 153 $ #define USER_EVENT 75 154 $ PLogEventRegister(USER_EVENT,"User event"); 155 $ PLogEventBegin(USER_EVENT,0,0,0,0); 156 $ [code segment to monitor] 157 $ PLogFlops(user_flops) 158 $ PLogEventEnd(USER_EVENT,0,0,0,0); 159 160 .seealso: PLogEventRegister(), PLogEventBegin(), PLogEventEnd() 161 162 .keywords: Petsc, log, flops, floating point operations 163 M*/ 164 165 extern int PLogPrint(MPI_Comm,FILE *); 166 extern int PLogBegin(); 167 extern int PLogAllBegin(); 168 extern int PLogDump(char*); 169 170 #endif 171