1 /* $Id: petsc.h,v 1.186 1997/11/12 04:08:43 bsmith Exp bsmith $ */ 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.21, Released November 13, 1997." 13 14 #define PETSC_VERSION_MAJOR 2 15 #define PETSC_VERSION_MINOR 0 16 #define PETSC_VERSION_SUBMINOR 21 17 #define PETSC_VERSION_DATE "November 13, 1997" 18 19 /* ========================================================================== */ 20 /* Before anything else, include the PETSc configuration file. This 21 contains various definitions that handle portability issues and the 22 presence of important features. For backward compatibility while 23 developing, this configuration is itself conditionally included. 24 */ 25 #ifdef HAVE_PETSCCONF_H 26 #include "petscconf.h" 27 #else 28 29 /* These are temporary; they contain PARCH_xxxx -> feature-specific 30 definitions */ 31 /* Common definitions (sometimes undef'ed below) */ 32 #define HAVE_READLINK 33 #define HAVE_MEMMOVE 34 35 #if defined(PARCH_sun4) 36 /* Fortran BLAS have slow dnrm2 */ 37 #define HAVE_SLOW_NRM2 38 /* Functions that we count on Sun4's having */ 39 #define HAVE_GETWD 40 #define HAVE_REALPATH 41 /* Functions that Sun4's don't have */ 42 #undef HAVE_MEMMOVE 43 #endif 44 45 #if defined(PARCH_rs6000) 46 /* Use bzero instead of memset( ,0, ) */ 47 #define PREFER_BZERO 48 /* Some versions of AIX require u_type definitions */ 49 /* #define NEED_UTYPE_TYPEDEFS */ 50 #endif 51 52 #if defined(PARCH_IRIX) || defined(PARCH_IRIX64) || defined(PARCH_IRIX5) 53 /* For some reason, we don't use readlink in grpath.c for IRIX */ 54 #undef HAVE_READLINK 55 /* gettimeofday required sys/resource.h and C++ prototype for gettimeof 56 day */ 57 #define NEEDS_GETTIMEOFDAY_PROTO 58 #endif 59 60 #if defined(PARCH_paragon) || defined(PARCH_alpha) 61 /* Some versions of these systems require u_type definitions */ 62 #define NEED_UTYPE_TYPEDEFS 63 #endif 64 #endif 65 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 use 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 int PetscMemcpy(void *,void *,int); 107 extern int PetscMemmove(void *,void *,int); 108 extern int 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 int PetscStrcpy(char *,char *); 115 extern int PetscStrcat(char *,char *); 116 extern int PetscStrncat(char *,char *,int); 117 extern int 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_DETERMINE PETSC_DECIDE 128 #define PETSC_DEFAULT -2 129 130 /* 131 Each PETSc object class has it's own cookie (internal integer in the 132 data structure used for error checking). These are all defined by an offset 133 from the lowest one, PETSC_COOKIE. If you increase these you must 134 increase the field sizes in petsc/src/plog/src/plog.c 135 */ 136 #define PETSC_COOKIE 1211211 137 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30 138 #define LARGEST_PETSC_COOKIE_ALLOWED PETSC_COOKIE + 50 139 extern int LARGEST_PETSC_COOKIE; 140 141 #include "viewer.h" 142 #include "options.h" 143 144 /* 145 Defines basic graphics available from PETSc. 146 */ 147 #include "draw.h" 148 149 extern PLogDouble PetscGetTime(); 150 extern PLogDouble PetscGetCPUTime(); 151 extern void PetscSleep(int); 152 153 extern int PetscInitialize(int*,char***,char*,char*); 154 extern int PetscFinalize(); 155 extern void PetscInitializeFortran(); 156 157 /* 158 Functions that can act on any PETSc object. 159 */ 160 typedef struct _p_PetscObject* PetscObject; 161 extern int PetscObjectDestroy(PetscObject); 162 extern int PetscObjectExists(PetscObject,int*); 163 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 164 extern int PetscObjectGetCookie(PetscObject,int *cookie); 165 extern int PetscObjectGetChild(PetscObject,void **child); 166 extern int PetscObjectGetType(PetscObject,int *type); 167 extern int PetscObjectSetName(PetscObject,char*); 168 extern int PetscObjectGetName(PetscObject,char**); 169 extern int PetscObjectCompose(PetscObject,void *, int (*)(void *,void **),int (*)(void*)); 170 extern int PetscObjectReference(PetscObject); 171 extern int PetscObjectDereference(PetscObject); 172 extern int PetscObjectGetNewTag(PetscObject,int *); 173 extern int PetscObjectRestoreNewTag(PetscObject,int *); 174 extern int PetscObjectView(PetscObject,Viewer); 175 176 typedef enum {PETSC_INT = 0, PETSC_DOUBLE = 1, PETSC_SHORT = 2, PETSC_FLOAT = 3, 177 PETSC_COMPLEX = 4, PETSC_CHAR = 5} PetscDataType; 178 #if defined(USE_PETSC_COMPLEX) 179 #define PETSC_SCALAR PETSC_COMPLEX 180 #else 181 #define PETSC_SCALAR PETSC_DOUBLE 182 #endif 183 184 typedef enum {PETSC_INT_SIZE = sizeof(int), PETSC_DOUBLE_SIZE = sizeof(double), 185 PETSC_SCALAR_SIZE = sizeof(Scalar), PETSC_COMPLEX_SIZE = sizeof(double), 186 PETSC_CHAR_SIZE = sizeof(char)} PetscDataTypeSize; 187 extern int PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 188 extern int PetscDataTypeGetSize(PetscDataType,int*); 189 extern int PetscDataTypeGetName(PetscDataType,char**); 190 191 /* 192 Defines PETSc error handling. 193 */ 194 #include "petscerror.h" 195 #include "petschead.h" 196 197 /* 198 Defines PETSc profiling. 199 */ 200 #include "petsclog.h" 201 202 extern int PetscSequentialPhaseBegin(MPI_Comm,int); 203 extern int PetscSequentialPhaseEnd(MPI_Comm,int); 204 205 /*M 206 PetscBarrier - Blocks until this routine is executed by all 207 processors owning the object A. 208 209 Input Parameters: 210 . A - PETSc object ( Mat, Vec, IS, SNES etc...) 211 212 Synopsis: 213 void PetscBarrier(PetscObject obj) 214 215 Notes: 216 This routine calls MPI_Barrier with the communicator 217 of the PETSc Object "A". 218 219 .keywords: barrier, petscobject 220 M*/ 221 222 #define PetscBarrier(A) \ 223 { \ 224 PetscValidHeader(A); \ 225 PLogEventBegin(Petsc_Barrier,A,0,0,0); \ 226 MPI_Barrier(((PetscObject)A)->comm); \ 227 PLogEventEnd(Petsc_Barrier,A,0,0,0); \ 228 } 229 230 extern int PetscMPIDump(FILE *); 231 232 /* 233 This code allows one to pass a PETSc object in C 234 to a Fortran routine, where (like all PETSc objects in 235 Fortran) it is treated as an integer. 236 */ 237 extern int PetscCObjectToFortranObject(void *,int *); 238 extern int PetscFortranObjectToCObject(int,void *); 239 extern int MPICCommToFortranComm(MPI_Comm,int *); 240 extern int MPIFortranCommToCComm(int,MPI_Comm*); 241 242 /* 243 Simple PETSc parallel IO for ASCII printing 244 */ 245 extern FILE *PetscFOpen(MPI_Comm,char *,char *); 246 extern int PetscFClose(MPI_Comm,FILE*); 247 extern int PetscFPrintf(MPI_Comm,FILE*,char *,...); 248 extern int PetscPrintf(MPI_Comm,char *,...); 249 250 extern int PetscSynchronizedPrintf(MPI_Comm,char *,...); 251 extern int PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...); 252 extern int PetscSynchronizedFlush(MPI_Comm); 253 254 /* 255 For incremental debugging 256 */ 257 extern int PetscCompare; 258 extern int PetscCompareDouble(double); 259 extern int PetscCompareScalar(Scalar); 260 extern int PetscCompareInt(int); 261 262 /* 263 For use in debuggers 264 */ 265 extern int PetscGlobalRank,PetscGlobalSize; 266 extern int PetscIntView(int,int*,Viewer); 267 extern int PetscDoubleView(int,double *,Viewer); 268 269 #endif 270