[MOAB-dev] commit/MOAB: danwu: If a non-set variable of MPAS (or GCRM) has no level dimension (so numLev is still 0), we should set numLev to 1, otherwise the variable size will be calculated as 0.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri May 9 23:24:43 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/1a3f3a2c6102/
Changeset:   1a3f3a2c6102
Branch:      master
User:        danwu
Date:        2014-05-10 06:24:31
Summary:     If a non-set variable of MPAS (or GCRM) has no level dimension (so numLev is still 0), we should set numLev to 1, otherwise the variable size will be calculated as 0.

Affected #:  4 files

diff --git a/src/io/NCHelperGCRM.cpp b/src/io/NCHelperGCRM.cpp
index 3bddecc..f61cca5 100644
--- a/src/io/NCHelperGCRM.cpp
+++ b/src/io/NCHelperGCRM.cpp
@@ -515,8 +515,10 @@ ErrorCode NCHelperGCRM::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC:
         break;
     }
 
-    // Finally: nVertLevels or other optional levels, it is possible that there
-    // is no level dimension for this non-set variable
+    // Finally: layers or other optional levels, it is possible that there is no
+    // level dimension (numLev is 0) for this non-set variable
+    if (vdatas[i].numLev < 1)
+      vdatas[i].numLev = 1;
     vdatas[i].readStarts[2] = 0;
     vdatas[i].readCounts[2] = vdatas[i].numLev;
 

diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index 4630216..5c964b9 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -604,6 +604,8 @@ ErrorCode NCHelperMPAS::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC:
 
     // Finally: nVertLevels or other optional levels, it is possible that there is no
     // level dimension (numLev is 0) for this non-set variable, e.g. (Time, nCells)
+    if (vdatas[i].numLev < 1)
+      vdatas[i].numLev = 1;
     vdatas[i].readStarts[2] = 0;
     vdatas[i].readCounts[2] = vdatas[i].numLev;
 

diff --git a/src/io/NCWriteGCRM.cpp b/src/io/NCWriteGCRM.cpp
index c449a67..d1a7aaf 100644
--- a/src/io/NCWriteGCRM.cpp
+++ b/src/io/NCWriteGCRM.cpp
@@ -216,15 +216,17 @@ ErrorCode NCWriteGCRM::collect_variable_data(std::vector<std::string>& var_names
           ERRORR(MB_FAILURE, "Unexpected entity location type for GCRM non-set variable.");
       }
 
-      // Finally: nVertLevels or other optional levels, it is possible that there
-      // is no level dimension for this non-set variable
+      // Finally: layers or other optional levels, it is possible that there is no
+      // level dimension (numLev is 0) for this non-set variable
+      if (currentVarData.numLev < 1)
+        currentVarData.numLev = 1;
       currentVarData.writeStarts[2] = 0;
       currentVarData.writeCounts[2] = currentVarData.numLev;
     }
 
     // Get variable size
     currentVarData.sz = 1;
-    for (std::size_t idx = 0; idx != currentVarData.writeCounts.size(); idx++)
+    for (std::size_t idx = 0; idx != 3; idx++)
       currentVarData.sz *= currentVarData.writeCounts[idx];
   }
 

diff --git a/src/io/NCWriteMPAS.cpp b/src/io/NCWriteMPAS.cpp
index 0665425..ac0f70a 100644
--- a/src/io/NCWriteMPAS.cpp
+++ b/src/io/NCWriteMPAS.cpp
@@ -216,15 +216,17 @@ ErrorCode NCWriteMPAS::collect_variable_data(std::vector<std::string>& var_names
           ERRORR(MB_FAILURE, "Unexpected entity location type for MPAS non-set variable.");
       }
 
-      // Finally: nVertLevels or other optional levels, it is possible that there
-      // is no level dimension for this non-set variable
+      // Finally: nVertLevels or other optional levels, it is possible that there is no
+      // level dimension (numLev is 0) for this non-set variable, e.g. (Time, nCells)
+      if (currentVarData.numLev < 1)
+        currentVarData.numLev = 1;
       currentVarData.writeStarts[2] = 0;
       currentVarData.writeCounts[2] = currentVarData.numLev;
     }
 
     // Get variable size
     currentVarData.sz = 1;
-    for (std::size_t idx = 0; idx != currentVarData.writeCounts.size(); idx++)
+    for (std::size_t idx = 0; idx != 3; idx++)
       currentVarData.sz *= currentVarData.writeCounts[idx];
   }

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