1*f1caa5a4SBarry Smith /* $Id: petscerror.h,v 1.4 1997/01/01 03:42:38 bsmith Exp bsmith $ */ 254a8ef01SBarry Smith /* 34f227f7cSBarry 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 104f227f7cSBarry 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 /* 174f227f7cSBarry Smith Defines the function where the compiled source is located; used 184f227f7cSBarry Smith in printing error messages. 194f227f7cSBarry Smith */ 204f227f7cSBarry Smith #if !defined(__FUNCTION__) 214f227f7cSBarry Smith #define __FUNCTION__ 0 224f227f7cSBarry Smith #endif 234f227f7cSBarry Smith 244f227f7cSBarry 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 294f227f7cSBarry Smith message: an a unique specific eroror code. (The specific error 304f227f7cSBarry Smith code is not yet in use, those will be generated automatically and 314f227f7cSBarry Smith embed an integer into the PetscError() calls. For non-English 324f227f7cSBarry Smith error messages that integer will be extracted and used to look up the 334f227f7cSBarry 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 */ 39*f1caa5a4SBarry Smith #define PETSC_ERR_FP 72 /* floating point exception */ 4045d48df9SBarry Smith 4145d48df9SBarry Smith #define PETSC_ERR_ARG_SIZ 60 /* nonconforming object sizes used in operation */ 4245d48df9SBarry Smith #define PETSC_ERR_ARG_IDN 61 /* two arguments not allowed to be the same */ 4345d48df9SBarry Smith #define PETSC_ERR_ARG_WRONG 62 /* wrong object (but object probably ok) */ 4445d48df9SBarry Smith #define PETSC_ERR_ARG_CORRUPT 64 /* null or corrupted PETSc object as argument */ 4545d48df9SBarry Smith #define PETSC_ERR_ARG_OUTOFRANGE 63 /* input argument, out of range */ 464f227f7cSBarry Smith #define PETSC_ERR_ARG_BADPTR 68 /* invalid pointer argument */ 474f227f7cSBarry Smith #define PETSC_ERR_ARG_NOTSAMETYPE 69 /* two args must be same object type */ 484f227f7cSBarry Smith 494f227f7cSBarry Smith #define PETSC_ERR_FILE_OPEN 65 /* unable to open file */ 504f227f7cSBarry Smith #define PETSC_ERR_FILE_READ 66 /* unable to read from file */ 514f227f7cSBarry Smith #define PETSC_ERR_FILE_WRITE 67 /* unable to write to file */ 5245d48df9SBarry Smith 5345d48df9SBarry Smith #define PETSC_ERR_KSP_BRKDWN 70 /* Break down in a Krylov method */ 544f227f7cSBarry Smith 5545d48df9SBarry Smith #define PETSC_ERR_MAT_LU_ZRPVT 71 /* Detected a zero pivot during LU factorization */ 5645d48df9SBarry Smith #define PETSC_ERR_MAT_CH_ZRPVT 71 /* Detected a zero pivot during Cholesky factorization */ 5754a8ef01SBarry Smith 5854a8ef01SBarry Smith #if defined(PETSC_DEBUG) 59e3372554SBarry Smith #define SETERRQ(n,p,s) {return PetscError(__LINE__,__FUNCTION__,__FILE__,__DIR__,n,p,s);} 60e3372554SBarry Smith #define SETERRA(n,p,s) {int _ierr = PetscError(__LINE__,__FUNCTION__,__FILE__,__DIR__,n,p,s);\ 6154a8ef01SBarry Smith MPI_Abort(PETSC_COMM_WORLD,_ierr);} 62e3372554SBarry Smith #define CHKERRQ(n) {if (n) SETERRQ(n,0,(char *)0);} 63e3372554SBarry Smith #define CHKERRA(n) {if (n) SETERRA(n,0,(char *)0);} 64e3372554SBarry Smith #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,0,(char*)0); 65e3372554SBarry Smith #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,0,(char*)0); 6654a8ef01SBarry Smith #else 67e3372554SBarry Smith #define SETERRQ(n,p,s) ; 68e3372554SBarry Smith #define SETERRA(n,p,s) ; 694f227f7cSBarry Smith #define CHKERRQ(n) ; 704f227f7cSBarry Smith #define CHKERRA(n) ; 714f227f7cSBarry Smith #define CHKPTRQ(p) ; 724f227f7cSBarry Smith #define CHKPTRA(p) ; 7354a8ef01SBarry Smith #endif 7454a8ef01SBarry Smith 75e3372554SBarry Smith extern int PetscTraceBackErrorHandler(int,char*,char*,char*,int,int,char*,void*); 76e3372554SBarry Smith extern int PetscStopErrorHandler(int,char*,char*,char*,int,int,char*,void*); 77e3372554SBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,char*,int,int,char*,void* ); 78e3372554SBarry Smith extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,int,char*,void*); 79e3372554SBarry Smith extern int PetscError(int,char*,char*,char*,int,int,char*); 80e3372554SBarry Smith extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,char*,int,int,char*,void*),void*); 8154a8ef01SBarry Smith extern int PetscPopErrorHandler(); 8254a8ef01SBarry Smith 8354a8ef01SBarry Smith extern int PetscDefaultSignalHandler(int,void*); 8454a8ef01SBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*); 8554a8ef01SBarry Smith extern int PetscPopSignalHandler(); 8654a8ef01SBarry Smith #define PETSC_FP_TRAP_OFF 0 8754a8ef01SBarry Smith #define PETSC_FP_TRAP_ON 1 8854a8ef01SBarry Smith extern int PetscSetFPTrap(int); 8954a8ef01SBarry Smith 9054a8ef01SBarry Smith #endif 91