1 /* $Id: petsc.h,v 1.58 1995/09/21 20:13:13 bsmith Exp bsmith $ */ 2 3 #if !defined(__PETSC_PACKAGE) 4 #define __PETSC_PACKAGE 5 6 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.Beta.8 Released ?, 1995." 7 8 #include <stdio.h> 9 #if defined(PARCH_sun4) && !defined(__cplusplus) 10 extern int fprintf(FILE*,const char*,...); 11 extern int printf(const char*,...); 12 extern int fflush(FILE *); 13 #endif 14 15 /* MPI interface */ 16 #include "mpi.h" 17 #include "mpiu.h" 18 19 #if defined(PETSC_COMPLEX) 20 /* work around for bug in alpha g++ compiler */ 21 #if defined(PARCH_alpha) 22 #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b)) 23 #endif 24 #include <complex.h> 25 #define PETSCREAL(a) real(a) 26 #define Scalar complex 27 #else 28 #define PETSCREAL(a) a 29 #define Scalar double 30 #endif 31 32 extern void *(*PetscMalloc)(unsigned int,int,char*); 33 extern int (*PetscFree)(void *,int,char*); 34 #define PETSCMALLOC(a) (*PetscMalloc)(a,__LINE__,__FILE__) 35 #define PETSCFREE(a) (*PetscFree)(a,__LINE__,__FILE__) 36 extern int PetscSetMalloc(void *(*)(unsigned int,int,char*),int (*)(void *,int,char*)); 37 extern int TrDump(FILE *); 38 extern int TrGetMaximumAllocated(double*); 39 40 #define PETSCNEW(A) (A*) PETSCMALLOC(sizeof(A)) 41 42 extern void PetscMemcpy(void *,void *,int); 43 extern void PetscZero(void *,int); 44 extern int PetscStrlen(char *); 45 extern int PetscStrcmp(char *,char *); 46 extern int PetscStrncmp(char *,char *,int ); 47 extern void PetscStrcpy(char *,char *); 48 extern void PetscStrcat(char *,char *); 49 extern void PetscStrncat(char *,char *,int); 50 extern void PetscStrncpy(char *,char *,int); 51 extern char* PetscStrchr(char *,char); 52 extern char* PetscStrrchr(char *,char); 53 extern char* PetscStrstr(char*,char*); 54 extern char* PetscStrtok(char*,char*); 55 extern char* PetscStrrtok(char*,char*); 56 57 #define PETSCMIN(a,b) ( ((a)<(b)) ? (a) : (b) ) 58 #define PETSCMAX(a,b) ( ((a)<(b)) ? (b) : (a) ) 59 #define PETSCABS(a) ( ((a)<0) ? -(a) : (a) ) 60 61 /* Macros for error checking */ 62 #if !defined(__DIR__) 63 #define __DIR__ 0 64 #endif 65 66 /* 67 Unable to malloc error and no supported function 68 */ 69 #define PETSC_ERR_MEM 55 /* unable to allocate requested memory */ 70 #define PETSC_ERR_SUP 56 /* no support yet for this operation */ 71 #define PETSC_ERR_ARG 57 /* bad input argument */ 72 #define PETSC_ERR_OBJ 58 /* null or corrupt PETSc object */ 73 74 #if defined(PETSC_DEBUG) 75 #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,s,n);} 76 #define SETERRA(n,s) {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\ 77 MPI_Abort(MPI_COMM_WORLD,_ierr);} 78 #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 79 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 80 #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0); 81 #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,(char*)0); 82 #else 83 #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,s,n);} 84 #define SETERRA(n,s) {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\ 85 MPI_Abort(MPI_COMM_WORLD,_ierr);} 86 #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 87 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 88 #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0); 89 #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,(char*)0); 90 #endif 91 92 typedef struct _PetscObject* PetscObject; 93 #define PETSC_COOKIE 1211211 94 #define PETSC_DECIDE -1 95 #define PETSC_DEFAULT -2 96 97 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth; 98 99 #include "viewer.h" 100 #include "options.h" 101 102 extern int PetscInitialize(int*,char***,char*,char*,char*); 103 extern int PetscFinalize(); 104 105 extern int PetscObjectDestroy(PetscObject); 106 extern int PetscObjectExists(PetscObject,int*); 107 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 108 extern int PetscObjectSetName(PetscObject,char*); 109 extern int PetscObjectGetName(PetscObject,char**); 110 111 extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*); 112 extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* ); 113 extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*); 114 extern int PetscError(int,char*,char*,char*,int); 115 extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,char*,int,void*),void*); 116 extern int PetscPopErrorHandler(); 117 118 extern int PetscSetDebugger(char *,int,char *); 119 extern int PetscAttachDebugger(); 120 121 extern int PetscDefaultSignalHandler(int,void*); 122 extern int PetscPushSignalHandler(int (*)(int,void *),void*); 123 extern int PetscPopSignalHandler(); 124 extern int PetscSetFPTrap(int); 125 #define FP_TRAP_OFF 0 126 #define FP_TRAP_ON 1 127 #define FP_TRAP_ALWAYS 2 128 129 /* 130 Definitions used for the Fortran interface: 131 FORTRANCAPS: Names are uppercase, no trailing underscore 132 FORTRANUNDERSCORE: Names are lowercase, trailing underscore 133 */ 134 #if defined(PARCH_cray) || defined(PARCH_NCUBE) || defined(PARCH_t3d) 135 #define FORTRANCAPS 136 #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_hpux) 137 #define FORTRANUNDERSCORE 138 #endif 139 140 #include "phead.h" 141 #include "plog.h" 142 143 extern void PetscSleep(int); 144 145 #endif 146