xref: /petsc/include/petsc.h (revision 123e9dcf60049fa281df349a411b5b888e600cbd)
12eac72dbSBarry Smith 
22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE)
32eac72dbSBarry Smith #define __PETSC_PACKAGE
42eac72dbSBarry Smith 
5f0479e8cSBarry Smith #include <stdio.h>
6f0479e8cSBarry Smith 
7f0479e8cSBarry Smith /* MPI interface */
8f0479e8cSBarry Smith #include "mpi.h"
9f0479e8cSBarry Smith #include "mpe.h"
10f0479e8cSBarry Smith #if defined(PETSC_COMPLEX)
11f0479e8cSBarry Smith #define MPI_SCALAR MPIR_dcomplex_dte
12f0479e8cSBarry Smith #else
13f0479e8cSBarry Smith #define MPI_SCALAR MPI_DOUBLE
14f0479e8cSBarry Smith #endif
15d6dfbf8fSBarry Smith extern FILE *MPE_fopen(MPI_Comm,char *,char *);
16d6dfbf8fSBarry Smith extern int MPE_fclose(MPI_Comm,FILE*);
17d6dfbf8fSBarry Smith extern int MPE_fprintf(MPI_Comm,FILE*,char *,...);
18d6dfbf8fSBarry Smith extern int MPE_printf(MPI_Comm,char *,...);
19d6dfbf8fSBarry Smith extern int MPE_Set_display(MPI_Comm,char **);
20f0479e8cSBarry Smith 
21f0479e8cSBarry Smith 
22c6a45a97SBarry Smith #if defined(PETSC_COMPLEX)
23c6a45a97SBarry Smith /* work around for bug in alpha g++ compiler */
24c6a45a97SBarry Smith #if defined(PARCH_alpha)
25c6a45a97SBarry Smith #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
26c6a45a97SBarry Smith /* extern double hypot(double,double); */
27c6a45a97SBarry Smith #endif
288ed539a5SBarry Smith #include <complex.h>
2920563c6bSBarry Smith #define PETSCREAL(a) real(a)
308ed539a5SBarry Smith #define Scalar       complex
318ed539a5SBarry Smith #else
3220563c6bSBarry Smith #define PETSCREAL(a) a
338ed539a5SBarry Smith #define Scalar       double
348ed539a5SBarry Smith #endif
358ed539a5SBarry Smith 
368ed539a5SBarry Smith 
372eac72dbSBarry Smith /*  Macros for getting and freeing memory */
388ed539a5SBarry Smith #if defined(PETSC_MALLOC)
398ed539a5SBarry Smith #define MALLOC(a)       trmalloc(a,__LINE__,__FILE__)
408ed539a5SBarry Smith #define FREE(a)         trfree(a,__LINE__,__FILE__)
418ed539a5SBarry Smith #else
422eac72dbSBarry Smith #define MALLOC(a)       malloc(a)
432eac72dbSBarry Smith #define FREE(a)         free(a)
448ed539a5SBarry Smith #endif
458ed539a5SBarry Smith #define NEW(a)          (a *) MALLOC(sizeof(a))
462eac72dbSBarry Smith #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
478ed539a5SBarry Smith #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
4820563c6bSBarry Smith #include <memory.h>
492eac72dbSBarry Smith 
502eac72dbSBarry Smith /*  Macros for error checking */
51f0479e8cSBarry Smith #if !defined(__DIR__)
52f0479e8cSBarry Smith #define __DIR__ 0
53f0479e8cSBarry Smith #endif
54f0479e8cSBarry Smith #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
55d6dfbf8fSBarry Smith #define SETERRA(n,s)    \
56d6dfbf8fSBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
57d6dfbf8fSBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
582eac72dbSBarry Smith #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
59d6dfbf8fSBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
602eac72dbSBarry Smith #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
61d6dfbf8fSBarry Smith #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
622eac72dbSBarry Smith 
632eac72dbSBarry Smith 
648ed539a5SBarry Smith typedef struct _PetscObject* PetscObject;
65da3a660dSBarry Smith 
668ed539a5SBarry Smith typedef struct _Viewer*      Viewer;
67d6dfbf8fSBarry Smith #define ViewerPrintf         (void *) 0
68da3a660dSBarry Smith #define VIEWER_COOKIE        0x123123
69da3a660dSBarry Smith #define MATLAB_VIEWER        1
702eac72dbSBarry Smith 
718ed539a5SBarry Smith /* useful Petsc routines (used often) */
72a0a59b22SBarry Smith extern int  PetscInitialize(int*,char***,char*,char*);
73a0a59b22SBarry Smith extern int  PetscFinalize();
74a0a59b22SBarry Smith 
758ed539a5SBarry Smith extern int  PetscDestroy(PetscObject);
768ed539a5SBarry Smith extern int  PetscView(PetscObject,Viewer);
772eac72dbSBarry Smith 
78f0479e8cSBarry Smith extern int  PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
79f0479e8cSBarry Smith extern int  PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
80f0479e8cSBarry Smith extern int  PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
81f0479e8cSBarry Smith extern int  PetscError(int,char*,char*,char*,int);
82f0479e8cSBarry Smith extern int  PetscPushErrorHandler(int
83f0479e8cSBarry Smith                          (*handler)(int,char*,char*,char*,int,void*),void* );
848ed539a5SBarry Smith extern int  PetscPopErrorHandler();
858ed539a5SBarry Smith 
868ed539a5SBarry Smith extern int  PetscSetDebugger(char *,int,char *);
878ed539a5SBarry Smith extern int  PetscAttachDebugger();
888ed539a5SBarry Smith 
89f0479e8cSBarry Smith extern int PetscDefaultSignalHandler(int,void*);
90f0479e8cSBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
91f0479e8cSBarry Smith extern int PetscPopSignalHandler();
92f0479e8cSBarry Smith extern int PetscSetFPTrap(int);
93f97c0401SBarry Smith 
94*123e9dcfSBarry Smith #if defined(PETSC_MALLOC)
958ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*);
968ed539a5SBarry Smith extern int  trfree(void *,int,char*);
9720563c6bSBarry Smith extern int  trdump(FILE *);
98*123e9dcfSBarry Smith #else
99*123e9dcfSBarry Smith #include <malloc.h>
100*123e9dcfSBarry Smith #endif
1018ed539a5SBarry Smith 
1021eb62cbbSBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE)
1038ed539a5SBarry Smith #define FORTRANCAPS
1041eb62cbbSBarry Smith #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX)
1058ed539a5SBarry Smith #define FORTRANUNDERSCORE
1062eac72dbSBarry Smith #endif
1072eac72dbSBarry Smith 
108*123e9dcfSBarry Smith #include <stdio.h> /* I don't like this, but? */
109*123e9dcfSBarry Smith 
1102eac72dbSBarry Smith #endif
111