xref: /petsc/include/petsc.h (revision e78c158d3e892157a2f28f9e3058d5e1a81a32a3)
1 
2 #if !defined(__PETSC_PACKAGE)
3 #define __PETSC_PACKAGE
4 
5 #if PETSC_COMPLEX
6 #include <complex.h>
7 #define Scalar complex
8 #else
9 #define Scalar double
10 #endif
11 
12 
13 /*  Macros for getting and freeing memory */
14 #if defined(PETSC_MALLOC)
15 #define MALLOC(a)       trmalloc(a,__LINE__,__FILE__)
16 #define FREE(a)         trfree(a,__LINE__,__FILE__)
17 #else
18 #define MALLOC(a)       malloc(a)
19 #define FREE(a)         free(a)
20 #endif
21 #define NEW(a)          (a *) MALLOC(sizeof(a))
22 #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
23 #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
24 
25 /*  Macros for error checking */
26 #define SETERR(n,s)     {return PetscError(__LINE__,__FILE__,s,n);}
27 #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
28 #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
29 
30 
31 typedef struct _PetscObject* PetscObject;
32 typedef struct _Viewer*      Viewer;
33 
34 /* useful Petsc routines (used often) */
35 extern int  PetscDestroy(PetscObject);
36 extern int  PetscView(PetscObject,Viewer);
37 
38 extern int  PetscError(int,char*,char*,int);
39 extern int  PetscPushErrorHandler(int (*handler)(int,char*,char*,int,void*),void* );
40 extern int  PetscPopErrorHandler();
41 
42 extern int  PetscDefaultErrorHandler(int,char*,char*,int,void*);
43 extern int  PetscAbortErrorHandler(int,char*,char*,int,void* );
44 extern int  PetscAttachDebuggerErrorHandler(int, char *,char *,int,void*);
45 
46 extern int  PetscSetDebugger(char *,int,char *);
47 extern int  PetscAttachDebugger();
48 
49 extern void *trmalloc(unsigned int,int,char*);
50 extern int  trfree(void *,int,char*);
51 
52 
53 #if defined(titan) || defined(cray) || defined(ncube)
54 #define FORTRANCAPS
55 #elif !defined(rs6000) && !defined(NeXT) && !defined(HPUX)
56 #define FORTRANUNDERSCORE
57 #endif
58 
59 #endif
60