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 . dir - the directory of the file (indicated by __SDIR__) 17e5c89e4eSSatish Balay . mess - an error text string, usually just printed to the screen 18e5c89e4eSSatish Balay . n - the generic error number 19668f157eSBarry Smith . p - PETSC_ERROR_INITIAL if error just detected, otherwise PETSC_ERROR_REPEAT 20e5c89e4eSSatish Balay - ctx - error handler context 21e5c89e4eSSatish Balay 22e5c89e4eSSatish Balay Level: developer 23e5c89e4eSSatish Balay 24e5c89e4eSSatish Balay Notes: 25e5c89e4eSSatish Balay Most users need not directly employ this routine and the other error 26e5c89e4eSSatish Balay handlers, but can instead use the simplified interface SETERRQ, which has 27e5c89e4eSSatish Balay the calling sequence 28e32f2f54SBarry Smith $ SETERRQ(comm,n,p,mess) 29e5c89e4eSSatish Balay 30e5c89e4eSSatish Balay Notes for experienced users: 31e5c89e4eSSatish Balay Use PetscPushErrorHandler() to set the desired error handler. The 32e5c89e4eSSatish Balay currently available PETSc error handlers include PetscTraceBackErrorHandler(), 33e8fb0fc0SBarry Smith PetscMPIAbortErrorHandler(), PetscAttachDebuggerErrorHandler(), and PetscAbortErrorHandler(). 34e5c89e4eSSatish Balay 35e5c89e4eSSatish Balay Concepts: error handler^stopping 36e5c89e4eSSatish Balay 37e5c89e4eSSatish Balay .seealso: PetscPushErrorHandler(), PetscAttachDebuggerErrorHandler(), 38e5c89e4eSSatish Balay PetscAbortErrorHandler(), PetscTraceBackErrorHandler() 39e5c89e4eSSatish Balay @*/ 407087cfbeSBarry Smith PetscErrorCode PetscMPIAbortErrorHandler(MPI_Comm comm,int line,const char *fun,const char *file,const char *dir,PetscErrorCode n,PetscErrorType p,const char *mess,void *ctx) 41e5c89e4eSSatish Balay { 42574034a9SJed Brown PetscBool flg1 = PETSC_FALSE,flg2 = PETSC_FALSE,flg3 = PETSC_FALSE; 43e5c89e4eSSatish Balay PetscLogDouble mem,rss; 44e5c89e4eSSatish Balay 45e5c89e4eSSatish Balay PetscFunctionBegin; 46e5c89e4eSSatish Balay if (!mess) mess = " "; 47e5c89e4eSSatish Balay 48e5c89e4eSSatish Balay if (n == PETSC_ERR_MEM) { 49e5c89e4eSSatish Balay (*PetscErrorPrintf)("%s() line %d in %s%s\n",fun,line,dir,file); 50e5c89e4eSSatish Balay (*PetscErrorPrintf)("Out of memory. This could be due to allocating\n"); 51e5c89e4eSSatish Balay (*PetscErrorPrintf)("too large an object or bleeding by not properly\n"); 52e5c89e4eSSatish Balay (*PetscErrorPrintf)("destroying unneeded objects.\n"); 53e5c89e4eSSatish Balay PetscMallocGetCurrentUsage(&mem); PetscMemoryGetCurrentUsage(&rss); 54*0298fd71SBarry Smith PetscOptionsGetBool(NULL,"-malloc_dump",&flg1,NULL); 55*0298fd71SBarry Smith PetscOptionsGetBool(NULL,"-malloc_log",&flg2,NULL); 56*0298fd71SBarry Smith PetscOptionsHasName(NULL,"-malloc_log_threshold",&flg3); 57a297a907SKarl Rupp if (flg2 || flg3) PetscMallocDumpLog(stdout); 58a297a907SKarl Rupp else { 59b85f3346SJed Brown (*PetscErrorPrintf)("Memory allocated %.0f Memory used by process %.0f\n",mem,rss); 60a297a907SKarl Rupp if (flg1) PetscMallocDump(stdout); 61a297a907SKarl Rupp else (*PetscErrorPrintf)("Try running with -malloc_dump or -malloc_log for info.\n"); 62e5c89e4eSSatish Balay } 63e5c89e4eSSatish Balay } else if (n == PETSC_ERR_SUP) { 64e5c89e4eSSatish Balay (*PetscErrorPrintf)("%s() line %d in %s%s\n",fun,line,dir,file); 65e5c89e4eSSatish Balay (*PetscErrorPrintf)("No support for this operation for this object type!\n"); 66e5c89e4eSSatish Balay (*PetscErrorPrintf)("%s\n",mess); 67a297a907SKarl Rupp } else if (n == PETSC_ERR_SIG) (*PetscErrorPrintf)("%s() line %d in %s%s %s\n",fun,line,dir,file,mess); 68a297a907SKarl Rupp else (*PetscErrorPrintf)("%s() line %d in %s%s\n %s\n",fun,line,dir,file,mess); 69a297a907SKarl Rupp 70e5c89e4eSSatish Balay MPI_Abort(PETSC_COMM_WORLD,n); 71e5c89e4eSSatish Balay PetscFunctionReturn(0); 72e5c89e4eSSatish Balay } 73e5c89e4eSSatish Balay 74