xref: /petsc/include/petsc.h (revision 9b0d118972bd5614e9e2d4aa76805104fdfe5302)
1 
2 #if !defined(__PETSC_PACKAGE)
3 #define __PETSC_PACKAGE
4 
5 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.Beta.3 Released May 29, 1995."
6 
7 #include <stdio.h>
8 #if defined(PARCH_sun4)
9 int fprintf(FILE*,char*,...);
10 int printf(char*,...);
11 int fflush(FILE*);
12 int fclose(FILE*);
13 #endif
14 
15 /* MPI interface */
16 #include "mpi.h"
17 #include "mpiu.h"
18 
19 #if defined(PETSC_COMPLEX)
20 /* work around for bug in alpha g++ compiler */
21 #if defined(PARCH_alpha)
22 #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
23 /* extern double hypot(double,double); */
24 #endif
25 #include <complex.h>
26 #define PETSCREAL(a) real(a)
27 #define Scalar       complex
28 #else
29 #define PETSCREAL(a) a
30 #define Scalar       double
31 #endif
32 
33 extern void *(*PetscMalloc)(unsigned int,int,char*);
34 extern int  (*PetscFree)(void *,int,char*);
35 #define MALLOC(a)       (*PetscMalloc)(a,__LINE__,__FILE__)
36 #define FREE(a)         (*PetscFree)(a,__LINE__,__FILE__)
37 extern int  PetscSetMalloc(void *(*)(unsigned int,int,char*),
38                            int (*)(void *,int,char*));
39 extern int  Trdump(FILE *);
40 
41 #define NEW(a)          (a *) MALLOC(sizeof(a))
42 #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
43 #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
44 #include <memory.h>
45 
46 /*  Macros for error checking */
47 #if !defined(__DIR__)
48 #define __DIR__ 0
49 #endif
50 #if defined(PETSC_DEBUG)
51 #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
52 #define SETERRA(n,s)    \
53                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
54                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
55 #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
56 #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
57 #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
58 #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
59 #else
60 #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
61 #define SETERRA(n,s)    \
62                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
63                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
64 #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
65 #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
66 #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
67 #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
68 #endif
69 
70 typedef struct _PetscObject* PetscObject;
71 #define PETSC_COOKIE         0x12121212
72 #define PETSC_DECIDE         -1
73 
74 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
75 
76 #include "viewer.h"
77 #include "options.h"
78 
79 /* useful Petsc routines (used often) */
80 extern int  PetscInitialize(int*,char***,char*,char*);
81 extern int  PetscFinalize();
82 
83 extern int  PetscDestroy(PetscObject);
84 extern int  PetscObjectGetComm(PetscObject,MPI_Comm *comm);
85 extern int  PetscObjectSetName(PetscObject,char*);
86 extern int  PetscObjectGetName(PetscObject,char**);
87 
88 extern int  PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
89 extern int  PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
90 extern int  PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
91 extern int  PetscError(int,char*,char*,char*,int);
92 extern int  PetscPushErrorHandler(int
93                          (*handler)(int,char*,char*,char*,int,void*),void* );
94 extern int  PetscPopErrorHandler();
95 
96 extern int  PetscSetDebugger(char *,int,char *);
97 extern int  PetscAttachDebugger();
98 
99 extern int PetscDefaultSignalHandler(int,void*);
100 extern int PetscPushSignalHandler(int (*)(int,void *),void*);
101 extern int PetscPopSignalHandler();
102 extern int PetscSetFPTrap(int);
103 #define FP_TRAP_OFF    0
104 #define FP_TRAP_ON     1
105 #define FP_TRAP_ALWAYS 2
106 
107 
108 #if defined(PARCH_cray) || defined(PARCH_NCUBE)
109 #define FORTRANCAPS
110 #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_hpux)
111 #define FORTRANUNDERSCORE
112 #endif
113 
114 #include <stdio.h> /* I don't like this, but? */
115 
116 /* Global flop counter */
117 extern double _TotalFlops;
118 #if defined(PETSC_LOG)
119 #define PLogFlops(n) {_TotalFlops += n;}
120 #else
121 #define PLogFlops(n)
122 #endif
123 
124 #endif
125