xref: /petsc/include/petsc.h (revision cac1d8b21e05ac70b09766bb260c4a9e737f8051)
1 /* $Id: petsc.h,v 1.170 1997/08/29 20:40:28 bsmith Exp gropp $ */
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 
33 #if defined(PARCH_sun4)
34 /* Fortran BLAS have slow dnrm2 */
35 #define HAVE_SLOW_NRM2
36 /* Functions that we count on Sun4's having */
37 #define HAVE_GETWD
38 #define HAVE_REALPATH
39 #endif
40 
41 #if defined(PARCH_rs6000)
42 /* Some versions of IBM's MPI have broken MPI_Request_free */
43 #define HAVE_BROKEN_REQUEST_FREE
44 #endif
45 
46 #if defined(PARCH_IRIX) || defined(PARCH_IRIX64)
47 /* For some reason, we don't use readlink in grpath.c for IRIX */
48 #undef HAVE_READLINK
49 #endif
50 #endif
51 
52 
53 #include <stdio.h>
54 /*
55     Defines the interface to MPI allowing the use of all MPI functions.
56 */
57 #include "mpi.h"
58 
59 /*
60     Defines some elementary mathematics functions and constants.
61 */
62 #include "petscmath.h"
63 
64 extern MPI_Comm PETSC_COMM_WORLD;
65 extern MPI_Comm PETSC_COMM_SELF;
66 extern int      PetscInitializedCalled;
67 extern int      PetscSetCommWorld(MPI_Comm);
68 
69 /*
70     Defines the malloc employed by PETSc. Users may employ these routines as well.
71 */
72 extern void *(*PetscTrMalloc)(unsigned int,int,char*,char*,char*);
73 extern int  (*PetscTrFree)(void *,int,char*,char*,char*);
74 extern int  PetscSetMalloc(void *(*)(unsigned int,int,char*,char*,char*),
75                            int (*)(void *,int,char*,char*,char*));
76 #define PetscMalloc(a)       (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
77 #define PetscNew(A)          (A*) PetscMalloc(sizeof(A))
78 #define PetscFree(a)         (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
79 
80 extern int   PetscTrDump(FILE *);
81 extern int   PetscTrSpace( PLogDouble *, PLogDouble *,PLogDouble *);
82 extern int   PetscTrValid(int,char *,char *,char *);
83 extern int   PetscTrDebugLevel(int);
84 extern int   PetscTrLog();
85 extern int   PetscTrLogDump(FILE *);
86 extern int   PetscGetResidentSetSize(PLogDouble *);
87 
88 /*
89     Basic memory and string operations
90 */
91 extern void  PetscMemcpy(void *,void *,int);
92 extern void  PetscMemmove(void *,void *,int);
93 extern void  PetscMemzero(void *,int);
94 extern int   PetscMemcmp(void*, void*, int);
95 extern int   PetscStrlen(char *);
96 extern int   PetscStrcmp(char *,char *);
97 extern int   PetscStrcasecmp(char *,char *);
98 extern int   PetscStrncmp(char *,char *,int );
99 extern void  PetscStrcpy(char *,char *);
100 extern void  PetscStrcat(char *,char *);
101 extern void  PetscStrncat(char *,char *,int);
102 extern void  PetscStrncpy(char *,char *,int);
103 extern char* PetscStrchr(char *,char);
104 extern char* PetscStrrchr(char *,char);
105 extern char* PetscStrstr(char*,char*);
106 extern char* PetscStrtok(char*,char*);
107 extern char* PetscStrrtok(char*,char*);
108 
109 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
110 #define PETSC_NULL            0
111 #define PETSC_DECIDE         -1
112 #define PETSC_DEFAULT        -2
113 
114 /*
115     Each PETSc object class has it's own cookie (internal integer in the
116   data structure used for error checking). These are all defined by an offset
117   from the lowest one, PETSC_COOKIE. If you increase these you must
118   increase the field sizes in petsc/src/plog/src/plog.c
119 */
120 #define PETSC_COOKIE                    1211211
121 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30
122 #define LARGEST_PETSC_COOKIE_ALLOWED    PETSC_COOKIE + 50
123 extern int LARGEST_PETSC_COOKIE;
124 
125 #include "viewer.h"
126 #include "options.h"
127 
128 /*
129     Defines basic graphics available from PETSc.
130 */
131 #include "draw.h"
132 
133 extern PLogDouble PetscGetTime();
134 extern PLogDouble PetscGetCPUTime();
135 extern void       PetscSleep(int);
136 
137 extern int    PetscInitialize(int*,char***,char*,char*);
138 extern int    PetscFinalize();
139 extern void   PetscInitializeFortran();
140 
141 /*
142     Functions that can act on any PETSc object.
143 */
144 typedef struct _p_PetscObject* PetscObject;
145 extern int PetscObjectDestroy(PetscObject);
146 extern int PetscObjectExists(PetscObject,int*);
147 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm);
148 extern int PetscObjectGetCookie(PetscObject,int *cookie);
149 extern int PetscObjectGetChild(PetscObject,void **child);
150 extern int PetscObjectGetType(PetscObject,int *type);
151 extern int PetscObjectSetName(PetscObject,char*);
152 extern int PetscObjectGetName(PetscObject,char**);
153 extern int PetscObjectInherit(PetscObject,void *, int (*)(void *,void **),int (*)(void*));
154 extern int PetscObjectReference(PetscObject);
155 extern int PetscObjectGetNewTag(PetscObject,int *);
156 extern int PetscObjectRestoreNewTag(PetscObject,int *);
157 extern int PetscObjectView(PetscObject,Viewer);
158 
159 /*
160     Defines PETSc error handling.
161 */
162 #include "petscerror.h"
163 #include "petschead.h"
164 
165 /*
166      Defines PETSc profiling.
167 */
168 #include "petsclog.h"
169 
170 extern int  PetscSequentialPhaseBegin(MPI_Comm,int);
171 extern int  PetscSequentialPhaseEnd(MPI_Comm,int);
172 
173 /*M
174     PetscBarrier - Blocks until this routine is executed by all
175                    processors owning the object A.
176 
177    Input Parameters:
178 .  A - PETSc object  ( Mat, Vec, IS, SNES etc...)
179 
180    Synopsis:
181    void PetscBarrier(PetscObject obj)
182 
183   Notes:
184   This routine calls MPI_Barrier with the communicator
185   of the PETSc Object "A".
186 
187 .keywords: barrier, petscobject
188 M*/
189 
190 #define PetscBarrier(A) \
191   { \
192     PetscValidHeader(A); \
193     PLogEventBegin(Petsc_Barrier,A,0,0,0); \
194     MPI_Barrier(((PetscObject)A)->comm); \
195     PLogEventEnd(Petsc_Barrier,A,0,0,0); \
196   }
197 
198 extern int PetscMPIDump(FILE *);
199 
200 /*
201       This code allows one to pass a PETSc object in C
202   to a Fortran routine, where (like all PETSc objects in
203   Fortran) it is treated as an integer.
204 */
205 extern int  PetscCObjectToFortranObject(void *,int *);
206 extern int  PetscFortranObjectToCObject(int,void *);
207 extern int  MPICCommToFortranComm(MPI_Comm,int *);
208 extern int  MPIFortranCommToCComm(int,MPI_Comm*);
209 
210 extern FILE *PetscFOpen(MPI_Comm,char *,char *);
211 extern int  PetscFClose(MPI_Comm,FILE*);
212 extern int  PetscFPrintf(MPI_Comm,FILE*,char *,...);
213 extern int  PetscPrintf(MPI_Comm,char *,...);
214 
215 extern int  PetscSynchronizedPrintf(MPI_Comm,char *,...);
216 extern int  PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...);
217 extern int  PetscSynchronizedFlush(MPI_Comm);
218 
219 /*
220    For incremental debugging
221 */
222 extern int PetscCompare;
223 extern int PetscCompareDouble(double);
224 extern int PetscCompareScalar(Scalar);
225 extern int PetscCompareInt(int);
226 
227 /*
228    For use in debuggers
229 */
230 extern int PetscGlobalRank,PetscGlobalSize;
231 extern int PetscIntView(int,int*,Viewer);
232 extern int PetscDoubleView(int,double *,Viewer);
233 
234 #endif
235