1 /* $Id: petscerror.h,v 1.2 1996/12/08 20:53:01 bsmith Exp bsmith $ */ 2 /* 3 Contains all error handling code for PETSc. 4 */ 5 #if !defined(__PETSCERROR_H) 6 #define __PETSCERROR_H 7 8 /* 9 Defines the directory where the compiled source is located; used 10 in printing error messages. __DIR__ is usually defined in the makefile. 11 */ 12 #if !defined(__DIR__) 13 #define __DIR__ 0 14 #endif 15 16 /* 17 Defines the function where the compiled source is located; used 18 in printing error messages. 19 */ 20 #if !defined(__FUNCTION__) 21 #define __FUNCTION__ 0 22 #endif 23 24 /* 25 These are the generic error codes. The same error code is used in 26 many different places in the code. 27 28 In addition, each specific error in the code has an error 29 message: an a unique specific eroror code. (The specific error 30 code is not yet in use, those will be generated automatically and 31 embed an integer into the PetscError() calls. For non-English 32 error messages that integer will be extracted and used to look up the 33 appropriate error message in the local language from a file.) 34 35 */ 36 #define PETSC_ERR_MEM 55 /* unable to allocate requested memory */ 37 #define PETSC_ERR_SUP 56 /* no support yet for requested operation */ 38 #define PETSC_ERR_SIG 59 /* signal received */ 39 40 #define PETSC_ERR_ARG_SIZ 60 /* nonconforming object sizes used in operation */ 41 #define PETSC_ERR_ARG_IDN 61 /* two arguments not allowed to be the same */ 42 #define PETSC_ERR_ARG_WRONG 62 /* wrong object (but object probably ok) */ 43 #define PETSC_ERR_ARG_CORRUPT 64 /* null or corrupted PETSc object as argument */ 44 #define PETSC_ERR_ARG_OUTOFRANGE 63 /* input argument, out of range */ 45 #define PETSC_ERR_ARG_BADPTR 68 /* invalid pointer argument */ 46 #define PETSC_ERR_ARG_NOTSAMETYPE 69 /* two args must be same object type */ 47 48 #define PETSC_ERR_FILE_OPEN 65 /* unable to open file */ 49 #define PETSC_ERR_FILE_READ 66 /* unable to read from file */ 50 #define PETSC_ERR_FILE_WRITE 67 /* unable to write to file */ 51 52 #define PETSC_ERR_KSP_BRKDWN 70 /* Break down in a Krylov method */ 53 54 #define PETSC_ERR_MAT_LU_ZRPVT 71 /* Detected a zero pivot during LU factorization */ 55 #define PETSC_ERR_MAT_CH_ZRPVT 71 /* Detected a zero pivot during Cholesky factorization */ 56 57 #if defined(PETSC_DEBUG) 58 #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,n,s);} 59 #define SETERRA(n,s) {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,n,s);\ 60 MPI_Abort(PETSC_COMM_WORLD,_ierr);} 61 #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 62 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 63 #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0); 64 #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,(char*)0); 65 #else 66 #define SETERRQ(n,s) ; 67 #define SETERRA(n,s) ; 68 #define CHKERRQ(n) ; 69 #define CHKERRA(n) ; 70 #define CHKPTRQ(p) ; 71 #define CHKPTRA(p) ; 72 #endif 73 74 extern int PetscTraceBackErrorHandler(int,char*,char*,int,char*,void*); 75 extern int PetscStopErrorHandler(int,char*,char*,int,char*,void*); 76 extern int PetscAbortErrorHandler(int,char*,char*,int,char*,void* ); 77 extern int PetscAttachDebuggerErrorHandler(int,char*,char*,int,char*,void*); 78 extern int PetscError(int,char*,char*,int,char*); 79 extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,int,char*,void*),void*); 80 extern int PetscPopErrorHandler(); 81 82 extern int PetscDefaultSignalHandler(int,void*); 83 extern int PetscPushSignalHandler(int (*)(int,void *),void*); 84 extern int PetscPopSignalHandler(); 85 #define PETSC_FP_TRAP_OFF 0 86 #define PETSC_FP_TRAP_ON 1 87 extern int PetscSetFPTrap(int); 88 89 #endif 90