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