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

iulian at mcs.anl.gov iulian at mcs.anl.gov
Fri Nov 16 10:50:23 CST 2012


Author: iulian
Date: 2012-11-16 10:50:22 -0600 (Fri, 16 Nov 2012)
New Revision: 5870

Modified:
   MOAB/trunk/src/io/ReadNC.cpp
Log:
do not read dimensions that are not variables
(so filter the list of dimension names, to include only the dimensions that are 
variables, too, in the create_tags method.)
This is called only for NOMESH and no variables option

Also, create an additional sparse tag, with the dimension values, in this
scenario


Modified: MOAB/trunk/src/io/ReadNC.cpp
===================================================================
--- MOAB/trunk/src/io/ReadNC.cpp	2012-11-16 01:06:34 UTC (rev 5869)
+++ MOAB/trunk/src/io/ReadNC.cpp	2012-11-16 16:50:22 UTC (rev 5870)
@@ -219,8 +219,14 @@
       return rval;
   }
   else {
-    // read dimension variable by default
-    rval = read_variables(tmp_set, dimNames, tstep_nums);
+    // read dimension variable by default, the ones that are also variables
+    std::vector<std::string> filteredDimNames;
+    for (unsigned int i = 0; i < dimNames.size(); i++) {
+      std::map<std::string, VarData>::iterator mit = varInfo.find(dimNames[i]);
+      if (mit != varInfo.end())
+        filteredDimNames.push_back(dimNames[i]);
+    }
+    rval = read_variables(tmp_set, filteredDimNames, tstep_nums);
     if (MB_FAILURE == rval)
       return rval;
   }
@@ -3202,6 +3208,20 @@
   if (MB_SUCCESS == rval)
     dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
 
+  // <__DIM_VALUES>
+  Tag dimValsTag = 0;
+  tag_name = "__DIM_VALUES";
+  //std::vector<int> dim;
+  int dimValsSz = (int)dimVals.size();
+
+  rval = mbImpl->tag_get_handle(tag_name.c_str(), 0, MB_TYPE_INTEGER, dimValsTag, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN);
+  ERRORR(rval, "Trouble creating __DIM_VALUES tag.");
+  ptr = &(dimVals[0]);
+  rval = mbImpl->tag_set_by_ptr(dimValsTag, &file_set, 1, &ptr, &dimValsSz);
+  ERRORR(rval, "Trouble setting data for __DIM_VALUES tag.");
+  if (MB_SUCCESS == rval)
+    dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
+
   // <__VAR_NAMES>
   Tag varNamesTag = 0;
   tag_name = "__VAR_NAMES";



More information about the moab-dev mailing list