12eac72dbSBarry Smith 22eac72dbSBarry Smith #if !defined(__PETSC_PACKAGE) 32eac72dbSBarry Smith #define __PETSC_PACKAGE 42eac72dbSBarry Smith 5*f0479e8cSBarry Smith #include <stdio.h> 6*f0479e8cSBarry Smith 7*f0479e8cSBarry Smith /* MPI interface */ 8*f0479e8cSBarry Smith #include "mpi.h" 9*f0479e8cSBarry Smith #include "mpe.h" 10*f0479e8cSBarry Smith #if defined(PETSC_COMPLEX) 11*f0479e8cSBarry Smith #define MPI_SCALAR MPIR_dcomplex_dte 12*f0479e8cSBarry Smith #else 13*f0479e8cSBarry Smith #define MPI_SCALAR MPI_DOUBLE 14*f0479e8cSBarry Smith #endif 15*f0479e8cSBarry Smith FILE *MPE_fopen(MPI_Comm,char *,char *); 16*f0479e8cSBarry Smith int MPE_fclose(MPI_Comm,FILE*); 17*f0479e8cSBarry Smith int MPE_fprintf(MPI_Comm,FILE*,char *,...); 18*f0479e8cSBarry Smith int MPE_printf(MPI_Comm,char *,...); 19*f0479e8cSBarry Smith 20*f0479e8cSBarry Smith 21c6a45a97SBarry Smith #if defined(PETSC_COMPLEX) 22c6a45a97SBarry Smith /* work around for bug in alpha g++ compiler */ 23c6a45a97SBarry Smith #if defined(PARCH_alpha) 24c6a45a97SBarry Smith #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b)) 25c6a45a97SBarry Smith /* extern double hypot(double,double); */ 26c6a45a97SBarry Smith #endif 278ed539a5SBarry Smith #include <complex.h> 2820563c6bSBarry Smith #define PETSCREAL(a) real(a) 298ed539a5SBarry Smith #define Scalar complex 308ed539a5SBarry Smith #else 3120563c6bSBarry Smith #define PETSCREAL(a) a 328ed539a5SBarry Smith #define Scalar double 338ed539a5SBarry Smith #endif 348ed539a5SBarry Smith 358ed539a5SBarry Smith 362eac72dbSBarry Smith /* Macros for getting and freeing memory */ 378ed539a5SBarry Smith #if defined(PETSC_MALLOC) 388ed539a5SBarry Smith #define MALLOC(a) trmalloc(a,__LINE__,__FILE__) 398ed539a5SBarry Smith #define FREE(a) trfree(a,__LINE__,__FILE__) 408ed539a5SBarry Smith #else 412eac72dbSBarry Smith #define MALLOC(a) malloc(a) 422eac72dbSBarry Smith #define FREE(a) free(a) 438ed539a5SBarry Smith #endif 448ed539a5SBarry Smith #define NEW(a) (a *) MALLOC(sizeof(a)) 452eac72dbSBarry Smith #define MEMCPY(a,b,n) memcpy((char*)(a),(char*)(b),n) 468ed539a5SBarry Smith #define MEMSET(a,b,n) memset((char*)(a),(int)(b),n) 4720563c6bSBarry Smith #include <memory.h> 482eac72dbSBarry Smith 492eac72dbSBarry Smith /* Macros for error checking */ 50*f0479e8cSBarry Smith #if !defined(__DIR__) 51*f0479e8cSBarry Smith #define __DIR__ 0 52*f0479e8cSBarry Smith #endif 53*f0479e8cSBarry Smith #define SETERR(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,s,n);} 542eac72dbSBarry Smith #define CHKERR(n) {if (n) SETERR(n,(char *)0);} 552eac72dbSBarry Smith #define CHKPTR(p) if (!p) SETERR(1,"No memory"); 562eac72dbSBarry Smith 572eac72dbSBarry Smith 588ed539a5SBarry Smith typedef struct _PetscObject* PetscObject; 598ed539a5SBarry Smith typedef struct _Viewer* Viewer; 602eac72dbSBarry Smith 618ed539a5SBarry Smith /* useful Petsc routines (used often) */ 62a0a59b22SBarry Smith extern int PetscInitialize(int*,char***,char*,char*); 63a0a59b22SBarry Smith extern int PetscFinalize(); 64a0a59b22SBarry Smith 658ed539a5SBarry Smith extern int PetscDestroy(PetscObject); 668ed539a5SBarry Smith extern int PetscView(PetscObject,Viewer); 672eac72dbSBarry Smith 68*f0479e8cSBarry Smith extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*); 69*f0479e8cSBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* ); 70*f0479e8cSBarry Smith extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*); 71*f0479e8cSBarry Smith extern int PetscError(int,char*,char*,char*,int); 72*f0479e8cSBarry Smith extern int PetscPushErrorHandler(int 73*f0479e8cSBarry Smith (*handler)(int,char*,char*,char*,int,void*),void* ); 748ed539a5SBarry Smith extern int PetscPopErrorHandler(); 758ed539a5SBarry Smith 768ed539a5SBarry Smith extern int PetscSetDebugger(char *,int,char *); 778ed539a5SBarry Smith extern int PetscAttachDebugger(); 788ed539a5SBarry Smith 79*f0479e8cSBarry Smith extern int PetscDefaultSignalHandler(int,void*); 80*f0479e8cSBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*); 81*f0479e8cSBarry Smith extern int PetscPopSignalHandler(); 82*f0479e8cSBarry Smith extern int PetscSetFPTrap(int); 83f97c0401SBarry Smith 848ed539a5SBarry Smith extern void *trmalloc(unsigned int,int,char*); 858ed539a5SBarry Smith extern int trfree(void *,int,char*); 8620563c6bSBarry Smith #include <stdio.h> /* I don't like this, but? */ 8720563c6bSBarry Smith extern int trdump(FILE *); 888ed539a5SBarry Smith 891eb62cbbSBarry Smith #if defined(PARCH_cray) || defined(PARCH_NCUBE) 908ed539a5SBarry Smith #define FORTRANCAPS 911eb62cbbSBarry Smith #elif !defined(PARCH_rs6000) && !defined(PACRH_NeXT) && !defined(PACRH_HPUX) 928ed539a5SBarry Smith #define FORTRANUNDERSCORE 932eac72dbSBarry Smith #endif 942eac72dbSBarry Smith 952eac72dbSBarry Smith #endif 96