1 /* $Id: petsc.h,v 1.216 1998/05/13 18:49:57 balay Exp bsmith $ */ 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 AliceInitialize(int*,char***,char*,char*); 153 extern int AliceInitializeNoArguments(void); 154 extern int AliceFinalize(void); 155 extern void AliceInitializeFortran(void); 156 157 extern int PetscInitialize(int*,char***,char*,char*); 158 extern int PetscInitializeNoArguments(void); 159 extern int PetscFinalize(void); 160 extern void PetscInitializeFortran(void); 161 162 /* 163 Functions that can act on any PETSc object. 164 */ 165 typedef struct _p_PetscObject* PetscObject; 166 extern int PetscObjectDestroy(PetscObject); 167 extern int PetscObjectExists(PetscObject,int*); 168 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 169 extern int PetscObjectGetCookie(PetscObject,int *cookie); 170 extern int PetscObjectGetType(PetscObject,int *type); 171 extern int PetscObjectSetName(PetscObject,char*); 172 extern int PetscObjectGetName(PetscObject,char**); 173 extern int PetscObjectReference(PetscObject); 174 extern int PetscObjectGetReference(PetscObject,int*); 175 extern int PetscObjectDereference(PetscObject); 176 extern int PetscObjectGetNewTag(PetscObject,int *); 177 extern int PetscObjectRestoreNewTag(PetscObject,int *); 178 extern int PetscObjectView(PetscObject,Viewer); 179 180 extern int PetscObjectCompose(PetscObject,char *,PetscObject); 181 extern int PetscObjectQuery(PetscObject,char *,PetscObject *); 182 #if defined(USE_DYNAMIC_LIBRARIES) 183 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,0) 184 #else 185 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,d) 186 #endif 187 extern int PetscObjectComposeFunction_Private(PetscObject,char *,char *,void *); 188 extern int PetscObjectQueryFunction(PetscObject,char *,void **); 189 190 191 /* 192 Defines PETSc error handling. 193 */ 194 #include "petscerror.h" 195 196 /* 197 Mechanism for managing lists of objects attached (composed) with 198 a PETSc object. 199 */ 200 typedef struct _OList *OList; 201 extern int OListDestroy(OList *); 202 extern int OListFind(OList,char *,PetscObject*); 203 extern int OListAdd(OList *,char *,PetscObject); 204 extern int OListRemove(OList *,char *); 205 extern int OListDuplicate(OList,OList *); 206 207 /* 208 Dynamic library lists. Lists of names of routines in dynamic 209 link libraries that will be loaded as needed. 210 */ 211 typedef struct _DLList *DLList; 212 extern int DLRegister_Private(DLList*,char*,char*,int (*)(void *)); 213 extern int DLRegisterCreate(DLList *); 214 extern int DLRegisterDestroy(DLList); 215 extern int DLRegisterFind(MPI_Comm,DLList,char*,int (**)(void*)); 216 extern int DLRegisterPrintTypes(MPI_Comm,FILE*,char*,char *,DLList); 217 #if defined(USE_DYNAMIC_LIBRARIES) 218 #define DLRegister(a,b,p,c) DLRegister_Private(a,b,p,0) 219 #else 220 #define DLRegister(a,b,p,c) DLRegister_Private(a,b,p,(int (*)(void *))c) 221 #endif 222 223 typedef struct _DLLibraryList *DLLibraryList; 224 extern DLLibraryList DLLibrariesLoaded; 225 extern int DLLibraryOpen(MPI_Comm,char *,void **); 226 extern int DLLibrarySym(MPI_Comm,DLLibraryList *,char*,char *, void **); 227 extern int DLLibraryAppend(MPI_Comm,DLLibraryList *,char *); 228 extern int DLLibraryPrepend(MPI_Comm,DLLibraryList *,char *); 229 extern int DLLibraryClose(DLLibraryList); 230 231 232 #include "petschead.h" 233 234 /* 235 Defines PETSc profiling. 236 */ 237 #include "petsclog.h" 238 239 extern int PetscSequentialPhaseBegin(MPI_Comm,int); 240 extern int PetscSequentialPhaseEnd(MPI_Comm,int); 241 242 /*M 243 PetscBarrier - Blocks until this routine is executed by all 244 processors owning the object A. 245 246 Input Parameters: 247 . A - PETSc object ( Mat, Vec, IS, SNES etc...) 248 249 Synopsis: 250 void PetscBarrier(PetscObject obj) 251 252 Notes: 253 This routine calls MPI_Barrier with the communicator 254 of the PETSc Object "A". 255 256 .keywords: barrier, petscobject 257 M*/ 258 259 #define PetscBarrier(A) \ 260 { \ 261 PetscValidHeader(A); \ 262 PLogEventBegin(Petsc_Barrier,A,0,0,0); \ 263 MPI_Barrier(((PetscObject)A)->comm); \ 264 PLogEventEnd(Petsc_Barrier,A,0,0,0); \ 265 } 266 267 extern int PetscMPIDump(FILE *); 268 269 /* 270 This code allows one to pass a PETSc object in C 271 to a Fortran routine, where (like all PETSc objects in 272 Fortran) it is treated as an integer. 273 */ 274 extern int PetscCObjectToFortranObject(void *,PetscFortranAddr *); 275 extern int PetscFortranObjectToCObject(PetscFortranAddr,void *); 276 extern int MPICCommToFortranComm(MPI_Comm,int *); 277 extern int MPIFortranCommToCComm(int,MPI_Comm*); 278 279 /* 280 Simple PETSc parallel IO for ASCII printing 281 */ 282 extern int PetscFixFilename(char*); 283 extern FILE *PetscFOpen(MPI_Comm,char *,char *); 284 extern int PetscFClose(MPI_Comm,FILE*); 285 extern int PetscFPrintf(MPI_Comm,FILE*,char *,...); 286 extern int PetscPrintf(MPI_Comm,char *,...); 287 extern int (*PetscErrorPrintf)(char *,...); 288 extern int (*PetscHelpPrintf)(MPI_Comm,char *,...); 289 290 extern int PetscSynchronizedPrintf(MPI_Comm,char *,...); 291 extern int PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...); 292 extern int PetscSynchronizedFlush(MPI_Comm); 293 294 295 typedef struct _p_PetscObjectContainer* PetscObjectContainer; 296 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **); 297 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *); 298 extern int PetscObjectContainerDestroy(PetscObjectContainer); 299 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *); 300 301 /* 302 C code optimization is often enhanced by telling the compiler 303 that certain pointer arguments to functions are not aliased to 304 to other arguments. This is not yet ANSI C standard so we define 305 the macro "restrict" to indicate that the variable is not aliased 306 to any other argument. 307 */ 308 #if defined(HAVE_RESTRICT) && !defined(__cplusplus) 309 #define restrict _Restrict 310 #else 311 #define restrict 312 #endif 313 314 /* 315 For incremental debugging 316 */ 317 extern int PetscCompare; 318 extern int PetscCompareDouble(double); 319 extern int PetscCompareScalar(Scalar); 320 extern int PetscCompareInt(int); 321 322 /* 323 For use in debuggers 324 */ 325 extern int PetscGlobalRank,PetscGlobalSize; 326 extern int PetscIntView(int,int*,Viewer); 327 extern int PetscDoubleView(int,double *,Viewer); 328 329 #endif 330