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