1 /* $Id: petsc.h,v 1.185 1997/11/12 04:07:52 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 /* 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 /* Use bzero instead of memset( ,0, ) */ 46 #define PREFER_BZERO 47 /* Some versions of AIX require u_type definitions */ 48 /* #define NEED_UTYPE_TYPEDEFS */ 49 #endif 50 51 #if defined(PARCH_IRIX) || defined(PARCH_IRIX64) || defined(PARCH_IRIX5) 52 /* For some reason, we don't use readlink in grpath.c for IRIX */ 53 #undef HAVE_READLINK 54 /* gettimeofday required sys/resource.h and C++ prototype for gettimeof 55 day */ 56 #define NEEDS_GETTIMEOFDAY_PROTO 57 #endif 58 59 #if defined(PARCH_paragon) || defined(PARCH_alpha) 60 /* Some versions of these systems require u_type definitions */ 61 #define NEED_UTYPE_TYPEDEFS 62 #endif 63 #endif 64 65 66 #include <stdio.h> 67 /* 68 Defines the interface to MPI allowing the use of all MPI functions. 69 */ 70 #include "mpi.h" 71 72 /* 73 Defines some elementary mathematics functions and constants. 74 */ 75 #include "petscmath.h" 76 77 extern MPI_Comm PETSC_COMM_WORLD; 78 extern MPI_Comm PETSC_COMM_SELF; 79 extern int PetscInitializedCalled; 80 extern int PetscSetCommWorld(MPI_Comm); 81 82 /* 83 Defines the malloc employed by PETSc. Users may employ these routines as well. 84 */ 85 extern void *(*PetscTrMalloc)(unsigned int,int,char*,char*,char*); 86 extern int (*PetscTrFree)(void *,int,char*,char*,char*); 87 extern int PetscSetMalloc(void *(*)(unsigned int,int,char*,char*,char*), 88 int (*)(void *,int,char*,char*,char*)); 89 #define PetscMalloc(a) (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 90 #define PetscNew(A) (A*) PetscMalloc(sizeof(A)) 91 #define PetscFree(a) (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 92 93 extern int PetscTrDump(FILE *); 94 extern int PetscTrSpace( PLogDouble *, PLogDouble *,PLogDouble *); 95 extern int PetscTrValid(int,char *,char *,char *); 96 extern int PetscTrDebugLevel(int); 97 extern int PetscTrLog(); 98 extern int PetscTrLogDump(FILE *); 99 extern int PetscGetResidentSetSize(PLogDouble *); 100 101 /* 102 Basic memory and string operations 103 */ 104 extern int PetscMemcpy(void *,void *,int); 105 extern int PetscMemmove(void *,void *,int); 106 extern int PetscMemzero(void *,int); 107 extern int PetscMemcmp(void*, void*, int); 108 extern int PetscStrlen(char *); 109 extern int PetscStrcmp(char *,char *); 110 extern int PetscStrcasecmp(char *,char *); 111 extern int PetscStrncmp(char *,char *,int ); 112 extern int PetscStrcpy(char *,char *); 113 extern int PetscStrcat(char *,char *); 114 extern int PetscStrncat(char *,char *,int); 115 extern int PetscStrncpy(char *,char *,int); 116 extern char* PetscStrchr(char *,char); 117 extern char* PetscStrrchr(char *,char); 118 extern char* PetscStrstr(char*,char*); 119 extern char* PetscStrtok(char*,char*); 120 extern char* PetscStrrtok(char*,char*); 121 122 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth; 123 #define PETSC_NULL 0 124 #define PETSC_DECIDE -1 125 #define PETSC_DETERMINE PETSC_DECIDE 126 #define PETSC_DEFAULT -2 127 128 /* 129 Each PETSc object class has it's own cookie (internal integer in the 130 data structure used for error checking). These are all defined by an offset 131 from the lowest one, PETSC_COOKIE. If you increase these you must 132 increase the field sizes in petsc/src/plog/src/plog.c 133 */ 134 #define PETSC_COOKIE 1211211 135 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30 136 #define LARGEST_PETSC_COOKIE_ALLOWED PETSC_COOKIE + 50 137 extern int LARGEST_PETSC_COOKIE; 138 139 #include "viewer.h" 140 #include "options.h" 141 142 /* 143 Defines basic graphics available from PETSc. 144 */ 145 #include "draw.h" 146 147 extern PLogDouble PetscGetTime(); 148 extern PLogDouble PetscGetCPUTime(); 149 extern void PetscSleep(int); 150 151 extern int PetscInitialize(int*,char***,char*,char*); 152 extern int PetscFinalize(); 153 extern void PetscInitializeFortran(); 154 155 /* 156 Functions that can act on any PETSc object. 157 */ 158 typedef struct _p_PetscObject* PetscObject; 159 extern int PetscObjectDestroy(PetscObject); 160 extern int PetscObjectExists(PetscObject,int*); 161 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 162 extern int PetscObjectGetCookie(PetscObject,int *cookie); 163 extern int PetscObjectGetChild(PetscObject,void **child); 164 extern int PetscObjectGetType(PetscObject,int *type); 165 extern int PetscObjectSetName(PetscObject,char*); 166 extern int PetscObjectGetName(PetscObject,char**); 167 extern int PetscObjectCompose(PetscObject,void *, int (*)(void *,void **),int (*)(void*)); 168 extern int PetscObjectReference(PetscObject); 169 extern int PetscObjectDereference(PetscObject); 170 extern int PetscObjectGetNewTag(PetscObject,int *); 171 extern int PetscObjectRestoreNewTag(PetscObject,int *); 172 extern int PetscObjectView(PetscObject,Viewer); 173 174 typedef enum {PETSC_INT = 0, PETSC_DOUBLE = 1, PETSC_SHORT = 2, PETSC_FLOAT = 3, 175 PETSC_COMPLEX = 4, PETSC_CHAR = 5} PetscDataType; 176 #if defined(USE_PETSC_COMPLEX) 177 #define PETSC_SCALAR PETSC_COMPLEX 178 #else 179 #define PETSC_SCALAR PETSC_DOUBLE 180 #endif 181 182 typedef enum {PETSC_INT_SIZE = sizeof(int), PETSC_DOUBLE_SIZE = sizeof(double), 183 PETSC_SCALAR_SIZE = sizeof(Scalar), PETSC_COMPLEX_SIZE = sizeof(double), 184 PETSC_CHAR_SIZE = sizeof(char)} PetscDataTypeSize; 185 extern int PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 186 extern int PetscDataTypeGetSize(PetscDataType,int*); 187 extern int PetscDataTypeGetName(PetscDataType,char**); 188 189 /* 190 Defines PETSc error handling. 191 */ 192 #include "petscerror.h" 193 #include "petschead.h" 194 195 /* 196 Defines PETSc profiling. 197 */ 198 #include "petsclog.h" 199 200 extern int PetscSequentialPhaseBegin(MPI_Comm,int); 201 extern int PetscSequentialPhaseEnd(MPI_Comm,int); 202 203 /*M 204 PetscBarrier - Blocks until this routine is executed by all 205 processors owning the object A. 206 207 Input Parameters: 208 . A - PETSc object ( Mat, Vec, IS, SNES etc...) 209 210 Synopsis: 211 void PetscBarrier(PetscObject obj) 212 213 Notes: 214 This routine calls MPI_Barrier with the communicator 215 of the PETSc Object "A". 216 217 .keywords: barrier, petscobject 218 M*/ 219 220 #define PetscBarrier(A) \ 221 { \ 222 PetscValidHeader(A); \ 223 PLogEventBegin(Petsc_Barrier,A,0,0,0); \ 224 MPI_Barrier(((PetscObject)A)->comm); \ 225 PLogEventEnd(Petsc_Barrier,A,0,0,0); \ 226 } 227 228 extern int PetscMPIDump(FILE *); 229 230 /* 231 This code allows one to pass a PETSc object in C 232 to a Fortran routine, where (like all PETSc objects in 233 Fortran) it is treated as an integer. 234 */ 235 extern int PetscCObjectToFortranObject(void *,int *); 236 extern int PetscFortranObjectToCObject(int,void *); 237 extern int MPICCommToFortranComm(MPI_Comm,int *); 238 extern int MPIFortranCommToCComm(int,MPI_Comm*); 239 240 /* 241 Simple PETSc parallel IO for ASCII printing 242 */ 243 extern FILE *PetscFOpen(MPI_Comm,char *,char *); 244 extern int PetscFClose(MPI_Comm,FILE*); 245 extern int PetscFPrintf(MPI_Comm,FILE*,char *,...); 246 extern int PetscPrintf(MPI_Comm,char *,...); 247 248 extern int PetscSynchronizedPrintf(MPI_Comm,char *,...); 249 extern int PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...); 250 extern int PetscSynchronizedFlush(MPI_Comm); 251 252 /* 253 For incremental debugging 254 */ 255 extern int PetscCompare; 256 extern int PetscCompareDouble(double); 257 extern int PetscCompareScalar(Scalar); 258 extern int PetscCompareInt(int); 259 260 /* 261 For use in debuggers 262 */ 263 extern int PetscGlobalRank,PetscGlobalSize; 264 extern int PetscIntView(int,int*,Viewer); 265 extern int PetscDoubleView(int,double *,Viewer); 266 267 #endif 268