1 2 #include <petscsys.h> /*I "petscsys.h" I*/ 3 4 /*@C 5 PetscMPIAbortErrorHandler - Calls PETSCABORT 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 Note: 21 Users do not directly call this routine 22 23 Use `PetscPushErrorHandler()` to set the desired error handler. The 24 currently available PETSc error handlers include `PetscTraceBackErrorHandler()`, 25 `PetscMPIAbortErrorHandler()`, `PetscAttachDebuggerErrorHandler()`, and `PetscAbortErrorHandler()`. 26 27 .seealso: `PetscError()`, `PetscPushErrorHandler()`, `PetscPopErrorHandler()`, `PetscAttachDebuggerErrorHandler()`, 28 `PetscAbortErrorHandler()`, `PetscMPIAbortErrorHandler()`, `PetscTraceBackErrorHandler()`, `PetscEmacsClientErrorHandler()`, `PetscReturnErrorHandler()` 29 @*/ 30 PetscErrorCode PetscMPIAbortErrorHandler(MPI_Comm comm, int line, const char *fun, const char *file, PetscErrorCode n, PetscErrorType p, const char *mess, void *ctx) 31 { 32 PetscBool flg1 = PETSC_FALSE, flg2 = PETSC_FALSE, flg3 = PETSC_FALSE; 33 PetscLogDouble mem, rss; 34 35 PetscFunctionBegin; 36 if (!mess) mess = " "; 37 38 if (n == PETSC_ERR_MEM) { 39 (*PetscErrorPrintf)("%s() at %s:%d\n", fun, file, line); 40 (*PetscErrorPrintf)("Out of memory. This could be due to allocating\n"); 41 (*PetscErrorPrintf)("too large an object or bleeding by not properly\n"); 42 (*PetscErrorPrintf)("destroying unneeded objects.\n"); 43 PetscMallocGetCurrentUsage(&mem); 44 PetscMemoryGetCurrentUsage(&rss); 45 PetscOptionsGetBool(NULL, NULL, "-malloc_dump", &flg1, NULL); 46 PetscOptionsGetBool(NULL, NULL, "-malloc_view", &flg2, NULL); 47 PetscOptionsHasName(NULL, NULL, "-malloc_view_threshold", &flg3); 48 if (flg2 || flg3) PetscMallocView(stdout); 49 else { 50 (*PetscErrorPrintf)("Memory allocated %.0f Memory used by process %.0f\n", mem, rss); 51 if (flg1) PetscMallocDump(stdout); 52 else (*PetscErrorPrintf)("Try running with -malloc_dump or -malloc_view for info.\n"); 53 } 54 } else if (n == PETSC_ERR_SUP) { 55 (*PetscErrorPrintf)("%s() at %s:%d\n", fun, file, line); 56 (*PetscErrorPrintf)("No support for this operation for this object type!\n"); 57 (*PetscErrorPrintf)("%s\n", mess); 58 } else if (n == PETSC_ERR_SIG) (*PetscErrorPrintf)("%s() at %s:%d %s\n", fun, file, line, mess); 59 else (*PetscErrorPrintf)("%s() at %s:%d\n %s\n", fun, file, line, mess); 60 61 PETSCABORT(PETSC_COMM_WORLD, n); 62 PetscFunctionReturn(0); 63 } 64