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

Comparing trunk/OOPSE/libBASS/simError.c (file contents):
Revision 447 by mmeineke, Thu Apr 3 20:21:54 2003 UTC vs.
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 22 | Line 24 | void initSimError( void ){
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 31 | Line 34 | int simError( void ) {
34  
35   int simError( void ) {
36    
34 #ifdef IS_MPI
37    int myError = 1;
38    int isError;
39 <
40 <   if( painCave.isEventLoop ){
41 <    fprintf( stderr,
42 <             "MPI Event Error on node %d: %s\n",
43 <             worldRank,
44 <             painCave.errMsg );
45 <    return 1;
46 <  }
47 <  else{
48 <    if( painCave.isFatal ){
49 <      fprintf( stderr,
50 <               "MPI Fatal Error on node %d: %s\n",
51 <               worldRank,
52 <               painCave.errMsg );
51 <      MPI_Allreduce( &myError, &isError, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD );
52 <      
53 <      MPI_Finalize();
54 <      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{
57 <      fprintf( stderr,
58 <               "MPI Warning on node %d: %s\n",
59 <               worldRank,
60 <               painCave.errMsg );
61 <    }
62 <    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 <  }
73 <  else{
74 <    fprintf( stderr,
75 <             "Warning: %s\n",
76 <             painCave.errMsg );
77 <  }
78 <  return 1;
79 <  
80 < #endif // IS_MPI
81 <  
82 <  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