xref: /petsc/include/petscerror.h (revision 4f227f7c95d81b381d1edbc596a04160ff701005)
1*4f227f7cSBarry Smith /* $Id: petscerror.h,v 1.2 1996/12/08 20:53:01 bsmith Exp bsmith $ */
254a8ef01SBarry Smith /*
3*4f227f7cSBarry Smith     Contains all error handling code for PETSc.
454a8ef01SBarry Smith */
545d48df9SBarry Smith #if !defined(__PETSCERROR_H)
645d48df9SBarry Smith #define __PETSCERROR_H
754a8ef01SBarry Smith 
854a8ef01SBarry Smith /*
954a8ef01SBarry Smith    Defines the directory where the compiled source is located; used
10*4f227f7cSBarry Smith    in printing error messages. __DIR__ is usually defined in the makefile.
1154a8ef01SBarry Smith */
1254a8ef01SBarry Smith #if !defined(__DIR__)
1354a8ef01SBarry Smith #define __DIR__ 0
1454a8ef01SBarry Smith #endif
1554a8ef01SBarry Smith 
1654a8ef01SBarry Smith /*
17*4f227f7cSBarry Smith    Defines the function where the compiled source is located; used
18*4f227f7cSBarry Smith    in printing error messages.
19*4f227f7cSBarry Smith */
20*4f227f7cSBarry Smith #if !defined(__FUNCTION__)
21*4f227f7cSBarry Smith #define __FUNCTION__ 0
22*4f227f7cSBarry Smith #endif
23*4f227f7cSBarry Smith 
24*4f227f7cSBarry Smith /*
2545d48df9SBarry Smith        These are the generic error codes. The same error code is used in
2645d48df9SBarry Smith      many different places in the code.
2745d48df9SBarry Smith 
2845d48df9SBarry Smith        In addition, each specific error in the code has an error
29*4f227f7cSBarry Smith      message: an a unique specific eroror code.  (The specific error
30*4f227f7cSBarry Smith      code is not yet in use, those will be generated automatically and
31*4f227f7cSBarry Smith      embed an integer into the PetscError() calls. For non-English
32*4f227f7cSBarry Smith      error messages that integer will be extracted and used to look up the
33*4f227f7cSBarry Smith      appropriate error message in the local language from a file.)
3445d48df9SBarry Smith 
3554a8ef01SBarry Smith */
3645d48df9SBarry Smith #define PETSC_ERR_MEM             55   /* unable to allocate requested memory */
3745d48df9SBarry Smith #define PETSC_ERR_SUP             56   /* no support yet for requested operation */
3845d48df9SBarry Smith #define PETSC_ERR_SIG             59   /* signal received */
3945d48df9SBarry Smith 
4045d48df9SBarry Smith #define PETSC_ERR_ARG_SIZ         60   /* nonconforming object sizes used in operation */
4145d48df9SBarry Smith #define PETSC_ERR_ARG_IDN         61   /* two arguments not allowed to be the same */
4245d48df9SBarry Smith #define PETSC_ERR_ARG_WRONG       62   /* wrong object (but object probably ok) */
4345d48df9SBarry Smith #define PETSC_ERR_ARG_CORRUPT     64   /* null or corrupted PETSc object as argument */
4445d48df9SBarry Smith #define PETSC_ERR_ARG_OUTOFRANGE  63   /* input argument, out of range */
45*4f227f7cSBarry Smith #define PETSC_ERR_ARG_BADPTR      68   /* invalid pointer argument */
46*4f227f7cSBarry Smith #define PETSC_ERR_ARG_NOTSAMETYPE 69   /* two args must be same object type */
47*4f227f7cSBarry Smith 
48*4f227f7cSBarry Smith #define PETSC_ERR_FILE_OPEN       65   /* unable to open file */
49*4f227f7cSBarry Smith #define PETSC_ERR_FILE_READ       66   /* unable to read from file */
50*4f227f7cSBarry Smith #define PETSC_ERR_FILE_WRITE      67   /* unable to write to file */
5145d48df9SBarry Smith 
5245d48df9SBarry Smith #define PETSC_ERR_KSP_BRKDWN      70   /* Break down in a Krylov method */
53*4f227f7cSBarry Smith 
5445d48df9SBarry Smith #define PETSC_ERR_MAT_LU_ZRPVT    71   /* Detected a zero pivot during LU factorization */
5545d48df9SBarry Smith #define PETSC_ERR_MAT_CH_ZRPVT    71   /* Detected a zero pivot during Cholesky factorization */
5654a8ef01SBarry Smith 
5754a8ef01SBarry Smith #if defined(PETSC_DEBUG)
5854a8ef01SBarry Smith #define SETERRQ(n,s)   {return PetscError(__LINE__,__DIR__,__FILE__,n,s);}
5954a8ef01SBarry Smith #define SETERRA(n,s)   {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,n,s);\
6054a8ef01SBarry Smith                           MPI_Abort(PETSC_COMM_WORLD,_ierr);}
6154a8ef01SBarry Smith #define CHKERRQ(n)     {if (n) SETERRQ(n,(char *)0);}
6254a8ef01SBarry Smith #define CHKERRA(n)     {if (n) SETERRA(n,(char *)0);}
6354a8ef01SBarry Smith #define CHKPTRQ(p)     if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0);
6454a8ef01SBarry Smith #define CHKPTRA(p)     if (!p) SETERRA(PETSC_ERR_MEM,(char*)0);
6554a8ef01SBarry Smith #else
66*4f227f7cSBarry Smith #define SETERRQ(n,s)   ;
67*4f227f7cSBarry Smith #define SETERRA(n,s)   ;
68*4f227f7cSBarry Smith #define CHKERRQ(n)     ;
69*4f227f7cSBarry Smith #define CHKERRA(n)     ;
70*4f227f7cSBarry Smith #define CHKPTRQ(p)     ;
71*4f227f7cSBarry Smith #define CHKPTRA(p)     ;
7254a8ef01SBarry Smith #endif
7354a8ef01SBarry Smith 
7454a8ef01SBarry Smith extern int PetscTraceBackErrorHandler(int,char*,char*,int,char*,void*);
7554a8ef01SBarry Smith extern int PetscStopErrorHandler(int,char*,char*,int,char*,void*);
7654a8ef01SBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,int,char*,void* );
7754a8ef01SBarry Smith extern int PetscAttachDebuggerErrorHandler(int,char*,char*,int,char*,void*);
7854a8ef01SBarry Smith extern int PetscError(int,char*,char*,int,char*);
7954a8ef01SBarry Smith extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,int,char*,void*),void*);
8054a8ef01SBarry Smith extern int PetscPopErrorHandler();
8154a8ef01SBarry Smith 
8254a8ef01SBarry Smith extern int PetscDefaultSignalHandler(int,void*);
8354a8ef01SBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
8454a8ef01SBarry Smith extern int PetscPopSignalHandler();
8554a8ef01SBarry Smith #define PETSC_FP_TRAP_OFF    0
8654a8ef01SBarry Smith #define PETSC_FP_TRAP_ON     1
8754a8ef01SBarry Smith extern int PetscSetFPTrap(int);
8854a8ef01SBarry Smith 
8954a8ef01SBarry Smith #endif
90