[MOAB-dev] r4698 - MOAB/trunk/src/io

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Mar 31 13:08:27 CDT 2011


Author: kraftche
Date: 2011-03-31 13:08:27 -0500 (Thu, 31 Mar 2011)
New Revision: 4698

Modified:
   MOAB/trunk/src/io/ReadHDF5.cpp
   MOAB/trunk/src/io/ReadHDF5VarLen.hpp
Log:
more informative error handling

Modified: MOAB/trunk/src/io/ReadHDF5.cpp
===================================================================
--- MOAB/trunk/src/io/ReadHDF5.cpp	2011-03-31 16:44:31 UTC (rev 4697)
+++ MOAB/trunk/src/io/ReadHDF5.cpp	2011-03-31 18:08:27 UTC (rev 4698)
@@ -81,11 +81,23 @@
 #define assert_range( PTR, CNT ) \
   assert( (PTR) >= (void*)dataBuffer ); assert( ((PTR)+(CNT)) <= (void*)(dataBuffer + bufferSize) );
 
+#define error(A) process_error(A,&dbgOut,__FILE__,__LINE__)
 
 // This function doesn't do anything useful.  It's just a nice
 // place to set a break point to determine why the reader fails.
-static inline ErrorCode error( ErrorCode rval )
-  { return rval; }
+//static inline ErrorCode process_error( ErrorCode rval )
+//  { return rval; }
+static inline ErrorCode process_error(ErrorCode code, DebugOutput* dbgOut, const char* file, int line)
+{
+  if (MB_SUCCESS != code) {
+    if (dbgOut)
+      dbgOut->printf(1,"Failure with error code %d at %s:%d\n", (int)code, file, line);
+#if defined(WITH_MPI) && !defined(NDEBUG)
+    MPI_Abort( MPI_COMM_WORLD ):
+#endif
+  }
+  return code;
+}
 
 // Call \c error function during HDF5 library errors to make
 // it easier to trap such errors in the debugger.  This function
@@ -99,7 +111,7 @@
   herr_t result = 0;
   if (h->func)
     result = (*h->func)(stack,h->data);
-  error(MB_FAILURE);
+  process_error(MB_FAILURE,0,__FILE__,__LINE__);
   return result;
 }
 #else
@@ -547,7 +559,10 @@
   if (rval == MB_SUCCESS && rval2 != MB_SUCCESS)
     rval = rval2;
   
-  dbgOut.tprint(1, "Read finished.\n");
+  if (MB_SUCCESS == rval)
+    dbgOut.tprint(1, "Read finished.\n");
+  else 
+    dbgOut.tprintf(1,"READ FAILED (ERROR CODE %d)\n", (int)rval);
   
   if (H5P_DEFAULT != collIO)
     H5Pclose( collIO );


More information about the moab-dev mailing list