1 /* $Id: petsc.h,v 1.214 1998/04/29 18:10:40 balay Exp balay $ */ 2 /* 3 This is the main PETSc include file (for C and C++). It is included by all 4 other PETSc include files, so it almost never has to be specifically included. 5 */ 6 #if !defined(__PETSC_PACKAGE) 7 #define __PETSC_PACKAGE 8 9 /* 10 Current PETSc Version 11 Note: Fix the version info in Changes.html, docs/tex/manual/manual.tex 12 */ 13 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.22, Released April 28, 1998." 14 15 #define PETSC_VERSION_MAJOR 2 16 #define PETSC_VERSION_MINOR 0 17 #define PETSC_VERSION_SUBMINOR 22 18 #define PETSC_VERSION_DATE "April 29, 1998" 19 #define PETSC_AUTHOR_INFO "The PETSc Team:\ 20 Satish Balay, Bill Gropp, Lois Curfman McInnes, Barry Smith\n\ 21 Bug reports, questions: petsc-maint@mcs.anl.gov\n\ 22 Web page: http://www.mcs.anl.gov/petsc/\n" 23 24 /* ========================================================================== */ 25 /* Before anything else, include the PETSc configuration file. This 26 contains various definitions that handle portability issues and the 27 presence of important features. 28 29 petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h 30 */ 31 #include "petscconf.h" 32 33 34 /* ========================================================================== */ 35 36 #include <stdio.h> 37 /* 38 Defines the interface to MPI allowing the use of all MPI functions. 39 */ 40 #include "mpi.h" 41 42 /* 43 Defines some elementary mathematics functions and constants. 44 */ 45 #include "petscmath.h" 46 /* 47 This shouuld be in petscmath.h? 48 */ 49 #if defined(USE_POINTER_CONVERSION) 50 #define PetscFortranAddr int 51 #else 52 #define PetscFortranAddr long 53 #endif 54 55 extern MPI_Comm PETSC_COMM_WORLD; 56 extern MPI_Comm PETSC_COMM_SELF; 57 extern int PetscInitializedCalled; 58 extern int PetscSetCommWorld(MPI_Comm); 59 60 /* 61 Defines the malloc employed by PETSc. Users may use these routines as well. 62 */ 63 #define PetscMalloc(a) (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 64 #define PetscNew(A) (A*) PetscMalloc(sizeof(A)) 65 #define PetscFree(a) (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 66 extern void *(*PetscTrMalloc)(unsigned int,int,char*,char*,char*); 67 extern int (*PetscTrFree)(void *,int,char*,char*,char*); 68 extern int PetscSetMalloc(void *(*)(unsigned int,int,char*,char*,char*), 69 int (*)(void *,int,char*,char*,char*)); 70 extern int PetscClearMalloc(void); 71 72 extern int PetscTrDump(FILE *); 73 extern int PetscTrSpace( PLogDouble *, PLogDouble *,PLogDouble *); 74 extern int PetscTrValid(int,char *,char *,char *); 75 extern int PetscTrDebugLevel(int); 76 extern int PetscTrLog(void); 77 extern int PetscTrLogDump(FILE *); 78 extern int PetscGetResidentSetSize(PLogDouble *); 79 80 #include "src/inline/bitarray.h" 81 82 typedef enum {PETSC_INT = 0, PETSC_DOUBLE = 1, PETSC_SHORT = 2, PETSC_FLOAT = 3, 83 PETSC_COMPLEX = 4, PETSC_CHAR = 5, PETSC_LOGICAL = 6} PetscDataType; 84 #if defined(USE_PETSC_COMPLEX) 85 #define PETSC_SCALAR PETSC_COMPLEX 86 #else 87 #define PETSC_SCALAR PETSC_DOUBLE 88 #endif 89 90 typedef enum {PETSC_INT_SIZE = sizeof(int), PETSC_DOUBLE_SIZE = sizeof(double), 91 PETSC_SCALAR_SIZE = sizeof(Scalar), PETSC_COMPLEX_SIZE = sizeof(double), 92 PETSC_CHAR_SIZE = sizeof(char), PETSC_LOGICAL_SIZE = 1} PetscDataTypeSize; 93 extern int PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 94 extern int PetscDataTypeGetSize(PetscDataType,int*); 95 extern int PetscDataTypeGetName(PetscDataType,char**); 96 97 /* 98 Basic memory and string operations 99 */ 100 extern int PetscMemcpy(void *,void *,int); 101 extern int PetscBitMemcpy(void*,int,void*,int,int,PetscDataType); 102 extern int PetscMemmove(void *,void *,int); 103 extern int PetscMemzero(void *,int); 104 extern int PetscMemcmp(void*, void*, int); 105 extern int PetscStrlen(char *); 106 extern int PetscStrcmp(char *,char *); 107 extern int PetscStrcasecmp(char *,char *); 108 extern int PetscStrncmp(char *,char *,int ); 109 extern int PetscStrcpy(char *,char *); 110 extern int PetscStrcat(char *,char *); 111 extern int PetscStrncat(char *,char *,int); 112 extern int PetscStrncpy(char *,char *,int); 113 extern char* PetscStrchr(char *,char); 114 extern char* PetscStrrchr(char *,char); 115 extern char* PetscStrstr(char*,char*); 116 extern char* PetscStrtok(char*,char*); 117 extern char* PetscStrrtok(char*,char*); 118 119 /* 120 Basic PETSc constants 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 int PetscGetTime(PLogDouble*); 148 extern int PetscGetCPUTime(PLogDouble*); 149 extern int PetscSleep(int); 150 151 extern int PetscInitialize(int*,char***,char*,char*); 152 extern int PetscInitializeNoArguments(void); 153 extern int PetscFinalize(void); 154 extern void PetscInitializeFortran(void); 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 PetscObjectGetType(PetscObject,int *type); 165 extern int PetscObjectSetName(PetscObject,char*); 166 extern int PetscObjectGetName(PetscObject,char**); 167 extern int PetscObjectReference(PetscObject); 168 extern int PetscObjectGetReference(PetscObject,int*); 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 extern int PetscObjectCompose(PetscObject,char *,PetscObject); 175 extern int PetscObjectQuery(PetscObject,char *,PetscObject *); 176 #if defined(USE_DYNAMIC_LIBRARIES) 177 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,0) 178 #else 179 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,d) 180 #endif 181 extern int PetscObjectComposeFunction_Private(PetscObject,char *,char *,void *); 182 extern int PetscObjectQueryFunction(PetscObject,char *,void **); 183 184 185 /* 186 Defines PETSc error handling. 187 */ 188 #include "petscerror.h" 189 190 /* 191 Mechanism for managing lists of objects attached (composed) with 192 a PETSc object. 193 */ 194 typedef struct _OList *OList; 195 extern int OListDestroy(OList *); 196 extern int OListFind(OList,char *,PetscObject*); 197 extern int OListAdd(OList *,char *,PetscObject); 198 extern int OListRemove(OList *,char *); 199 extern int OListDuplicate(OList,OList *); 200 201 /* 202 Dynamic library lists. Lists of names of routines in dynamic 203 link libraries that will be loaded as needed. 204 */ 205 typedef struct _DLList *DLList; 206 extern int DLRegister_Private(DLList*,char*,char*,int (*)(void *)); 207 extern int DLRegisterCreate(DLList *); 208 extern int DLRegisterDestroy(DLList); 209 extern int DLRegisterFind(MPI_Comm,DLList,char*,int (**)(void*)); 210 extern int DLRegisterPrintTypes(MPI_Comm,FILE*,char*,char *,DLList); 211 #if defined(USE_DYNAMIC_LIBRARIES) 212 #define DLRegister(a,b,p,c) DLRegister_Private(a,b,p,0) 213 #else 214 #define DLRegister(a,b,p,c) DLRegister_Private(a,b,p,(int (*)(void *))c) 215 #endif 216 217 typedef struct _DLLibraryList *DLLibraryList; 218 extern DLLibraryList DLLibrariesLoaded; 219 extern int DLLibraryOpen(MPI_Comm,char *,void **); 220 extern int DLLibrarySym(MPI_Comm,DLLibraryList *,char*,char *, void **); 221 extern int DLLibraryAppend(MPI_Comm,DLLibraryList *,char *); 222 extern int DLLibraryPrepend(MPI_Comm,DLLibraryList *,char *); 223 extern int DLLibraryClose(DLLibraryList); 224 225 226 #include "petschead.h" 227 228 /* 229 Defines PETSc profiling. 230 */ 231 #include "petsclog.h" 232 233 extern int PetscSequentialPhaseBegin(MPI_Comm,int); 234 extern int PetscSequentialPhaseEnd(MPI_Comm,int); 235 236 /*M 237 PetscBarrier - Blocks until this routine is executed by all 238 processors owning the object A. 239 240 Input Parameters: 241 . A - PETSc object ( Mat, Vec, IS, SNES etc...) 242 243 Synopsis: 244 void PetscBarrier(PetscObject obj) 245 246 Notes: 247 This routine calls MPI_Barrier with the communicator 248 of the PETSc Object "A". 249 250 .keywords: barrier, petscobject 251 M*/ 252 253 #define PetscBarrier(A) \ 254 { \ 255 PetscValidHeader(A); \ 256 PLogEventBegin(Petsc_Barrier,A,0,0,0); \ 257 MPI_Barrier(((PetscObject)A)->comm); \ 258 PLogEventEnd(Petsc_Barrier,A,0,0,0); \ 259 } 260 261 extern int PetscMPIDump(FILE *); 262 263 /* 264 This code allows one to pass a PETSc object in C 265 to a Fortran routine, where (like all PETSc objects in 266 Fortran) it is treated as an integer. 267 */ 268 extern int PetscCObjectToFortranObject(void *,PetscFortranAddr *); 269 extern int PetscFortranObjectToCObject(PetscFortranAddr,void *); 270 extern int MPICCommToFortranComm(MPI_Comm,int *); 271 extern int MPIFortranCommToCComm(int,MPI_Comm*); 272 273 /* 274 Simple PETSc parallel IO for ASCII printing 275 */ 276 extern int PetscFixFilename(char*); 277 extern FILE *PetscFOpen(MPI_Comm,char *,char *); 278 extern int PetscFClose(MPI_Comm,FILE*); 279 extern int PetscFPrintf(MPI_Comm,FILE*,char *,...); 280 extern int PetscPrintf(MPI_Comm,char *,...); 281 extern int (*PetscErrorPrintf)(char *,...); 282 extern int (*PetscHelpPrintf)(MPI_Comm,char *,...); 283 284 extern int PetscSynchronizedPrintf(MPI_Comm,char *,...); 285 extern int PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...); 286 extern int PetscSynchronizedFlush(MPI_Comm); 287 288 289 typedef struct _p_PetscObjectContainer* PetscObjectContainer; 290 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **); 291 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *); 292 extern int PetscObjectContainerDestroy(PetscObjectContainer); 293 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *); 294 295 /* 296 C code optimization is often enhanced by telling the compiler 297 that certain pointer arguments to functions are not aliased to 298 to other arguments. This is not yet ANSI C standard so we define 299 the macro "restrict" to indicate that the variable is not aliased 300 to any other argument. 301 */ 302 #if defined(HAVE_RESTRICT) && !defined(__cplusplus) 303 #define restrict _Restrict 304 #else 305 #define restrict 306 #endif 307 308 /* 309 For incremental debugging 310 */ 311 extern int PetscCompare; 312 extern int PetscCompareDouble(double); 313 extern int PetscCompareScalar(Scalar); 314 extern int PetscCompareInt(int); 315 316 /* 317 For use in debuggers 318 */ 319 extern int PetscGlobalRank,PetscGlobalSize; 320 extern int PetscIntView(int,int*,Viewer); 321 extern int PetscDoubleView(int,double *,Viewer); 322 323 #endif 324