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