xref: /petsc/include/petscerror.h (revision d252947ab307443ec0f8cabd384072ff75afeb3e)
1*d252947aSBarry Smith /* $Id: petscerror.h,v 1.8 1997/01/27 18:19:37 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 */
205615d1e5SSatish Balay #if !defined(__FUNC__)
2194a9d846SBarry Smith #define __FUNC__ "unknownfunction"
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 */
39f1caa5a4SBarry 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 */
48*d252947aSBarry Smith #define PETSC_ERR_ARG_WRONGSTATE  73   /* object in argument is in wrong state, e.g. unassembled mat */
494f227f7cSBarry Smith 
504f227f7cSBarry Smith #define PETSC_ERR_FILE_OPEN       65   /* unable to open file */
514f227f7cSBarry Smith #define PETSC_ERR_FILE_READ       66   /* unable to read from file */
524f227f7cSBarry Smith #define PETSC_ERR_FILE_WRITE      67   /* unable to write to file */
5345d48df9SBarry Smith 
5445d48df9SBarry Smith #define PETSC_ERR_KSP_BRKDWN      70   /* Break down in a Krylov method */
554f227f7cSBarry Smith 
5645d48df9SBarry Smith #define PETSC_ERR_MAT_LU_ZRPVT    71   /* Detected a zero pivot during LU factorization */
5745d48df9SBarry Smith #define PETSC_ERR_MAT_CH_ZRPVT    71   /* Detected a zero pivot during Cholesky factorization */
5854a8ef01SBarry Smith 
5954a8ef01SBarry Smith #if defined(PETSC_DEBUG)
605615d1e5SSatish Balay #define SETERRQ(n,p,s) {return PetscError(__LINE__,__FUNC__,__FILE__,__DIR__,n,p,s);}
615615d1e5SSatish Balay #define SETERRA(n,p,s) {int _ierr = PetscError(__LINE__,__FUNC__,__FILE__,__DIR__,n,p,s);\
6254a8ef01SBarry Smith                           MPI_Abort(PETSC_COMM_WORLD,_ierr);}
63e3372554SBarry Smith #define CHKERRQ(n)     {if (n) SETERRQ(n,0,(char *)0);}
64e3372554SBarry Smith #define CHKERRA(n)     {if (n) SETERRA(n,0,(char *)0);}
65e3372554SBarry Smith #define CHKPTRQ(p)     if (!p) SETERRQ(PETSC_ERR_MEM,0,(char*)0);
66e3372554SBarry Smith #define CHKPTRA(p)     if (!p) SETERRA(PETSC_ERR_MEM,0,(char*)0);
6754a8ef01SBarry Smith #else
68e3372554SBarry Smith #define SETERRQ(n,p,s) ;
69e3372554SBarry Smith #define SETERRA(n,p,s) ;
704f227f7cSBarry Smith #define CHKERRQ(n)     ;
714f227f7cSBarry Smith #define CHKERRA(n)     ;
724f227f7cSBarry Smith #define CHKPTRQ(p)     ;
734f227f7cSBarry Smith #define CHKPTRA(p)     ;
7454a8ef01SBarry Smith #endif
7554a8ef01SBarry Smith 
76e3372554SBarry Smith extern int PetscTraceBackErrorHandler(int,char*,char*,char*,int,int,char*,void*);
77e3372554SBarry Smith extern int PetscStopErrorHandler(int,char*,char*,char*,int,int,char*,void*);
78e3372554SBarry Smith extern int PetscAbortErrorHandler(int,char*,char*,char*,int,int,char*,void* );
79e3372554SBarry Smith extern int PetscAttachDebuggerErrorHandler(int,char*,char*,char*,int,int,char*,void*);
80e3372554SBarry Smith extern int PetscError(int,char*,char*,char*,int,int,char*);
81e3372554SBarry Smith extern int PetscPushErrorHandler(int (*handler)(int,char*,char*,char*,int,int,char*,void*),void*);
8254a8ef01SBarry Smith extern int PetscPopErrorHandler();
8354a8ef01SBarry Smith 
8454a8ef01SBarry Smith extern int PetscDefaultSignalHandler(int,void*);
8554a8ef01SBarry Smith extern int PetscPushSignalHandler(int (*)(int,void *),void*);
8654a8ef01SBarry Smith extern int PetscPopSignalHandler();
8754a8ef01SBarry Smith #define PETSC_FP_TRAP_OFF    0
8854a8ef01SBarry Smith #define PETSC_FP_TRAP_ON     1
8954a8ef01SBarry Smith extern int PetscSetFPTrap(int);
900513a670SBarry Smith extern int PetscInitializeNans(Scalar*,int);
910513a670SBarry Smith extern int PetscInitializeLargeInts(int *,int);
9254a8ef01SBarry Smith 
9354a8ef01SBarry Smith #endif
94