xref: /petsc/include/petsc.h (revision 1eb62cbb64d64b61ce4c1a3ec8cb7777b3ff11c2)
1 
2 #if !defined(__PETSC_PACKAGE)
3 #define __PETSC_PACKAGE
4 
5 #if PETSC_COMPLEX
6 #include <complex.h>
7 #define PETSCREAL(a) real(a)
8 #define Scalar       complex
9 #else
10 #define PETSCREAL(a) a
11 #define Scalar       double
12 #endif
13 
14 
15 /*  Macros for getting and freeing memory */
16 #if defined(PETSC_MALLOC)
17 #define MALLOC(a)       trmalloc(a,__LINE__,__FILE__)
18 #define FREE(a)         trfree(a,__LINE__,__FILE__)
19 #else
20 #define MALLOC(a)       malloc(a)
21 #define FREE(a)         free(a)
22 #endif
23 #define NEW(a)          (a *) MALLOC(sizeof(a))
24 #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
25 #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
26 #include <memory.h>
27 
28 /*  Macros for error checking */
29 #define SETERR(n,s)     {return PetscError(__LINE__,__FILE__,s,n);}
30 #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
31 #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
32 
33 
34 typedef struct _PetscObject* PetscObject;
35 typedef struct _Viewer*      Viewer;
36 
37 /* useful Petsc routines (used often) */
38 extern int  PetscInitialize(int*,char***,char*,char*);
39 extern int  PetscFinalize();
40 
41 extern int  PetscDestroy(PetscObject);
42 extern int  PetscView(PetscObject,Viewer);
43 
44 extern int  PetscError(int,char*,char*,int);
45 extern int  PetscPushErrorHandler(int (*handler)(int,char*,char*,int,void*),void* );
46 extern int  PetscPopErrorHandler();
47 
48 extern int  PetscDefaultErrorHandler(int,char*,char*,int,void*);
49 extern int  PetscAbortErrorHandler(int,char*,char*,int,void* );
50 extern int  PetscAttachDebuggerErrorHandler(int, char *,char *,int,void*);
51 
52 extern int  PetscSetDebugger(char *,int,char *);
53 extern int  PetscAttachDebugger();
54 
55 #include <signal.h> /* I don't like this, but? */
56 #if !defined(PARCH_rs6000) && !defined(PARCH_freebsd) && !defined(PARCH_alpha)
57 extern int PetscSetSignalHandler(void (*)(int,int,struct sigcontext *,char*));
58 #else
59 extern int PetscSetSignalHandler(void (*)(int));
60 #endif
61 
62 extern void *trmalloc(unsigned int,int,char*);
63 extern int  trfree(void *,int,char*);
64 #include <stdio.h> /* I don't like this, but? */
65 extern int  trdump(FILE *);
66 
67 #if defined(PARCH_cray) || defined(PARCH_NCUBE)
68 #define FORTRANCAPS
69 #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX)
70 #define FORTRANUNDERSCORE
71 #endif
72 
73 #endif
74