xref: /petsc/include/petsc.h (revision eaa2832de4c8c4ee7603eea4e7d1f3cd6050bcea)
1 
2 #if !defined(__PETSC_PACKAGE)
3 #define __PETSC_PACKAGE
4 
5 #include <stdio.h>
6 #if defined(PARCH_sun4)
7 int fprintf(FILE*,char*,...);
8 int printf(char*,...);
9 int fflush(FILE*);
10 int fclose(FILE*);
11 #endif
12 
13 /* MPI interface */
14 #include "mpi.h"
15 #include "mpe.h"
16 #if defined(PETSC_COMPLEX)
17 #define MPI_SCALAR MPIR_dcomplex_dte
18 #else
19 #define MPI_SCALAR MPI_DOUBLE
20 #endif
21 extern FILE *MPE_fopen(MPI_Comm,char *,char *);
22 extern int MPE_fclose(MPI_Comm,FILE*);
23 extern int MPE_fprintf(MPI_Comm,FILE*,char *,...);
24 extern int MPE_printf(MPI_Comm,char *,...);
25 extern int MPE_Set_display(MPI_Comm,char **);
26 
27 
28 #if defined(PETSC_COMPLEX)
29 /* work around for bug in alpha g++ compiler */
30 #if defined(PARCH_alpha)
31 #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
32 /* extern double hypot(double,double); */
33 #endif
34 #include <complex.h>
35 #define PETSCREAL(a) real(a)
36 #define Scalar       complex
37 #else
38 #define PETSCREAL(a) a
39 #define Scalar       double
40 #endif
41 
42 
43 /*  Macros for getting and freeing memory */
44 #if defined(PETSC_MALLOC)
45 #define MALLOC(a)       trmalloc(a,__LINE__,__FILE__)
46 #define FREE(a)         trfree(a,__LINE__,__FILE__)
47 #else
48 #define MALLOC(a)       malloc(a)
49 #define FREE(a)         free(a)
50 #endif
51 #define NEW(a)          (a *) MALLOC(sizeof(a))
52 #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
53 #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
54 #include <memory.h>
55 
56 /*  Macros for error checking */
57 #if !defined(__DIR__)
58 #define __DIR__ 0
59 #endif
60 #if defined(PETSC_DEBUG)
61 #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
62 #define SETERRA(n,s)    \
63                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
64                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
65 #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
66 #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
67 #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
68 #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
69 #else
70 #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
71 #define SETERRA(n,s)    \
72                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
73                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
74 #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
75 #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
76 #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
77 #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
78 #endif
79 
80 typedef struct _PetscObject* PetscObject;
81 #define PETSC_COOKIE         0x12121212
82 typedef struct _Viewer*      Viewer;
83 #define ViewerPrintf         (void *) 0
84 #define VIEWER_COOKIE        PETSC_COOKIE+1
85 #define MATLAB_VIEWER        0
86 extern int ViewerMatlabOpen(char*,int,Viewer *);
87 
88 /* useful Petsc routines (used often) */
89 extern int  PetscInitialize(int*,char***,char*,char*);
90 extern int  PetscFinalize();
91 
92 extern int  PetscDestroy(PetscObject);
93 extern int  PetscView(PetscObject,Viewer);
94 extern int  PetscObjectSetName(PetscObject,char*);
95 extern int  PetscObjectGetName(PetscObject,char**);
96 
97 extern int  PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
98 extern int  PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
99 extern int  PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
100 extern int  PetscError(int,char*,char*,char*,int);
101 extern int  PetscPushErrorHandler(int
102                          (*handler)(int,char*,char*,char*,int,void*),void* );
103 extern int  PetscPopErrorHandler();
104 
105 extern int  PetscSetDebugger(char *,int,char *);
106 extern int  PetscAttachDebugger();
107 
108 extern int PetscDefaultSignalHandler(int,void*);
109 extern int PetscPushSignalHandler(int (*)(int,void *),void*);
110 extern int PetscPopSignalHandler();
111 extern int PetscSetFPTrap(int);
112 
113 #if defined(PETSC_MALLOC)
114 extern void *trmalloc(unsigned int,int,char*);
115 extern int  trfree(void *,int,char*);
116 extern int  trdump(FILE *);
117 #else
118 #include <malloc.h>
119 #endif
120 
121 #if defined(PARCH_cray) || defined(PARCH_NCUBE)
122 #define FORTRANCAPS
123 #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX)
124 #define FORTRANUNDERSCORE
125 #endif
126 
127 #include <stdio.h> /* I don't like this, but? */
128 
129 #endif
130