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