1e5c89e4eSSatish Balay 2c6db04a5SJed Brown #include <petscsys.h> /*I "petscsys.h" I*/ 3e5c89e4eSSatish Balay 4e5c89e4eSSatish Balay #undef __FUNCT__ 5e8fb0fc0SBarry Smith #define __FUNCT__ "PetscMPIAbortErrorHandler" 6e5c89e4eSSatish Balay /*@C 7e8fb0fc0SBarry Smith PetscMPIAbortErrorHandler - Calls MPI_abort() and exits. 8e5c89e4eSSatish Balay 9e5c89e4eSSatish Balay Not Collective 10e5c89e4eSSatish Balay 11e5c89e4eSSatish Balay Input Parameters: 12e32f2f54SBarry Smith + comm - communicator over which error occurred 13e32f2f54SBarry Smith . line - the line number of the error (indicated by __LINE__) 14e5c89e4eSSatish Balay . fun - the function where the error occurred (indicated by __FUNCT__) 15e5c89e4eSSatish Balay . file - the file in which the error was detected (indicated by __FILE__) 16e5c89e4eSSatish Balay . mess - an error text string, usually just printed to the screen 17e5c89e4eSSatish Balay . n - the generic error number 18668f157eSBarry Smith . p - PETSC_ERROR_INITIAL if error just detected, otherwise PETSC_ERROR_REPEAT 19e5c89e4eSSatish Balay - ctx - error handler context 20e5c89e4eSSatish Balay 21e5c89e4eSSatish Balay Level: developer 22e5c89e4eSSatish Balay 23e5c89e4eSSatish Balay Notes: 24e5c89e4eSSatish Balay Most users need not directly employ this routine and the other error 25e5c89e4eSSatish Balay handlers, but can instead use the simplified interface SETERRQ, which has 26e5c89e4eSSatish Balay the calling sequence 27e32f2f54SBarry Smith $ SETERRQ(comm,n,p,mess) 28e5c89e4eSSatish Balay 29e5c89e4eSSatish Balay Notes for experienced users: 30e5c89e4eSSatish Balay Use PetscPushErrorHandler() to set the desired error handler. The 31e5c89e4eSSatish Balay currently available PETSc error handlers include PetscTraceBackErrorHandler(), 32e8fb0fc0SBarry Smith PetscMPIAbortErrorHandler(), PetscAttachDebuggerErrorHandler(), and PetscAbortErrorHandler(). 33e5c89e4eSSatish Balay 34e5c89e4eSSatish Balay Concepts: error handler^stopping 35e5c89e4eSSatish Balay 36e5c89e4eSSatish Balay .seealso: PetscPushErrorHandler(), PetscAttachDebuggerErrorHandler(), 37e5c89e4eSSatish Balay PetscAbortErrorHandler(), PetscTraceBackErrorHandler() 38e5c89e4eSSatish Balay @*/ 39*efca3c55SSatish Balay PetscErrorCode PetscMPIAbortErrorHandler(MPI_Comm comm,int line,const char *fun,const char *file,PetscErrorCode n,PetscErrorType p,const char *mess,void *ctx) 40e5c89e4eSSatish Balay { 41574034a9SJed Brown PetscBool flg1 = PETSC_FALSE,flg2 = PETSC_FALSE,flg3 = PETSC_FALSE; 42e5c89e4eSSatish Balay PetscLogDouble mem,rss; 43e5c89e4eSSatish Balay 44e5c89e4eSSatish Balay PetscFunctionBegin; 45e5c89e4eSSatish Balay if (!mess) mess = " "; 46e5c89e4eSSatish Balay 47e5c89e4eSSatish Balay if (n == PETSC_ERR_MEM) { 48*efca3c55SSatish Balay (*PetscErrorPrintf)("%s() line %d in %s\n",fun,line,file); 49e5c89e4eSSatish Balay (*PetscErrorPrintf)("Out of memory. This could be due to allocating\n"); 50e5c89e4eSSatish Balay (*PetscErrorPrintf)("too large an object or bleeding by not properly\n"); 51e5c89e4eSSatish Balay (*PetscErrorPrintf)("destroying unneeded objects.\n"); 52e5c89e4eSSatish Balay PetscMallocGetCurrentUsage(&mem); PetscMemoryGetCurrentUsage(&rss); 530298fd71SBarry Smith PetscOptionsGetBool(NULL,"-malloc_dump",&flg1,NULL); 540298fd71SBarry Smith PetscOptionsGetBool(NULL,"-malloc_log",&flg2,NULL); 550298fd71SBarry Smith PetscOptionsHasName(NULL,"-malloc_log_threshold",&flg3); 56a297a907SKarl Rupp if (flg2 || flg3) PetscMallocDumpLog(stdout); 57a297a907SKarl Rupp else { 58b85f3346SJed Brown (*PetscErrorPrintf)("Memory allocated %.0f Memory used by process %.0f\n",mem,rss); 59a297a907SKarl Rupp if (flg1) PetscMallocDump(stdout); 60a297a907SKarl Rupp else (*PetscErrorPrintf)("Try running with -malloc_dump or -malloc_log for info.\n"); 61e5c89e4eSSatish Balay } 62e5c89e4eSSatish Balay } else if (n == PETSC_ERR_SUP) { 63*efca3c55SSatish Balay (*PetscErrorPrintf)("%s() line %d in %s\n",fun,line,file); 64e5c89e4eSSatish Balay (*PetscErrorPrintf)("No support for this operation for this object type!\n"); 65e5c89e4eSSatish Balay (*PetscErrorPrintf)("%s\n",mess); 66*efca3c55SSatish Balay } else if (n == PETSC_ERR_SIG) (*PetscErrorPrintf)("%s() line %d in %s %s\n",fun,line,file,mess); 67*efca3c55SSatish Balay else (*PetscErrorPrintf)("%s() line %d in %s\n %s\n",fun,line,file,mess); 68a297a907SKarl Rupp 69e5c89e4eSSatish Balay MPI_Abort(PETSC_COMM_WORLD,n); 70e5c89e4eSSatish Balay PetscFunctionReturn(0); 71e5c89e4eSSatish Balay } 72e5c89e4eSSatish Balay 73