[MOAB-dev] commit/MOAB: danwu: Updated NC writer to handle some GCRM variables without default level dimension (i.e. layers). Failed NC writer unit test should pass now.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jun 2 12:17:55 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/1a4fcfb9f6ee/
Changeset:   1a4fcfb9f6ee
Branch:      master
User:        danwu
Date:        2014-06-02 19:17:44
Summary:     Updated NC writer to handle some GCRM variables without default level dimension (i.e. layers). Failed NC writer unit test should pass now.

Affected #:  1 file

diff --git a/src/io/NCWriteGCRM.cpp b/src/io/NCWriteGCRM.cpp
index 1f9bb97..b80d90a 100644
--- a/src/io/NCWriteGCRM.cpp
+++ b/src/io/NCWriteGCRM.cpp
@@ -123,6 +123,21 @@ ErrorCode NCWriteGCRM::collect_variable_data(std::vector<std::string>& var_names
 {
   NCWriteHelper::collect_variable_data(var_names, tstep_nums);
 
+  std::vector<std::string>& dimNames = _writeNC->dimNames;
+  std::vector<int>& dimLens = _writeNC->dimLens;
+
+  // Dimension indices for other optional levels
+  std::vector<unsigned int> opt_lev_dims;
+
+  unsigned int lev_idx;
+  std::vector<std::string>::iterator vecIt;
+
+  // Get index of interface levels
+  if ((vecIt = std::find(dimNames.begin(), dimNames.end(), "interfaces")) != dimNames.end()) {
+    lev_idx = vecIt - dimNames.begin();
+    opt_lev_dims.push_back(lev_idx);
+  }
+
   std::map<std::string, WriteNC::VarData>& varInfo = _writeNC->varInfo;
 
   for (size_t i = 0; i < var_names.size(); i++) {
@@ -132,14 +147,22 @@ ErrorCode NCWriteGCRM::collect_variable_data(std::vector<std::string>& var_names
       ERRORR(MB_FAILURE, "Can't find one variable.");
 
     WriteNC::VarData& currentVarData = vit->second;
-#ifndef NDEBUG
     std::vector<int>& varDims = currentVarData.varDims;
-#endif
 
     // Skip edge variables, if there are no edges
     if (localEdgesOwned.empty() && currentVarData.entLoc == WriteNC::ENTLOCEDGE)
       continue;
 
+    // If layers dimension is not found, try other optional levels such as interfaces
+    if (std::find(varDims.begin(), varDims.end(), levDim) == varDims.end()) {
+      for (unsigned int j = 0; j < opt_lev_dims.size(); j++) {
+        if (std::find(varDims.begin(), varDims.end(), opt_lev_dims[j]) != varDims.end()) {
+          currentVarData.numLev = dimLens[opt_lev_dims[j]];
+          break;
+        }
+      }
+    }
+
     // Skip set variables, which were already processed in NCWriteHelper::collect_variable_data()
     if (WriteNC::ENTLOCSET == currentVarData.entLoc)
       continue;

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