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