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