ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libBASS/simError.c
(Generate patch)

Comparing:
branches/mmeineke/OOPSE/libBASS/simError.c (file contents), Revision 377 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
trunk/OOPSE/libBASS/simError.c (file contents), Revision 1233 by gezelter, Fri Jun 4 02:38:23 2004 UTC

# Line 1 | Line 1
1   #include <stdlib.h>
2   #include <stdio.h>
3 + #include <string.h>
4 + #include "config.h"
5  
6   #ifdef  IS_MPI
7   #include <mpi.h>
# Line 9 | Line 11 | int nChecks;
11  
12   #include "simError.h"
13  
14 + errorStruct painCave;
15  
16 + #ifdef IS_MPI
17 +
18 + char checkPointMsg[MAX_SIM_ERROR_MSG_LENGTH];
19 + int worldRank;
20 +
21 + #endif
22 +
23 +
24   void initSimError( void ){
25    painCave.errMsg[0] = '\0';
26    painCave.isFatal = 0;
27 +  painCave.severity = OOPSE_ERROR;
28   #ifdef IS_MPI
29    painCave.isEventLoop = 0;
30    nChecks = 0;
# Line 22 | Line 34 | int simError( void ) {
34  
35   int simError( void ) {
36    
25 #ifdef IS_MPI
37    int myError = 1;
38    int isError;
39 <  int isFatal;
40 <
41 <   if( painCave.isEventLoop ){
42 <    fprintf( stderr,
43 <             "MPI Event Error on node %d: %s\n",
44 <             worldRank,
45 <             painCave.errMsg );
46 <    return 1;
47 <  }
48 <  else{
49 <    if( painCave.isFatal ){
50 <      fprintf( stderr,
51 <               "MPI Fatal Error on node %d: %s\n",
52 <               worldRank,
42 <               painCave.errMsg );
43 <      MPI_Allreduce( &myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
44 <      
45 <      MPI_Finalize();
46 <      exit(0);
39 >  char errorMsg[MAX_SIM_ERROR_MSG_LENGTH];
40 >  char nodeMsg[MAX_SIM_ERROR_MSG_LENGTH];
41 >  
42 >  strcpy(errorMsg, "OOPSE ");
43 >  switch( painCave.severity ) {
44 >  case OOPSE_WARNING:
45 >    strcat(errorMsg, "WARNING");
46 >    break;
47 >  case OOPSE_INFO:
48 >    strcat(errorMsg, "INFO");
49 >    break;
50 >  default:
51 >    if( painCave.isFatal ) {
52 >      strcat(errorMsg, "FATAL ");
53      }
54 <    else{
49 <      fprintf( stderr,
50 <               "MPI Non-Fatal Error on node %d: %s\n",
51 <               worldRank,
52 <               painCave.errMsg );
53 <    }
54 <    return 1;
54 >    strcat(errorMsg, "ERROR");
55    }
56 +  
57 + #ifdef IS_MPI
58 +  if ( painCave.isEventLoop ) {
59 +    sprintf( nodeMsg, " (reported by MPI node %d)", worldRank);
60 +    strncat(errorMsg, nodeMsg, strlen(nodeMsg));
61 +  }
62 + #endif
63  
64 < #else
64 >  strcat(errorMsg, ":\n\t");
65  
66 <  if( painCave.isFatal ){
67 <    fprintf( stderr,
68 <             "Fatal Error: %s\n",
69 <             painCave.errMsg );
66 >  strncat(errorMsg, painCave.errMsg, strlen(painCave.errMsg));
67 >
68 >  strcat(errorMsg, "\n");
69 >  fprintf(stderr, errorMsg);
70 >
71 > #ifdef IS_MPI
72 >  if (painCave.isEventLoop)
73 >    return 1;
74 > #endif  
75 >
76 >  if (painCave.isFatal) {
77 > #ifdef IS_MPI    
78 >    MPI_Allreduce( &myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
79 >    MPI_Finalize();
80 > #endif
81      exit(0);
82 <  }
65 <  else{
66 <    fprintf( stderr,
67 <             "Warning: %s\n",
68 <             painCave.errMsg );
69 <  }
70 <  return 1;
71 <  
72 < #endif // IS_MPI
73 <  
74 <  return 0; // in case nobody caught that.
82 >  }
83  
84 +  return 1;  
85   }
86  
87    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines