xref: /petsc/include/petsc.h (revision 1eb62cbb64d64b61ce4c1a3ec8cb7777b3ff11c2)
12eac72dbSBarry Smith 
22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE)
32eac72dbSBarry Smith #define __PETSC_PACKAGE
42eac72dbSBarry Smith 
58ed539a5SBarry Smith #if PETSC_COMPLEX
68ed539a5SBarry Smith #include <complex.h>
720563c6bSBarry Smith #define PETSCREAL(a) real(a)
88ed539a5SBarry Smith #define Scalar       complex
98ed539a5SBarry Smith #else
1020563c6bSBarry Smith #define PETSCREAL(a) a
118ed539a5SBarry Smith #define Scalar       double
128ed539a5SBarry Smith #endif
138ed539a5SBarry Smith 
148ed539a5SBarry Smith 
152eac72dbSBarry Smith /*  Macros for getting and freeing memory */
168ed539a5SBarry Smith #if defined(PETSC_MALLOC)
178ed539a5SBarry Smith #define MALLOC(a)       trmalloc(a,__LINE__,__FILE__)
188ed539a5SBarry Smith #define FREE(a)         trfree(a,__LINE__,__FILE__)
198ed539a5SBarry Smith #else
202eac72dbSBarry Smith #define MALLOC(a)       malloc(a)
212eac72dbSBarry Smith #define FREE(a)         free(a)
228ed539a5SBarry Smith #endif
238ed539a5SBarry Smith #define NEW(a)          (a *) MALLOC(sizeof(a))
242eac72dbSBarry Smith #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
258ed539a5SBarry Smith #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
2620563c6bSBarry Smith #include <memory.h>
272eac72dbSBarry Smith 
282eac72dbSBarry Smith /*  Macros for error checking */
298ed539a5SBarry Smith #define SETERR(n,s)     {return PetscError(__LINE__,__FILE__,s,n);}
302eac72dbSBarry Smith #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
312eac72dbSBarry Smith #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
322eac72dbSBarry Smith 
332eac72dbSBarry Smith 
348ed539a5SBarry Smith typedef struct _PetscObject* PetscObject;
358ed539a5SBarry Smith typedef struct _Viewer*      Viewer;
362eac72dbSBarry Smith 
378ed539a5SBarry Smith /* useful Petsc routines (used often) */
38a0a59b22SBarry Smith extern int  PetscInitialize(int*,char***,char*,char*);
39a0a59b22SBarry Smith extern int  PetscFinalize();
40a0a59b22SBarry Smith 
418ed539a5SBarry Smith extern int  PetscDestroy(PetscObject);
428ed539a5SBarry Smith extern int  PetscView(PetscObject,Viewer);
432eac72dbSBarry Smith 
448ed539a5SBarry Smith extern int  PetscError(int,char*,char*,int);
458ed539a5SBarry Smith extern int  PetscPushErrorHandler(int (*handler)(int,char*,char*,int,void*),void* );
468ed539a5SBarry Smith extern int  PetscPopErrorHandler();
478ed539a5SBarry Smith 
488ed539a5SBarry Smith extern int  PetscDefaultErrorHandler(int,char*,char*,int,void*);
498ed539a5SBarry Smith extern int  PetscAbortErrorHandler(int,char*,char*,int,void* );
508ed539a5SBarry Smith extern int  PetscAttachDebuggerErrorHandler(int, char *,char *,int,void*);
518ed539a5SBarry Smith 
528ed539a5SBarry Smith extern int  PetscSetDebugger(char *,int,char *);
538ed539a5SBarry Smith extern int  PetscAttachDebugger();
548ed539a5SBarry Smith 
55f97c0401SBarry Smith #include <signal.h> /* I don't like this, but? */
56*1eb62cbbSBarry Smith #if !defined(PARCH_rs6000) && !defined(PARCH_freebsd) && !defined(PARCH_alpha)
57f97c0401SBarry Smith extern int PetscSetSignalHandler(void (*)(int,int,struct sigcontext *,char*));
58*1eb62cbbSBarry Smith #else
59*1eb62cbbSBarry Smith extern int PetscSetSignalHandler(void (*)(int));
60*1eb62cbbSBarry Smith #endif
61f97c0401SBarry Smith 
628ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*);
638ed539a5SBarry Smith extern int  trfree(void *,int,char*);
6420563c6bSBarry Smith #include <stdio.h> /* I don't like this, but? */
6520563c6bSBarry Smith extern int  trdump(FILE *);
668ed539a5SBarry Smith 
67*1eb62cbbSBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE)
688ed539a5SBarry Smith #define FORTRANCAPS
69*1eb62cbbSBarry Smith #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX)
708ed539a5SBarry Smith #define FORTRANUNDERSCORE
712eac72dbSBarry Smith #endif
722eac72dbSBarry Smith 
732eac72dbSBarry Smith #endif
74