1 /* $Id: petsc.h,v 1.219 1998/05/18 18:45:30 bsmith Exp curfman $ */ 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 This should be in petscmath.h? 50 */ 51 #if defined(USE_POINTER_CONVERSION) 52 #define PetscFortranAddr int 53 #else 54 #define PetscFortranAddr long 55 #endif 56 57 extern MPI_Comm PETSC_COMM_WORLD; 58 extern MPI_Comm PETSC_COMM_SELF; 59 extern int PetscInitializedCalled; 60 extern int PetscSetCommWorld(MPI_Comm); 61 62 /* 63 Defines the malloc employed by PETSc. Users may use these routines as well. 64 */ 65 #define PetscMalloc(a) (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 66 #define PetscNew(A) (A*) PetscMalloc(sizeof(A)) 67 #define PetscFree(a) (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 68 extern void *(*PetscTrMalloc)(unsigned int,int,char*,char*,char*); 69 extern int (*PetscTrFree)(void *,int,char*,char*,char*); 70 extern int PetscSetMalloc(void *(*)(unsigned int,int,char*,char*,char*), 71 int (*)(void *,int,char*,char*,char*)); 72 extern int PetscClearMalloc(void); 73 74 extern int PetscTrDump(FILE *); 75 extern int PetscTrSpace( PLogDouble *, PLogDouble *,PLogDouble *); 76 extern int PetscTrValid(int,char *,char *,char *); 77 extern int PetscTrDebugLevel(int); 78 extern int PetscTrLog(void); 79 extern int PetscTrLogDump(FILE *); 80 extern int PetscGetResidentSetSize(PLogDouble *); 81 82 #include "src/inline/bitarray.h" 83 84 typedef enum {PETSC_INT = 0, PETSC_DOUBLE = 1, PETSC_SHORT = 2, PETSC_FLOAT = 3, 85 PETSC_COMPLEX = 4, PETSC_CHAR = 5, PETSC_LOGICAL = 6} PetscDataType; 86 #if defined(USE_PETSC_COMPLEX) 87 #define PETSC_SCALAR PETSC_COMPLEX 88 #else 89 #define PETSC_SCALAR PETSC_DOUBLE 90 #endif 91 92 typedef enum {PETSC_INT_SIZE = sizeof(int), PETSC_DOUBLE_SIZE = sizeof(double), 93 PETSC_SCALAR_SIZE = sizeof(Scalar), PETSC_COMPLEX_SIZE = sizeof(double), 94 PETSC_CHAR_SIZE = sizeof(char), PETSC_LOGICAL_SIZE = 1} PetscDataTypeSize; 95 extern int PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 96 extern int PetscDataTypeGetSize(PetscDataType,int*); 97 extern int PetscDataTypeGetName(PetscDataType,char**); 98 99 /* 100 Basic memory and string operations 101 */ 102 extern int PetscMemcpy(void *,void *,int); 103 extern int PetscBitMemcpy(void*,int,void*,int,int,PetscDataType); 104 extern int PetscMemmove(void *,void *,int); 105 extern int PetscMemzero(void *,int); 106 extern int PetscMemcmp(void*, void*, int); 107 extern int PetscStrlen(char *); 108 extern int PetscStrcmp(char *,char *); 109 extern int PetscStrcasecmp(char *,char *); 110 extern int PetscStrncmp(char *,char *,int ); 111 extern int PetscStrcpy(char *,char *); 112 extern int PetscStrcat(char *,char *); 113 extern int PetscStrncat(char *,char *,int); 114 extern int PetscStrncpy(char *,char *,int); 115 extern char* PetscStrchr(char *,char); 116 extern char* PetscStrrchr(char *,char); 117 extern char* PetscStrstr(char*,char*); 118 extern char* PetscStrtok(char*,char*); 119 extern char* PetscStrrtok(char*,char*); 120 121 /* 122 Basic PETSc constants 123 */ 124 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth; 125 #define PETSC_NULL 0 126 #define PETSC_DECIDE -1 127 #define PETSC_DETERMINE PETSC_DECIDE 128 #define PETSC_DEFAULT -2 129 130 /* 131 Each PETSc object class has it's own cookie (internal integer in the 132 data structure used for error checking). These are all defined by an offset 133 from the lowest one, PETSC_COOKIE. If you increase these you must 134 increase the field sizes in petsc/src/plog/src/plog.c 135 */ 136 #define PETSC_COOKIE 1211211 137 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30 138 #define LARGEST_PETSC_COOKIE_ALLOWED PETSC_COOKIE + 50 139 extern int LARGEST_PETSC_COOKIE; 140 141 #include "viewer.h" 142 #include "options.h" 143 144 /* 145 Defines basic graphics available from PETSc. 146 */ 147 #include "draw.h" 148 149 extern int PetscGetTime(PLogDouble*); 150 extern int PetscGetCPUTime(PLogDouble*); 151 extern int PetscSleep(int); 152 153 /* 154 Initialization of PETSc or its micro-kernel ALICE 155 */ 156 extern int AliceInitialize(int*,char***,char*,char*); 157 extern int AliceInitializeNoArguments(void); 158 extern int AliceFinalize(void); 159 extern void AliceInitializeFortran(void); 160 161 extern int PetscInitialize(int*,char***,char*,char*); 162 extern int PetscInitializeNoArguments(void); 163 extern int PetscFinalize(void); 164 extern void PetscInitializeFortran(void); 165 166 /* 167 Functions that can act on any PETSc object. 168 */ 169 typedef struct _p_PetscObject* PetscObject; 170 extern int PetscObjectDestroy(PetscObject); 171 extern int PetscObjectExists(PetscObject,int*); 172 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 173 extern int PetscObjectGetCookie(PetscObject,int *cookie); 174 extern int PetscObjectGetType(PetscObject,int *type); 175 extern int PetscObjectSetName(PetscObject,char*); 176 extern int PetscObjectGetName(PetscObject,char**); 177 extern int PetscObjectReference(PetscObject); 178 extern int PetscObjectGetReference(PetscObject,int*); 179 extern int PetscObjectDereference(PetscObject); 180 extern int PetscObjectGetNewTag(PetscObject,int *); 181 extern int PetscObjectRestoreNewTag(PetscObject,int *); 182 extern int PetscObjectView(PetscObject,Viewer); 183 184 extern int PetscObjectCompose(PetscObject,char *,PetscObject); 185 extern int PetscObjectQuery(PetscObject,char *,PetscObject *); 186 extern int PetscObjectComposeFunction_Private(PetscObject,char *,char *,void *); 187 #if defined(USE_DYNAMIC_LIBRARIES) 188 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,0) 189 #else 190 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,d) 191 #endif 192 extern int PetscObjectQueryFunction(PetscObject,char *,void **); 193 194 /* 195 Defines PETSc error handling. 196 */ 197 #include "petscerror.h" 198 199 /* 200 Mechanism for managing lists of objects attached (composed) with 201 a PETSc object. 202 */ 203 typedef struct _OList *OList; 204 extern int OListDestroy(OList *); 205 extern int OListFind(OList,char *,PetscObject*); 206 extern int OListAdd(OList *,char *,PetscObject); 207 extern int OListRemove(OList *,char *); 208 extern int OListDuplicate(OList,OList *); 209 210 /* 211 Dynamic library lists. Lists of names of routines in dynamic 212 link libraries that will be loaded as needed. 213 */ 214 typedef struct _DLList *DLList; 215 extern int DLRegister_Private(DLList*,char*,char*,int (*)(void *)); 216 extern int DLRegisterCreate(DLList *); 217 extern int DLRegisterDestroy(DLList); 218 extern int DLRegisterFind(MPI_Comm,DLList,char*,int (**)(void*)); 219 extern int DLRegisterPrintTypes(MPI_Comm,FILE*,char*,char *,DLList); 220 #if defined(USE_DYNAMIC_LIBRARIES) 221 #define DLRegister(a,b,p,c) DLRegister_Private(a,b,p,0) 222 #else 223 #define DLRegister(a,b,p,c) DLRegister_Private(a,b,p,(int (*)(void *))c) 224 #endif 225 226 typedef struct _DLLibraryList *DLLibraryList; 227 extern DLLibraryList DLLibrariesLoaded; 228 extern int DLLibraryOpen(MPI_Comm,char *,void **); 229 extern int DLLibrarySym(MPI_Comm,DLLibraryList *,char*,char *, void **); 230 extern int DLLibraryAppend(MPI_Comm,DLLibraryList *,char *); 231 extern int DLLibraryPrepend(MPI_Comm,DLLibraryList *,char *); 232 extern int DLLibraryClose(DLLibraryList); 233 234 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage; 235 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C 236 extern int PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *); 237 extern int PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **); 238 239 #include "petschead.h" 240 241 /* 242 Defines PETSc profiling. 243 */ 244 #include "petsclog.h" 245 246 extern int PetscSequentialPhaseBegin(MPI_Comm,int); 247 extern int PetscSequentialPhaseEnd(MPI_Comm,int); 248 extern int PetscBarrier(PetscObject); 249 extern int PetscMPIDump(FILE *); 250 251 /* 252 This code allows one to pass a PETSc object in C 253 to a Fortran routine, where (like all PETSc objects in 254 Fortran) it is treated as an integer. 255 */ 256 extern int PetscCObjectToFortranObject(void *,PetscFortranAddr *); 257 extern int PetscFortranObjectToCObject(PetscFortranAddr,void *); 258 extern int MPICCommToFortranComm(MPI_Comm,int *); 259 extern int MPIFortranCommToCComm(int,MPI_Comm*); 260 261 /* 262 Simple PETSc parallel IO for ASCII printing 263 */ 264 extern int PetscFixFilename(char*); 265 extern FILE *PetscFOpen(MPI_Comm,char *,char *); 266 extern int PetscFClose(MPI_Comm,FILE*); 267 extern int PetscFPrintf(MPI_Comm,FILE*,char *,...); 268 extern int PetscPrintf(MPI_Comm,char *,...); 269 extern int (*PetscErrorPrintf)(char *,...); 270 extern int (*PetscHelpPrintf)(MPI_Comm,char *,...); 271 272 extern int PetscSynchronizedPrintf(MPI_Comm,char *,...); 273 extern int PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...); 274 extern int PetscSynchronizedFlush(MPI_Comm); 275 276 277 /* 278 Simple PETSc object that contains a pointer to any required data 279 */ 280 typedef struct _p_PetscObjectContainer* PetscObjectContainer; 281 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **); 282 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *); 283 extern int PetscObjectContainerDestroy(PetscObjectContainer); 284 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *); 285 286 287 /* 288 C code optimization is often enhanced by telling the compiler 289 that certain pointer arguments to functions are not aliased to 290 to other arguments. This is not yet ANSI C standard so we define 291 the macro "restrict" to indicate that the variable is not aliased 292 to any other argument. 293 */ 294 #if defined(HAVE_RESTRICT) && !defined(__cplusplus) 295 #define restrict _Restrict 296 #else 297 #define restrict 298 #endif 299 300 /* 301 For incremental debugging 302 */ 303 extern int PetscCompare; 304 extern int PetscCompareDouble(double); 305 extern int PetscCompareScalar(Scalar); 306 extern int PetscCompareInt(int); 307 308 /* 309 For use in debuggers 310 */ 311 extern int PetscGlobalRank,PetscGlobalSize; 312 extern int PetscIntView(int,int*,Viewer); 313 extern int PetscDoubleView(int,double *,Viewer); 314 315 #endif 316