1 /* $Id: petsc.h,v 1.222 1998/06/11 19:59:10 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_H) 7 #define __PETSC_H 8 9 /* ========================================================================== */ 10 /* 11 Current PETSc version number and release date, also listed in 12 docs/changes.html 13 docs/tex/manual/manual.tex and 14 docs/tex/manual/manual_tex.tex. 15 */ 16 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.22, Released April 28, 1998." 17 18 #define PETSC_VERSION_MAJOR 2 19 #define PETSC_VERSION_MINOR 0 20 #define PETSC_VERSION_SUBMINOR 22 21 #define PETSC_VERSION_DATE "April 29, 1998" 22 #define PETSC_AUTHOR_INFO "The PETSc Team:\ 23 Satish Balay, Bill Gropp, Lois Curfman McInnes, Barry Smith\n\ 24 Bug reports, questions: petsc-maint@mcs.anl.gov\n\ 25 Web page: http://www.mcs.anl.gov/petsc/\n" 26 27 /* ========================================================================== */ 28 /* 29 The PETSc configuration file. Contains various definitions that 30 handle portability issues and the presence of machine features. 31 32 petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h 33 */ 34 #include "petscconf.h" 35 36 /* ========================================================================== */ 37 38 #include <stdio.h> 39 /* 40 Defines the interface to MPI allowing the use of all MPI functions. 41 */ 42 #include "mpi.h" 43 44 /* 45 Defines some elementary mathematics functions and constants. 46 */ 47 #include "petscmath.h" 48 49 /* 50 Variable type where we stash PETSc object pointers in Fortran. 51 Assumes that sizeof(long) == sizeof(void *) which is true on 52 all machines that we know. 53 */ 54 #define PetscFortranAddr long 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 /* 153 Initialization of PETSc or its micro-kernel ALICE 154 */ 155 extern int AliceInitialize(int*,char***,char*,char*); 156 extern int AliceInitializeNoArguments(void); 157 extern int AliceFinalize(void); 158 extern void AliceInitializeFortran(void); 159 160 extern int PetscInitialize(int*,char***,char*,char*); 161 extern int PetscInitializeNoArguments(void); 162 extern int PetscFinalize(void); 163 extern void PetscInitializeFortran(void); 164 165 /* 166 Functions that can act on any PETSc object. 167 */ 168 typedef struct _p_PetscObject* PetscObject; 169 extern int PetscObjectDestroy(PetscObject); 170 extern int PetscObjectExists(PetscObject,int*); 171 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 172 extern int PetscObjectGetCookie(PetscObject,int *cookie); 173 extern int PetscObjectGetType(PetscObject,int *type); 174 extern int PetscObjectSetName(PetscObject,char*); 175 extern int PetscObjectGetName(PetscObject,char**); 176 extern int PetscObjectReference(PetscObject); 177 extern int PetscObjectGetReference(PetscObject,int*); 178 extern int PetscObjectDereference(PetscObject); 179 extern int PetscObjectGetNewTag(PetscObject,int *); 180 extern int PetscObjectRestoreNewTag(PetscObject,int *); 181 extern int PetscObjectView(PetscObject,Viewer); 182 extern int PetscObjectCompose(PetscObject,char *,PetscObject); 183 extern int PetscObjectQuery(PetscObject,char *,PetscObject *); 184 extern int PetscObjectComposeFunction_Private(PetscObject,char *,char *,void *); 185 #if defined(USE_DYNAMIC_LIBRARIES) 186 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,0) 187 #else 188 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,d) 189 #endif 190 extern int PetscObjectQueryFunction(PetscObject,char *,void **); 191 extern int PetscObjectSetOptionsPrefix(PetscObject,char*); 192 extern int PetscObjectAppendOptionsPrefix(PetscObject,char*); 193 extern int PetscObjectGetOptionsPrefix(PetscObject,char**); 194 extern int PetscObjectPublish(PetscObject); 195 196 /* 197 Defines PETSc error handling. 198 */ 199 #include "petscerror.h" 200 201 /* 202 Mechanism for managing lists of objects attached (composed) with 203 a PETSc object. 204 */ 205 typedef struct _OList *OList; 206 extern int OListDestroy(OList *); 207 extern int OListFind(OList,char *,PetscObject*); 208 extern int OListAdd(OList *,char *,PetscObject); 209 extern int OListRemove(OList *,char *); 210 extern int OListDuplicate(OList,OList *); 211 212 /* 213 Dynamic library lists. Lists of names of routines in dynamic 214 link libraries that will be loaded as needed. 215 */ 216 typedef struct _DLList *DLList; 217 extern int DLRegister_Private(DLList*,char*,char*,int (*)(void *)); 218 extern int DLRegisterCreate(DLList *); 219 extern int DLRegisterDestroy(DLList); 220 extern int DLRegisterFind(MPI_Comm,DLList,char*,int (**)(void*)); 221 extern int DLRegisterPrintTypes(MPI_Comm,FILE*,char*,char *,DLList); 222 #if defined(USE_DYNAMIC_LIBRARIES) 223 #define DLRegister(a,b,p,c) DLRegister_Private(a,b,p,0) 224 #else 225 #define DLRegister(a,b,p,c) DLRegister_Private(a,b,p,(int (*)(void *))c) 226 #endif 227 228 typedef struct _DLLibraryList *DLLibraryList; 229 extern DLLibraryList DLLibrariesLoaded; 230 extern int DLLibraryOpen(MPI_Comm,char *,void **); 231 extern int DLLibrarySym(MPI_Comm,DLLibraryList *,char*,char *, void **); 232 extern int DLLibraryAppend(MPI_Comm,DLLibraryList *,char *); 233 extern int DLLibraryPrepend(MPI_Comm,DLLibraryList *,char *); 234 extern int DLLibraryClose(DLLibraryList); 235 extern int DLLibraryPrintPath(); 236 237 /* 238 Mechanism for translating PETSc object representations between languages 239 */ 240 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage; 241 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C 242 extern int PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *); 243 extern int PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **); 244 245 #include "petschead.h" 246 247 /* 248 Defines PETSc profiling. 249 */ 250 #include "petsclog.h" 251 252 extern int PetscSequentialPhaseBegin(MPI_Comm,int); 253 extern int PetscSequentialPhaseEnd(MPI_Comm,int); 254 extern int PetscBarrier(PetscObject); 255 extern int PetscMPIDump(FILE *); 256 257 /* 258 This code allows one to pass a MPI communicator between 259 C and Fortran. MPI 2.0 defines a standard API for doing this. 260 The code here is provided to allow PETSc to work with MPI 1.1 261 standard MPI libraries. 262 */ 263 extern int MPICCommToFortranComm(MPI_Comm,int *); 264 extern int MPIFortranCommToCComm(int,MPI_Comm*); 265 266 /* 267 Simple PETSc parallel IO for ASCII printing 268 */ 269 extern int PetscFixFilename(char*); 270 extern FILE *PetscFOpen(MPI_Comm,char *,char *); 271 extern int PetscFClose(MPI_Comm,FILE*); 272 extern int PetscFPrintf(MPI_Comm,FILE*,char *,...); 273 extern int PetscPrintf(MPI_Comm,char *,...); 274 extern int (*PetscErrorPrintf)(char *,...); 275 extern int (*PetscHelpPrintf)(MPI_Comm,char *,...); 276 277 extern int PetscSynchronizedPrintf(MPI_Comm,char *,...); 278 extern int PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...); 279 extern int PetscSynchronizedFlush(MPI_Comm); 280 281 282 /* 283 Simple PETSc object that contains a pointer to any required data 284 */ 285 typedef struct _p_PetscObjectContainer* PetscObjectContainer; 286 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **); 287 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *); 288 extern int PetscObjectContainerDestroy(PetscObjectContainer); 289 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *); 290 291 292 /* 293 C code optimization is often enhanced by telling the compiler 294 that certain pointer arguments to functions are not aliased to 295 to other arguments. This is not yet ANSI C standard so we define 296 the macro "restrict" to indicate that the variable is not aliased 297 to any other argument. 298 */ 299 #if defined(HAVE_RESTRICT) && !defined(__cplusplus) 300 #define restrict _Restrict 301 #else 302 #define restrict 303 #endif 304 305 /* 306 For incremental debugging 307 */ 308 extern int PetscCompare; 309 extern int PetscCompareDouble(double); 310 extern int PetscCompareScalar(Scalar); 311 extern int PetscCompareInt(int); 312 313 /* 314 For use in debuggers 315 */ 316 extern int PetscGlobalRank,PetscGlobalSize; 317 extern int PetscIntView(int,int*,Viewer); 318 extern int PetscDoubleView(int,double *,Viewer); 319 320 #endif 321