xref: /petsc/include/petsc.h (revision a2596bdbc30ea25b67c8aa9d27518270ab3efaa7)
1 /* $Id: petsc.h,v 1.177 1997/09/11 20:42:38 bsmith Exp balay $ */
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) || defined(PARCH_IRIX5)
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 int   PetscMemcpy(void *,void *,int);
105 extern int   PetscMemmove(void *,void *,int);
106 extern int   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 int   PetscStrcpy(char *,char *);
113 extern int   PetscStrcat(char *,char *);
114 extern int   PetscStrncat(char *,char *,int);
115 extern int   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 PetscObjectDereference(PetscObject);
169 extern int PetscObjectGetNewTag(PetscObject,int *);
170 extern int PetscObjectRestoreNewTag(PetscObject,int *);
171 extern int PetscObjectView(PetscObject,Viewer);
172 
173 /*
174     Defines PETSc error handling.
175 */
176 #include "petscerror.h"
177 #include "petschead.h"
178 
179 /*
180      Defines PETSc profiling.
181 */
182 #include "petsclog.h"
183 
184 extern int  PetscSequentialPhaseBegin(MPI_Comm,int);
185 extern int  PetscSequentialPhaseEnd(MPI_Comm,int);
186 
187 /*M
188     PetscBarrier - Blocks until this routine is executed by all
189                    processors owning the object A.
190 
191    Input Parameters:
192 .  A - PETSc object  ( Mat, Vec, IS, SNES etc...)
193 
194    Synopsis:
195    void PetscBarrier(PetscObject obj)
196 
197   Notes:
198   This routine calls MPI_Barrier with the communicator
199   of the PETSc Object "A".
200 
201 .keywords: barrier, petscobject
202 M*/
203 
204 #define PetscBarrier(A) \
205   { \
206     PetscValidHeader(A); \
207     PLogEventBegin(Petsc_Barrier,A,0,0,0); \
208     MPI_Barrier(((PetscObject)A)->comm); \
209     PLogEventEnd(Petsc_Barrier,A,0,0,0); \
210   }
211 
212 extern int PetscMPIDump(FILE *);
213 
214 /*
215       This code allows one to pass a PETSc object in C
216   to a Fortran routine, where (like all PETSc objects in
217   Fortran) it is treated as an integer.
218 */
219 extern int  PetscCObjectToFortranObject(void *,int *);
220 extern int  PetscFortranObjectToCObject(int,void *);
221 extern int  MPICCommToFortranComm(MPI_Comm,int *);
222 extern int  MPIFortranCommToCComm(int,MPI_Comm*);
223 
224 extern FILE *PetscFOpen(MPI_Comm,char *,char *);
225 extern int  PetscFClose(MPI_Comm,FILE*);
226 extern int  PetscFPrintf(MPI_Comm,FILE*,char *,...);
227 extern int  PetscPrintf(MPI_Comm,char *,...);
228 
229 extern int  PetscSynchronizedPrintf(MPI_Comm,char *,...);
230 extern int  PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...);
231 extern int  PetscSynchronizedFlush(MPI_Comm);
232 
233 /*
234    For incremental debugging
235 */
236 extern int PetscCompare;
237 extern int PetscCompareDouble(double);
238 extern int PetscCompareScalar(Scalar);
239 extern int PetscCompareInt(int);
240 
241 /*
242    For use in debuggers
243 */
244 extern int PetscGlobalRank,PetscGlobalSize;
245 extern int PetscIntView(int,int*,Viewer);
246 extern int PetscDoubleView(int,double *,Viewer);
247 
248 #endif
249