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