1e5c89e4eSSatish Balay #define PETSC_DLL 2e5c89e4eSSatish Balay /* 3e5c89e4eSSatish Balay The default error handlers and code that allows one to change 4e5c89e4eSSatish Balay error handlers. 5e5c89e4eSSatish Balay */ 6d382aafbSBarry Smith #include "petscsys.h" /*I "petscsys.h" I*/ 7e5c89e4eSSatish Balay #if defined(PETSC_HAVE_STDLIB_H) 8e5c89e4eSSatish Balay #include <stdlib.h> 9e5c89e4eSSatish Balay #endif 10e5c89e4eSSatish Balay 11e5c89e4eSSatish Balay #undef __FUNCT__ 12e5c89e4eSSatish Balay #define __FUNCT__ "PetscAbortErrorHandler" 13e5c89e4eSSatish Balay /*@C 14e5c89e4eSSatish Balay PetscAbortErrorHandler - Error handler that calls abort on error. 15e5c89e4eSSatish Balay This routine is very useful when running in the debugger, because the 16e5c89e4eSSatish Balay user can look directly at the stack frames and the variables. 17e5c89e4eSSatish Balay 18e5c89e4eSSatish Balay Not Collective 19e5c89e4eSSatish Balay 20e5c89e4eSSatish Balay Input Parameters: 21*e32f2f54SBarry Smith + comm - communicator over which error occurred 22*e32f2f54SBarry Smith . line - the line number of the error (indicated by __LINE__) 23e5c89e4eSSatish Balay . func - function where error occured (indicated by __FUNCT__) 24e5c89e4eSSatish Balay . file - the file in which the error was detected (indicated by __FILE__) 25e5c89e4eSSatish Balay . dir - the directory of the file (indicated by __SDIR__) 26e5c89e4eSSatish Balay . mess - an error text string, usually just printed to the screen 27e5c89e4eSSatish Balay . n - the generic error number 28e5c89e4eSSatish Balay . p - specific error number 29e5c89e4eSSatish Balay - ctx - error handler context 30e5c89e4eSSatish Balay 31e5c89e4eSSatish Balay Options Database Keys: 32e5c89e4eSSatish Balay + -on_error_abort - Activates aborting when an error is encountered 33e5c89e4eSSatish Balay - -start_in_debugger [noxterm,dbx,xxgdb] [-display name] - Starts all 34e5c89e4eSSatish Balay processes in the debugger and uses PetscAbortErrorHandler(). By default the 35e5c89e4eSSatish Balay debugger is gdb; alternatives are dbx and xxgdb. 36e5c89e4eSSatish Balay 37e5c89e4eSSatish Balay Level: developer 38e5c89e4eSSatish Balay 39e5c89e4eSSatish Balay Notes: 40e5c89e4eSSatish Balay Most users need not directly employ this routine and the other error 41e5c89e4eSSatish Balay handlers, but can instead use the simplified interface SETERRQ, which 42e5c89e4eSSatish Balay has the calling sequence 43*e32f2f54SBarry Smith $ SETERRQ(comm,number,mess) 44e5c89e4eSSatish Balay or its variants, SETERRQ1(number,formatstring,arg1), SETERRQ2(), ... that 45e5c89e4eSSatish Balay allow including arguments in the message. 46e5c89e4eSSatish Balay 47e5c89e4eSSatish Balay Notes for experienced users: 48e5c89e4eSSatish Balay Use PetscPushErrorHandler() to set the desired error handler. The 49e5c89e4eSSatish Balay currently available PETSc error handlers include PetscTraceBackErrorHandler(), 50e5c89e4eSSatish Balay PetscAttachDebuggerErrorHandler(), and PetscAbortErrorHandler(). 51e5c89e4eSSatish Balay 52e5c89e4eSSatish Balay Concepts: error handler^aborting 53e5c89e4eSSatish Balay Concepts: aborting on error 54e5c89e4eSSatish Balay 55e5c89e4eSSatish Balay .seealso: PetscPushErrorHandler(), PetscTraceBackErrorHandler(), 56e5c89e4eSSatish Balay PetscAttachDebuggerErrorHandler() 57e5c89e4eSSatish Balay @*/ 58*e32f2f54SBarry Smith PetscErrorCode PETSC_DLLEXPORT PetscAbortErrorHandler(MPI_Comm comm,int line,const char *fun,const char *file,const char* dir,PetscErrorCode n,int p,const char *mess,void *ctx) 59e5c89e4eSSatish Balay { 60e5c89e4eSSatish Balay PetscFunctionBegin; 61e5c89e4eSSatish Balay (*PetscErrorPrintf)("%s() line %d in %s%s %s\n",fun,line,dir,file,mess); 62e5c89e4eSSatish Balay abort(); 63e5c89e4eSSatish Balay PetscFunctionReturn(0); 64e5c89e4eSSatish Balay } 65e5c89e4eSSatish Balay 66