1*e3372554SBarry Smith /* $Id: petscerror.h,v 1.3 1996/12/08 23:59:22 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 */ 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 */ 454f227f7cSBarry Smith #define PETSC_ERR_ARG_BADPTR 68 /* invalid pointer argument */ 464f227f7cSBarry Smith #define PETSC_ERR_ARG_NOTSAMETYPE 69 /* two args must be same object type */ 474f227f7cSBarry Smith 484f227f7cSBarry Smith #define PETSC_ERR_FILE_OPEN 65 /* unable to open file */ 494f227f7cSBarry Smith #define PETSC_ERR_FILE_READ 66 /* unable to read from file */ 504f227f7cSBarry 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 */ 534f227f7cSBarry 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) 58*e3372554SBarry Smith #define SETERRQ(n,p,s) {return PetscError(__LINE__,__FUNCTION__,__FILE__,__DIR__,n,p,s);} 59*e3372554SBarry Smith #define SETERRA(n,p,s) {int _ierr = PetscError(__LINE__,__FUNCTION__,__FILE__,__DIR__,n,p,s);\ 6054a8ef01SBarry Smith MPI_Abort(PETSC_COMM_WORLD,_ierr);} 61*e3372554SBarry Smith #define CHKERRQ(n) {if (n) SETERRQ(n,0,(char *)0);} 62*e3372554SBarry Smith #define CHKERRA(n) {if (n) SETERRA(n,0,(char *)0);} 63*e3372554SBarry Smith #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,0,(char*)0); 64*e3372554SBarry Smith #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,0,(char*)0); 6554a8ef01SBarry Smith #else 66*e3372554SBarry Smith #define SETERRQ(n,p,s) ; 67*e3372554SBarry Smith #define SETERRA(n,p,s) ; 684f227f7cSBarry Smith #define CHKERRQ(n) ; 694f227f7cSBarry Smith #define CHKERRA(n) ; 704f227f7cSBarry Smith #define CHKPTRQ(p) ; 714f227f7cSBarry Smith #define CHKPTRA(p) ; 7254a8ef01SBarry Smith #endif 7354a8ef01SBarry Smith 74*e3372554SBarry Smith extern int PetscTraceBackErrorHandler(int,char*,char*,char*,int,int,char*,void*); 75*e3372554SBarry Smith extern int PetscStopErrorHandler(int,char*,char*,char*,int,int,char*,void*); 76*e3372554SBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,char*,int,int,char*,void* ); 77*e3372554SBarry Smith extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,int,char*,void*); 78*e3372554SBarry Smith extern int PetscError(int,char*,char*,char*,int,int,char*); 79*e3372554SBarry Smith extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,char*,int,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