1 /* $Id: petsc.h,v 1.172 1997/09/05 19:36:26 gropp Exp gropp $ */ 2 /* 3 This is the main PETSc include file (for C and C++). It is included by 4 all other PETSc include files so almost never has to be specifically included. 5 */ 6 #if !defined(__PETSC_PACKAGE) 7 #define __PETSC_PACKAGE 8 9 /* 10 Current PETSc Version 11 */ 12 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.19, Released August 13, 1997." 13 14 #define PETSC_VERSION_MAJOR 2 15 #define PETSC_VERSION_MINOR 0 16 #define PETSC_VERSION_SUBMINOR 19 17 #define PETSC_VERSION_DATE "August 13, 1997" 18 19 /* Before anything else, include the PETSc configuration file. This 20 contains various definitions that handle portability issues and the 21 presence of important features. For backward compatibility while 22 developing, this configuration is itself conditionally included. 23 */ 24 #ifdef HAVE_PETSCCONF_H 25 #include "petscconf.h" 26 #else 27 28 /* These are temporary; they contain PARCH_xxxx -> feature-specific 29 definitions */ 30 /* Common definitions (sometimes undef'ed below) */ 31 #define HAVE_READLINK 32 #define HAVE_MEMMOVE 33 34 #if defined(PARCH_sun4) 35 /* Fortran BLAS have slow dnrm2 */ 36 #define HAVE_SLOW_NRM2 37 /* Functions that we count on Sun4's having */ 38 #define HAVE_GETWD 39 #define HAVE_REALPATH 40 /* Functions that Sun4's don't have */ 41 #undef HAVE_MEMMOVE 42 #endif 43 44 #if defined(PARCH_rs6000) 45 /* Some versions of IBM's MPI have broken MPI_Request_free */ 46 #define HAVE_BROKEN_REQUEST_FREE 47 /* Use bzero instead of memset( ,0, ) */ 48 #define PREFER_BZERO 49 /* Some versions of AIX require u_type definitions */ 50 #define NEED_UTYPE_TYPEDEFS 51 #endif 52 53 #if defined(PARCH_IRIX) || defined(PARCH_IRIX64) 54 /* For some reason, we don't use readlink in grpath.c for IRIX */ 55 #undef HAVE_READLINK 56 /* gettimeofday required sys/resource.h and C++ prototype for gettimeof 57 day */ 58 #define NEEDS_GETTIMEOFDAY_PROTO 59 #endif 60 61 #if defined(PARCH_paragon) || defined(PARCH_alpha) 62 /* Some versions of these systems require u_type definitions */ 63 #define NEED_UTYPE_TYPEDEFS 64 #endif 65 #endif 66 67 68 #include <stdio.h> 69 /* 70 Defines the interface to MPI allowing the use of all MPI functions. 71 */ 72 #include "mpi.h" 73 74 /* 75 Defines some elementary mathematics functions and constants. 76 */ 77 #include "petscmath.h" 78 79 extern MPI_Comm PETSC_COMM_WORLD; 80 extern MPI_Comm PETSC_COMM_SELF; 81 extern int PetscInitializedCalled; 82 extern int PetscSetCommWorld(MPI_Comm); 83 84 /* 85 Defines the malloc employed by PETSc. Users may employ these routines as well. 86 */ 87 extern void *(*PetscTrMalloc)(unsigned int,int,char*,char*,char*); 88 extern int (*PetscTrFree)(void *,int,char*,char*,char*); 89 extern int PetscSetMalloc(void *(*)(unsigned int,int,char*,char*,char*), 90 int (*)(void *,int,char*,char*,char*)); 91 #define PetscMalloc(a) (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 92 #define PetscNew(A) (A*) PetscMalloc(sizeof(A)) 93 #define PetscFree(a) (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 94 95 extern int PetscTrDump(FILE *); 96 extern int PetscTrSpace( PLogDouble *, PLogDouble *,PLogDouble *); 97 extern int PetscTrValid(int,char *,char *,char *); 98 extern int PetscTrDebugLevel(int); 99 extern int PetscTrLog(); 100 extern int PetscTrLogDump(FILE *); 101 extern int PetscGetResidentSetSize(PLogDouble *); 102 103 /* 104 Basic memory and string operations 105 */ 106 extern void PetscMemcpy(void *,void *,int); 107 extern void PetscMemmove(void *,void *,int); 108 extern void PetscMemzero(void *,int); 109 extern int PetscMemcmp(void*, void*, int); 110 extern int PetscStrlen(char *); 111 extern int PetscStrcmp(char *,char *); 112 extern int PetscStrcasecmp(char *,char *); 113 extern int PetscStrncmp(char *,char *,int ); 114 extern void PetscStrcpy(char *,char *); 115 extern void PetscStrcat(char *,char *); 116 extern void PetscStrncat(char *,char *,int); 117 extern void PetscStrncpy(char *,char *,int); 118 extern char* PetscStrchr(char *,char); 119 extern char* PetscStrrchr(char *,char); 120 extern char* PetscStrstr(char*,char*); 121 extern char* PetscStrtok(char*,char*); 122 extern char* PetscStrrtok(char*,char*); 123 124 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth; 125 #define PETSC_NULL 0 126 #define PETSC_DECIDE -1 127 #define PETSC_DEFAULT -2 128 129 /* 130 Each PETSc object class has it's own cookie (internal integer in the 131 data structure used for error checking). These are all defined by an offset 132 from the lowest one, PETSC_COOKIE. If you increase these you must 133 increase the field sizes in petsc/src/plog/src/plog.c 134 */ 135 #define PETSC_COOKIE 1211211 136 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30 137 #define LARGEST_PETSC_COOKIE_ALLOWED PETSC_COOKIE + 50 138 extern int LARGEST_PETSC_COOKIE; 139 140 #include "viewer.h" 141 #include "options.h" 142 143 /* 144 Defines basic graphics available from PETSc. 145 */ 146 #include "draw.h" 147 148 extern PLogDouble PetscGetTime(); 149 extern PLogDouble PetscGetCPUTime(); 150 extern void PetscSleep(int); 151 152 extern int PetscInitialize(int*,char***,char*,char*); 153 extern int PetscFinalize(); 154 extern void PetscInitializeFortran(); 155 156 /* 157 Functions that can act on any PETSc object. 158 */ 159 typedef struct _p_PetscObject* PetscObject; 160 extern int PetscObjectDestroy(PetscObject); 161 extern int PetscObjectExists(PetscObject,int*); 162 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 163 extern int PetscObjectGetCookie(PetscObject,int *cookie); 164 extern int PetscObjectGetChild(PetscObject,void **child); 165 extern int PetscObjectGetType(PetscObject,int *type); 166 extern int PetscObjectSetName(PetscObject,char*); 167 extern int PetscObjectGetName(PetscObject,char**); 168 extern int PetscObjectInherit(PetscObject,void *, int (*)(void *,void **),int (*)(void*)); 169 extern int PetscObjectReference(PetscObject); 170 extern int PetscObjectGetNewTag(PetscObject,int *); 171 extern int PetscObjectRestoreNewTag(PetscObject,int *); 172 extern int PetscObjectView(PetscObject,Viewer); 173 174 /* 175 Defines PETSc error handling. 176 */ 177 #include "petscerror.h" 178 #include "petschead.h" 179 180 /* 181 Defines PETSc profiling. 182 */ 183 #include "petsclog.h" 184 185 extern int PetscSequentialPhaseBegin(MPI_Comm,int); 186 extern int PetscSequentialPhaseEnd(MPI_Comm,int); 187 188 /*M 189 PetscBarrier - Blocks until this routine is executed by all 190 processors owning the object A. 191 192 Input Parameters: 193 . A - PETSc object ( Mat, Vec, IS, SNES etc...) 194 195 Synopsis: 196 void PetscBarrier(PetscObject obj) 197 198 Notes: 199 This routine calls MPI_Barrier with the communicator 200 of the PETSc Object "A". 201 202 .keywords: barrier, petscobject 203 M*/ 204 205 #define PetscBarrier(A) \ 206 { \ 207 PetscValidHeader(A); \ 208 PLogEventBegin(Petsc_Barrier,A,0,0,0); \ 209 MPI_Barrier(((PetscObject)A)->comm); \ 210 PLogEventEnd(Petsc_Barrier,A,0,0,0); \ 211 } 212 213 extern int PetscMPIDump(FILE *); 214 215 /* 216 This code allows one to pass a PETSc object in C 217 to a Fortran routine, where (like all PETSc objects in 218 Fortran) it is treated as an integer. 219 */ 220 extern int PetscCObjectToFortranObject(void *,int *); 221 extern int PetscFortranObjectToCObject(int,void *); 222 extern int MPICCommToFortranComm(MPI_Comm,int *); 223 extern int MPIFortranCommToCComm(int,MPI_Comm*); 224 225 extern FILE *PetscFOpen(MPI_Comm,char *,char *); 226 extern int PetscFClose(MPI_Comm,FILE*); 227 extern int PetscFPrintf(MPI_Comm,FILE*,char *,...); 228 extern int PetscPrintf(MPI_Comm,char *,...); 229 230 extern int PetscSynchronizedPrintf(MPI_Comm,char *,...); 231 extern int PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...); 232 extern int PetscSynchronizedFlush(MPI_Comm); 233 234 /* 235 For incremental debugging 236 */ 237 extern int PetscCompare; 238 extern int PetscCompareDouble(double); 239 extern int PetscCompareScalar(Scalar); 240 extern int PetscCompareInt(int); 241 242 /* 243 For use in debuggers 244 */ 245 extern int PetscGlobalRank,PetscGlobalSize; 246 extern int PetscIntView(int,int*,Viewer); 247 extern int PetscDoubleView(int,double *,Viewer); 248 249 #endif 250