xref: /petsc/include/petsc.h (revision edd2f0e15628dd9b7f6ddd2a5df1609eab2c4ee0)
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 
90 /* useful Petsc routines (used often) */
91 extern int  PetscInitialize(int*,char***,char*,char*);
92 extern int  PetscFinalize();
93 
94 extern int  PetscDestroy(PetscObject);
95 extern int  PetscObjectGetComm(PetscObject,MPI_Comm *comm);
96 extern int  PetscObjectSetName(PetscObject,char*);
97 extern int  PetscObjectGetName(PetscObject,char**);
98 
99 extern int  PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
100 extern int  PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
101 extern int  PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
102 extern int  PetscError(int,char*,char*,char*,int);
103 extern int  PetscPushErrorHandler(int
104                          (*handler)(int,char*,char*,char*,int,void*),void* );
105 extern int  PetscPopErrorHandler();
106 
107 extern int  PetscSetDebugger(char *,int,char *);
108 extern int  PetscAttachDebugger();
109 
110 extern int PetscDefaultSignalHandler(int,void*);
111 extern int PetscPushSignalHandler(int (*)(int,void *),void*);
112 extern int PetscPopSignalHandler();
113 extern int PetscSetFPTrap(int);
114 #define FP_TRAP_OFF    0
115 #define FP_TRAP_ON     1
116 #define FP_TRAP_ALWAYS 2
117 
118 #if defined(PETSC_MALLOC)
119 extern void *Trmalloc(unsigned int,int,char*);
120 extern int  Trfree(void *,int,char*);
121 extern int  Trdump(FILE *);
122 #else
123 #include <malloc.h>
124 #endif
125 
126 #if defined(PARCH_cray) || defined(PARCH_NCUBE)
127 #define FORTRANCAPS
128 #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_HPUX)
129 #define FORTRANUNDERSCORE
130 #endif
131 
132 #include <stdio.h> /* I don't like this, but? */
133 
134 /* Global flop counter */
135 extern double _TotalFlops;
136 #if defined(PETSC_LOG)
137 #define PLogFlops(n) {_TotalFlops += n;}
138 #else
139 #define PLogFlops(n)
140 #endif
141 
142 #endif
143