xref: /petsc/include/petsc.h (revision 4b0eab3994be0807b08867cec0f0409ea672a39e)
12eac72dbSBarry Smith 
22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE)
32eac72dbSBarry Smith #define __PETSC_PACKAGE
42eac72dbSBarry Smith 
5*4b0eab39SBarry Smith #define PETSC_VERSION_NUMBER "PETSc Version 2.0.Beta.2 Released May 14, 1995."
67e59f0e8SBarry Smith 
7f0479e8cSBarry Smith #include <stdio.h>
828988994SBarry Smith #if defined(PARCH_sun4)
96abc6512SBarry Smith int fprintf(FILE*,char*,...);
106abc6512SBarry Smith int printf(char*,...);
116abc6512SBarry Smith int fflush(FILE*);
126abc6512SBarry Smith int fclose(FILE*);
1328988994SBarry Smith #endif
14f0479e8cSBarry Smith 
15f0479e8cSBarry Smith /* MPI interface */
16f0479e8cSBarry Smith #include "mpi.h"
17f0479e8cSBarry Smith #include "mpe.h"
18f0479e8cSBarry Smith #if defined(PETSC_COMPLEX)
19f0479e8cSBarry Smith #define MPI_SCALAR MPIR_dcomplex_dte
20f0479e8cSBarry Smith #else
21f0479e8cSBarry Smith #define MPI_SCALAR MPI_DOUBLE
22f0479e8cSBarry Smith #endif
23d6dfbf8fSBarry Smith extern FILE *MPE_fopen(MPI_Comm,char *,char *);
24d6dfbf8fSBarry Smith extern int MPE_fclose(MPI_Comm,FILE*);
25d6dfbf8fSBarry Smith extern int MPE_fprintf(MPI_Comm,FILE*,char *,...);
26d6dfbf8fSBarry Smith extern int MPE_printf(MPI_Comm,char *,...);
27d6dfbf8fSBarry Smith extern int MPE_Set_display(MPI_Comm,char **);
28f0479e8cSBarry Smith 
29f0479e8cSBarry Smith 
30c6a45a97SBarry Smith #if defined(PETSC_COMPLEX)
31c6a45a97SBarry Smith /* work around for bug in alpha g++ compiler */
32c6a45a97SBarry Smith #if defined(PARCH_alpha)
33c6a45a97SBarry Smith #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
34c6a45a97SBarry Smith /* extern double hypot(double,double); */
35c6a45a97SBarry Smith #endif
368ed539a5SBarry Smith #include <complex.h>
3720563c6bSBarry Smith #define PETSCREAL(a) real(a)
388ed539a5SBarry Smith #define Scalar       complex
398ed539a5SBarry Smith #else
4020563c6bSBarry Smith #define PETSCREAL(a) a
418ed539a5SBarry Smith #define Scalar       double
428ed539a5SBarry Smith #endif
438ed539a5SBarry Smith 
448ed539a5SBarry Smith 
452eac72dbSBarry Smith /*  Macros for getting and freeing memory */
468ed539a5SBarry Smith #if defined(PETSC_MALLOC)
476b5873e3SBarry Smith #define MALLOC(a)       Trmalloc(a,__LINE__,__FILE__)
486b5873e3SBarry Smith #define FREE(a)         Trfree(a,__LINE__,__FILE__)
498ed539a5SBarry Smith #else
502eac72dbSBarry Smith #define MALLOC(a)       malloc(a)
512eac72dbSBarry Smith #define FREE(a)         free(a)
528ed539a5SBarry Smith #endif
538ed539a5SBarry Smith #define NEW(a)          (a *) MALLOC(sizeof(a))
542eac72dbSBarry Smith #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
558ed539a5SBarry Smith #define MEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
5620563c6bSBarry Smith #include <memory.h>
572eac72dbSBarry Smith 
582eac72dbSBarry Smith /*  Macros for error checking */
59f0479e8cSBarry Smith #if !defined(__DIR__)
60f0479e8cSBarry Smith #define __DIR__ 0
61f0479e8cSBarry Smith #endif
6228988994SBarry Smith #if defined(PETSC_DEBUG)
63f0479e8cSBarry Smith #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
64d6dfbf8fSBarry Smith #define SETERRA(n,s)    \
65d6dfbf8fSBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
66d6dfbf8fSBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
672eac72dbSBarry Smith #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
68d6dfbf8fSBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
692eac72dbSBarry Smith #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
70d6dfbf8fSBarry Smith #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
7128988994SBarry Smith #else
7228988994SBarry Smith #define SETERR(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
7328988994SBarry Smith #define SETERRA(n,s)    \
7428988994SBarry Smith                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
7528988994SBarry Smith                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
7628988994SBarry Smith #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
7728988994SBarry Smith #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
7828988994SBarry Smith #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
7928988994SBarry Smith #define CHKPTRA(p)      if (!p) SETERRA(1,"No memory");
8028988994SBarry Smith #endif
812eac72dbSBarry Smith 
828ed539a5SBarry Smith typedef struct _PetscObject* PetscObject;
839e25ed09SBarry Smith #define PETSC_COOKIE         0x12121212
846b5873e3SBarry Smith #define PETSC_DECIDE         -1
85da69df5fSBarry Smith 
86ca9b4cbeSLois Curfman McInnes typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
87ca9b4cbeSLois Curfman McInnes 
88da69df5fSBarry Smith #include "viewer.h"
892eac72dbSBarry Smith 
908ed539a5SBarry Smith /* useful Petsc routines (used often) */
91a0a59b22SBarry Smith extern int  PetscInitialize(int*,char***,char*,char*);
92a0a59b22SBarry Smith extern int  PetscFinalize();
93a0a59b22SBarry Smith 
948ed539a5SBarry Smith extern int  PetscDestroy(PetscObject);
957f223b93SBarry Smith extern int  PetscObjectGetComm(PetscObject,MPI_Comm *comm);
96a5a9c739SBarry Smith extern int  PetscObjectSetName(PetscObject,char*);
97a5a9c739SBarry Smith extern int  PetscObjectGetName(PetscObject,char**);
982eac72dbSBarry Smith 
99f0479e8cSBarry Smith extern int  PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
100f0479e8cSBarry Smith extern int  PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
101f0479e8cSBarry Smith extern int  PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
102f0479e8cSBarry Smith extern int  PetscError(int,char*,char*,char*,int);
103f0479e8cSBarry Smith extern int  PetscPushErrorHandler(int
104f0479e8cSBarry Smith                          (*handler)(int,char*,char*,char*,int,void*),void* );
1058ed539a5SBarry Smith extern int  PetscPopErrorHandler();
1068ed539a5SBarry Smith 
1078ed539a5SBarry Smith extern int  PetscSetDebugger(char *,int,char *);
1088ed539a5SBarry Smith extern int  PetscAttachDebugger();
1098ed539a5SBarry Smith 
110f0479e8cSBarry Smith extern int PetscDefaultSignalHandler(int,void*);
111f0479e8cSBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
112f0479e8cSBarry Smith extern int PetscPopSignalHandler();
113f0479e8cSBarry Smith extern int PetscSetFPTrap(int);
1146b5873e3SBarry Smith #define FP_TRAP_OFF    0
1156b5873e3SBarry Smith #define FP_TRAP_ON     1
1166b5873e3SBarry Smith #define FP_TRAP_ALWAYS 2
117f97c0401SBarry Smith 
118123e9dcfSBarry Smith #if defined(PETSC_MALLOC)
1196b5873e3SBarry Smith extern void *Trmalloc(unsigned int,int,char*);
1206b5873e3SBarry Smith extern int  Trfree(void *,int,char*);
1216b5873e3SBarry Smith extern int  Trdump(FILE *);
122123e9dcfSBarry Smith #else
123123e9dcfSBarry Smith #include <malloc.h>
124123e9dcfSBarry Smith #endif
1258ed539a5SBarry Smith 
1261eb62cbbSBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE)
1278ed539a5SBarry Smith #define FORTRANCAPS
12800c700d8SBarry Smith #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_HPUX)
1298ed539a5SBarry Smith #define FORTRANUNDERSCORE
1302eac72dbSBarry Smith #endif
1312eac72dbSBarry Smith 
132123e9dcfSBarry Smith #include <stdio.h> /* I don't like this, but? */
133123e9dcfSBarry Smith 
1347857610eSBarry Smith /* Global flop counter */
1357857610eSBarry Smith extern double _TotalFlops;
1367857610eSBarry Smith #if defined(PETSC_LOG)
1377857610eSBarry Smith #define PLogFlops(n) {_TotalFlops += n;}
1387857610eSBarry Smith #else
1397857610eSBarry Smith #define PLogFlops(n)
1407857610eSBarry Smith #endif
1417857610eSBarry Smith 
1422eac72dbSBarry Smith #endif
143