1 /* $Id: petsc.h,v 1.56 1995/08/22 02:23:57 bsmith Exp bsmith $ */ 2 3 #if !defined(__PETSC_PACKAGE) 4 #define __PETSC_PACKAGE 5 6 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.Beta.7 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 #define PETSCABS(a) ( ((a)<0) ? -(a) : (a) ) 51 52 /* Macros for error checking */ 53 #if !defined(__DIR__) 54 #define __DIR__ 0 55 #endif 56 57 /* 58 Unable to malloc error and no supported function 59 */ 60 #define PETSC_ERR_MEM 55 61 #define PETSC_ERR_SUP 56 62 63 #if defined(PETSC_DEBUG) 64 #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,s,n);} 65 #define SETERRA(n,s) \ 66 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\ 67 MPI_Abort(MPI_COMM_WORLD,_ierr);} 68 #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 69 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 70 #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0); 71 #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,(char*)0); 72 #else 73 #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,s,n);} 74 #define SETERRA(n,s) \ 75 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\ 76 MPI_Abort(MPI_COMM_WORLD,_ierr);} 77 #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 78 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 79 #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0); 80 #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,(char*)0); 81 #endif 82 83 typedef struct _PetscObject* PetscObject; 84 #define PETSC_COOKIE 1211211 85 #define PETSC_DECIDE -1 86 #define PETSC_DEFAULT -2 87 88 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth; 89 90 #include "viewer.h" 91 #include "options.h" 92 93 extern int PetscInitialize(int*,char***,char*,char*); 94 extern int PetscFinalize(); 95 96 extern int PetscObjectDestroy(PetscObject); 97 extern int PetscObjectExists(PetscObject,int*); 98 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 99 extern int PetscObjectSetName(PetscObject,char*); 100 extern int PetscObjectGetName(PetscObject,char**); 101 102 extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*); 103 extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* ); 104 extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*); 105 extern int PetscError(int,char*,char*,char*,int); 106 extern int PetscPushErrorHandler(int 107 (*handler)(int,char*,char*,char*,int,void*),void* ); 108 extern int PetscPopErrorHandler(); 109 110 extern int PetscSetDebugger(char *,int,char *); 111 extern int PetscAttachDebugger(); 112 113 extern int PetscDefaultSignalHandler(int,void*); 114 extern int PetscPushSignalHandler(int (*)(int,void *),void*); 115 extern int PetscPopSignalHandler(); 116 extern int PetscSetFPTrap(int); 117 #define FP_TRAP_OFF 0 118 #define FP_TRAP_ON 1 119 #define FP_TRAP_ALWAYS 2 120 121 /* 122 Definitions used for the Fortran interface: 123 FORTRANCAPS: Names are uppercase, no trailing underscore 124 FORTRANUNDERSCORE: Names are lowercase, trailing underscore 125 */ 126 #if defined(PARCH_cray) || defined(PARCH_NCUBE) || defined(PARCH_t3d) 127 #define FORTRANCAPS 128 #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_hpux) 129 #define FORTRANUNDERSCORE 130 #endif 131 132 #include "phead.h" 133 #include "plog.h" 134 135 extern void PetscSleep(int); 136 137 #endif 138