1 /* $Id: petsc.h,v 1.217 1998/05/15 15:22:59 bsmith 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 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage; 232 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C 233 234 #include "petschead.h" 235 236 /* 237 Defines PETSc profiling. 238 */ 239 #include "petsclog.h" 240 241 extern int PetscSequentialPhaseBegin(MPI_Comm,int); 242 extern int PetscSequentialPhaseEnd(MPI_Comm,int); 243 244 /*M 245 PetscBarrier - Blocks until this routine is executed by all 246 processors owning the object A. 247 248 Input Parameters: 249 . A - PETSc object ( Mat, Vec, IS, SNES etc...) 250 251 Synopsis: 252 void PetscBarrier(PetscObject obj) 253 254 Notes: 255 This routine calls MPI_Barrier with the communicator 256 of the PETSc Object "A". 257 258 .keywords: barrier, petscobject 259 M*/ 260 261 #define PetscBarrier(A) \ 262 { \ 263 PetscValidHeader(A); \ 264 PLogEventBegin(Petsc_Barrier,A,0,0,0); \ 265 MPI_Barrier(((PetscObject)A)->comm); \ 266 PLogEventEnd(Petsc_Barrier,A,0,0,0); \ 267 } 268 269 extern int PetscMPIDump(FILE *); 270 271 /* 272 This code allows one to pass a PETSc object in C 273 to a Fortran routine, where (like all PETSc objects in 274 Fortran) it is treated as an integer. 275 */ 276 extern int PetscCObjectToFortranObject(void *,PetscFortranAddr *); 277 extern int PetscFortranObjectToCObject(PetscFortranAddr,void *); 278 extern int MPICCommToFortranComm(MPI_Comm,int *); 279 extern int MPIFortranCommToCComm(int,MPI_Comm*); 280 281 /* 282 Simple PETSc parallel IO for ASCII printing 283 */ 284 extern int PetscFixFilename(char*); 285 extern FILE *PetscFOpen(MPI_Comm,char *,char *); 286 extern int PetscFClose(MPI_Comm,FILE*); 287 extern int PetscFPrintf(MPI_Comm,FILE*,char *,...); 288 extern int PetscPrintf(MPI_Comm,char *,...); 289 extern int (*PetscErrorPrintf)(char *,...); 290 extern int (*PetscHelpPrintf)(MPI_Comm,char *,...); 291 292 extern int PetscSynchronizedPrintf(MPI_Comm,char *,...); 293 extern int PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...); 294 extern int PetscSynchronizedFlush(MPI_Comm); 295 296 297 typedef struct _p_PetscObjectContainer* PetscObjectContainer; 298 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **); 299 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *); 300 extern int PetscObjectContainerDestroy(PetscObjectContainer); 301 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *); 302 303 304 /* 305 C code optimization is often enhanced by telling the compiler 306 that certain pointer arguments to functions are not aliased to 307 to other arguments. This is not yet ANSI C standard so we define 308 the macro "restrict" to indicate that the variable is not aliased 309 to any other argument. 310 */ 311 #if defined(HAVE_RESTRICT) && !defined(__cplusplus) 312 #define restrict _Restrict 313 #else 314 #define restrict 315 #endif 316 317 /* 318 For incremental debugging 319 */ 320 extern int PetscCompare; 321 extern int PetscCompareDouble(double); 322 extern int PetscCompareScalar(Scalar); 323 extern int PetscCompareInt(int); 324 325 /* 326 For use in debuggers 327 */ 328 extern int PetscGlobalRank,PetscGlobalSize; 329 extern int PetscIntView(int,int*,Viewer); 330 extern int PetscDoubleView(int,double *,Viewer); 331 332 #endif 333