[MOAB-dev] commit/MOAB: danwu: Updated some files in error_handling_enhancement branch.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Jun 4 17:10:41 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/09a2d37791ab/
Changeset:   09a2d37791ab
Branch:      error_handling_enhancement
User:        danwu
Date:        2014-06-05 00:10:29
Summary:     Updated some files in error_handling_enhancement branch.

Affected #:  5 files

diff --git a/examples/makefile b/examples/makefile
index 787c8d3..ff565af 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -10,6 +10,7 @@ MESH_DIR="../MeshFiles/unittest"
 EXAMPLES = HelloMOAB GetEntities SetsNTags LoadPartial structuredmesh StructuredMeshSimple DirectAccessWithHoles DirectAccessNoHoles point_in_elem_search DeformMeshRemap
 PAREXAMPLES = HelloParMOAB ReduceExchangeTags LloydRelaxation CrystalRouterExample
 EXOIIEXAMPLES = TestExodusII
+ERROREXAMPLES = TestErrorHandling TestErrorHandlingPar ErrorHandlingModel
 F90EXAMPLES = DirectAccessNoHolesF90 PushParMeshIntoMoabF90
 
 default: ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES} ${F90EXAMPLES}
@@ -66,13 +67,22 @@ DeformMeshRemap: DeformMeshRemap.o ${MOAB_LIBDIR}/libMOAB.la
 	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} -lmbcoupler ${MOAB_LIBS_LINK}
 
 VisTags: VisTags.o ${MOAB_LIBDIR}/libMOAB.la
-	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} 
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
 
 ReadWriteTest: ReadWriteTest.o ${MOAB_LIBDIR}/libMOAB.la
-	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK} 
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
+TestErrorHandling: TestErrorHandling.o ${MOAB_LIBDIR}/libMOAB.la
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
+TestErrorHandlingPar: TestErrorHandlingPar.o ${MOAB_LIBDIR}/libMOAB.la
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
+
+ErrorHandlingModel: ErrorHandlingModel.o ${MOAB_LIBDIR}/libMOAB.la
+	${MOAB_CXX} -o $@ $< ${MOAB_LIBS_LINK}
 	
 clean:
-	rm -rf *.o *.mod *.h5m ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES} ${F90EXAMPLES}
+	rm -rf *.o *.mod *.h5m ${EXAMPLES} ${PAREXAMPLES} ${EXOIIEXAMPLES} ${ERROREXAMPLES} ${F90EXAMPLES}
 
 .cpp.o:
 	${MOAB_CXX} ${CXXFLAGS} ${MOAB_CXXFLAGS} ${MOAB_CPPFLAGS} ${MOAB_INCLUDES} -DMESH_DIR=\"${MESH_DIR}\" -c $<

diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index 950d20c..b0798ed 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -10,12 +10,6 @@
 #include "moab/ReadUtilIface.hpp"
 #include "MBTagConventions.hpp"
 
-#define ERRORR(rval, str) \
-  if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
-
-#define ERRORS(err, str) \
-  if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
-
 namespace moab {
 
 NCHelper* NCHelper::get_nc_helper(ReadNC* readNC, int fileId, const FileOptions& opts, EntityHandle fileSet)
@@ -54,7 +48,7 @@ NCHelper* NCHelper::get_nc_helper(ReadNC* readNC, int fileId, const FileOptions&
       return new (std::nothrow) NCHelperHOMME(readNC, fileId, opts, fileSet);
     // gcrm reader
     else if (NCHelperGCRM::can_read_file(readNC))
-          return new (std::nothrow) NCHelperGCRM(readNC, fileId, opts, fileSet);
+      return new (std::nothrow) NCHelperGCRM(readNC, fileId, opts, fileSet);
   }
 
   // Unknown NetCDF grid (will fill this in later for POP, CICE and CLM)
@@ -80,9 +74,9 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   tag_name = "__NUM_DIMS";
   int numDims = dimNames.size();
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 1, MB_TYPE_INTEGER, numDimsTag, MB_TAG_SPARSE | MB_TAG_CREAT);
-  ERRORR(rval, "Trouble creating __NUM_DIMS tag.");
+  CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
   rval = mbImpl->tag_set_data(numDimsTag, &_fileSet, 1, &numDims);
-  ERRORR(rval, "Trouble setting data for __NUM_DIMS tag.");
+  CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -91,9 +85,9 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   tag_name = "__NUM_VARS";
   int numVars = varInfo.size();
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 1, MB_TYPE_INTEGER, numVarsTag, MB_TAG_SPARSE | MB_TAG_CREAT);
-  ERRORR(rval, "Trouble creating __NUM_VARS tag.");
+  CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
   rval = mbImpl->tag_set_data(numVarsTag, &_fileSet, 1, &numVars);
-  ERRORR(rval, "Trouble setting data for __NUM_VARS tag.");
+  CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -108,10 +102,10 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   }
   int dimnamesSz = dimnames.size();
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, dimNamesTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-  ERRORR(rval, "Trouble creating __DIM_NAMES tag.");
+  CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
   const void* ptr = dimnames.c_str();
   rval = mbImpl->tag_set_by_ptr(dimNamesTag, &_fileSet, 1, &ptr, &dimnamesSz);
-  ERRORR(rval, "Trouble setting data for __DIM_NAMES tag.");
+  CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -120,10 +114,10 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   tag_name = "__DIM_LENS";
   int dimLensSz = dimLens.size();
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_INTEGER, dimLensTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-  ERRORR(rval, "Trouble creating __DIM_LENS tag.");
+  CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
   ptr = &(dimLens[0]);
   rval = mbImpl->tag_set_by_ptr(dimLensTag, &_fileSet, 1, &ptr, &dimLensSz);
-  ERRORR(rval, "Trouble setting data for __DIM_LENS tag.");
+  CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -138,10 +132,10 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   }
   int varnamesSz = varnames.size();
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, varNamesTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-  ERRORR(rval, "Trouble creating __VAR_NAMES tag.");
+  CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
   ptr = varnames.c_str();
   rval = mbImpl->tag_set_by_ptr(varNamesTag, &_fileSet, 1, &ptr, &varnamesSz);
-  ERRORR(rval, "Trouble setting data for __VAR_NAMES tag.");
+  CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -156,9 +150,9 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
       val[0] = 0;
       val[1] = nTimeSteps - 1;
       rval = mbImpl->tag_get_handle(tag_name.c_str(), 2, MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
-      ERRORR(rval, "Trouble creating __<dim_name>_LOC_MINMAX tag.");
+      CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
       rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
-      ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_MINMAX tag.");
+      CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
       if (MB_SUCCESS == rval)
         dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
     }
@@ -180,9 +174,9 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
       ss_tag_name << "__" << dimNames[i] << "_LOC_VALS";
       tag_name = ss_tag_name.str();
       rval = mbImpl->tag_get_handle(tag_name.c_str(), val.size(), MB_TYPE_INTEGER, tagh, MB_TAG_SPARSE | MB_TAG_CREAT);
-      ERRORR(rval, "Trouble creating __<dim_name>_LOC_VALS tag.");
+      CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
       rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &val[0]);
-      ERRORR(rval, "Trouble setting data for __<dim_name>_LOC_VALS tag.");
+      CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
       if (MB_SUCCESS == rval)
         dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
     }
@@ -205,9 +199,9 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
       varDimTags[i] = tmptag;
     }
     rval = mbImpl->tag_get_handle(tag_name.c_str(), varDimSz, MB_TYPE_HANDLE, varNamesDimsTag, MB_TAG_SPARSE | MB_TAG_CREAT);
-    ERRORR(rval, "Trouble creating __<var_name>_DIMS tag.");
+    CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
     rval = mbImpl->tag_set_data(varNamesDimsTag, &_fileSet, 1, &(varDimTags[0]));
-    ERRORR(rval, "Trouble setting data for __<var_name>_DIMS tag.");
+    CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
     if (MB_SUCCESS == rval)
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }
@@ -215,9 +209,9 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   // <PARTITION_METHOD>
   Tag part_tag = scdi->part_method_tag();
   if (!part_tag)
-    ERRORR(MB_FAILURE, "Trouble getting partition method tag.");
+    SET_ERR(MB_FAILURE, "Trouble getting PARTITION_METHOD tag");
   rval = mbImpl->tag_set_data(part_tag, &_fileSet, 1, &partMethod);
-  ERRORR(rval, "Trouble setting data for PARTITION_METHOD tag.");
+  CHK_ERR1(rval, "Trouble setting data for PARTITION_METHOD tag");
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -225,15 +219,15 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   tag_name = "__GLOBAL_ATTRIBS";
   Tag globalAttTag = 0;
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, globalAttTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-  ERRORR(rval, "Trouble creating __GLOBAL_ATTRIBS tag.");
+  CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
   std::string gattVal;
   std::vector<int> gattLen;
   rval = create_attrib_string(globalAtts, gattVal, gattLen);
-  ERRORR(rval, "Trouble creating attribute strings.");
+  CHK_ERR1(rval, "Trouble creating global attribute string");
   const void* gattptr = gattVal.c_str();
   int globalAttSz = gattVal.size();
   rval = mbImpl->tag_set_by_ptr(globalAttTag, &_fileSet, 1, &gattptr, &globalAttSz);
-  ERRORR(rval, "Trouble setting data for __GLOBAL_ATTRIBS tag.");
+  CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -243,9 +237,9 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   if (gattLen.size() == 0)
     gattLen.push_back(0);
   rval = mbImpl->tag_get_handle(tag_name.c_str(), gattLen.size(), MB_TYPE_INTEGER, globalAttLenTag, MB_TAG_SPARSE | MB_TAG_CREAT);
-  ERRORR(rval, "Trouble creating __GLOBAL_ATTRIBS_LEN tag.");
+  CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
   rval = mbImpl->tag_set_data(globalAttLenTag, &_fileSet, 1, &gattLen[0]);
-  ERRORR(rval, "Trouble setting data for __GLOBAL_ATTRIBS_LEN tag.");
+  CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -256,7 +250,7 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
     tag_name = ssTagName.str();
     Tag varAttTag = 0;
     rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, varAttTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-    ERRORR(rval, "Trouble creating __<var_name>_ATTRIBS tag.");
+    CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
 
     std::string varAttVal;
     std::vector<int> varAttLen;
@@ -272,14 +266,14 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
     }
     else {
       rval = create_attrib_string(mapIter->second.varAtts, varAttVal, varAttLen);
-      ERRORR(rval, "Trouble creating attribute string.");
+      CHK_ERR1_STR(rval, "Trouble creating attribute string for variable " << mapIter->first);
     }
     const void* varAttPtr = varAttVal.c_str();
     int varAttSz = varAttVal.size();
     if (0 == varAttSz)
       varAttSz = 1;
     rval = mbImpl->tag_set_by_ptr(varAttTag, &_fileSet, 1, &varAttPtr, &varAttSz);
-    ERRORR(rval, "Trouble setting data for __<var_name>_ATTRIBS tag.");
+    CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
     if (MB_SUCCESS == rval)
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -289,9 +283,9 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
     if (0 == varAttLen.size())
       varAttLen.push_back(0);
     rval = mbImpl->tag_get_handle(tag_name.c_str(), varAttLen.size(), MB_TYPE_INTEGER, varAttLenTag, MB_TAG_SPARSE | MB_TAG_CREAT);
-    ERRORR(rval, "Trouble creating __<var_name>_ATTRIBS_LEN tag.");
+    CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
     rval = mbImpl->tag_set_data(varAttLenTag, &_fileSet, 1, &varAttLen[0]);
-    ERRORR(rval, "Trouble setting data for __<var_name>_ATTRIBS_LEN tag.");
+    CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
     if (MB_SUCCESS == rval)
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }
@@ -302,12 +296,12 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   std::vector<int> varNamesLocs(varInfo.size());
   rval = mbImpl->tag_get_handle(tag_name.c_str(), varNamesLocs.size(), MB_TYPE_INTEGER, varNamesLocsTag, MB_TAG_CREAT
       | MB_TAG_SPARSE);
-  ERRORR(rval, "Trouble creating __VAR_NAMES_LOCATIONS tag.");
+  CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
   for (mapIter = varInfo.begin(); mapIter != varInfo.end(); ++mapIter) {
     varNamesLocs[std::distance(varInfo.begin(), mapIter)] = mapIter->second.entLoc;
   }
   rval = mbImpl->tag_set_data(varNamesLocsTag, &_fileSet, 1, &varNamesLocs[0]);
-  ERRORR(rval, "Trouble setting data for __VAR_NAMES_LOCATIONS tag.");
+  CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -317,11 +311,11 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
   std::string meshTypeName = get_mesh_type_name();
 
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_OPAQUE, meshTypeTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-  ERRORR(rval, "Trouble creating __MESH_TYPE tag.");
+  CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
   ptr = meshTypeName.c_str();
   int leng = meshTypeName.size();
   rval = mbImpl->tag_set_by_ptr(meshTypeTag, &_fileSet, 1, &ptr, &leng);
-  ERRORR(rval, "Trouble setting data for __MESH_TYPE tag.");
+  CHK_ERR1_STR(rval, "Trouble setting data for conventional tag " << tag_name);
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
@@ -344,9 +338,9 @@ ErrorCode NCHelper::update_time_tag_vals()
   const void* data = NULL;
   int time_tag_size = 0;
   rval = mbImpl->tag_get_handle(time_tag_name.c_str(), 0, MB_TYPE_DOUBLE, time_tag, MB_TAG_VARLEN);
-  ERRORR(rval, "Trouble getting time tag.");
+  CHK_ERR1(rval, "Trouble getting time tag");
   rval = mbImpl->tag_get_by_ptr(time_tag, &_fileSet, 1, &data, &time_tag_size);
-  ERRORR(rval, "Trouble getting values for time tag.");
+  CHK_ERR1(rval, "Trouble getting values for time tag");
   const double* time_tag_vals = static_cast<const double*>(data);
 
   // Merge tVals (read from current file) to existing time tag
@@ -375,12 +369,12 @@ ErrorCode NCHelper::update_time_tag_vals()
   data = &merged_time_vals[0];
   time_tag_size = merged_time_vals.size();
   rval = mbImpl->tag_set_by_ptr(time_tag, &_fileSet, 1, &data, &time_tag_size);
-  ERRORR(rval, "Failed to set data for time tag.");
+  CHK_ERR1(rval, "Failed to set data for time tag.");
 
   return MB_SUCCESS;
 }
 
-ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std::vector<int>& tstep_nums,
+ErrorCode NCHelper::read_variables_setup(std::vector<std::string>& var_names, std::vector<int>& tstep_nums,
                                         std::vector<ReadNC::VarData>& vdatas, std::vector<ReadNC::VarData>& vsetdatas)
 {
   std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
@@ -424,7 +418,7 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
           vdatas.push_back(vd);
       }
       else {
-        ERRORR(MB_FAILURE, "Couldn't find variable.");
+        SET_ERR_STR(MB_FAILURE, "Couldn't find specified variable " << var_names[i]);
       }
     }
   }
@@ -464,13 +458,13 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
   return MB_SUCCESS;
 }
 
-ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
+ErrorCode NCHelper::read_variables_to_set(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   Interface*& mbImpl = _readNC->mbImpl;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
-  ErrorCode rval = read_variable_to_set_allocate(vdatas, tstep_nums);
-  ERRORR(rval, "Trouble allocating read variables to set.");
+  ErrorCode rval = read_variables_to_set_allocate(vdatas, tstep_nums);
+  CHK_ERR1(rval, "Trouble allocating space to read set variables");
 
   // Finally, read into that space
   int success;
@@ -490,42 +484,44 @@ ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, s
         case NC_CHAR:
           success = NCFUNCAG(_vara_text)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
                                         &vdatas[i].readCounts[0], (char*) data);
-          ERRORS(success, "Failed to read char data.");
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read char data for set variable " << vdatas[i].varName);
           break;
         case NC_DOUBLE:
           success = NCFUNCAG(_vara_double)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
                                         &vdatas[i].readCounts[0], (double*) data);
-          ERRORS(success, "Failed to read double data.");
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read double data for set variable " << vdatas[i].varName);
           break;
         case NC_FLOAT:
           success = NCFUNCAG(_vara_float)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
                                         &vdatas[i].readCounts[0], (float*) data);
-          ERRORS(success, "Failed to read float data.");
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read float data for set variable " << vdatas[i].varName);
           break;
         case NC_INT:
           success = NCFUNCAG(_vara_int)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
                                         &vdatas[i].readCounts[0], (int*) data);
-          ERRORS(success, "Failed to read int data.");
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read int data for set variable " << vdatas[i].varName);
           break;
         case NC_SHORT:
           success = NCFUNCAG(_vara_short)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
                                         &vdatas[i].readCounts[0], (short*) data);
-          ERRORS(success, "Failed to read short data.");
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read short data for set variable " << vdatas[i].varName);
           break;
         default:
-          success = 1;
+          SET_ERR_STR(MB_FAILURE, "Unrecognized data type for set variable " << vdatas[i].varName);
       }
 
-      if (success)
-        ERRORR(MB_FAILURE, "Trouble reading variable.");
-
       dbgOut.tprintf(2, "Converting variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
       rval = convert_variable(vdatas[i], t);
-      ERRORR(rval, "Failed to convert variable.");
+      CHK_ERR1_STR(rval, "Failed to convert set variable " << vdatas[i].varName);
 
       dbgOut.tprintf(2, "Setting data for variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
       rval = mbImpl->tag_set_by_ptr(vdatas[i].varTags[t], &_fileSet, 1, &data, &vdatas[i].sz);
-      ERRORR(rval, "Failed to set data for variable.");
+      CHK_ERR1_STR(rval, "Failed to set tag data for set variable " << vdatas[i].varName);
 
       // Memory pointed by pointer data can be deleted, as tag_set_by_ptr() has already copied the tag values
       switch (vdatas[i].varDataType) {
@@ -575,7 +571,6 @@ ErrorCode NCHelper::convert_variable(ReadNC::VarData& var_data, int tstep_num)
   assert(sz > 0);
 
   // Finally, read into that space
-  int success = 0;
   int* idata;
   double* ddata;
   float* fdata;
@@ -597,10 +592,10 @@ ErrorCode NCHelper::convert_variable(ReadNC::VarData& var_data, int tstep_num)
         idata[i] = sdata[i];
       break;
     default:
-      success = 1;
+      break;
   }
 
-  if (2 <= dbgOut.get_verbosity() && !success) {
+  if (2 <= dbgOut.get_verbosity()) {
     double dmin, dmax;
     int imin, imax;
     switch (var_data.varDataType) {
@@ -638,8 +633,8 @@ ErrorCode NCHelper::convert_variable(ReadNC::VarData& var_data, int tstep_num)
       case NC_BYTE:
       case NC_CHAR:
         break;
-      default: // Default case added to remove compiler warnings
-        success = 1;
+      default:
+        break;
     }
   }
 
@@ -651,13 +646,13 @@ ErrorCode NCHelper::read_coordinate(const char* var_name, int lmin, int lmax, st
   std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
   std::map<std::string, ReadNC::VarData>::iterator vmit = varInfo.find(var_name);
   if (varInfo.end() == vmit)
-    return MB_FAILURE;
+    SET_ERR_STR(MB_FAILURE, "Couldn't find coordinate variable " << var_name);
 
   assert(lmin >= 0 && lmax >= lmin);
   NCDF_SIZE tstart = lmin;
   NCDF_SIZE tcount = lmax - lmin + 1;
   NCDF_DIFF dum_stride = 1;
-  int fail;
+  int success;
 
   // Check size
   if ((std::size_t)tcount != cvals.size())
@@ -665,19 +660,19 @@ ErrorCode NCHelper::read_coordinate(const char* var_name, int lmin, int lmax, st
 
   // Check to make sure it's a float or double
   if (NC_DOUBLE == (*vmit).second.varDataType) {
-    fail = NCFUNCAG(_vars_double)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &cvals[0]);
-    if (fail)
-      ERRORS(MB_FAILURE, "Failed to get coordinate values.");
+    success = NCFUNCAG(_vars_double)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &cvals[0]);
+    if (success)
+      SET_ERR_STR(MB_FAILURE, "Failed to get double values for coordinate variable " << var_name);
   }
   else if (NC_FLOAT == (*vmit).second.varDataType) {
     std::vector<float> tcvals(tcount);
-    fail = NCFUNCAG(_vars_float)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &tcvals[0]);
-    if (fail)
-      ERRORS(MB_FAILURE, "Failed to get coordinate values.");
+    success = NCFUNCAG(_vars_float)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &tcvals[0]);
+    if (success)
+      SET_ERR_STR(MB_FAILURE, "Failed to get float values for coordinate variable " << var_name);
     std::copy(tcvals.begin(), tcvals.end(), cvals.begin());
   }
   else {
-    ERRORR(MB_FAILURE, "Wrong data type for coordinate variable.");
+    SET_ERR_STR(MB_FAILURE, "Wrong data type for coordinate variable " << var_name);
   }
 
   return MB_SUCCESS;
@@ -714,8 +709,7 @@ ErrorCode NCHelper::get_tag_to_set(ReadNC::VarData& var_data, int tstep_num, Tag
       rval = mbImpl->tag_get_handle(tag_name.str().c_str(), 0, MB_TYPE_INTEGER, tagh, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
       break;
     default:
-      std::cerr << "Unrecognized data type for tag " << tag_name << std::endl;
-      rval = MB_FAILURE;
+      SET_ERR_STR(MB_FAILURE, "Unrecognized data type for set variable " << var_data.varName);
   }
 
   if (MB_SUCCESS == rval)
@@ -752,8 +746,7 @@ ErrorCode NCHelper::get_tag_to_nonset(ReadNC::VarData& var_data, int tstep_num,
       rval = mbImpl->tag_get_handle(tag_name.str().c_str(), num_lev, MB_TYPE_INTEGER, tagh, MB_TAG_DENSE | MB_TAG_CREAT);
       break;
     default:
-      std::cerr << "Unrecognized data type for tag " << tag_name.str() << std::endl;
-      rval = MB_FAILURE;
+      SET_ERR_STR(MB_FAILURE, "Unrecognized data type for non-set variable " << var_data.varName);
   }
 
   if (MB_SUCCESS == rval)
@@ -778,39 +771,44 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
         sz = attIt->second.attLen;
         attData = (char *) malloc(sz);
         success = NCFUNC(get_att_text)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (char*) attData);
-        ERRORS(success, "Failed to read attribute char data.");
+        if (success)
+          SET_ERR_STR(MB_FAILURE, "Failed to read char data for attribute " << attIt->second.attName);
         ssAtt << "char;";
         break;
       case NC_DOUBLE:
         sz = attIt->second.attLen * sizeof(double);
         attData = (double *) malloc(sz);
         success = NCFUNC(get_att_double)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (double*) attData);
-        ERRORS(success, "Failed to read attribute double data.");
+        if (success)
+          SET_ERR_STR(MB_FAILURE, "Failed to read double data for attribute " << attIt->second.attName);
         ssAtt << "double;";
         break;
       case NC_FLOAT:
         sz = attIt->second.attLen * sizeof(float);
         attData = (float *) malloc(sz);
         success = NCFUNC(get_att_float)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (float*) attData);
-        ERRORS(success, "Failed to read attribute float data.");
+        if (success)
+          SET_ERR_STR(MB_FAILURE, "Failed to read float data for attribute " << attIt->second.attName);
         ssAtt << "float;";
         break;
       case NC_INT:
         sz = attIt->second.attLen * sizeof(int);
         attData = (int *) malloc(sz);
         success = NCFUNC(get_att_int)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (int*) attData);
-        ERRORS(success, "Failed to read attribute int data.");
+        if (success)
+          SET_ERR_STR(MB_FAILURE, "Failed to read int data for attribute " << attIt->second.attName);
         ssAtt << "int;";
         break;
       case NC_SHORT:
         sz = attIt->second.attLen * sizeof(short);
         attData = (short *) malloc(sz);
         success = NCFUNC(get_att_short)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (short*) attData);
-        ERRORS(success, "Failed to read attribute short data.");
+        if (success)
+          SET_ERR_STR(MB_FAILURE, "Failed to read short data for attribute " << attIt->second.attName);
         ssAtt << "short;";
         break;
       default:
-        success = 1;
+        SET_ERR_STR(MB_FAILURE, "Unrecognized data type for attribute " << attIt->second.attName);
     }
     char* tmpc = (char *) attData;
     for (unsigned int counter = 0; counter != sz; ++counter)
@@ -844,7 +842,7 @@ ErrorCode NCHelper::create_dummy_variables()
     int sizeTotalVar = varInfo.size();
     std::string var_name(dimNames[i]);
     ReadNC::VarData& data = varInfo[var_name];
-    data.varName = std::string(var_name);
+    data.varName = var_name;
     data.varId = sizeTotalVar;
     data.varTags.resize(1, 0);
     data.varDataType = NC_INT;
@@ -852,21 +850,21 @@ ErrorCode NCHelper::create_dummy_variables()
     data.varDims[0] = (int)i;
     data.numAtts = 0;
     data.entLoc = ReadNC::ENTLOCSET;
-    dummyVarNames.insert(dimNames[i]);
-    dbgOut.tprintf(2, "Dummy coordinate variable created for dimension %s\n", dimNames[i].c_str());
+    dummyVarNames.insert(var_name);
+    dbgOut.tprintf(2, "Dummy coordinate variable created for dimension %s\n", var_name.c_str());
 
     // Create a corresponding sparse tag
     Tag tagh;
-    ErrorCode rval = mbImpl->tag_get_handle(dimNames[i].c_str(), 0, MB_TYPE_INTEGER, tagh,
+    ErrorCode rval = mbImpl->tag_get_handle(var_name.c_str(), 0, MB_TYPE_INTEGER, tagh,
                                             MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
-    ERRORR(rval, "Failed to create tag for a dummy coordinate variable.");
+    CHK_ERR1_STR(rval, "Failed to create tag for dummy coordinate variable " << var_name);
 
     // Tag value is the dimension length
     const void* ptr = &dimLens[i];
     // Tag size is 1
     int size = 1;
     rval = mbImpl->tag_set_by_ptr(tagh, &_fileSet, 1, &ptr, &size);
-    ERRORR(rval, "Failed to set data for dimension tag.");
+    CHK_ERR1_STR(rval, "Failed to set tag data for dummy coordinate variable " << var_name);
 
     dbgOut.tprintf(2, "Sparse tag created for dimension %s\n", dimNames[i].c_str());
   }
@@ -874,7 +872,7 @@ ErrorCode NCHelper::create_dummy_variables()
   return MB_SUCCESS;
 }
 
-ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
+ErrorCode NCHelper::read_variables_to_set_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   std::vector<int>& dimLens = _readNC->dimLens;
   DebugOutput& dbgOut = _readNC->dbgOut;
@@ -889,7 +887,7 @@ ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>&
       vdatas[i].readCounts.push_back(1);
 
       // Next: other dimensions
-      for (unsigned int idx = 1; idx != vdatas[i].varDims.size(); idx++){
+      for (unsigned int idx = 1; idx != vdatas[i].varDims.size(); idx++) {
         vdatas[i].readStarts.push_back(0);
         vdatas[i].readCounts.push_back(dimLens[vdatas[i].varDims[idx]]);
       }
@@ -901,7 +899,7 @@ ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>&
         vdatas[i].readCounts.push_back(1);
       }
       else {
-        for (unsigned int idx = 0; idx != vdatas[i].varDims.size(); idx++){
+        for (unsigned int idx = 0; idx != vdatas[i].varDims.size(); idx++) {
           vdatas[i].readStarts.push_back(0);
           vdatas[i].readCounts.push_back(dimLens[vdatas[i].varDims[idx]]);
         }
@@ -918,13 +916,13 @@ ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>&
       dbgOut.tprintf(2, "Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
 
       if (tstep_nums[t] >= dimLens[tDim]) {
-        ERRORR(MB_INDEX_OUT_OF_RANGE, "Wrong value for a timestep number.");
+        SET_ERR_STR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number " << tstep_nums[t]);
       }
 
       // Get the tag to read into
       if (!vdatas[i].varTags[t]) {
         rval = get_tag_to_set(vdatas[i], tstep_nums[t], vdatas[i].varTags[t]);
-        ERRORR(rval, "Trouble getting tag for a set variable.");
+        CHK_ERR1_STR(rval, "Trouble getting tag for set variable " << vdatas[i].varName);
       }
 
       switch (vdatas[i].varDataType) {
@@ -941,8 +939,7 @@ ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>&
           vdatas[i].varDatas[t] = new int[vdatas[i].sz];
           break;
         default:
-          std::cerr << "Unrecognized data type for set variable tag values" << std::endl;
-          rval = MB_FAILURE;
+          SET_ERR_STR(MB_FAILURE, "Unrecognized data type for set variable " << vdatas[i].varName);
       }
 
       // Loop continues only for set variables with timesteps, e.g. xtime(Time) or xtime(Time, StrLen)
@@ -960,7 +957,7 @@ ErrorCode ScdNCHelper::check_existing_mesh() {
   // Get the number of vertices
   int num_verts;
   ErrorCode rval = mbImpl->get_number_entities_by_dimension(_fileSet, 0, num_verts);
-  ERRORR(rval, "Trouble getting number of vertices.");
+  CHK_ERR1(rval, "Trouble getting number of vertices");
 
   /*
   // Check against parameters
@@ -968,7 +965,7 @@ ErrorCode ScdNCHelper::check_existing_mesh() {
   if (num_verts > 0) {
     int expected_verts = (lDims[3] - lDims[0] + 1) * (lDims[4] - lDims[1] + 1) * (-1 == lDims[2] ? 1 : lDims[5] - lDims[2] + 1);
     if (num_verts != expected_verts) {
-      ERRORR(MB_FAILURE, "Number of vertices doesn't match.");
+      SET_ERR(MB_FAILURE, "Number of vertices doesn't match");
     }
   }
   */
@@ -976,7 +973,7 @@ ErrorCode ScdNCHelper::check_existing_mesh() {
   // Check the number of elements too
   int num_elems;
   rval = mbImpl->get_number_entities_by_dimension(_fileSet, (-1 == lCDims[2] ? 2 : 3), num_elems);
-  ERRORR(rval, "Trouble getting number of elements.");
+  CHK_ERR1(rval, "Trouble getting number of elements");
 
   /*
   // Check against parameters
@@ -984,7 +981,7 @@ ErrorCode ScdNCHelper::check_existing_mesh() {
   if (num_elems > 0) {
     int expected_elems = (lCDims[3] - lCDims[0] + 1) * (lCDims[4] - lCDims[1] + 1) * (-1 == lCDims[2] ? 1 : (lCDims[5] - lCDims[2] + 1));
     if (num_elems != expected_elems) {
-      ERRORR(MB_FAILURE, "Number of elements doesn't match.");
+      SET_ERR(MB_FAILURE, "Number of elements doesn't match");
     }
   }
   */
@@ -1006,7 +1003,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
 
   ErrorCode rval = scdi->construct_box(HomCoord(lDims[0], lDims[1], lDims[2], 1), HomCoord(lDims[3], lDims[4], lDims[5], 1), 
                                        NULL, 0, scd_box, locallyPeriodic, &parData, true);
-  ERRORR(rval, "Trouble creating scd vertex sequence.");
+  CHK_ERR1(rval, "Trouble creating scd vertex sequence");
 
   // Add verts to tmp_range first, so we can duplicate global ids in vertex ids
   tmp_range.insert(scd_box->start_vertex(), scd_box->start_vertex() + scd_box->num_vertices() - 1);
@@ -1015,11 +1012,11 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
     int count;
     void* data;
     rval = mbImpl->tag_iterate(*mpFileIdTag, tmp_range.begin(), tmp_range.end(), count, data);
-    ERRORR(rval, "Failed to get tag iterator on file id tag.");
+    CHK_ERR1(rval, "Failed to get tag iterator on file id tag");
     assert(count == scd_box->num_vertices());
     int* fid_data = (int*) data;
     rval = mbImpl->tag_iterate(mGlobalIdTag, tmp_range.begin(), tmp_range.end(), count, data);
-    ERRORR(rval, "Failed to get tag iterator on global id tag.");
+    CHK_ERR1(rval, "Failed to get tag iterator on global id tag");
     assert(count == scd_box->num_vertices());
     int* gid_data = (int*) data;
     for (int i = 0; i < count; i++)
@@ -1030,21 +1027,21 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
   tmp_range.insert(scd_box->start_element(), scd_box->start_element() + scd_box->num_elements() - 1);
   tmp_range.insert(scd_box->box_set());
   rval = mbImpl->add_entities(_fileSet, tmp_range);
-  ERRORR(rval, "Couldn't add new vertices to file set.");
+  CHK_ERR1(rval, "Couldn't add new vertices to current file set");
 
   dbgOut.tprintf(1, "scdbox %d quads, %d vertices\n", scd_box->num_elements(), scd_box->num_vertices());
 
   // Set the vertex coordinates
   double *xc, *yc, *zc;
   rval = scd_box->get_coordinate_arrays(xc, yc, zc);
-  ERRORR(rval, "Couldn't get vertex coordinate arrays.");
+  CHK_ERR1(rval, "Couldn't get vertex coordinate arrays");
 
   int i, j, k, il, jl, kl;
   int dil = lDims[3] - lDims[0] + 1;
   int djl = lDims[4] - lDims[1] + 1;
   assert(dil == (int)ilVals.size() && djl == (int)jlVals.size() &&
       (-1 == lDims[2] || lDims[5] - lDims[2] + 1 == (int)levVals.size()));
-//#define INDEX(i, j, k) ()
+
   for (kl = lDims[2]; kl <= lDims[5]; kl++) {
     k = kl - lDims[2];
     for (jl = lDims[1]; jl <= lDims[4]; jl++) {
@@ -1058,14 +1055,13 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
       }
     }
   }
-//#undef INDEX
 
 #ifndef NDEBUG
   int num_verts = (lDims[3] - lDims[0] + 1) * (lDims[4] - lDims[1] + 1) * (-1 == lDims[2] ? 1 : lDims[5] - lDims[2] + 1);
   std::vector<int> gids(num_verts);
   Range verts(scd_box->start_vertex(), scd_box->start_vertex() + scd_box->num_vertices() - 1);
   rval = mbImpl->tag_get_data(mGlobalIdTag, verts, &gids[0]);
-  ERRORR(rval, "Trouble getting gid values.");
+  CHK_ERR1(rval, "Trouble getting local gid values of vertices");
   int vmin = *(std::min_element(gids.begin(), gids.end())), vmax = *(std::max_element(gids.begin(), gids.end()));
   dbgOut.tprintf(1, "Vertex gids %d-%d\n", vmin, vmax);
 #endif
@@ -1077,14 +1073,14 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
     assert(scd_box->boundary_complete());
     EntityHandle dum_ent = scd_box->start_element();
     rval = mbImpl->list_entities(&dum_ent, 1);
-    ERRORR(rval, "Trouble listing first hex.");
+    CHK_ERR1(rval, "Trouble listing first hex");
 
     std::vector<EntityHandle> connect;
     rval = mbImpl->get_connectivity(&dum_ent, 1, connect);
-    ERRORR(rval, "Trouble getting connectivity.");
+    CHK_ERR1(rval, "Trouble getting connectivity");
 
     rval = mbImpl->list_entities(&connect[0], connect.size());
-    ERRORR(rval, "Trouble listing element connectivity.");
+    CHK_ERR1(rval, "Trouble listing element connectivity");
   }
 
   Range edges;
@@ -1092,7 +1088,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
 
   // Create COORDS tag for quads
   rval = create_quad_coordinate_tag();
-  ERRORR(rval, "Trouble creating coordinate tags to entities quads");
+  CHK_ERR1(rval, "Trouble creating coordinate tags to entities quads");
 
   return MB_SUCCESS;
 }
@@ -1102,23 +1098,23 @@ ErrorCode ScdNCHelper::read_variables(std::vector<std::string>& var_names, std::
   std::vector<ReadNC::VarData> vdatas;
   std::vector<ReadNC::VarData> vsetdatas;
 
-  ErrorCode rval = read_variable_setup(var_names, tstep_nums, vdatas, vsetdatas);
-  ERRORR(rval, "Trouble setting up read variable.");
+  ErrorCode rval = read_variables_setup(var_names, tstep_nums, vdatas, vsetdatas);
+  CHK_ERR1(rval, "Trouble setting up to read variables");
 
   if (!vsetdatas.empty()) {
-    rval = read_variable_to_set(vsetdatas, tstep_nums);
-    ERRORR(rval, "Trouble read variables to set.");
+    rval = read_variables_to_set(vsetdatas, tstep_nums);
+    CHK_ERR1(rval, "Trouble reading variables to set");
   }
 
   if (!vdatas.empty()) {
-    rval = read_scd_variable_to_nonset(vdatas, tstep_nums);
-    ERRORR(rval, "Trouble read variables to entities verts/edges/faces.");
+    rval = read_scd_variables_to_nonset(vdatas, tstep_nums);
+    CHK_ERR1(rval, "Trouble reading variables to verts/edges/faces");
   }
 
   return MB_SUCCESS;
 }
 
-ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
+ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   Interface*& mbImpl = _readNC->mbImpl;
   std::vector<int>& dimLens = _readNC->dimLens;
@@ -1131,18 +1127,18 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
   // Get vertices in set
   Range verts;
   rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts);
-  ERRORR(rval, "Trouble getting vertices in set.");
+  CHK_ERR1(rval, "Trouble getting vertices in current file set");
   assert("Should only have a single vertex subrange, since they were read in one shot" &&
       verts.psize() == 1);
 
   Range edges;
   rval = mbImpl->get_entities_by_dimension(_fileSet, 1, edges);
-  ERRORR(rval, "Trouble getting edges in set.");
+  CHK_ERR1(rval, "Trouble getting edges in current file set");
 
   // Get faces in set
   Range faces;
   rval = mbImpl->get_entities_by_dimension(_fileSet, 2, faces);
-  ERRORR(rval, "Trouble getting faces in set.");
+  CHK_ERR1(rval, "Trouble getting faces in current file set");
   assert("Should only have a single face subrange, since they were read in one shot" &&
       faces.psize() == 1);
 
@@ -1152,7 +1148,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
   if (isParallel) {
     ParallelComm*& myPcomm = _readNC->myPcomm;
     rval = myPcomm->filter_pstatus(faces, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1, &faces_owned);
-    ERRORR(rval, "Trouble getting owned faces in set.");
+    CHK_ERR1(rval, "Trouble getting owned faces in current file set");
   }
   else
     faces_owned = faces; // Not running in parallel, but still with MPI
@@ -1188,11 +1184,9 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
         range = &verts;
         break;
       case ReadNC::ENTLOCNSEDGE:
-        ERRORR(MB_FAILURE, "Reading edge data not implemented yet.");
-        break;
       case ReadNC::ENTLOCEWEDGE:
-        ERRORR(MB_FAILURE, "Reading edge data not implemented yet.");
-        break;
+      case ReadNC::ENTLOCEDGE:
+        SET_GLB_ERR(MB_NOT_IMPLEMENTED, "Reading edge data is not implemented yet");
       case ReadNC::ENTLOCFACE:
         // Faces
         vdatas[i].readStarts[2] = lCDims[1];
@@ -1209,28 +1203,27 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
         // Set
         break;
       default:
-        ERRORR(MB_FAILURE, "Unrecognized entity location type.");
-        break;
+        SET_ERR_STR(MB_FAILURE, "Unexpected entity location type for non-set variable " << vdatas[i].varName);
     }
 
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       dbgOut.tprintf(2, "Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
 
       if (tstep_nums[t] >= dimLens[tDim]) {
-        ERRORR(MB_INDEX_OUT_OF_RANGE, "Wrong value for a timestep number.");
+        SET_ERR_STR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number " << tstep_nums[t]);
       }
 
       // Get the tag to read into
       if (!vdatas[i].varTags[t]) {
         rval = get_tag_to_nonset(vdatas[i], tstep_nums[t], vdatas[i].varTags[t], vdatas[i].numLev);
-        ERRORR(rval, "Trouble getting tag.");
+        CHK_ERR1_STR(rval, "Trouble getting tag for non-set variable " << vdatas[i].varName);
       }
 
       // Get ptr to tag space
       void* data;
       int count;
       rval = mbImpl->tag_iterate(vdatas[i].varTags[t], range->begin(), range->end(), count, data);
-      ERRORR(rval, "Failed to get tag iterator.");
+      CHK_ERR1_STR(rval, "Failed to get tag iterator for non-set variable " << vdatas[i].varName);
       assert((unsigned)count == range->size());
       vdatas[i].varDatas[t] = data;
     }
@@ -1244,12 +1237,12 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
   return rval;
 }
 
-ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
+ErrorCode ScdNCHelper::read_scd_variables_to_nonset(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   DebugOutput& dbgOut = _readNC->dbgOut;
 
-  ErrorCode rval = read_scd_variable_to_nonset_allocate(vdatas, tstep_nums);
-  ERRORR(rval, "Trouble allocating read variables.");
+  ErrorCode rval = read_scd_variables_to_nonset_allocate(vdatas, tstep_nums);
+  CHK_ERR1(rval, "Trouble allocating space to read non-set variables");
 
   // Finally, read into that space
   int success;
@@ -1275,87 +1268,88 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
           std::vector<char> tmpchardata(sz);
           success = NCFUNCAG(_vara_text)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0], &vdatas[i].readCounts[0],
                                         &tmpchardata[0]);
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read char data for non-set variable " << vdatas[i].varName);
           if (vdatas[i].numLev > 1)
             // Transpose (lev, lat, lon) to (lat, lon, lev)
-            success = kji_to_jik(ni, nj, nk, data, &tmpchardata[0]);
+            kji_to_jik(ni, nj, nk, data, &tmpchardata[0]);
           else {
             for (std::size_t idx = 0; idx != tmpchardata.size(); idx++)
               ((char*) data)[idx] = tmpchardata[idx];
           }
-          ERRORS(success, "Failed to read char data.");
           break;
         }
         case NC_DOUBLE: {
           std::vector<double> tmpdoubledata(sz);
           success = NCFUNCAG(_vara_double)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0], &vdatas[i].readCounts[0],
                                           &tmpdoubledata[0]);
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read double data for non-set variable " << vdatas[i].varName);
           if (vdatas[i].numLev > 1)
             // Transpose (lev, lat, lon) to (lat, lon, lev)
-            success = kji_to_jik(ni, nj, nk, data, &tmpdoubledata[0]);
+            kji_to_jik(ni, nj, nk, data, &tmpdoubledata[0]);
           else {
             for (std::size_t idx = 0; idx != tmpdoubledata.size(); idx++)
               ((double*) data)[idx] = tmpdoubledata[idx];
           }
-          ERRORS(success, "Failed to read double data.");
           break;
         }
         case NC_FLOAT: {
           std::vector<float> tmpfloatdata(sz);
           success = NCFUNCAG(_vara_float)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0], &vdatas[i].readCounts[0],
                                           &tmpfloatdata[0]);
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read float data for non-set variable " << vdatas[i].varName);
           if (vdatas[i].numLev > 1)
             // Transpose (lev, lat, lon) to (lat, lon, lev)
-            success = kji_to_jik(ni, nj, nk, data, &tmpfloatdata[0]);
+            kji_to_jik(ni, nj, nk, data, &tmpfloatdata[0]);
           else {
             for (std::size_t idx = 0; idx != tmpfloatdata.size(); idx++)
               ((float*) data)[idx] = tmpfloatdata[idx];
           }
-          ERRORS(success, "Failed to read float data.");
           break;
         }
         case NC_INT: {
           std::vector<int> tmpintdata(sz);
           success = NCFUNCAG(_vara_int)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0], &vdatas[i].readCounts[0],
                                         &tmpintdata[0]);
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read int data for non-set variable " << vdatas[i].varName);
           if (vdatas[i].numLev > 1)
             // Transpose (lev, lat, lon) to (lat, lon, lev)
-            success = kji_to_jik(ni, nj, nk, data, &tmpintdata[0]);
+            kji_to_jik(ni, nj, nk, data, &tmpintdata[0]);
           else {
             for (std::size_t idx = 0; idx != tmpintdata.size(); idx++)
               ((int*) data)[idx] = tmpintdata[idx];
           }
-          ERRORS(success, "Failed to read int data.");
           break;
         }
         case NC_SHORT: {
           std::vector<short> tmpshortdata(sz);
           success = NCFUNCAG(_vara_short)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0], &vdatas[i].readCounts[0],
                                           &tmpshortdata[0]);
+          if (success)
+            SET_ERR_STR(MB_FAILURE, "Failed to read short data for non-set variable " << vdatas[i].varName);
           if (vdatas[i].numLev > 1)
             // Transpose (lev, lat, lon) to (lat, lon, lev)
-            success = kji_to_jik(ni, nj, nk, data, &tmpshortdata[0]);
+            kji_to_jik(ni, nj, nk, data, &tmpshortdata[0]);
           else {
             for (std::size_t idx = 0; idx != tmpshortdata.size(); idx++)
               ((short*) data)[idx] = tmpshortdata[idx];
           }
-          ERRORS(success, "Failed to read short data.");
           break;
         }
         default:
-          success = 1;
+          SET_ERR_STR(MB_FAILURE, "Unrecognized data type for non-set variable " << vdatas[i].varName);
       }
-
-      if (success)
-        ERRORR(MB_FAILURE, "Trouble reading variable.");
     }
   }
 
   for (unsigned int i = 0; i < vdatas.size(); i++) {
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       dbgOut.tprintf(2, "Converting variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
-      ErrorCode tmp_rval = convert_variable(vdatas[i], t);
-      if (MB_SUCCESS != tmp_rval)
-        rval = tmp_rval;
+      rval = convert_variable(vdatas[i], t);
+      CHK_ERR1_STR(rval, "Failed to convert non-set variable " << vdatas[i].varName);
     }
   }
 
@@ -1375,7 +1369,7 @@ ErrorCode ScdNCHelper::create_quad_coordinate_tag() {
 
   Range ents;
   ErrorCode rval = mbImpl->get_entities_by_type(_fileSet, moab::MBQUAD, ents);
-  ERRORR(rval, "Trouble getting QUAD entity.");
+  CHK_ERR1(rval, "Trouble getting quads");
 
   std::size_t numOwnedEnts = 0;
 #ifdef USE_MPI
@@ -1384,7 +1378,7 @@ ErrorCode ScdNCHelper::create_quad_coordinate_tag() {
   if (isParallel) {
     ParallelComm*& myPcomm = _readNC->myPcomm;
     rval = myPcomm->filter_pstatus(ents, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1, &ents_owned);
-    ERRORR(rval, "Trouble getting owned QUAD entity.");
+    CHK_ERR1(rval, "Trouble getting owned quads");
     numOwnedEnts = ents_owned.size();
   }
   else {
@@ -1412,16 +1406,17 @@ ErrorCode ScdNCHelper::create_quad_coordinate_tag() {
   std::string tag_name = "COORDS";
   Tag tagh = 0;
   rval = mbImpl->tag_get_handle(tag_name.c_str(), 3, MB_TYPE_DOUBLE, tagh, MB_TAG_DENSE | MB_TAG_CREAT);
-  ERRORR(rval, "Trouble creating COORDS tag.");
+  CHK_ERR1(rval, "Trouble creating COORDS tag");
 
-  void *data;
+  void* data;
   int count;
 #ifdef USE_MPI
   rval = mbImpl->tag_iterate(tagh, ents_owned.begin(), ents_owned.end(), count, data);
+  CHK_ERR1(rval, "Failed to get COORDS tag iterator on owned quads");
 #else
   rval = mbImpl->tag_iterate(tagh, ents.begin(), ents.end(), count, data);
+  CHK_ERR1(rval, "Failed to get COORDS tag iterator on quads");
 #endif
-  ERRORR(rval, "Failed to get COORDS tag iterator.");
   assert(count == (int)numOwnedEnts);
   double* quad_data = (double*) data;
   std::copy(coords.begin(), coords.end(), quad_data);
@@ -1434,23 +1429,24 @@ ErrorCode UcdNCHelper::read_variables(std::vector<std::string>& var_names, std::
   std::vector<ReadNC::VarData> vdatas;
   std::vector<ReadNC::VarData> vsetdatas;
 
-  ErrorCode rval = read_variable_setup(var_names, tstep_nums, vdatas, vsetdatas);
-  ERRORR(rval, "Trouble setting up read variable.");
+  ErrorCode rval = read_variables_setup(var_names, tstep_nums, vdatas, vsetdatas);
+  CHK_ERR1(rval, "Trouble setting up to read variables");
 
   if (!vsetdatas.empty()) {
-    rval = read_variable_to_set(vsetdatas, tstep_nums);
-    ERRORR(rval, "Trouble read variables to set.");
+    rval = read_variables_to_set(vsetdatas, tstep_nums);
+    CHK_ERR1(rval, "Trouble reading variables to set");
   }
 
   if (!vdatas.empty()) {
 #ifdef PNETCDF_FILE
     // With pnetcdf support, we will use async read
-    rval = read_ucd_variable_to_nonset_async(vdatas, tstep_nums);
+    rval = read_ucd_variables_to_nonset_async(vdatas, tstep_nums);
+    CHK_ERR1(rval, "Trouble reading variables to verts/edges/faces");
 #else
     // Without pnetcdf support, we will use old read
-    rval = read_ucd_variable_to_nonset(vdatas, tstep_nums);
+    rval = read_ucd_variables_to_nonset(vdatas, tstep_nums);
+    CHK_ERR1(rval, "Trouble reading variables to verts/edges/faces");
 #endif
-    ERRORR(rval, "Trouble read variables to entities verts/edges/faces.");
   }
 
   return MB_SUCCESS;

diff --git a/src/io/NCHelperGCRM.cpp b/src/io/NCHelperGCRM.cpp
index f0cc7aa..25fe9ac 100644
--- a/src/io/NCHelperGCRM.cpp
+++ b/src/io/NCHelperGCRM.cpp
@@ -422,7 +422,7 @@ ErrorCode NCHelperGCRM::create_mesh(Range& faces)
   return MB_SUCCESS;
 }
 
-ErrorCode NCHelperGCRM::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
+ErrorCode NCHelperGCRM::read_ucd_variables_to_nonset_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   Interface*& mbImpl = _readNC->mbImpl;
   std::vector<int>& dimLens = _readNC->dimLens;
@@ -561,13 +561,13 @@ ErrorCode NCHelperGCRM::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC:
 }
 
 #ifdef PNETCDF_FILE
-ErrorCode NCHelperGCRM::read_ucd_variable_to_nonset_async(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
+ErrorCode NCHelperGCRM::read_ucd_variables_to_nonset_async(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   Interface*& mbImpl = _readNC->mbImpl;
   bool& noEdges = _readNC->noEdges;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
-  ErrorCode rval = read_ucd_variable_to_nonset_allocate(vdatas, tstep_nums);
+  ErrorCode rval = read_ucd_variables_to_nonset_allocate(vdatas, tstep_nums);
   ERRORR(rval, "Trouble allocating read variables.");
 
   // Finally, read into that space
@@ -716,13 +716,13 @@ ErrorCode NCHelperGCRM::read_ucd_variable_to_nonset_async(std::vector<ReadNC::Va
   return rval;
 }
 #else
-ErrorCode NCHelperGCRM::read_ucd_variable_to_nonset(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
+ErrorCode NCHelperGCRM::read_ucd_variables_to_nonset(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
   Interface*& mbImpl = _readNC->mbImpl;
   bool& noEdges = _readNC->noEdges;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
-  ErrorCode rval = read_ucd_variable_to_nonset_allocate(vdatas, tstep_nums);
+  ErrorCode rval = read_ucd_variables_to_nonset_allocate(vdatas, tstep_nums);
   ERRORR(rval, "Trouble allocating read variables.");
 
   // Finally, read into that space

diff --git a/src/io/NCHelperGCRM.hpp b/src/io/NCHelperGCRM.hpp
index 3c445f3..b415bd2 100644
--- a/src/io/NCHelperGCRM.hpp
+++ b/src/io/NCHelperGCRM.hpp
@@ -30,16 +30,16 @@ private:
   //! Implementation of NCHelper::get_mesh_type_name()
   virtual std::string get_mesh_type_name() { return "GCRM"; }
 
-  //! Implementation of UcdNCHelper::read_ucd_variable_to_nonset_allocate()
-  virtual ErrorCode read_ucd_variable_to_nonset_allocate(std::vector<ReadNC::VarData>& vdatas,
+  //! Implementation of UcdNCHelper::read_ucd_variables_to_nonset_allocate()
+  virtual ErrorCode read_ucd_variables_to_nonset_allocate(std::vector<ReadNC::VarData>& vdatas,
                                                          std::vector<int>& tstep_nums);
 #ifdef PNETCDF_FILE
-  //! Implementation of UcdNCHelper::read_ucd_variable_to_nonset_async()
-  virtual ErrorCode read_ucd_variable_to_nonset_async(std::vector<ReadNC::VarData>& vdatas,
+  //! Implementation of UcdNCHelper::read_ucd_variables_to_nonset_async()
+  virtual ErrorCode read_ucd_variables_to_nonset_async(std::vector<ReadNC::VarData>& vdatas,
                                                       std::vector<int>& tstep_nums);
 #else
-  //! Implementation of UcdNCHelper::read_ucd_variable_to_nonset()
-  virtual ErrorCode read_ucd_variable_to_nonset(std::vector<ReadNC::VarData>& vdatas,
+  //! Implementation of UcdNCHelper::read_ucd_variables_to_nonset()
+  virtual ErrorCode read_ucd_variables_to_nonset(std::vector<ReadNC::VarData>& vdatas,
                                                 std::vector<int>& tstep_nums);
 #endif
 

diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index cd2c004..7607927 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -5,12 +5,6 @@
 #include "MBTagConventions.hpp"
 #include "moab/FileOptions.hpp"
 
-#define ERRORR(rval, str) \
-  if (MB_SUCCESS != rval) { readMeshIface->report_error("%s", str); return rval; }
-
-#define ERRORS(err, str) \
-  if (err) { readMeshIface->report_error("%s", str); return MB_FAILURE; }
-
 namespace moab {
 
 ReaderIface* ReadNC::factory(Interface* iface)
@@ -51,15 +45,14 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
   // Get and cache predefined tag handles
   int dum_val = 0;
   rval = mbImpl->tag_get_handle(GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, mGlobalIdTag, MB_TAG_DENSE | MB_TAG_CREAT, &dum_val);
-  if (MB_SUCCESS != rval)
-    return rval;
+  CHK_ERR(rval);
 
   // Store the pointer to the tag; if not null, set when global id tag
   // is set too, with the same data, duplicated
   mpFileIdTag = file_id_tag;
 
   rval = parse_options(opts, var_names, tstep_nums, tstep_vals);
-  ERRORR(rval, "Trouble parsing option string.");
+  CHK_ERR1(rval, "Trouble parsing option string");
 
   // Open the file
   dbgOut.tprintf(1, "Opening file %s\n", file_name);
@@ -74,21 +67,21 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
 #else
   success = NCFUNC(open)(file_name, 0, &fileId);
 #endif
-
-  ERRORS(success, "Trouble opening file.");
+  if (success)
+    SET_ERR(MB_FAILURE, "Trouble opening file");
 
   // Read the header (num dimensions, dimensions, num variables, global attribs)
   rval = read_header();
-  ERRORR(rval, "Trouble reading file header.");
+  CHK_ERR1(rval, "Trouble reading file header");
 
   // Make sure there's a file set to put things in
   EntityHandle tmp_set;
   if (noMesh && !file_set) {
-    ERRORR(MB_FAILURE, "NOMESH option requires non-NULL file set on input.\n");
+    SET_ERR(MB_FAILURE, "NOMESH option requires non-NULL file set on input");
   }
   else if (!file_set || (file_set && *file_set == 0)) {
     rval = mbImpl->create_meshset(MESHSET_SET, tmp_set);
-    ERRORR(rval, "Trouble creating file set.");
+    CHK_ERR1(rval, "Trouble creating file set");
   }
   else
     tmp_set = *file_set;
@@ -105,17 +98,17 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
   // Get appropriate NC helper instance based on information read from the header
   myHelper = NCHelper::get_nc_helper(this, fileId, opts, tmp_set);
   if (NULL == myHelper) {
-    ERRORR(MB_FAILURE, "Failed to get NCHelper class instance.");
+    SET_ERR(MB_FAILURE, "Failed to get NCHelper class instance");
   }
 
   // Initialize mesh values
   rval = myHelper->init_mesh_vals();
-  ERRORR(rval, "Trouble initializing mesh values.");
+  CHK_ERR1(rval, "Trouble initializing mesh values");
 
   // Check existing mesh from last read
   if (noMesh && !noVars) {
     rval = myHelper->check_existing_mesh();
-    ERRORR(rval, "Trouble checking mesh from last read.\n");
+    CHK_ERR1(rval, "Trouble checking mesh from last read");
   }
 
   // Create some conventional tags, e.g. __NUM_DIMS
@@ -126,7 +119,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
   int def_val = 0;
   rval = mbImpl->tag_get_handle("__CONV_TAGS_CREATED", 1, MB_TYPE_INTEGER, convTagsCreated,
                                 MB_TAG_SPARSE | MB_TAG_CREAT, &def_val);
-  ERRORR(rval, "Trouble getting _CONV_TAGS_CREATED tag.");
+  CHK_ERR1(rval, "Trouble getting _CONV_TAGS_CREATED tag");
   int create_conv_tags_flag = 0;
   rval = mbImpl->tag_get_data(convTagsCreated, &tmp_set, 1, &create_conv_tags_flag);
   // The first read to the file set
@@ -134,14 +127,14 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
     // Read dimensions (coordinate variables) by default to create tags like __<var_name>_DIMS
     // This is done only once (assume that all files read to the file set have the same dimensions)
     rval = myHelper->read_variables(dimNames, tstep_nums);
-    ERRORR(rval, "Trouble reading dimensions.");
+    CHK_ERR1(rval, "Trouble reading dimensions");
 
     rval = myHelper->create_conventional_tags(tstep_nums);
-    ERRORR(rval, "Trouble creating NC conventional tags.");
+    CHK_ERR1(rval, "Trouble creating NC conventional tags");
 
     create_conv_tags_flag = 1;
     rval = mbImpl->tag_set_data(convTagsCreated, &tmp_set, 1, &create_conv_tags_flag);
-    ERRORR(rval, "Trouble setting data for _CONV_TAGS_CREATED tag.");
+    CHK_ERR1(rval, "Trouble setting data for _CONV_TAGS_CREATED tag");
   }
   // Another read to the file set
   else {
@@ -149,7 +142,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
       // If timesteps spread across files, merge time values read
       // from current file to existing time tag
       rval = myHelper->update_time_tag_vals();
-      ERRORR(rval, "Trouble updating time tag values.");
+      CHK_ERR1(rval, "Trouble updating time tag values");
     }
   }
 
@@ -157,7 +150,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
   Range faces;
   if (!noMesh) {
     rval = myHelper->create_mesh(faces);
-    ERRORR(rval, "Trouble creating mesh.");
+    CHK_ERR1(rval, "Trouble creating mesh");
   }
 
   // Read specified variables onto grid
@@ -165,7 +158,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
     if (var_names.empty()) {
       // If VARIABLE option is missing, read all variables
       rval = myHelper->read_variables(var_names, tstep_nums);
-      ERRORR(rval, "Trouble reading all variables.");
+      CHK_ERR1(rval, "Trouble reading all variables");
     }
     else {
       // Exclude dimensions that are read to the file set by default
@@ -177,7 +170,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
 
       if (!non_dim_var_names.empty()) {
         rval = myHelper->read_variables(non_dim_var_names, tstep_nums);
-        ERRORR(rval, "Trouble reading specified variables.");
+        CHK_ERR1(rval, "Trouble reading specified variables");
       }
     }
   }
@@ -187,17 +180,17 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
   if (isParallel) {
     EntityHandle partn_set;
     rval = mbImpl->create_meshset(MESHSET_SET, partn_set);
-    ERRORR(rval, "Trouble creating partition set.");
+    CHK_ERR1(rval, "Trouble creating partition set");
 
     rval = mbImpl->add_entities(partn_set, faces);
-    ERRORR(rval, "Couldn't add new faces to partition set.");
+    CHK_ERR1(rval, "Couldn't add new faces to partition set");
 
     Range verts;
     rval = mbImpl->get_connectivity(faces, verts);
-    ERRORR(rval, "Couldn't get verts of faces");
+    CHK_ERR1(rval, "Couldn't get verts of faces");
 
     rval = mbImpl->add_entities(partn_set, verts);
-    ERRORR(rval, "Couldn't add new verts to partition set.");
+    CHK_ERR1(rval, "Couldn't add new verts to partition set");
 
     myPcomm->partition_sets().insert(partn_set);
 
@@ -205,8 +198,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
     Tag part_tag = myPcomm->partition_tag();
     int dum_rank = myPcomm->proc_config().proc_rank();
     rval = mbImpl->tag_set_data(part_tag, &partn_set, 1, &dum_rank);
-    if (MB_SUCCESS != rval)
-      return rval;
+    CHK_ERR(rval);
   }
 #endif
 
@@ -215,7 +207,8 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
 
   // Close the file
   success = NCFUNC(close)(fileId);
-  ERRORS(success, "Trouble closing file.");
+  if (success)
+    SET_ERR(MB_FAILURE, "Trouble closing file");
 
   return MB_SUCCESS;
 }
@@ -279,18 +272,16 @@ ErrorCode ReadNC::parse_options(const FileOptions& opts, std::vector<std::string
 
   rval = opts.get_int_option("GATHER_SET", 0, gatherSetRank);
   if (MB_TYPE_OUT_OF_RANGE == rval) {
-    readMeshIface->report_error("Invalid value for GATHER_SET option");
-    return rval;
+    SET_ERR(rval, "Invalid value for GATHER_SET option");
   }
 
   rval = opts.get_int_option("TIMESTEPBASE", 0, tStepBase);
   if (MB_TYPE_OUT_OF_RANGE == rval) {
-    readMeshIface->report_error("Invalid value for TIMESTEPBASE option");
-    return rval;
+    SET_ERR(rval, "Invalid value for TIMESTEPBASE option");
   }
 
 #ifdef USE_MPI
-  isParallel = (opts.match_option("PARALLEL","READ_PART") != MB_ENTITY_NOT_FOUND);
+  isParallel = (opts.match_option("PARALLEL", "READ_PART") != MB_ENTITY_NOT_FOUND);
 
   if (!isParallel)
   // Return success here, since rval still has _NOT_FOUND from not finding option
@@ -300,10 +291,10 @@ ErrorCode ReadNC::parse_options(const FileOptions& opts, std::vector<std::string
 
   int pcomm_no = 0;
   rval = opts.get_int_option("PARALLEL_COMM", pcomm_no);
-  if (rval == MB_TYPE_OUT_OF_RANGE) {
-    readMeshIface->report_error("Invalid value for PARALLEL_COMM option");
-    return rval;
+  if (MB_TYPE_OUT_OF_RANGE == rval) {
+    SET_ERR(rval, "Invalid value for PARALLEL_COMM option");
   }
+
   myPcomm = ParallelComm::get_pcomm(mbImpl, pcomm_no);
   if (0 == myPcomm) {
     myPcomm = new ParallelComm(mbImpl, MPI_COMM_WORLD);
@@ -313,11 +304,10 @@ ErrorCode ReadNC::parse_options(const FileOptions& opts, std::vector<std::string
 
   int dum;
   rval = opts.match_option("PARTITION_METHOD", ScdParData::PartitionMethodNames, dum);
-  if (rval == MB_FAILURE) {
-    readMeshIface->report_error("Unknown partition method specified.");
-    partMethod = ScdParData::ALLJORKORI;
+  if (MB_FAILURE == rval) {
+    SET_ERR(rval, "Unknown partition method specified");
   }
-  else if (rval == MB_ENTITY_NOT_FOUND)
+  else if (MB_ENTITY_NOT_FOUND == rval)
     partMethod = ScdParData::ALLJORKORI;
   else
     partMethod = dum;
@@ -334,21 +324,22 @@ ErrorCode ReadNC::read_header()
   int numgatts;
   int success;
   success = NCFUNC(inq_natts )(fileId, &numgatts);
-  ERRORS(success, "Couldn't get number of global attributes.");
+  if (success)
+    SET_ERR(MB_FAILURE, "Couldn't get number of global attributes");
 
   // Read attributes into globalAtts
   ErrorCode result = get_attributes(NC_GLOBAL, numgatts, globalAtts);
-  ERRORR(result, "Getting attributes.");
+  CHK_ERR1(result, "Trouble getting attributes");
   dbgOut.tprintf(1, "Read %u attributes\n", (unsigned int) globalAtts.size());
 
   // Read in dimensions into dimNames and dimLens
   result = get_dimensions(fileId, dimNames, dimLens);
-  ERRORR(result, "Getting dimensions.");
+  CHK_ERR1(result, "Trouble getting dimensions");
   dbgOut.tprintf(1, "Read %u dimensions\n", (unsigned int) dimNames.size());
 
   // Read in variables into varInfo
   result = get_variables();
-  ERRORR(result, "Getting variables.");
+  CHK_ERR1(result, "Trouble getting variables");
   dbgOut.tprintf(1, "Read %u variables\n", (unsigned int) varInfo.size());
 
   return MB_SUCCESS;
@@ -361,12 +352,14 @@ ErrorCode ReadNC::get_attributes(int var_id, int num_atts, std::map<std::string,
   for (int i = 0; i < num_atts; i++) {
     // Get the name
     int success = NCFUNC(inq_attname)(fileId, var_id, i, dum_name);
-    ERRORS(success, "Trouble getting attribute name.");
+    if (success)
+      SET_ERR(MB_FAILURE, "Trouble getting attribute name");
 
     AttData &data = atts[std::string(dum_name)];
     data.attName = std::string(dum_name);
     success = NCFUNC(inq_att)(fileId, var_id, dum_name, &data.attDataType, &data.attLen);
-    ERRORS(success, "Trouble getting attribute info.");
+    if (success)
+      SET_ERR(MB_FAILURE, "Trouble getting attribute info");
     data.attVarId = var_id;
 
     dbgOut.tprintf(2, "%sAttribute %s: length=%u, varId=%d, type=%d\n", (prefix ? prefix : ""), data.attName.c_str(),
@@ -381,11 +374,11 @@ ErrorCode ReadNC::get_dimensions(int file_id, std::vector<std::string>& dim_name
   // Get the number of dimensions
   int num_dims;
   int success = NCFUNC(inq_ndims)(file_id, &num_dims);
-  ERRORS(success, "Trouble getting number of dimensions.");
+  if (success)
+    SET_ERR(MB_FAILURE, "Trouble getting number of dimensions");
 
   if (num_dims > NC_MAX_DIMS) {
-    readMeshIface->report_error("ReadNC: File contains %d dims but NetCDF library supports only %d\n", num_dims, (int) NC_MAX_DIMS);
-    return MB_FAILURE;
+    SET_ERR_STR(MB_FAILURE, "ReadNC: File contains " << num_dims << " dims but NetCDF library supports only " << NC_MAX_DIMS);
   }
 
   char dim_name[NC_MAX_NAME + 1];
@@ -395,7 +388,8 @@ ErrorCode ReadNC::get_dimensions(int file_id, std::vector<std::string>& dim_name
 
   for (int i = 0; i < num_dims; i++) {
     success = NCFUNC(inq_dim)(file_id, i, dim_name, &dim_len);
-    ERRORS(success, "Trouble getting dimension info.");
+    if (success)
+      SET_ERR(MB_FAILURE, "Trouble getting dimension info");
 
     dim_names[i] = std::string(dim_name);
     dim_lens[i] = dim_len;
@@ -422,11 +416,11 @@ ErrorCode ReadNC::get_variables()
   // Get the number of variables
   int num_vars;
   int success = NCFUNC(inq_nvars)(fileId, &num_vars);
-  ERRORS(success, "Trouble getting number of variables.");
+  if (success)
+    SET_ERR(MB_FAILURE, "Trouble getting number of variables");
 
   if (num_vars > NC_MAX_VARS) {
-    readMeshIface->report_error("ReadNC: File contains %d vars but NetCDF library supports only %d\n", num_vars, (int) NC_MAX_VARS);
-    return MB_FAILURE;
+    SET_ERR_STR(MB_FAILURE, "ReadNC: File contains " << num_vars << " vars but NetCDF library supports only " << NC_MAX_VARS);
   }
 
   char var_name[NC_MAX_NAME + 1];
@@ -435,7 +429,8 @@ ErrorCode ReadNC::get_variables()
   for (int i = 0; i < num_vars; i++) {
     // Get the name first, so we can allocate a map iterate for this var
     success = NCFUNC(inq_varname )(fileId, i, var_name);
-    ERRORS(success, "Trouble getting var name.");
+    if (success)
+      SET_ERR(MB_FAILURE, "Trouble getting var name");
     VarData &data = varInfo[std::string(var_name)];
     data.varName = std::string(var_name);
     data.varId = i;
@@ -443,26 +438,30 @@ ErrorCode ReadNC::get_variables()
 
     // Get the data type
     success = NCFUNC(inq_vartype)(fileId, i, &data.varDataType);
-    ERRORS(success, "Trouble getting variable data type.");
+    if (success)
+      SET_ERR(MB_FAILURE, "Trouble getting variable data type");
 
     // Get the number of dimensions, then the dimensions
     success = NCFUNC(inq_varndims)(fileId, i, &var_ndims);
-    ERRORS(success, "Trouble getting number of dims of a variable.");
+    if (success)
+      SET_ERR(MB_FAILURE, "Trouble getting number of dims of a variable");
     data.varDims.resize(var_ndims);
 
     success = NCFUNC(inq_vardimid)(fileId, i, &data.varDims[0]);
-    ERRORS(success, "Trouble getting variable dimensions.");
+    if (success)
+      SET_ERR(MB_FAILURE, "Trouble getting variable dimensions");
 
     // Finally, get the number of attributes, then the attributes
     success = NCFUNC(inq_varnatts)(fileId, i, &data.numAtts);
-    ERRORS(success, "Trouble getting number of dims of a variable.");
+    if (success)
+      SET_ERR(MB_FAILURE, "Trouble getting number of dims of a variable");
 
     // Print debug info here so attribute info comes afterwards
     dbgOut.tprintf(2, "Variable %s: Id=%d, numAtts=%d, datatype=%d, num_dims=%u\n", data.varName.c_str(), data.varId, data.numAtts,
         data.varDataType, (unsigned int) data.varDims.size());
 
     ErrorCode rval = get_attributes(i, data.numAtts, data.varAtts, "   ");
-    ERRORR(rval, "Trouble getting attributes for a variable.");
+    CHK_ERR1(rval, "Trouble getting attributes for a variable");
   }
 
   return MB_SUCCESS;

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list