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

iulian at mcs.anl.gov iulian at mcs.anl.gov
Sat Sep 29 13:44:46 CDT 2012


Author: iulian
Date: 2012-09-29 13:44:46 -0500 (Sat, 29 Sep 2012)
New Revision: 5762

Modified:
   MOAB/trunk/src/io/ReadNC.cpp
Log:
correct reading data to set; new double[] bug too


Modified: MOAB/trunk/src/io/ReadNC.cpp
===================================================================
--- MOAB/trunk/src/io/ReadNC.cpp	2012-09-28 14:41:33 UTC (rev 5761)
+++ MOAB/trunk/src/io/ReadNC.cpp	2012-09-29 18:44:46 UTC (rev 5762)
@@ -1222,8 +1222,7 @@
   ErrorCode rval = MB_SUCCESS;
 
   for (unsigned int i = 0; i < vdatas.size(); ++i) {
-    if ((std::find(vdatas[i].varDims.begin(), vdatas[i].varDims.end(), tDim) != vdatas[i].varDims.end())
-        && (vdatas[i].varDims.size() != 1))
+    if ((std::find(vdatas[i].varDims.begin(), vdatas[i].varDims.end(), tDim) != vdatas[i].varDims.end()))
       vdatas[i].has_t = true;
 
     for (unsigned int t = 0; t < tstep_nums.size(); ++t) {
@@ -1240,9 +1239,20 @@
         ERRORR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number.");
 
       // set up the dimensions and counts
-      // first time
-      vdatas[i].readDims[t].push_back(tstep_nums[t]);
-      vdatas[i].readCounts[t].push_back(1);
+      // first variable dimension is time, if it exists
+      if (vdatas[i].has_t)
+      {
+        if (vdatas[i].varDims.size() != 1)
+        {
+          vdatas[i].readDims[t].push_back(tstep_nums[t]);
+          vdatas[i].readCounts[t].push_back(1);
+        }
+        else
+        {
+          vdatas[i].readDims[t].push_back(0);
+          vdatas[i].readCounts[t].push_back(tstep_nums.size());
+        }
+      }
 
       // set up other dimensions and counts
       if (vdatas[i].varDims.empty()) {
@@ -1251,9 +1261,12 @@
         vdatas[i].readCounts[t].push_back(1);
       }
       else {
-        for (unsigned int idx = 0; idx != vdatas[i].varDims.size(); ++idx) {
-          vdatas[i].readDims[t].push_back(0);
-          vdatas[i].readCounts[t].push_back(dimVals[vdatas[i].varDims[idx]]);
+        for (unsigned int idx = 0; idx != vdatas[i].varDims.size(); ++idx){
+          if (tDim != vdatas[i].varDims[idx]){
+            // push other variable dimensions, except time, which was already pushed
+            vdatas[i].readDims[t].push_back(0);
+            vdatas[i].readCounts[t].push_back(dimVals[vdatas[i].varDims[idx]]);
+          }


More information about the moab-dev mailing list