xref: /petsc/include/petsc.h (revision 1a7c28d59d4bc937eda0c8e7b268b82df2814007)
1 /* $Id: petsc.h,v 1.226 1998/07/22 19:52:42 balay 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.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,const char[],const char[],const char[]);
76 extern int   PetscTrDebugLevel(int);
77 extern int   PetscTrLog(void);
78 extern int   PetscTrLogDump(FILE *);
79 extern int   PetscGetResidentSetSize(PLogDouble *);
80 
81 
82 typedef enum {PETSC_INT = 0, PETSC_DOUBLE = 1, PETSC_SHORT = 2, PETSC_FLOAT = 3,
83               PETSC_COMPLEX = 4, PETSC_CHAR = 5, PETSC_LOGICAL = 6} PetscDataType;
84 #if defined(USE_PETSC_COMPLEX)
85 #define PETSC_SCALAR PETSC_COMPLEX
86 #else
87 #define PETSC_SCALAR PETSC_DOUBLE
88 #endif
89 
90 typedef enum {PETSC_INT_SIZE = sizeof(int), PETSC_DOUBLE_SIZE = sizeof(double),
91               PETSC_SCALAR_SIZE = sizeof(Scalar), PETSC_COMPLEX_SIZE = sizeof(double),
92               PETSC_CHAR_SIZE = sizeof(char), PETSC_LOGICAL_SIZE = 1} PetscDataTypeSize;
93 extern int PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
94 extern int PetscDataTypeGetSize(PetscDataType,int*);
95 extern int PetscDataTypeGetName(PetscDataType,char*[]);
96 
97 /*
98     Basic memory and string operations
99 */
100 extern int   PetscMemcpy(void *,const void *,int);
101 extern int   PetscBitMemcpy(void*,int,const void*,int,int,PetscDataType);
102 extern int   PetscMemmove(void *,void *,int);
103 extern int   PetscMemzero(void *,int);
104 extern int   PetscMemcmp(const void*,const void*, int);
105 extern int   PetscStrlen(const char[]);
106 extern int   PetscStrcmp(const char[],const char[]);
107 extern int   PetscStrcasecmp(const char[],const char[]);
108 extern int   PetscStrncmp(const char[],const char[],int );
109 extern int   PetscStrcpy(char[],const char[]);
110 extern int   PetscStrcat(char[],const char[]);
111 extern int   PetscStrncat(char[],const char[],int);
112 extern int   PetscStrncpy(char[],const char[],int);
113 extern char* PetscStrchr(const char[],char);
114 extern char* PetscStrrchr(const char[],char);
115 extern char* PetscStrstr(const char[],const char[]);
116 extern char* PetscStrtok(const char[],const char[]);
117 
118 /*
119        Basic PETSc constants
120 */
121 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
122 #define PETSC_NULL            0
123 #define PETSC_DECIDE         -1
124 #define PETSC_DETERMINE      PETSC_DECIDE
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 int PetscGetTime(PLogDouble*);
147 extern int PetscGetCPUTime(PLogDouble*);
148 extern int PetscSleep(int);
149 
150 /*
151     Initialization of PETSc or its micro-kernel ALICE
152 */
153 extern int  AliceInitialize(int*,char***,const char[],const char[]);
154 extern int  AliceInitializeNoArguments(void);
155 extern int  AliceFinalize(void);
156 extern void AliceInitializeFortran(void);
157 
158 extern int  PetscInitialize(int*,char***,char[],const char[]);
159 extern int  PetscInitializeNoArguments(void);
160 extern int  PetscFinalize(void);
161 extern void PetscInitializeFortran(void);
162 
163 /*
164     Functions that can act on any PETSc object.
165 */
166 typedef struct _p_PetscObject* PetscObject;
167 extern int PetscObjectDestroy(PetscObject);
168 extern int PetscObjectExists(PetscObject,int*);
169 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm);
170 extern int PetscObjectGetCookie(PetscObject,int *cookie);
171 extern int PetscObjectGetType(PetscObject,int *type);
172 extern int PetscObjectSetName(PetscObject,const char[]);
173 extern int PetscObjectGetName(PetscObject,char*[]);
174 extern int PetscObjectReference(PetscObject);
175 extern int PetscObjectGetReference(PetscObject,int*);
176 extern int PetscObjectDereference(PetscObject);
177 extern int PetscObjectGetNewTag(PetscObject,int *);
178 extern int PetscObjectRestoreNewTag(PetscObject,int *);
179 extern int PetscObjectView(PetscObject,Viewer);
180 extern int PetscObjectCompose(PetscObject,const char[],PetscObject);
181 extern int PetscObjectQuery(PetscObject,const char[],PetscObject *);
182 extern int PetscObjectComposeFunction_Private(PetscObject,const char[],const char[],void *);
183 #if defined(USE_DYNAMIC_LIBRARIES)
184 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,0)
185 #else
186 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,d)
187 #endif
188 extern int PetscObjectQueryFunction(PetscObject,const char[],void **);
189 extern int PetscObjectSetOptionsPrefix(PetscObject,const char[]);
190 extern int PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
191 extern int PetscObjectGetOptionsPrefix(PetscObject,char*[]);
192 extern int PetscObjectPublish(PetscObject);
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,const char[],PetscObject*);
206 extern int OListAdd(OList *,const char[],PetscObject);
207 extern int OListDuplicate(OList,OList *);
208 
209 /*
210     Dynamic library lists. Lists of names of routines in dynamic
211   link libraries that will be loaded as needed.
212 */
213 typedef struct _FList *FList;
214 extern int FListAdd_Private(FList*,const char[],const char[],int (*)(void *));
215 extern int FListDestroy(FList);
216 extern int FListFind(MPI_Comm,FList,const char[],int (**)(void*));
217 extern int FListPrintTypes(MPI_Comm,FILE*,const char[],const char[],FList);
218 #if defined(USE_DYNAMIC_LIBRARIES)
219 #define    FListAdd(a,b,p,c) FListAdd_Private(a,b,p,0)
220 #else
221 #define    FListAdd(a,b,p,c) FListAdd_Private(a,b,p,(int (*)(void *))c)
222 #endif
223 extern int FListDuplicate(FList,FList *);
224 
225 typedef struct _DLLibraryList *DLLibraryList;
226 extern DLLibraryList DLLibrariesLoaded;
227 extern int DLLibraryOpen(MPI_Comm,const char[],void **);
228 extern int DLLibrarySym(MPI_Comm,DLLibraryList *,const char[],const char[],void **);
229 extern int DLLibraryAppend(MPI_Comm,DLLibraryList *,const char[]);
230 extern int DLLibraryPrepend(MPI_Comm,DLLibraryList *,const char[]);
231 extern int DLLibraryClose(DLLibraryList);
232 extern int DLLibraryPrintPath();
233 
234 /*
235     Mechanism for translating PETSc object representations between languages
236 */
237 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage;
238 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C
239 extern int PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *);
240 extern int PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **);
241 
242 #include "petschead.h"
243 
244 /*
245      Defines PETSc profiling.
246 */
247 #include "petsclog.h"
248 
249 extern int  PetscSequentialPhaseBegin(MPI_Comm,int);
250 extern int  PetscSequentialPhaseEnd(MPI_Comm,int);
251 extern int  PetscBarrier(PetscObject);
252 extern int  PetscMPIDump(FILE*);
253 
254 /*
255       This code allows one to pass a MPI communicator between
256     C and Fortran. MPI 2.0 defines a standard API for doing this.
257     The code here is provided to allow PETSc to work with MPI 1.1
258     standard MPI libraries.
259 */
260 extern int  MPICCommToFortranComm(MPI_Comm,int *);
261 extern int  MPIFortranCommToCComm(int,MPI_Comm*);
262 
263 /*
264       Simple PETSc parallel IO for ASCII printing
265 */
266 extern int  PetscFixFilename(const char[],char[]);
267 extern FILE *PetscFOpen(MPI_Comm,const char[],const char[]);
268 extern int  PetscFClose(MPI_Comm,FILE*);
269 extern int  PetscFPrintf(MPI_Comm,FILE*,const char[],...);
270 extern int  PetscPrintf(MPI_Comm,const char[],...);
271 extern int  (*PetscErrorPrintf)(const char[],...);
272 extern int  (*PetscHelpPrintf)(MPI_Comm,const char[],...);
273 
274 extern int  PetscSynchronizedPrintf(MPI_Comm,const char[],...);
275 extern int  PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...);
276 extern int  PetscSynchronizedFlush(MPI_Comm);
277 
278 
279 /*
280     Simple PETSc object that contains a pointer to any required data
281 */
282 typedef struct _p_PetscObjectContainer*  PetscObjectContainer;
283 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **);
284 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *);
285 extern int PetscObjectContainerDestroy(PetscObjectContainer);
286 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *);
287 
288 
289 /*
290    For incremental debugging
291 */
292 extern int PetscCompare;
293 extern int PetscCompareDouble(double);
294 extern int PetscCompareScalar(Scalar);
295 extern int PetscCompareInt(int);
296 
297 /*
298    For use in debuggers
299 */
300 extern int PetscGlobalRank,PetscGlobalSize;
301 extern int PetscIntView(int,int[],Viewer);
302 extern int PetscDoubleView(int,double[],Viewer);
303 
304 
305 /*
306     C code optimization is often enhanced by telling the compiler
307   that certain pointer arguments to functions are not aliased to
308   to other arguments. This is not yet ANSI C standard so we define
309   the macro "restrict" to indicate that the variable is not aliased
310   to any other argument.
311 */
312 #if defined(HAVE_RESTRICT) && !defined(__cplusplus)
313 #define restrict _Restrict
314 #else
315 #define restrict
316 #endif
317 
318 /*
319       Determine if some of the kernel computation routines use
320    Fortran (rather than C) for the numerical calculations. On some machines
321    and compilers (like complex numbers) the Fortran version of the routines
322    is faster than the C/C++ versions.
323 */
324 #if defined(USE_FORTRAN_KERNELS)
325 
326 #if !defined(USE_FORTRAN_KERNEL_MULTAIJ)
327 #define USE_FORTRAN_KERNEL_MULTAIJ
328 #endif
329 
330 #if !defined(USE_FORTRAN_KERNEL_NORMSQR)
331 #define USE_FORTRAN_KERNEL_NORMSQR
332 #endif
333 
334 #if !defined(USE_FORTRAN_KERNEL_MAXPY)
335 #define USE_FORTRAN_KERNEL_MAXPY
336 #endif
337 
338 #if !defined(USE_FORTRAN_KERNEL_SOLVEAIJ)
339 #define USE_FORTRAN_KERNEL_SOLVEAIJ
340 #endif
341 
342 #if !defined(USE_FORTRAN_KERNEL_MULTADDAIJ)
343 #define USE_FORTRAN_KERNEL_MULTADDAIJ
344 #endif
345 
346 #if !defined(USE_FORTRAN_KERNEL_MDOT)
347 #define USE_FORTRAN_KERNEL_MDOT
348 #endif
349 
350 #endif
351 
352 #endif
353