[MOAB-dev] commit/MOAB: danwu: Refined some error messages in NCHelper.cpp

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Mar 18 13:21:41 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/8cb7d48b2608/
Changeset:   8cb7d48b2608
Branch:      error_handling_enhancement
User:        danwu
Date:        2014-03-18 19:21:22
Summary:     Refined some error messages in NCHelper.cpp

Affected #:  1 file

diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index 58e9e16..eccb43f 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -69,22 +69,22 @@ 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); \
-  CHK_ERR1(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); \
-  CHK_ERR1(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());
+    dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
 
   // <__NUM_VARS>
   Tag numVarsTag = 0;
   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); \
-  CHK_ERR1(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); \
-  CHK_ERR1(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());
+    dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
 
   // <__DIM_NAMES>
   Tag dimNamesTag = 0;
@@ -97,24 +97,24 @@ 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); \
-  CHK_ERR1(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); \
-  CHK_ERR1(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());
+    dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
 
   // <__DIM_LENS>
   Tag dimLensTag = 0;
   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); \
-  CHK_ERR1(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); \
-  CHK_ERR1(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());
+    dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
 
   // <__VAR_NAMES>
   Tag varNamesTag = 0;
@@ -127,12 +127,12 @@ 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); \
-  CHK_ERR1(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); \
-  CHK_ERR1(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());
+    dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
 
   // __<dim_name>_LOC_MINMAX (for time)
   for (unsigned int i = 0; i != dimNamesSz; i++) {
@@ -145,11 +145,11 @@ 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); \
-      CHK_ERR1(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]); \
-      CHK_ERR1(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());
+        dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
     }
   }
 
@@ -169,11 +169,11 @@ 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); \
-      CHK_ERR1(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]); \
-      CHK_ERR1(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());
+        dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
     }
   }
 
@@ -194,37 +194,35 @@ ErrorCode NCHelper::create_conventional_tags(const std::vector<int>& tstep_nums)
       varInfo[mapIter->first].varTags[i] = tmptag;
     }
     rval = mbImpl->tag_get_handle(tag_name.c_str(), varDimSz, MB_TYPE_HANDLE, varNamesDimsTag, MB_TAG_SPARSE | MB_TAG_CREAT); \
-    CHK_ERR1(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, &(varInfo[mapIter->first].varTags[0])); \
-    CHK_ERR1(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());
+      dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
   }
 
   // <PARTITION_METHOD>
   Tag part_tag = scdi->part_method_tag();
   if (!part_tag)
-    SET_ERR(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); \
   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());
 
   // <__GLOBAL_ATTRIBS>
   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); \
-  CHK_ERR1(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); \
-  CHK_ERR1(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); \
-  CHK_ERR1(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());
+    dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
 
   // <__GLOBAL_ATTRIBS_LEN>
   tag_name = "__GLOBAL_ATTRIBS_LEN";
@@ -232,11 +230,11 @@ 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); \
-  CHK_ERR1(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]); \
-  CHK_ERR1(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());
+    dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
 
   // __<var_name>_ATTRIBS and __<var_name>_ATTRIBS_LEN
   for (mapIter = varInfo.begin(); mapIter != varInfo.end(); ++mapIter) {
@@ -245,28 +243,29 @@ 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); \
-    CHK_ERR1(rval, "Trouble creating __<var_name>_ATTRIBS tag");
+    CHK_ERR1_STR(rval, "Trouble creating conventional tag " << tag_name);
     std::string varAttVal;
     std::vector<int> varAttLen;
     rval = create_attrib_string(mapIter->second.varAtts, varAttVal, varAttLen); \
-    CHK_ERR1(rval, "Trouble creating attribute strings");
+    CHK_ERR1_STR(rval, "Trouble creating attribute string for variable " << mapIter->first);
     const void* varAttPtr = varAttVal.c_str();
     int varAttSz = varAttVal.size();
     rval = mbImpl->tag_set_by_ptr(varAttTag, &_fileSet, 1, &varAttPtr, &varAttSz); \
-    CHK_ERR1(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());
+      dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
+
     if (varAttLen.size() == 0)
       varAttLen.push_back(0);
     ssTagName << "_LEN";
     tag_name = ssTagName.str();
     Tag varAttLenTag = 0;
     rval = mbImpl->tag_get_handle(tag_name.c_str(), varAttLen.size(), MB_TYPE_INTEGER, varAttLenTag, MB_TAG_SPARSE | MB_TAG_CREAT); \
-    CHK_ERR1(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]); \
-    CHK_ERR1(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());
+      dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
   }
 
   // <__VAR_NAMES_LOCATIONS>
@@ -275,14 +274,14 @@ 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); \
-  CHK_ERR1(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]); \
-  CHK_ERR1(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());
+    dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
 
   // <__MESH_TYPE>
   Tag meshTypeTag = 0;
@@ -290,13 +289,13 @@ 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); \
-  CHK_ERR1(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); \
-  CHK_ERR1(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());
+    dbgOut.tprintf(2, "Conventional tag %s is created.\n", tag_name.c_str());
 
   return MB_SUCCESS;
 }
@@ -341,7 +340,7 @@ ErrorCode NCHelper::read_variables_setup(std::vector<std::string>& var_names, st
           vdatas.push_back(vd);
       }
       else {
-        SET_ERR_STR(MB_FAILURE, "Couldn't find variable " << var_names[i]);
+        SET_ERR_STR(MB_FAILURE, "Couldn't find specified variable " << var_names[i]);
       }
     }
   }
@@ -392,13 +391,13 @@ ErrorCode NCHelper::read_variables_to_set(std::vector<ReadNC::VarData>& vdatas,
   // Finally, read into that space
   int success = 0;
   for (unsigned int i = 0; i < vdatas.size(); i++) {
-    // Note, for set variables without timesteps, loop one time and then break
+    // Note, for most set variables without timesteps, loop one time and then break
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       void* data = vdatas[i].varDatas[t];
 
-      // Set variables with timesteps, e.g. xtime(Time, StrLen)
+      // Rare case: set variables with timesteps, e.g. xtime(Time, StrLen)
       if (vdatas[i].has_tsteps) {
-        // Set readStart for each timestep along time dimension
+        // Set up readStart for each timestep along time dimension
         vdatas[i].readStarts[0] = tstep_nums[t];
       }
 
@@ -408,43 +407,43 @@ ErrorCode NCHelper::read_variables_to_set(std::vector<ReadNC::VarData>& vdatas,
           success = NCFUNCAG(_vara_text)(_fileId, vdatas[i].varId, &vdatas[i].readStarts[0],
                                         &vdatas[i].readCounts[0], (char*) data);
           if (success)
-            SET_ERR(MB_FAILURE, "Failed to read char data");
+            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);
           if (success)
-            SET_ERR(MB_FAILURE, "Failed to read double data");
+            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);
           if (success)
-            SET_ERR(MB_FAILURE, "Failed to read float data");
+            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);
           if (success)
-            SET_ERR(MB_FAILURE, "Failed to read int data");
+            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);
           if (success)
-            SET_ERR(MB_FAILURE, "Failed to read short data");
+            SET_ERR_STR(MB_FAILURE, "Failed to read short data for set variable " << vdatas[i].varName);
           break;
         default:
           SET_ERR_STR(MB_FAILURE, "Unrecognized data type for set variable " << vdatas[i].varName);
       }
 
-      dbgOut.tprintf(2, "Converting variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
+      dbgOut.tprintf(2, "Converting set variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
       rval = convert_variable(vdatas[i], t); \
-      CHK_ERR1(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]);
+      dbgOut.tprintf(2, "Setting tag data for set 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); \
-      CHK_ERR1(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) {
@@ -465,7 +464,7 @@ ErrorCode NCHelper::read_variables_to_set(std::vector<ReadNC::VarData>& vdatas,
       }
       vdatas[i].varDatas[t] = NULL;
 
-      // Loop continues only for set variables with timesteps, e.g. xtime(Time, StrLen)
+      // Note, loop continues only for set variables with timesteps, e.g. xtime(Time, StrLen)
       if (!vdatas[i].has_tsteps)
         break;
     }
@@ -473,7 +472,7 @@ ErrorCode NCHelper::read_variables_to_set(std::vector<ReadNC::VarData>& vdatas,
 
   // Debug output, if requested
   if (1 == dbgOut.get_verbosity()) {
-    dbgOut.printf(1, "Read variables: %s", vdatas.begin()->varName.c_str());
+    dbgOut.printf(1, "Read set variables: %s", vdatas.begin()->varName.c_str());
     for (unsigned int i = 1; i < vdatas.size(); i++)
       dbgOut.printf(1, ", %s ", vdatas[i].varName.c_str());
     dbgOut.tprintf(1, "\n");
@@ -565,7 +564,7 @@ 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) {
-    SET_ERR_STR(MB_FAILURE, "Couldn't find variable " << var_name);
+    SET_ERR_STR(MB_FAILURE, "Couldn't find coordinate variable " << var_name);
   }
 
   assert(lmin >= 0 && lmax >= lmin);
@@ -582,17 +581,17 @@ ErrorCode NCHelper::read_coordinate(const char* var_name, int lmin, int lmax, st
   if (NC_DOUBLE == (*vmit).second.varDataType) {
     success = NCFUNCAG(_vars_double)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &cvals[0]);
     if (success)
-      SET_ERR(MB_FAILURE, "Failed to get coordinate values");
+      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);
     success = NCFUNCAG(_vars_float)(_fileId, (*vmit).second.varId, &tstart, &tcount, &dum_stride, &tcvals[0]);
     if (success)
-      SET_ERR(MB_FAILURE, "Failed to get coordinate values");
+      SET_ERR_STR(MB_FAILURE, "Failed to get float values for coordinate variable " << var_name);
     std::copy(tcvals.begin(), tcvals.end(), cvals.begin());
   }
   else {
-    SET_ERR(MB_FAILURE, "Wrong data type for coordinate variable");
+    SET_ERR_STR(MB_FAILURE, "Wrong data type for coordinate variable " << var_name);
   }
 
   return MB_SUCCESS;
@@ -625,11 +624,11 @@ 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:
-      SET_ERR_STR(MB_FAILURE, "Unrecognized data type for tag " << tag_name.str());
+      SET_ERR_STR(MB_FAILURE, "Unrecognized data type for set variable " << var_data.varName);
   }
 
   if (MB_SUCCESS == rval)
-    dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.str().c_str());
+    dbgOut.tprintf(2, "Tag %s is created for set variable %s.\n", tag_name.str().c_str(), var_data.varName.c_str());
 
   return rval;
 }
@@ -658,11 +657,11 @@ 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:
-      SET_ERR_STR(MB_FAILURE, "Unrecognized data type for tag " << tag_name.str());
+      SET_ERR_STR(MB_FAILURE, "Unrecognized data type for non-set variable " << var_data.varName);
   }
 
   if (MB_SUCCESS == rval)
-    dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.str().c_str());
+    dbgOut.tprintf(2, "Tag %s is created for non-set variable %s.\n", tag_name.str().c_str(), var_data.varName.c_str());
 
   return rval;
 }
@@ -684,7 +683,7 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
         attData = (char *) malloc(sz);
         success = NCFUNC(get_att_text)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (char*) attData);
         if (success)
-          SET_ERR(MB_FAILURE, "Failed to read attribute char data");
+          SET_ERR_STR(MB_FAILURE, "Failed to read char data for attribute " << attIt->second.attName);
         ssAtt << "char;";
         break;
       case NC_DOUBLE:
@@ -692,7 +691,7 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
         attData = (double *) malloc(sz);
         success = NCFUNC(get_att_double)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (double*) attData);
         if (success)
-          SET_ERR(MB_FAILURE, "Failed to read attribute double data");
+          SET_ERR_STR(MB_FAILURE, "Failed to read double data for attribute " << attIt->second.attName);
         ssAtt << "double;";
         break;
       case NC_FLOAT:
@@ -700,7 +699,7 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
         attData = (float *) malloc(sz);
         success = NCFUNC(get_att_float)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (float*) attData);
         if (success)
-          SET_ERR(MB_FAILURE, "Failed to read attribute float data");
+          SET_ERR_STR(MB_FAILURE, "Failed to read float data for attribute " << attIt->second.attName);
         ssAtt << "float;";
         break;
       case NC_INT:
@@ -708,7 +707,7 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
         attData = (int *) malloc(sz);
         success = NCFUNC(get_att_int)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (int*) attData);
         if (success)
-          SET_ERR(MB_FAILURE, "Failed to read attribute int data");
+          SET_ERR_STR(MB_FAILURE, "Failed to read int data for attribute " << attIt->second.attName);
         ssAtt << "int;";
         break;
       case NC_SHORT:
@@ -716,7 +715,7 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
         attData = (short *) malloc(sz);
         success = NCFUNC(get_att_short)(_fileId, attIt->second.attVarId, attIt->second.attName.c_str(), (short*) attData);
         if (success)
-          SET_ERR(MB_FAILURE, "Failed to read attribute short data");
+          SET_ERR_STR(MB_FAILURE, "Failed to read short data for attribute " << attIt->second.attName);
         ssAtt << "short;";
         break;
       default:
@@ -754,7 +753,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;
@@ -762,23 +761,23 @@ 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 variable created for dimension %s\n", dimNames[i].c_str());
+    dummyVarNames.insert(var_name);
+    dbgOut.tprintf(2, "Dummy 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); \
-    CHK_ERR1(rval, "Failed to create tag for a dummy dimension variable");
+    CHK_ERR1_STR(rval, "Failed to create tag for dimension " << 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); \
-    CHK_ERR1(rval, "Failed to set data for dimension tag");
+    CHK_ERR1_STR(rval, "Failed to set tag data for dimension " << var_name);
 
-    dbgOut.tprintf(2, "Sparse tag created for dimension %s\n", dimNames[i].c_str());
+    dbgOut.tprintf(2, "Sparse tag is created for dimension %s\n", var_name.c_str());
   }
 
   return MB_SUCCESS;
@@ -825,16 +824,16 @@ ErrorCode NCHelper::read_variables_to_set_allocate(std::vector<ReadNC::VarData>&
 
     // Note, for set variables without timesteps, loop one time and then break
     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]);
+      dbgOut.tprintf(2, "Reading set variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
 
       if (tstep_nums[t] >= dimLens[tDim]) {
-        SET_ERR(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]); \
-        CHK_ERR1(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) {
@@ -851,10 +850,10 @@ ErrorCode NCHelper::read_variables_to_set_allocate(std::vector<ReadNC::VarData>&
           vdatas[i].varDatas[t] = new int[vdatas[i].sz];
           break;
         default:
-          SET_ERR_STR(MB_FAILURE, "Unrecognized data type for tag values of set variable " << vdatas[i].varName);
+          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, StrLen)
+      // Note, loop continues only for set variables with timesteps, e.g. xtime(Time, StrLen)
       if (!vdatas[i].has_tsteps)
         break;
     }
@@ -1007,21 +1006,19 @@ ErrorCode ScdNCHelper::read_variables(std::vector<std::string>& var_names, std::
   std::vector<ReadNC::VarData> vsetdatas;
 
   ErrorCode rval = read_variables_setup(var_names, tstep_nums, vdatas, vsetdatas); \
-  CHK_ERR1(rval, "Trouble setting up read variable");
+  CHK_ERR1(rval, "Trouble setting up to read variables");
 
-  // Create COORDS tag for quads
   rval = create_quad_coordinate_tag(); \
-  CHK_ERR1(rval, "Trouble creating coordinate tags to entities quads");
+  CHK_ERR1(rval, "Trouble creating COORDS tag for quads");
 
   if (!vsetdatas.empty()) {
     rval = read_variables_to_set(vsetdatas, tstep_nums); \
-    CHK_ERR1(rval, "Trouble read variables to set");
+    CHK_ERR1(rval, "Trouble reading variables to set");
   }
 
   if (!vdatas.empty()) {
-    rval = read_scd_variables_to_nonset(vdatas, tstep_nums);
-    if (MB_SUCCESS != rval)
-      SET_ERR(rval, "Trouble reading 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;
@@ -1098,7 +1095,7 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
         break;
       case ReadNC::ENTLOCNSEDGE:
       case ReadNC::ENTLOCEWEDGE:
-        SET_GLB_ERR(MB_NOT_IMPLEMENTED, "Reading edge data not implemented yet");
+        SET_GLB_ERR(MB_NOT_IMPLEMENTED, "Reading edge data is not implemented yet");
       case ReadNC::ENTLOCFACE:
         // Faces
         vdatas[i].readStarts[2] = lCDims[1];
@@ -1115,27 +1112,27 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
         // Set
         break;
       default:
-        SET_ERR(MB_FAILURE, "Unrecognized entity location type");
+        SET_ERR_STR(MB_FAILURE, "Unrecognized 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]);
+      dbgOut.tprintf(2, "Reading non-set variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
 
       if (tstep_nums[t] >= dimLens[tDim]) {
-        SET_ERR(MB_INDEX_OUT_OF_RANGE, "Wrong value for a timestep number");
+        SET_ERR_STR(MB_INDEX_OUT_OF_RANGE, "Wrong value for a 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); \
-        CHK_ERR1(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); \
-      CHK_ERR1(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;
     }
@@ -1180,75 +1177,75 @@ ErrorCode ScdNCHelper::read_scd_variables_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];
           }
-          if (success)
-            SET_ERR(MB_FAILURE, "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];
           }
-          if (success)
-            SET_ERR(MB_FAILURE, "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];
           }
-          if (success)
-            SET_ERR(MB_FAILURE, "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];
           }
-          if (success)
-            SET_ERR(MB_FAILURE, "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];
           }
-          if (success)
-            SET_ERR(MB_FAILURE, "Failed to read short data");
           break;
         }
         default:
@@ -1259,14 +1256,15 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset(std::vector<ReadNC::VarData>
 
   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]);
-      rval = convert_variable(vdatas[i], t);CHK_ERR(rval);
+      dbgOut.tprintf(2, "Converting non-set variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
+      rval = convert_variable(vdatas[i], t); \
+      CHK_ERR1_STR(rval, "Failed to convert non-set variable " << vdatas[i].varName);
     }
   }
 
   // Debug output, if requested
   if (1 == dbgOut.get_verbosity()) {
-    dbgOut.printf(1, "Read variables: %s", vdatas.begin()->varName.c_str());
+    dbgOut.printf(1, "Read non-set variables: %s", vdatas.begin()->varName.c_str());
     for (unsigned int i = 1; i < vdatas.size(); i++)
       dbgOut.printf(1, ", %s ", vdatas[i].varName.c_str());
     dbgOut.tprintf(1, "\n");
@@ -1280,7 +1278,7 @@ ErrorCode ScdNCHelper::create_quad_coordinate_tag() {
 
   Range ents;
   ErrorCode rval = mbImpl->get_entities_by_type(_fileSet, moab::MBQUAD, ents); \
-  CHK_ERR1(rval, "Trouble getting QUAD entity");
+  CHK_ERR1(rval, "Trouble getting quads");
 
   std::size_t numOwnedEnts = 0;
 #ifdef USE_MPI
@@ -1289,7 +1287,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); \
-    CHK_ERR1(rval, "Trouble getting owned QUAD entity");
+    CHK_ERR1(rval, "Trouble getting owned quads");
     numOwnedEnts = ents_owned.size();
   }
   else {
@@ -1323,10 +1321,10 @@ ErrorCode ScdNCHelper::create_quad_coordinate_tag() {
   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");
+  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");
+  CHK_ERR1(rval, "Failed to get COORDS tag iterator on quads");
 #endif
   assert(count == (int)numOwnedEnts);
   double* quad_data = (double*) data;
@@ -1352,11 +1350,11 @@ ErrorCode UcdNCHelper::read_variables(std::vector<std::string>& var_names, std::
 #ifdef PNETCDF_FILE
     // With pnetcdf support, we will use async read
     rval = read_ucd_variables_to_nonset_async(vdatas, tstep_nums); \
-    CHK_ERR1(rval, "Trouble reading variables to entities verts/edges/faces");
+    CHK_ERR1(rval, "Trouble reading variables to verts/edges/faces");
 #else
     // Without pnetcdf support, we will use old read
     rval = read_ucd_variables_to_nonset(vdatas, tstep_nums); \
-    CHK_ERR1(rval, "Trouble reading variables to entities verts/edges/faces");
+    CHK_ERR1(rval, "Trouble reading variables to verts/edges/faces");
 #endif
   }

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