1 /* $Id: petsc.h,v 1.173 1997/09/08 15:05:04 gropp Exp bsmith $ */ 2 /* 3 This is the main PETSc include file (for C and C++). It is included by 4 all other PETSc include files so almost never has to be specifically included. 5 */ 6 #if !defined(__PETSC_PACKAGE) 7 #define __PETSC_PACKAGE 8 9 /* 10 Current PETSc Version 11 */ 12 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.19, Released August 13, 1997." 13 14 #define PETSC_VERSION_MAJOR 2 15 #define PETSC_VERSION_MINOR 0 16 #define PETSC_VERSION_SUBMINOR 19 17 #define PETSC_VERSION_DATE "August 13, 1997" 18 19 /* Before anything else, include the PETSc configuration file. This 20 contains various definitions that handle portability issues and the 21 presence of important features. For backward compatibility while 22 developing, this configuration is itself conditionally included. 23 */ 24 #ifdef HAVE_PETSCCONF_H 25 #include "petscconf.h" 26 #else 27 28 /* These are temporary; they contain PARCH_xxxx -> feature-specific 29 definitions */ 30 /* Common definitions (sometimes undef'ed below) */ 31 #define HAVE_READLINK 32 #define HAVE_MEMMOVE 33 34 #if defined(PARCH_sun4) 35 /* Fortran BLAS have slow dnrm2 */ 36 #define HAVE_SLOW_NRM2 37 /* Functions that we count on Sun4's having */ 38 #define HAVE_GETWD 39 #define HAVE_REALPATH 40 /* Functions that Sun4's don't have */ 41 #undef HAVE_MEMMOVE 42 #endif 43 44 #if defined(PARCH_rs6000) 45 /* Use bzero instead of memset( ,0, ) */ 46 #define PREFER_BZERO 47 /* Some versions of AIX require u_type definitions */ 48 #define NEED_UTYPE_TYPEDEFS 49 #endif 50 51 #if defined(PARCH_IRIX) || defined(PARCH_IRIX64) 52 /* For some reason, we don't use readlink in grpath.c for IRIX */ 53 #undef HAVE_READLINK 54 /* gettimeofday required sys/resource.h and C++ prototype for gettimeof 55 day */ 56 #define NEEDS_GETTIMEOFDAY_PROTO 57 #endif 58 59 #if defined(PARCH_paragon) || defined(PARCH_alpha) 60 /* Some versions of these systems require u_type definitions */ 61 #define NEED_UTYPE_TYPEDEFS 62 #endif 63 #endif 64 65 66 #include <stdio.h> 67 /* 68 Defines the interface to MPI allowing the use of all MPI functions. 69 */ 70 #include "mpi.h" 71 72 /* 73 Defines some elementary mathematics functions and constants. 74 */ 75 #include "petscmath.h" 76 77 extern MPI_Comm PETSC_COMM_WORLD; 78 extern MPI_Comm PETSC_COMM_SELF; 79 extern int PetscInitializedCalled; 80 extern int PetscSetCommWorld(MPI_Comm); 81 82 /* 83 Defines the malloc employed by PETSc. Users may employ these routines as well. 84 */ 85 extern void *(*PetscTrMalloc)(unsigned int,int,char*,char*,char*); 86 extern int (*PetscTrFree)(void *,int,char*,char*,char*); 87 extern int PetscSetMalloc(void *(*)(unsigned int,int,char*,char*,char*), 88 int (*)(void *,int,char*,char*,char*)); 89 #define PetscMalloc(a) (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 90 #define PetscNew(A) (A*) PetscMalloc(sizeof(A)) 91 #define PetscFree(a) (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__) 92 93 extern int PetscTrDump(FILE *); 94 extern int PetscTrSpace( PLogDouble *, PLogDouble *,PLogDouble *); 95 extern int PetscTrValid(int,char *,char *,char *); 96 extern int PetscTrDebugLevel(int); 97 extern int PetscTrLog(); 98 extern int PetscTrLogDump(FILE *); 99 extern int PetscGetResidentSetSize(PLogDouble *); 100 101 /* 102 Basic memory and string operations 103 */ 104 extern void PetscMemcpy(void *,void *,int); 105 extern void PetscMemmove(void *,void *,int); 106 extern void PetscMemzero(void *,int); 107 extern int PetscMemcmp(void*, void*, int); 108 extern int PetscStrlen(char *); 109 extern int PetscStrcmp(char *,char *); 110 extern int PetscStrcasecmp(char *,char *); 111 extern int PetscStrncmp(char *,char *,int ); 112 extern void PetscStrcpy(char *,char *); 113 extern void PetscStrcat(char *,char *); 114 extern void PetscStrncat(char *,char *,int); 115 extern void PetscStrncpy(char *,char *,int); 116 extern char* PetscStrchr(char *,char); 117 extern char* PetscStrrchr(char *,char); 118 extern char* PetscStrstr(char*,char*); 119 extern char* PetscStrtok(char*,char*); 120 extern char* PetscStrrtok(char*,char*); 121 122 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth; 123 #define PETSC_NULL 0 124 #define PETSC_DECIDE -1 125 #define PETSC_DEFAULT -2 126 127 /* 128 Each PETSc object class has it's own cookie (internal integer in the 129 data structure used for error checking). These are all defined by an offset 130 from the lowest one, PETSC_COOKIE. If you increase these you must 131 increase the field sizes in petsc/src/plog/src/plog.c 132 */ 133 #define PETSC_COOKIE 1211211 134 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30 135 #define LARGEST_PETSC_COOKIE_ALLOWED PETSC_COOKIE + 50 136 extern int LARGEST_PETSC_COOKIE; 137 138 #include "viewer.h" 139 #include "options.h" 140 141 /* 142 Defines basic graphics available from PETSc. 143 */ 144 #include "draw.h" 145 146 extern PLogDouble PetscGetTime(); 147 extern PLogDouble PetscGetCPUTime(); 148 extern void PetscSleep(int); 149 150 extern int PetscInitialize(int*,char***,char*,char*); 151 extern int PetscFinalize(); 152 extern void PetscInitializeFortran(); 153 154 /* 155 Functions that can act on any PETSc object. 156 */ 157 typedef struct _p_PetscObject* PetscObject; 158 extern int PetscObjectDestroy(PetscObject); 159 extern int PetscObjectExists(PetscObject,int*); 160 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm); 161 extern int PetscObjectGetCookie(PetscObject,int *cookie); 162 extern int PetscObjectGetChild(PetscObject,void **child); 163 extern int PetscObjectGetType(PetscObject,int *type); 164 extern int PetscObjectSetName(PetscObject,char*); 165 extern int PetscObjectGetName(PetscObject,char**); 166 extern int PetscObjectInherit(PetscObject,void *, int (*)(void *,void **),int (*)(void*)); 167 extern int PetscObjectReference(PetscObject); 168 extern int PetscObjectGetNewTag(PetscObject,int *); 169 extern int PetscObjectRestoreNewTag(PetscObject,int *); 170 extern int PetscObjectView(PetscObject,Viewer); 171 172 /* 173 Defines PETSc error handling. 174 */ 175 #include "petscerror.h" 176 #include "petschead.h" 177 178 /* 179 Defines PETSc profiling. 180 */ 181 #include "petsclog.h" 182 183 extern int PetscSequentialPhaseBegin(MPI_Comm,int); 184 extern int PetscSequentialPhaseEnd(MPI_Comm,int); 185 186 /*M 187 PetscBarrier - Blocks until this routine is executed by all 188 processors owning the object A. 189 190 Input Parameters: 191 . A - PETSc object ( Mat, Vec, IS, SNES etc...) 192 193 Synopsis: 194 void PetscBarrier(PetscObject obj) 195 196 Notes: 197 This routine calls MPI_Barrier with the communicator 198 of the PETSc Object "A". 199 200 .keywords: barrier, petscobject 201 M*/ 202 203 #define PetscBarrier(A) \ 204 { \ 205 PetscValidHeader(A); \ 206 PLogEventBegin(Petsc_Barrier,A,0,0,0); \ 207 MPI_Barrier(((PetscObject)A)->comm); \ 208 PLogEventEnd(Petsc_Barrier,A,0,0,0); \ 209 } 210 211 extern int PetscMPIDump(FILE *); 212 213 /* 214 This code allows one to pass a PETSc object in C 215 to a Fortran routine, where (like all PETSc objects in 216 Fortran) it is treated as an integer. 217 */ 218 extern int PetscCObjectToFortranObject(void *,int *); 219 extern int PetscFortranObjectToCObject(int,void *); 220 extern int MPICCommToFortranComm(MPI_Comm,int *); 221 extern int MPIFortranCommToCComm(int,MPI_Comm*); 222 223 extern FILE *PetscFOpen(MPI_Comm,char *,char *); 224 extern int PetscFClose(MPI_Comm,FILE*); 225 extern int PetscFPrintf(MPI_Comm,FILE*,char *,...); 226 extern int PetscPrintf(MPI_Comm,char *,...); 227 228 extern int PetscSynchronizedPrintf(MPI_Comm,char *,...); 229 extern int PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...); 230 extern int PetscSynchronizedFlush(MPI_Comm); 231 232 /* 233 For incremental debugging 234 */ 235 extern int PetscCompare; 236 extern int PetscCompareDouble(double); 237 extern int PetscCompareScalar(Scalar); 238 extern int PetscCompareInt(int); 239 240 /* 241 For use in debuggers 242 */ 243 extern int PetscGlobalRank,PetscGlobalSize; 244 extern int PetscIntView(int,int*,Viewer); 245 extern int PetscDoubleView(int,double *,Viewer); 246 247 #endif 248