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

iulian at mcs.anl.gov iulian at mcs.anl.gov
Fri Nov 9 12:10:27 CST 2012


Author: iulian
Date: 2012-11-09 12:10:27 -0600 (Fri, 09 Nov 2012)
New Revision: 5859

Modified:
   MOAB/trunk/src/io/ReadNC.cpp
Log:
in case of Homme grids, add a tag name ncol, even though we do not have
a variable with this name
We do have dimensions with this name
this is a temporary solution;


Modified: MOAB/trunk/src/io/ReadNC.cpp
===================================================================
--- MOAB/trunk/src/io/ReadNC.cpp	2012-11-08 16:35:46 UTC (rev 5858)
+++ MOAB/trunk/src/io/ReadNC.cpp	2012-11-09 18:10:27 UTC (rev 5859)
@@ -1200,9 +1200,6 @@
     else {
       for (unsigned int i = 0; i < var_names.size(); i++) {
 
-        if (var_names[i] == "ncol")
-          continue;
-
         mit = varInfo.find(var_names[i]);
         if (mit != varInfo.end()) {
           VarData vd = (*mit).second;
@@ -1568,6 +1565,8 @@
   int success;
   std::vector<int> requests(vdatas.size() * tstep_nums.size()), statuss(vdatas.size() * tstep_nums.size());
   for (unsigned int i = 0; i < vdatas.size(); i++) {
+	  if (vdatas[i].varName=="ncol" )
+		  continue;// this is a dummy one, we don't have it; we created it for the dummy tag
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       void *data = vdatas[i].varDatas[t];
 
@@ -2958,6 +2957,24 @@
 
   std::copy(gDims, gDims + 6, lDims);
 
+  // create a dummy tag called ncol, filled with completely dummy data;
+  // we will need just the name of the tag, in the end; need to fix this in the client
+  {
+    int sizeTotalVar = varInfo.size();
+    std::string var_name("ncol");
+    VarData &data = varInfo[var_name];
+    data.varName = std::string(var_name);
+    data.varId =sizeTotalVar;
+    data.varTags.resize(1, 0);
+    data.varDataType = NC_DOUBLE;
+    data.varDims.resize(1);
+    std::vector<std::string>::iterator vit = std::find(dimNames.begin(), dimNames.end(), "ncol");
+    if (vit == dimNames.end())
+      ERRORR(MB_FAILURE, "Trouble hacking ncol.");
+    data.varDims[0]= (int)(vit - dimNames.begin());
+    data.numAtts=0;
+
+  }
   // don't read coordinates of columns until we actually create the mesh
   return MB_SUCCESS;
 }



More information about the moab-dev mailing list