Actual source code: errstop.c
petsc-3.3-p7 2013-05-11
2: #include <petscsys.h> /*I "petscsys.h" I*/
6: /*@C
7: PetscMPIAbortErrorHandler - Calls MPI_abort() and exits.
9: Not Collective
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
22: Level: developer
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)
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().
35: Concepts: error handler^stopping
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;
43: PetscLogDouble mem,rss;
46: if (!mess) mess = " ";
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: if (flg2) {
57: PetscMallocDumpLog(stdout);
58: } else {
59: (*PetscErrorPrintf)("Memory allocated %.0f Memory used by process %.0f\n",mem,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: return(0);
77: }