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