1 #define PETSC_DLL 2 3 #include "petscsys.h" /*I "petscsys.h" I*/ 4 5 #undef __FUNCT__ 6 #define __FUNCT__ "PetscMPIAbortErrorHandler" 7 /*@C 8 PetscMPIAbortErrorHandler - Calls MPI_abort() and exits. 9 10 Not Collective 11 12 Input Parameters: 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 - the specific error number 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(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 PETSC_DLLEXPORT PetscMPIAbortErrorHandler(int line,const char *fun,const char *file,const char *dir,PetscErrorCode n,int p,const char *mess,void *ctx) 41 { 42 PetscTruth flg1 = PETSC_FALSE,flg2 = 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 PetscOptionsGetTruth(PETSC_NULL,"-malloc_dump",&flg1,PETSC_NULL); 55 PetscOptionsGetTruth(PETSC_NULL,"-malloc_log",&flg2,PETSC_NULL); 56 if (flg2) { 57 PetscMallocDumpLog(stdout); 58 } else { 59 (*PetscErrorPrintf)("Memory allocated %D Memory used by process %D\n",(PetscInt)mem,(PetscInt)rss); 60 if (flg1) { 61 PetscMallocDump(stdout); 62 } else { 63 (*PetscErrorPrintf)("Try running with -malloc_dump or -malloc_log for info.\n"); 64 } 65 } 66 } else if (n == PETSC_ERR_SUP) { 67 (*PetscErrorPrintf)("%s() line %d in %s%s\n",fun,line,dir,file); 68 (*PetscErrorPrintf)("No support for this operation for this object type!\n"); 69 (*PetscErrorPrintf)("%s\n",mess); 70 } else if (n == PETSC_ERR_SIG) { 71 (*PetscErrorPrintf)("%s() line %d in %s%s %s\n",fun,line,dir,file,mess); 72 } else { 73 (*PetscErrorPrintf)("%s() line %d in %s%s\n %s\n",fun,line,dir,file,mess); 74 } 75 MPI_Abort(PETSC_COMM_WORLD,n); 76 PetscFunctionReturn(0); 77 } 78 79