Actual source code: errstop.c
1: /*$Id: errstop.c,v 1.17 2001/04/10 19:34:27 bsmith Exp $*/
3: #include petsc.h
5: #undef __FUNCT__
7: /*@C
8: PetscStopErrorHandler - Calls MPI_abort() and exists.
10: Not Collective
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
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(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: PetscStopErrorHandler(), PetscAttachDebuggerErrorHandler(), and PetscAbortErrorHandler().
35: Concepts: error handler^stopping
37: .seealso: PetscPushErrorHandler(), PetscAttachDebuggerErrorHandler(),
38: PetscAbortErrorHandler(), PetscTraceBackErrorHandler()
39: @*/
40: int PetscStopErrorHandler(int line,char *fun,char *file,char *dir,int n,int p,char *mess,void *ctx)
41: {
42: int rank;
43: PetscTruth flg1,flg2;
44: PetscLogDouble mem,rss;
47: if (!mess) mess = " ";
49: MPI_Comm_rank(MPI_COMM_WORLD,&rank);
50: if (n == PETSC_ERR_MEM) {
51: (*PetscErrorPrintf)("[%d]PETSC ERROR: %s() line %d in %s%sn",rank,fun,line,dir,file);
52: (*PetscErrorPrintf)("[%d]PETSC ERROR: Out of memory. This could be due to allocatingn",rank);
53: (*PetscErrorPrintf)("[%d]PETSC ERROR: too large an object or bleeding by not properlyn",rank);
54: (*PetscErrorPrintf)("[%d]PETSC ERROR: destroying unneeded objects.n",rank);
55: PetscTrSpace(&mem,PETSC_NULL,PETSC_NULL); PetscGetResidentSetSize(&rss);
56: PetscOptionsHasName(PETSC_NULL,"-trdump",&flg1);
57: PetscOptionsHasName(PETSC_NULL,"-trmalloc_log",&flg2);
58: if (flg2) {
59: PetscTrLogDump(stdout);
60: } else if (flg1) {
61: (*PetscErrorPrintf)("[%d]PETSC ERROR: Memory allocated %d Memory used by process %dn",rank,(int)mem,(int)rss);
62: PetscTrDump(stdout);
63: } else {
64: (*PetscErrorPrintf)("[%d]PETSC ERROR: Memory allocated %d Memory used by process %dn",rank,(int)mem,(int)rss);
65: (*PetscErrorPrintf)("[%d]PETSC ERROR: Try running with -trdump or -trmalloc_log for info.n",rank);
66: }
67: } else if (n == PETSC_ERR_SUP) {
68: (*PetscErrorPrintf)("[%d]PETSC ERROR: %s() line %d in %s%sn",rank,fun,line,dir,file);
69: (*PetscErrorPrintf)("[%d]PETSC ERROR: No support for this operation for this object type!n",rank);
70: (*PetscErrorPrintf)("[%d]PETSC ERROR: %sn",rank,mess);
71: } else if (n == PETSC_ERR_SIG) {
72: (*PetscErrorPrintf)("[%d]PETSC ERROR: %s() line %d in %s%s %sn",rank,fun,line,dir,file,mess);
73: } else {
74: (*PetscErrorPrintf)("[%d]PETSC ERROR: %s() line %d in %s%sn %sn",rank,fun,line,dir,file,mess);
75: }
76: MPI_Abort(PETSC_COMM_WORLD,n);
77: return(0);
78: }