1*45d48df9SBarry Smith /* $Id: petscerror.h,v 1.1 1996/12/07 20:22:53 bsmith Exp bsmith $ */ 254a8ef01SBarry Smith /* 3*45d48df9SBarry Smith Contains all the error handling code for PETSc. 454a8ef01SBarry Smith */ 5*45d48df9SBarry Smith #if !defined(__PETSCERROR_H) 6*45d48df9SBarry Smith #define __PETSCERROR_H 754a8ef01SBarry Smith 854a8ef01SBarry Smith /* 954a8ef01SBarry Smith Defines the directory where the compiled source is located; used 1054a8ef01SBarry Smith in print 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*45d48df9SBarry Smith These are the generic error codes. The same error code is used in 18*45d48df9SBarry Smith many different places in the code. 19*45d48df9SBarry Smith 20*45d48df9SBarry Smith In addition, each specific error in the code has an error 21*45d48df9SBarry Smith message: a text string imbedded in the code in English; and a 22*45d48df9SBarry Smith specific eroror code. (The specific error code is not yet in 23*45d48df9SBarry Smith use, those will be generated automatically and embed a integer 24*45d48df9SBarry Smith charactor string at the begin of the error message string. For 25*45d48df9SBarry Smith non-English error messages that integer will be extracted from 26*45d48df9SBarry Smith the English error message and used to look up the appropriate 27*45d48df9SBarry Smith error message in the local language from a file.) 28*45d48df9SBarry Smith 2954a8ef01SBarry Smith */ 30*45d48df9SBarry Smith /* 31*45d48df9SBarry Smith The next four error flags are being replaced 32*45d48df9SBarry Smith */ 33*45d48df9SBarry Smith 3454a8ef01SBarry Smith #define PETSC_ERR_ARG 57 /* bad input argument */ 35*45d48df9SBarry Smith #define PETSC_ERR_OBJ 58 /* wrong, null or corrupted PETSc object */ 3654a8ef01SBarry Smith #define PETSC_ERR_IDN 61 /* two arguments not allowed to be the same */ 37*45d48df9SBarry Smith #define PETSC_ERR_SIZ 60 /* nonconforming object sizes used in operation */ 38*45d48df9SBarry Smith 39*45d48df9SBarry Smith 40*45d48df9SBarry Smith #define PETSC_ERR_MEM 55 /* unable to allocate requested memory */ 41*45d48df9SBarry Smith #define PETSC_ERR_SUP 56 /* no support yet for requested operation */ 42*45d48df9SBarry Smith #define PETSC_ERR_SIG 59 /* signal received */ 43*45d48df9SBarry Smith 44*45d48df9SBarry Smith #define PETSC_ERR_ARG_SIZ 60 /* nonconforming object sizes used in operation */ 45*45d48df9SBarry Smith #define PETSC_ERR_ARG_IDN 61 /* two arguments not allowed to be the same */ 46*45d48df9SBarry Smith #define PETSC_ERR_ARG_WRONG 62 /* wrong object (but object probably ok) */ 47*45d48df9SBarry Smith #define PETSC_ERR_ARG_CORRUPT 64 /* null or corrupted PETSc object as argument */ 48*45d48df9SBarry Smith #define PETSC_ERR_ARG_OUTOFRANGE 63 /* input argument, out of range */ 49*45d48df9SBarry Smith 50*45d48df9SBarry Smith #define PETSC_ERR_KSP_BRKDWN 70 /* Break down in a Krylov method */ 51*45d48df9SBarry Smith #define PETSC_ERR_MAT_LU_ZRPVT 71 /* Detected a zero pivot during LU factorization */ 52*45d48df9SBarry Smith #define PETSC_ERR_MAT_CH_ZRPVT 71 /* Detected a zero pivot during Cholesky factorization */ 5354a8ef01SBarry Smith 5454a8ef01SBarry Smith #if defined(PETSC_DEBUG) 5554a8ef01SBarry Smith #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,n,s);} 5654a8ef01SBarry Smith #define SETERRA(n,s) {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,n,s);\ 5754a8ef01SBarry Smith MPI_Abort(PETSC_COMM_WORLD,_ierr);} 5854a8ef01SBarry Smith #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 5954a8ef01SBarry Smith #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 6054a8ef01SBarry Smith #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0); 6154a8ef01SBarry Smith #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,(char*)0); 6254a8ef01SBarry Smith #else 6354a8ef01SBarry Smith #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,n,s);} 6454a8ef01SBarry Smith #define SETERRA(n,s) {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,n,s);\ 6554a8ef01SBarry Smith MPI_Abort(PETSC_COMM_WORLD,_ierr);} 6654a8ef01SBarry Smith #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 6754a8ef01SBarry Smith #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 6854a8ef01SBarry Smith #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0); 6954a8ef01SBarry Smith #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,(char*)0); 7054a8ef01SBarry Smith #endif 7154a8ef01SBarry Smith 7254a8ef01SBarry Smith extern int PetscTraceBackErrorHandler(int,char*,char*,int,char*,void*); 7354a8ef01SBarry Smith extern int PetscStopErrorHandler(int,char*,char*,int,char*,void*); 7454a8ef01SBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,int,char*,void* ); 7554a8ef01SBarry Smith extern int PetscAttachDebuggerErrorHandler(int,char*,char*,int,char*,void*); 7654a8ef01SBarry Smith extern int PetscError(int,char*,char*,int,char*); 7754a8ef01SBarry Smith extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,int,char*,void*),void*); 7854a8ef01SBarry Smith extern int PetscPopErrorHandler(); 7954a8ef01SBarry Smith 8054a8ef01SBarry Smith extern int PetscDefaultSignalHandler(int,void*); 8154a8ef01SBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*); 8254a8ef01SBarry Smith extern int PetscPopSignalHandler(); 8354a8ef01SBarry Smith #define PETSC_FP_TRAP_OFF 0 8454a8ef01SBarry Smith #define PETSC_FP_TRAP_ON 1 8554a8ef01SBarry Smith extern int PetscSetFPTrap(int); 8654a8ef01SBarry Smith 8754a8ef01SBarry Smith #endif 88