xref: /petsc/include/petscversion.h (revision d763cef207eb7fa01b459cfa1b5fffdd1cf73419)
1 /* $Id: petsc.h,v 1.244 1999/03/31 03:40:39 bsmith Exp balay $ */
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.24, Released April 6, 1999"
17 
18 #define PETSC_VERSION_MAJOR    2
19 #define PETSC_VERSION_MINOR    0
20 #define PETSC_VERSION_SUBMINOR 24
21 #define PETSC_VERSION_DATE     "April 6, 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 it is
33    found automatically by the compiler due to the -I${PETSC_DIR}/bmake/${PETSC_ARCH}
34    in the bmake/common definition of PETSC_INCLUDE
35 */
36 #include "petscconf.h"
37 
38 /* ========================================================================== */
39 
40 #include <stdio.h>
41 /*
42     Defines the interface to MPI allowing the use of all MPI functions.
43 */
44 #include "mpi.h"
45 
46 /*
47     Defines some elementary mathematics functions and constants.
48 */
49 #include "petscmath.h"
50 
51 /*
52     Variable type where we stash PETSc object pointers in Fortran.
53     Assumes that sizeof(long) == sizeof(void *) which is true on
54     all machines that we know.
55 */
56 #define PetscFortranAddr   long
57 
58 extern MPI_Comm PETSC_COMM_WORLD;
59 extern MPI_Comm PETSC_COMM_SELF;
60 extern int      PetscInitializedCalled;
61 extern int      PetscSetCommWorld(MPI_Comm);
62 
63 /*
64     Defines the malloc employed by PETSc. Users may use these routines as well.
65 */
66 #define PetscMalloc(a)       (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
67 #define PetscNew(A)          (A*) PetscMalloc(sizeof(A))
68 #define PetscFree(a)         (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
69 extern void *(*PetscTrMalloc)(int,int,char*,char*,char*);
70 extern int  (*PetscTrFree)(void *,int,char*,char*,char*);
71 extern int  PetscSetMalloc(void *(*)(int,int,char*,char*,char*),
72                            int (*)(void *,int,char*,char*,char*));
73 extern int  PetscClearMalloc(void);
74 
75 /*
76    Routines for tracing memory corruption/bleeding with default PETSc
77    memory allocation
78 */
79 extern int   PetscTrDump(FILE *);
80 extern int   PetscTrSpace(PLogDouble *, PLogDouble *,PLogDouble *);
81 extern int   PetscTrValid(int,const char[],const char[],const char[]);
82 extern int   PetscTrDebugLevel(int);
83 extern int   PetscTrLog(void);
84 extern int   PetscTrLogDump(FILE *);
85 extern int   PetscGetResidentSetSize(PLogDouble *);
86 
87 /*
88      Constants and functions used for handling different basic data types.
89      These are used, for example, in binary IO routines
90 */
91 typedef enum {PETSC_INT = 0, PETSC_DOUBLE = 1, PETSC_SHORT = 2, PETSC_FLOAT = 3,
92               PETSC_COMPLEX = 4, PETSC_CHAR = 5, PETSC_LOGICAL = 6} PetscDataType;
93 #if defined(USE_PETSC_COMPLEX)
94 #define PETSC_SCALAR PETSC_COMPLEX
95 #else
96 #define PETSC_SCALAR PETSC_DOUBLE
97 #endif
98 typedef enum {PETSC_INT_SIZE = sizeof(int), PETSC_DOUBLE_SIZE = sizeof(double),
99               PETSC_SCALAR_SIZE = sizeof(Scalar), PETSC_COMPLEX_SIZE = sizeof(double),
100               PETSC_CHAR_SIZE = sizeof(char), PETSC_LOGICAL_SIZE = 1} PetscDataTypeSize;
101 extern int PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
102 extern int PetscDataTypeGetSize(PetscDataType,int*);
103 extern int PetscDataTypeGetName(PetscDataType,char*[]);
104 
105 /*
106     Basic memory and string operations. These are usually simple wrappers
107    around the basic Unix system calls, but a few of them have additional
108    functionality and/or error checking.
109 */
110 extern int   PetscMemcpy(void *,const void *,int);
111 extern int   PetscBitMemcpy(void*,int,const void*,int,int,PetscDataType);
112 extern int   PetscMemmove(void *,void *,int);
113 extern int   PetscMemzero(void *,int);
114 extern int   PetscMemcmp(const void*,const void*, int);
115 extern int   PetscStrlen(const char[]);
116 extern int   PetscStrcmp(const char[],const char[]);
117 extern int   PetscStrcasecmp(const char[],const char[]);
118 extern int   PetscStrncmp(const char[],const char[],int );
119 extern int   PetscStrcpy(char[],const char[]);
120 extern int   PetscStrcat(char[],const char[]);
121 extern int   PetscStrncat(char[],const char[],int);
122 extern int   PetscStrncpy(char[],const char[],int);
123 extern char* PetscStrchr(const char[],char);
124 extern char* PetscStrrchr(const char[],char);
125 extern char* PetscStrstr(const char[],const char[]);
126 extern char* PetscStrtok(const char[],const char[]);
127 
128 #define PetscTypeCompare(a,b) (!PetscStrcmp((char*)(a),(char *)(b)))
129 
130 /*
131        Basic PETSc constants
132 */
133 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
134 #define PETSC_NULL            0
135 #define PETSC_DECIDE         -1
136 #define PETSC_DETERMINE      PETSC_DECIDE
137 #define PETSC_DEFAULT        -2
138 
139 /*
140     Each PETSc object class has it's own cookie (internal integer in the
141   data structure used for error checking). These are all defined by an offset
142   from the lowest one, PETSC_COOKIE. If you increase these you must
143   increase the field sizes in petsc/src/sys/src/plog/plog.c
144 */
145 #define PETSC_COOKIE                    1211211
146 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30
147 #define LARGEST_PETSC_COOKIE_ALLOWED    PETSC_COOKIE + 50
148 extern int LARGEST_PETSC_COOKIE;
149 
150 typedef struct _FList *FList;
151 
152 #include "viewer.h"
153 #include "options.h"
154 
155 extern int PetscGetTime(PLogDouble*);
156 extern int PetscGetCPUTime(PLogDouble*);
157 extern int PetscSleep(int);
158 
159 /*
160     Initialization of PETSc or its micro-kernel ALICE
161 */
162 extern int  AliceInitialize(int*,char***,const char[],const char[]);
163 extern int  AliceInitializeNoArguments(void);
164 extern int  AliceFinalize(void);
165 extern void AliceInitializeFortran(void);
166 
167 extern int  PetscInitialize(int*,char***,char[],const char[]);
168 extern int  PetscInitializeNoArguments(void);
169 extern int  PetscFinalize(void);
170 extern void PetscInitializeFortran(void);
171 
172 /*
173     Functions that can act on any PETSc object.
174 */
175 typedef struct _p_PetscObject* PetscObject;
176 extern int PetscObjectDestroy(PetscObject);
177 extern int PetscObjectExists(PetscObject,PetscTruth*);
178 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm);
179 extern int PetscObjectGetCookie(PetscObject,int *cookie);
180 extern int PetscObjectGetType(PetscObject,int *type);
181 extern int PetscObjectSetName(PetscObject,const char[]);
182 extern int PetscObjectGetName(PetscObject,char*[]);
183 extern int PetscObjectReference(PetscObject);
184 extern int PetscObjectGetReference(PetscObject,int*);
185 extern int PetscObjectDereference(PetscObject);
186 extern int PetscObjectGetNewTag(PetscObject,int *);
187 extern int PetscObjectRestoreNewTag(PetscObject,int *);
188 extern int PetscCommGetNewTag(MPI_Comm,int *);
189 extern int PetscCommRestoreNewTag(MPI_Comm,int *);
190 extern int PetscObjectView(PetscObject,Viewer);
191 extern int PetscObjectCompose(PetscObject,const char[],PetscObject);
192 extern int PetscObjectQuery(PetscObject,const char[],PetscObject *);
193 extern int PetscObjectComposeFunction_Private(PetscObject,const char[],const char[],void *);
194 #if defined(USE_DYNAMIC_LIBRARIES)
195 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,0)
196 #else
197 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,d)
198 #endif
199 extern int PetscObjectQueryFunction(PetscObject,const char[],void **);
200 extern int PetscObjectSetOptionsPrefix(PetscObject,const char[]);
201 extern int PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
202 extern int PetscObjectPrependOptionsPrefix(PetscObject,const char[]);
203 extern int PetscObjectGetOptionsPrefix(PetscObject,char*[]);
204 extern int PetscObjectPublish(PetscObject);
205 
206 /*
207     Defines PETSc error handling.
208 */
209 #include "petscerror.h"
210 
211 /*
212     Mechanism for managing lists of objects attached (composed) with
213    a PETSc object.
214 */
215 typedef struct _OList *OList;
216 extern int OListDestroy(OList *);
217 extern int OListFind(OList,const char[],PetscObject*);
218 extern int OListReverseFind(OList,PetscObject,char**);
219 extern int OListAdd(OList *,const char[],PetscObject);
220 extern int OListDuplicate(OList,OList *);
221 
222 /*
223     Dynamic library lists. Lists of names of routines in dynamic
224   link libraries that will be loaded as needed.
225 */
226 extern int FListAdd_Private(FList*,const char[],const char[],int (*)(void *));
227 extern int FListDestroy(FList);
228 extern int FListFind(MPI_Comm,FList,const char[],int (**)(void*));
229 extern int FListPrintTypes(MPI_Comm,FILE*,const char[],const char[],FList);
230 #if defined(USE_DYNAMIC_LIBRARIES)
231 #define    FListAdd(a,b,p,c) FListAdd_Private(a,b,p,0)
232 #else
233 #define    FListAdd(a,b,p,c) FListAdd_Private(a,b,p,(int (*)(void *))c)
234 #endif
235 extern int FListDuplicate(FList,FList *);
236 extern int FListView(FList,Viewer);
237 
238 /*
239    Routines for handling dynamic libraries. PETSc uses dynamic libraries
240   by default on most machines (except IBM). This is controlled by the
241   flag USE_DYNAMIC_LIBRARIES in petscconf.h
242 */
243 typedef struct _DLLibraryList *DLLibraryList;
244 extern DLLibraryList DLLibrariesLoaded;
245 extern int DLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *);
246 extern int DLLibraryOpen(MPI_Comm,const char[],void **);
247 extern int DLLibrarySym(MPI_Comm,DLLibraryList *,const char[],const char[],void **);
248 extern int DLLibraryAppend(MPI_Comm,DLLibraryList *,const char[]);
249 extern int DLLibraryPrepend(MPI_Comm,DLLibraryList *,const char[]);
250 extern int DLLibraryClose(DLLibraryList);
251 extern int DLLibraryPrintPath(void);
252 extern int DLLibraryGetInfo(void *,char *,char **);
253 
254 /*
255     Mechanism for translating PETSc object representations between languages
256     Not currently used.
257 */
258 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage;
259 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C
260 extern int PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *);
261 extern int PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **);
262 
263 /*
264      Useful utility routines
265 */
266 extern int PetscSplitOwnership(MPI_Comm,int*,int*);
267 extern int  PetscSequentialPhaseBegin(MPI_Comm,int);
268 extern int  PetscSequentialPhaseEnd(MPI_Comm,int);
269 extern int  PetscBarrier(PetscObject);
270 extern int  PetscMPIDump(FILE*);
271 
272 /*
273     Defines basic graphics available from PETSc.
274 */
275 #include "draw.h"
276 
277 /*
278     Defines the base data structures for all PETSc objects
279 */
280 #include "petschead.h"
281 
282 /*
283      Defines PETSc profiling.
284 */
285 #include "petsclog.h"
286 
287 #if defined(HAVE_AMS)
288 extern PetscTruth PetscAMSPublishAll;
289 #define PetscPublishAll(v)\
290   { if (PetscAMSPublishAll) { \
291     int __ierr;\
292     __ierr = PetscObjectPublish((PetscObject)v);CHKERRQ(__ierr);\
293   }}
294 #else
295 #define PetscPublishAll(v)
296 #endif
297 
298 /*
299       This code allows one to pass a MPI communicator between
300     C and Fortran. MPI 2.0 defines a standard API for doing this.
301     The code here is provided to allow PETSc to work with MPI 1.1
302     standard MPI libraries.
303 */
304 extern int  MPICCommToFortranComm(MPI_Comm,int *);
305 extern int  MPIFortranCommToCComm(int,MPI_Comm*);
306 
307 /*
308       Simple PETSc parallel IO for ASCII printing
309 */
310 extern int  PetscFixFilename(const char[],char[]);
311 extern FILE *PetscFOpen(MPI_Comm,const char[],const char[]);
312 extern int  PetscFClose(MPI_Comm,FILE*);
313 extern int  PetscFPrintf(MPI_Comm,FILE*,const char[],...);
314 extern int  PetscPrintf(MPI_Comm,const char[],...);
315 extern int  (*PetscErrorPrintf)(const char[],...);
316 extern int  (*PetscHelpPrintf)(MPI_Comm,const char[],...);
317 
318 extern int  PetscSynchronizedPrintf(MPI_Comm,const char[],...);
319 extern int  PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...);
320 extern int  PetscSynchronizedFlush(MPI_Comm);
321 
322 /*
323     Simple PETSc object that contains a pointer to any required data
324 */
325 typedef struct _p_PetscObjectContainer*  PetscObjectContainer;
326 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **);
327 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *);
328 extern int PetscObjectContainerDestroy(PetscObjectContainer);
329 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *);
330 
331 /*
332    For incremental debugging
333 */
334 extern int PetscCompare;
335 extern int PetscCompareDouble(double);
336 extern int PetscCompareScalar(Scalar);
337 extern int PetscCompareInt(int);
338 
339 /*
340    For use in debuggers
341 */
342 extern int PetscGlobalRank,PetscGlobalSize;
343 extern int PetscIntView(int,int[],Viewer);
344 extern int PetscDoubleView(int,double[],Viewer);
345 extern int PetscScalarView(int,Scalar[],Viewer);
346 
347 /*
348     C code optimization is often enhanced by telling the compiler
349   that certain pointer arguments to functions are not aliased to
350   to other arguments. This is not yet ANSI C standard so we define
351   the macro "restrict" to indicate that the variable is not aliased
352   to any other argument.
353 */
354 #if defined(HAVE_RESTRICT) && !defined(__cplusplus)
355 #define restrict _Restrict
356 #else
357 #define restrict
358 #endif
359 
360 /*
361       Determine if some of the kernel computation routines use
362    Fortran (rather than C) for the numerical calculations. On some machines
363    and compilers (like complex numbers) the Fortran version of the routines
364    is faster than the C/C++ versions. The flag USE_FORTRAN_KERNELS
365    would be set in the petscconf.h file
366 */
367 #if defined(USE_FORTRAN_KERNELS)
368 
369 #if !defined(USE_FORTRAN_KERNEL_MULTAIJ)
370 #define USE_FORTRAN_KERNEL_MULTAIJ
371 #endif
372 
373 #if !defined(USE_FORTRAN_KERNEL_NORMSQR)
374 #define USE_FORTRAN_KERNEL_NORMSQR
375 #endif
376 
377 #if !defined(USE_FORTRAN_KERNEL_MAXPY)
378 #define USE_FORTRAN_KERNEL_MAXPY
379 #endif
380 
381 #if !defined(USE_FORTRAN_KERNEL_SOLVEAIJ)
382 #define USE_FORTRAN_KERNEL_SOLVEAIJ
383 #endif
384 
385 #if !defined(USE_FORTRAN_KERNEL_SOLVEBAIJ)
386 #define USE_FORTRAN_KERNEL_SOLVEBAIJ
387 #endif
388 
389 #if !defined(USE_FORTRAN_KERNEL_MULTADDAIJ)
390 #define USE_FORTRAN_KERNEL_MULTADDAIJ
391 #endif
392 
393 #if !defined(USE_FORTRAN_KERNEL_MDOT)
394 #define USE_FORTRAN_KERNEL_MDOT
395 #endif
396 
397 #if !defined(USE_FORTRAN_KERNEL_XTIMESY)
398 #define USE_FORTRAN_KERNEL_XTIMESY
399 #endif
400 
401 #endif
402 
403 /*
404     Macros for indicating code that should be compiled with a C interface,
405    rather than a C++ interface. Any routines that are dynamically loaded
406    (such as the PCCreate_XXX() routines) must be wrapped so that the name
407    mangler does not change the functions symbol name. This just hides the
408    ugly extern "C" {} wrappers.
409 */
410 #if defined(__cplusplus)
411 #define EXTERN_C_BEGIN extern "C" {
412 #define EXTERN_C_END }
413 #else
414 #define EXTERN_C_BEGIN
415 #define EXTERN_C_END
416 #endif
417 
418 #endif
419