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

tautges at mcs.anl.gov tautges at mcs.anl.gov
Tue Dec 14 14:55:06 CST 2010


Author: tautges
Date: 2010-12-14 14:55:05 -0600 (Tue, 14 Dec 2010)
New Revision: 4371

Modified:
   MOAB/trunk/src/io/ReadNC.cpp
Log:
Fixed problem with converting from float to double variable.  2d works now too.



Modified: MOAB/trunk/src/io/ReadNC.cpp
===================================================================
--- MOAB/trunk/src/io/ReadNC.cpp	2010-12-14 20:26:06 UTC (rev 4370)
+++ MOAB/trunk/src/io/ReadNC.cpp	2010-12-14 20:55:05 UTC (rev 4371)
@@ -268,7 +268,7 @@
   int djl = jlMax - jlMin + 1;
   int di = iMax - iMin + 1;
   int dj = jMax - jMin + 1;
-  assert(di == (int)ilVals.size() && dj == (int)jlVals.size() && 
+  assert(dil == (int)ilVals.size() && djl == (int)jlVals.size() && 
          (-1 == klMin || klMax-klMin+1 == (int)klVals.size()));
   for (kl = klMin; kl <= klMax; kl++) {
     k = kl - klMin;
@@ -280,7 +280,7 @@
         xc[pos] = ilVals[i];
         yc[pos] = jlVals[j];
         zc[pos] = (-1 == klMin ? 0.0 : klVals[k]);
-        *gid_data = kl*di*dj + jl*di + il + 1;
+        *gid_data = (-1 != kl ? kl*di*dj : 0) + jl*di + il + 1;
         gid_data++;
       }
     }
@@ -460,27 +460,32 @@
     case NC_BYTE:
     case NC_CHAR:
         success = NCFUNCA(get_vara_text)(fileId, var_data.varId, &dims[0], &counts[0], (char*)data);
+        ERRORS(success, "Failed to read char data.");
         break;
     case NC_DOUBLE:
         success = NCFUNCA(get_vara_double)(fileId, var_data.varId, &dims[0], &counts[0], (double*)data);
+        ERRORS(success, "Failed to read double data.");
         break;
     case NC_FLOAT:
         success = NCFUNCA(get_vara_float)(fileId, var_data.varId, &dims[0], &counts[0], (float*)data);
+        ERRORS(success, "Failed to read float data.");
         ddata = (double*)data;
         fdata = (float*)data;
           // convert in-place
-        for (unsigned int i = verts.size(); i > 0; i--) 
+        for (int i = verts.size()-1; i >= 0; i--) 
           ddata[i] = fdata[i];
         break;
     case NC_INT:
         success = NCFUNCA(get_vara_int)(fileId, var_data.varId, &dims[0], &counts[0], (int*)data);
+        ERRORS(success, "Failed to read int data.");
         break;
     case NC_SHORT:
         success = NCFUNCA(get_vara_short)(fileId, var_data.varId, &dims[0], &counts[0], (short*)data);
+        ERRORS(success, "Failed to read short data.");
         idata = (int*)data;
         sdata = (short*)data;


More information about the moab-dev mailing list