xref: /petsc/include/petsc.h (revision dbb450ca0a1bd4568a196678f20f5151425d3a04)
1 /* $Id: petsc.h,v 1.57 1995/09/06 03:06:53 bsmith Exp bsmith $ */
2 
3 #if !defined(__PETSC_PACKAGE)
4 #define __PETSC_PACKAGE
5 
6 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.Beta.8 Released ?, 1995."
7 
8 #include <stdio.h>
9 #if defined(PARCH_sun4)
10 int fprintf(FILE*,char*,...);
11 int printf(char*,...);
12 int fflush(FILE*);
13 int fclose(FILE*);
14 #endif
15 
16 /* MPI interface */
17 #include "mpi.h"
18 #include "mpiu.h"
19 
20 #if defined(PETSC_COMPLEX)
21 /* work around for bug in alpha g++ compiler */
22 #if defined(PARCH_alpha)
23 #define hypot(a,b) (double) sqrt((a)*(a)+(b)*(b))
24 /* extern double hypot(double,double); */
25 #endif
26 #include <complex.h>
27 #define PETSCREAL(a) real(a)
28 #define Scalar       complex
29 #else
30 #define PETSCREAL(a) a
31 #define Scalar       double
32 #endif
33 
34 extern void *(*PetscMalloc)(unsigned int,int,char*);
35 extern int  (*PetscFree)(void *,int,char*);
36 #define PETSCMALLOC(a)       (*PetscMalloc)(a,__LINE__,__FILE__)
37 #define PETSCFREE(a)         (*PetscFree)(a,__LINE__,__FILE__)
38 extern int  PetscSetMalloc(void *(*)(unsigned int,int,char*),
39                            int (*)(void *,int,char*));
40 extern int  TrDump(FILE *);
41 extern int  TrGetMaximumAllocated(double*);
42 
43 #define PETSCNEW(A)         (A*) PETSCMALLOC(sizeof(A))
44 #define PETSCMEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
45 #define PETSCMEMSET(a,b,n)   memset((char*)(a),(int)(b),n)
46 #include <memory.h>
47 
48 #define PETSCMIN(a,b)      ( ((a)<(b)) ? (a) : (b) )
49 #define PETSCMAX(a,b)      ( ((a)<(b)) ? (b) : (a) )
50 #define PETSCABS(a)        ( ((a)<0)   ? -(a) : (a) )
51 
52 /*  Macros for error checking */
53 #if !defined(__DIR__)
54 #define __DIR__ 0
55 #endif
56 
57 /*
58        Unable to malloc error and no supported function
59 */
60 #define PETSC_ERR_MEM 55   /* unalbe to allocate requested memory */
61 #define PETSC_ERR_SUP 56   /* no support yet for this operation */
62 #define PETSC_ERR_ARG 57   /* bad input argument */
63 #define PETSC_ERR_OBJ 58   /* null or corrupt PETSc object */
64 
65 #if defined(PETSC_DEBUG)
66 #define SETERRQ(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
67 #define SETERRA(n,s)    \
68                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
69                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
70 #define CHKERRQ(n)       {if (n) SETERRQ(n,(char *)0);}
71 #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
72 #define CHKPTRQ(p)       if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0);
73 #define CHKPTRA(p)       if (!p) SETERRA(PETSC_ERR_MEM,(char*)0);
74 #else
75 #define SETERRQ(n,s)     {return PetscError(__LINE__,__DIR__,__FILE__,s,n);}
76 #define SETERRA(n,s)    \
77                 {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,s,n);\
78                  MPI_Abort(MPI_COMM_WORLD,_ierr);}
79 #define CHKERRQ(n)       {if (n) SETERRQ(n,(char *)0);}
80 #define CHKERRA(n)      {if (n) SETERRA(n,(char *)0);}
81 #define CHKPTRQ(p)       if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0);
82 #define CHKPTRA(p)       if (!p) SETERRA(PETSC_ERR_MEM,(char*)0);
83 #endif
84 
85 typedef struct _PetscObject* PetscObject;
86 #define PETSC_COOKIE         1211211
87 #define PETSC_DECIDE         -1
88 #define PETSC_DEFAULT        -2
89 
90 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
91 
92 #include "viewer.h"
93 #include "options.h"
94 
95 extern int PetscInitialize(int*,char***,char*,char*);
96 extern int PetscFinalize();
97 
98 extern int PetscObjectDestroy(PetscObject);
99 extern int PetscObjectExists(PetscObject,int*);
100 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm);
101 extern int PetscObjectSetName(PetscObject,char*);
102 extern int PetscObjectGetName(PetscObject,char**);
103 
104 extern int PetscDefaultErrorHandler(int,char*,char*,char*,int,void*);
105 extern int PetscAbortErrorHandler(int,char*,char*,char*,int,void* );
106 extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,void*);
107 extern int PetscError(int,char*,char*,char*,int);
108 extern int PetscPushErrorHandler(int
109                          (*handler)(int,char*,char*,char*,int,void*),void* );
110 extern int PetscPopErrorHandler();
111 
112 extern int PetscSetDebugger(char *,int,char *);
113 extern int PetscAttachDebugger();
114 
115 extern int PetscDefaultSignalHandler(int,void*);
116 extern int PetscPushSignalHandler(int (*)(int,void *),void*);
117 extern int PetscPopSignalHandler();
118 extern int PetscSetFPTrap(int);
119 #define FP_TRAP_OFF    0
120 #define FP_TRAP_ON     1
121 #define FP_TRAP_ALWAYS 2
122 
123 /*
124    Definitions used for the Fortran interface:
125    FORTRANCAPS:       Names are uppercase, no trailing underscore
126    FORTRANUNDERSCORE: Names are lowercase, trailing underscore
127  */
128 #if defined(PARCH_cray) || defined(PARCH_NCUBE) || defined(PARCH_t3d)
129 #define FORTRANCAPS
130 #elif !defined(PARCH_rs6000) && !defined(PARCH_NeXT) && !defined(PARCH_hpux)
131 #define FORTRANUNDERSCORE
132 #endif
133 
134 #include "phead.h"
135 #include "plog.h"
136 
137 extern void PetscSleep(int);
138 
139 #endif
140