1 /* $Id: petscerror.h,v 1.1 1996/12/07 20:22:53 bsmith Exp bsmith $ */ 2 /* 3 Contains all the 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 print error messages. __DIR__ is usually defined in the makefile. 11 */ 12 #if !defined(__DIR__) 13 #define __DIR__ 0 14 #endif 15 16 /* 17 These are the generic error codes. The same error code is used in 18 many different places in the code. 19 20 In addition, each specific error in the code has an error 21 message: a text string imbedded in the code in English; and a 22 specific eroror code. (The specific error code is not yet in 23 use, those will be generated automatically and embed a integer 24 charactor string at the begin of the error message string. For 25 non-English error messages that integer will be extracted from 26 the English error message and used to look up the appropriate 27 error message in the local language from a file.) 28 29 */ 30 /* 31 The next four error flags are being replaced 32 */ 33 34 #define PETSC_ERR_ARG 57 /* bad input argument */ 35 #define PETSC_ERR_OBJ 58 /* wrong, null or corrupted PETSc object */ 36 #define PETSC_ERR_IDN 61 /* two arguments not allowed to be the same */ 37 #define PETSC_ERR_SIZ 60 /* nonconforming object sizes used in operation */ 38 39 40 #define PETSC_ERR_MEM 55 /* unable to allocate requested memory */ 41 #define PETSC_ERR_SUP 56 /* no support yet for requested operation */ 42 #define PETSC_ERR_SIG 59 /* signal received */ 43 44 #define PETSC_ERR_ARG_SIZ 60 /* nonconforming object sizes used in operation */ 45 #define PETSC_ERR_ARG_IDN 61 /* two arguments not allowed to be the same */ 46 #define PETSC_ERR_ARG_WRONG 62 /* wrong object (but object probably ok) */ 47 #define PETSC_ERR_ARG_CORRUPT 64 /* null or corrupted PETSc object as argument */ 48 #define PETSC_ERR_ARG_OUTOFRANGE 63 /* input argument, out of range */ 49 50 #define PETSC_ERR_KSP_BRKDWN 70 /* Break down in a Krylov method */ 51 #define PETSC_ERR_MAT_LU_ZRPVT 71 /* Detected a zero pivot during LU factorization */ 52 #define PETSC_ERR_MAT_CH_ZRPVT 71 /* Detected a zero pivot during Cholesky factorization */ 53 54 #if defined(PETSC_DEBUG) 55 #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,n,s);} 56 #define SETERRA(n,s) {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,n,s);\ 57 MPI_Abort(PETSC_COMM_WORLD,_ierr);} 58 #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 59 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 60 #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0); 61 #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,(char*)0); 62 #else 63 #define SETERRQ(n,s) {return PetscError(__LINE__,__DIR__,__FILE__,n,s);} 64 #define SETERRA(n,s) {int _ierr = PetscError(__LINE__,__DIR__,__FILE__,n,s);\ 65 MPI_Abort(PETSC_COMM_WORLD,_ierr);} 66 #define CHKERRQ(n) {if (n) SETERRQ(n,(char *)0);} 67 #define CHKERRA(n) {if (n) SETERRA(n,(char *)0);} 68 #define CHKPTRQ(p) if (!p) SETERRQ(PETSC_ERR_MEM,(char*)0); 69 #define CHKPTRA(p) if (!p) SETERRA(PETSC_ERR_MEM,(char*)0); 70 #endif 71 72 extern int PetscTraceBackErrorHandler(int,char*,char*,int,char*,void*); 73 extern int PetscStopErrorHandler(int,char*,char*,int,char*,void*); 74 extern int PetscAbortErrorHandler(int,char*,char*,int,char*,void* ); 75 extern int PetscAttachDebuggerErrorHandler(int,char*,char*,int,char*,void*); 76 extern int PetscError(int,char*,char*,int,char*); 77 extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,int,char*,void*),void*); 78 extern int PetscPopErrorHandler(); 79 80 extern int PetscDefaultSignalHandler(int,void*); 81 extern int PetscPushSignalHandler(int (*)(int,void *),void*); 82 extern int PetscPopSignalHandler(); 83 #define PETSC_FP_TRAP_OFF 0 84 #define PETSC_FP_TRAP_ON 1 85 extern int PetscSetFPTrap(int); 86 87 #endif 88