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 790 by mmeineke, Mon Sep 29 21:16:11 2003 UTC vs.
Revision 1220 by chrisfen, Wed Jun 2 14:56:06 2004 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines