[MOAB-dev] commit/MOAB: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Nov 14 15:34:37 CST 2013


2 new commits in MOAB:

https://bitbucket.org/fathomteam/moab/commits/d7a5a2be5184/
Changeset:   d7a5a2be5184
Branch:      None
User:        tautges
Date:        2013-11-14 22:33:51
Summary:     Fix parallel_unit_test so it works for 4 procs as well as 2 (not all entities are only pairwise-shared).
Add an MPI_Finalize to scdtest in case of error.

Affected #:  2 files

diff --git a/test/parallel/parallel_unit_tests.cpp b/test/parallel/parallel_unit_tests.cpp
index 45ef1c5..85cc3b8 100644
--- a/test/parallel/parallel_unit_tests.cpp
+++ b/test/parallel/parallel_unit_tests.cpp
@@ -1447,8 +1447,10 @@ template <typename T> ErrorCode check_shared_ents(ParallelComm &pcomm, Tag tagh,
     if (1 == np && shprocs[0] != (int) pcomm.proc_config().proc_rank()) np++;
     if      (mpi_op == MPI_SUM) {if (dum_vals[i] != fact*np) return MB_FAILURE;}
     else if (mpi_op == MPI_PROD) {if (dum_vals[i] != pow(fact, np)) return MB_FAILURE;}
-    else if (mpi_op == MPI_MAX) {if (dum_vals[i] != fact) return MB_FAILURE;}
-    else if (mpi_op == MPI_MIN) {if (dum_vals[i] != fact) return MB_FAILURE;}
+    else if (mpi_op == MPI_MAX) {if (pcomm.rank() && std::find(&shprocs[0],&shprocs[np], 0) != &shprocs[np] &&
+                                     dum_vals[i] != fact) return MB_FAILURE;}
+    else if (mpi_op == MPI_MIN) {if (pcomm.rank() && std::find(&shprocs[0],&shprocs[np], 0) != &shprocs[np] &&
+                                     dum_vals[i] != fact) return MB_FAILURE;}
     else return MB_FAILURE;
   }
   

diff --git a/test/parallel/scdtest.cpp b/test/parallel/scdtest.cpp
index 3202621..5338b81 100644
--- a/test/parallel/scdtest.cpp
+++ b/test/parallel/scdtest.cpp
@@ -49,6 +49,7 @@ int main(int argc, char *argv[])
   MPI_Comm_size(MPI_COMM_WORLD, &size);
   if (size != 4 && size != 2) {
     cerr << "Run this with 2 or 4 processes\n";
+    MPI_Finalize();
     exit(1);
   }
 


https://bitbucket.org/fathomteam/moab/commits/7c37ce441fdd/
Changeset:   7c37ce441fdd
Branch:      master
User:        tautges
Date:        2013-11-14 22:34:11
Summary:     Merge branch 'master' of bitbucket.org:fathomteam/moab

Affected #:  8 files

diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index be91ef8..ebf149c 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -10,10 +10,10 @@
 #include "MBTagConventions.hpp"
 
 #define ERRORR(rval, str) \
-    if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
+  if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
 
 #define ERRORS(err, str) \
-    if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
+  if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
 
 namespace moab {
 
@@ -315,8 +315,10 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
     for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
       ReadNC::VarData vd = (*mit).second;
 
-      // This variable will not be read
-      if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end())
+      // No need to read ignored variables. Upon creation of dummy variables,
+      // tag values have already been set
+      if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end() ||
+          dummyVarNames.find(vd.varName) != dummyVarNames.end())
          continue;
 
       if (vd.entLoc == ReadNC::ENTLOCSET)
@@ -331,8 +333,10 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
       if (mit != varInfo.end()) {
         ReadNC::VarData vd = (*mit).second;
 
-        // This variable will not be read
-        if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end())
+        // No need to read ignored variables. Upon creation of dummy variables,
+        // tag values have already been set
+        if (ignoredVarNames.find(vd.varName) != ignoredVarNames.end() ||
+            dummyVarNames.find(vd.varName) != dummyVarNames.end())
            continue;
 
         if (vd.entLoc == ReadNC::ENTLOCSET)
@@ -382,7 +386,6 @@ ErrorCode NCHelper::read_variable_setup(std::vector<std::string>& var_names, std
 
 ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
-  std::set<std::string>& dummyVarNames = _readNC->dummyVarNames;
   Interface*& mbImpl = _readNC->mbImpl;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
@@ -392,11 +395,6 @@ ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, s
   // Finally, read into that space
   int success;
   for (unsigned int i = 0; i < vdatas.size(); i++) {
-    // This is a dummy variable for a dimension with no corresponding coordinate variable
-    // No need to set its tag data
-    if (dummyVarNames.find(vdatas[i].varName) != dummyVarNames.end())
-       continue;
-
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       void* data = vdatas[i].varDatas[t];
 
@@ -719,56 +717,63 @@ ErrorCode NCHelper::create_attrib_string(const std::map<std::string, ReadNC::Att
   return MB_SUCCESS;
 }
 
-void NCHelper::init_dims_with_no_coord_vars_info()
+ErrorCode NCHelper::create_dummy_variables()
 {
+  Interface*& mbImpl = _readNC->mbImpl;
   std::vector<std::string>& dimNames = _readNC->dimNames;
-  std::set<std::string>& dummyVarNames = _readNC->dummyVarNames;
+  std::vector<int>& dimLens = _readNC->dimLens;
   std::map<std::string, ReadNC::VarData>& varInfo = _readNC->varInfo;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
   // Hack: look at all dimensions, and see if we have one that does not appear in the list of varInfo names
-  // Right now, candidates are from unstructured meshes, such as ncol(HOMME) and nCells(MPAS)
-  // For them, create dummy tags
+  // Right now, candidates are from unstructured meshes, such as ncol (HOMME) and nCells (MPAS)
+  // For each of them, create a dummy variable with a sparse tag to store the dimension length
   for (unsigned int i = 0; i < dimNames.size(); i++) {
-    // If there is a variable with this dimension name, skip, we are fine; if not, create a dummy varInfo
+    // If there is a variable with this dimension name, skip
     if (varInfo.find(dimNames[i]) != varInfo.end())
       continue;
 
+    // Create a dummy variable
     int sizeTotalVar = varInfo.size();
     std::string var_name(dimNames[i]);
     ReadNC::VarData& data = varInfo[var_name];
     data.varName = std::string(var_name);
     data.varId = sizeTotalVar;
     data.varTags.resize(1, 0);
-    data.varDataType = NC_DOUBLE; // Could be int, actually, but we do not really need the type
+    data.varDataType = NC_INT;
     data.varDims.resize(1);
     data.varDims[0] = (int)i;
     data.numAtts = 0;
     data.entLoc = ReadNC::ENTLOCSET;
-    dbgOut.tprintf(2, "Dummy varInfo created for dimension %s\n", dimNames[i].c_str());
     dummyVarNames.insert(dimNames[i]);
+    dbgOut.tprintf(2, "Dummy variable created for dimension %s\n", dimNames[i].c_str());
+
+    // Create a sparse tag to store the dimension length
+    Tag tagh;
+    ErrorCode rval = mbImpl->tag_get_handle(dimNames[i].c_str(), 1, MB_TYPE_INTEGER, tagh,
+                                            MB_TAG_SPARSE | MB_TAG_CREAT | MB_TAG_EXCL);
+    // If the tag already exists, skip
+    if (MB_ALREADY_ALLOCATED == rval)
+      continue;
+    ERRORR(rval, "Failed to create dimension tag.");
+
+    rval = mbImpl->tag_set_data(tagh, &_fileSet, 1, &dimLens[i]);
+    ERRORR(rval, "Failed to set data for dimension tag.");
+
+    dbgOut.tprintf(2, "Sparse tag created for dimension %s\n", dimNames[i].c_str());
   }
+
+  return MB_SUCCESS;
 }
 
 ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>& vdatas, std::vector<int>& tstep_nums)
 {
-  std::set<std::string>& dummyVarNames = _readNC->dummyVarNames;
   std::vector<int>& dimLens = _readNC->dimLens;
   DebugOutput& dbgOut = _readNC->dbgOut;
 
   ErrorCode rval = MB_SUCCESS;
 
   for (unsigned int i = 0; i < vdatas.size(); i++) {
-    // This is a dummy variable for a dimension with no corresponding coordinate variable
-    // No need to allocate memory to read it
-    if (dummyVarNames.find(vdatas[i].varName) != dummyVarNames.end()) {
-      if (!vdatas[i].varTags[0]) {
-        rval = get_tag_to_set(vdatas[i], 0, vdatas[i].varTags[0]);
-        ERRORR(rval, "Trouble getting dummy tag.");
-      }
-      continue;
-    }
-
     if ((std::find(vdatas[i].varDims.begin(), vdatas[i].varDims.end(), tDim) != vdatas[i].varDims.end()))
       vdatas[i].has_t = true;
 
@@ -893,7 +898,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
   ScdParData& parData = _readNC->parData;
 
   Range tmp_range;
-  ScdBox *scd_box;
+  ScdBox* scd_box;
 
   ErrorCode rval = scdi->construct_box(HomCoord(lDims[0], lDims[1], lDims[2], 1), HomCoord(lDims[3], lDims[4], lDims[5], 1), 
                                        NULL, 0, scd_box, locallyPeriodic, &parData, true);
@@ -1050,8 +1055,6 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
 #endif
 
   for (unsigned int i = 0; i < vdatas.size(); i++) {
-    vdatas[i].numLev = nLevels;
-
     for (unsigned int t = 0; t < tstep_nums.size(); t++) {
       dbgOut.tprintf(2, "Reading variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
 
@@ -1074,17 +1077,14 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
       vdatas[i].readStarts[t].push_back(tstep_nums[t]);
       vdatas[i].readCounts[t].push_back(1);
 
-      // Next: numLev
-      if (vdatas[i].numLev != 1) {
-        vdatas[i].readStarts[t].push_back(0);
-        vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
-      }
+      // Next: numLev, even if it is 1
+      vdatas[i].readStarts[t].push_back(0);
+      vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
 
       // Finally: y and x
       switch (vdatas[i].entLoc) {
         case ReadNC::ENTLOCVERT:
           // Vertices
-          // Only structured mesh has j parameter that multiplies i to get total # vertices
           vdatas[i].readStarts[t].push_back(lDims[1]);
           vdatas[i].readCounts[t].push_back(lDims[4] - lDims[1] + 1);
           vdatas[i].readStarts[t].push_back(lDims[0]);
@@ -1101,8 +1101,8 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
         case ReadNC::ENTLOCFACE:
           // Faces
           vdatas[i].readStarts[t].push_back(lCDims[1]);
-          vdatas[i].readStarts[t].push_back(lCDims[0]);
           vdatas[i].readCounts[t].push_back(lCDims[4] - lCDims[1] + 1);
+          vdatas[i].readStarts[t].push_back(lCDims[0]);
           vdatas[i].readCounts[t].push_back(lCDims[3] - lCDims[0] + 1);
           assert(vdatas[i].readStarts[t].size() == vdatas[i].varDims.size());
 #ifdef USE_MPI
@@ -1245,6 +1245,7 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
         rval = tmp_rval;
     }
   }
+
   // Debug output, if requested
   if (1 == dbgOut.get_verbosity()) {
     dbgOut.printf(1, "Read variables: %s", vdatas.begin()->varName.c_str());

diff --git a/src/io/NCHelper.hpp b/src/io/NCHelper.hpp
index dcb006e..817257c 100644
--- a/src/io/NCHelper.hpp
+++ b/src/io/NCHelper.hpp
@@ -55,18 +55,18 @@ protected:
 
   ErrorCode get_tag_to_nonset(ReadNC::VarData& var_data, int tstep_num, Tag& tagh, int num_lev);
 
-  //! Create a character string attString of attMap.  with '\0'
+  //! Create a character string attString of attMap. with '\0'
   //! terminating each attribute name, ';' separating the data type
   //! and value, and ';' separating one name/data type/value from
-  //! the next'.  attLen stores the end position for each name/data
+  //! the next'. attLen stores the end position for each name/data
   //! type/ value.
   ErrorCode create_attrib_string(const std::map<std::string, ReadNC::AttData>& attMap,
                                  std::string& attString,
                                  std::vector<int>& attLen);
 
-  //! Initialize information for dimensions that don't have corresponding
-  //! coordinate variables - this information is used for creating dummy tags
-  void init_dims_with_no_coord_vars_info();
+  //! For a dimension that does not have a corresponding coordinate variable (e.g. ncol for HOMME),
+  //! create a dummy variable with a sparse tag to store the dimension length
+  ErrorCode create_dummy_variables();
 
 private:
   //! Used by read_variable_to_set()
@@ -90,8 +90,11 @@ protected:
   //! Dimension numbers for time and level
   int tDim, levDim;
 
-  //! Skip unexpected variables
+  //! Ignored variables
   std::set<std::string> ignoredVarNames;
+
+  //! Dummy variables
+  std::set<std::string> dummyVarNames;
 };
 
 //! Child helper class for scd mesh, e.g. CAM_EL or CAM_FV

diff --git a/src/io/NCHelperEuler.cpp b/src/io/NCHelperEuler.cpp
index 48056c6..b117921 100644
--- a/src/io/NCHelperEuler.cpp
+++ b/src/io/NCHelperEuler.cpp
@@ -6,10 +6,10 @@
 #include <sstream>
 
 #define ERRORR(rval, str) \
-    if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
+  if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
 
 #define ERRORS(err, str) \
-    if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
+  if (err) {_readNC->readMeshIface->report_error("%s", str); return MB_FAILURE;}
 
 namespace moab {
 
@@ -319,13 +319,21 @@ ErrorCode NCHelperEuler::init_mesh_vals()
   dbgOut.tprintf(1, "%d elements, %d vertices\n", (lDims[3] - lDims[0]) * (lDims[4] - lDims[1]), (lDims[3] - lDims[0] + 1)
       * (lDims[4] - lDims[1] + 1));
 
-  // Determine the entity location type of a variable
+  // For each variable, determine the entity location type and number of levels
   std::map<std::string, ReadNC::VarData>::iterator mit;
   for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
     ReadNC::VarData& vd = (*mit).second;
-    if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
-        vd.varDims.end(), jCDim) != vd.varDims.end()))
-      vd.entLoc = ReadNC::ENTLOCFACE;
+
+    vd.entLoc = ReadNC::ENTLOCSET;
+    if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+      if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) &&
+          (std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()))
+        vd.entLoc = ReadNC::ENTLOCFACE;
+    }
+
+    vd.numLev = 1;
+    if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
+      vd.numLev = nLevels;
   }
 
   // For Eul models, slon and slat are "virtual" dimensions (not defined in the file header)
@@ -451,8 +459,9 @@ ErrorCode NCHelperEuler::init_mesh_vals()
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }
 
-  // Hack: create dummy tags, if needed, for dimensions with no corresponding coordinate variables
-  init_dims_with_no_coord_vars_info();
+  // Hack: create dummy variables, if needed, for dimensions with no corresponding coordinate variables
+  rval = create_dummy_variables();
+  ERRORR(rval, "Failed to create dummy variables.");
 
   return MB_SUCCESS;
 }

diff --git a/src/io/NCHelperFV.cpp b/src/io/NCHelperFV.cpp
index 253d598..7725b55 100644
--- a/src/io/NCHelperFV.cpp
+++ b/src/io/NCHelperFV.cpp
@@ -6,7 +6,7 @@
 #include <sstream>
 
 #define ERRORR(rval, str) \
-    if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
+ if (MB_SUCCESS != rval) {_readNC->readMeshIface->report_error("%s", str); return rval;}
 
 namespace moab {
 
@@ -315,19 +315,27 @@ ErrorCode NCHelperFV::init_mesh_vals()
   dbgOut.tprintf(1, "%d elements, %d vertices\n", (lDims[3] - lDims[0]) * (lDims[4] - lDims[1]), (lDims[3] - lDims[0] + 1)
       * (lDims[4] - lDims[1] + 1));
 
-  // Determine the entity location type of a variable
+  // For each variable, determine the entity location type and number of levels
   std::map<std::string, ReadNC::VarData>::iterator mit;
   for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
     ReadNC::VarData& vd = (*mit).second;
-    if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
-        vd.varDims.end(), jCDim) != vd.varDims.end()))
-      vd.entLoc = ReadNC::ENTLOCFACE;
-    else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
-        vd.varDims.end(), iCDim) != vd.varDims.end()))
-      vd.entLoc = ReadNC::ENTLOCNSEDGE;
-    else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
-        vd.varDims.end(), iDim) != vd.varDims.end()))
-      vd.entLoc = ReadNC::ENTLOCEWEDGE;
+
+    vd.entLoc = ReadNC::ENTLOCSET;
+    if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+      if ((std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()) &&
+          (std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()))
+        vd.entLoc = ReadNC::ENTLOCFACE;
+      else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jDim) != vd.varDims.end()) &&
+          (std::find(vd.varDims.begin(), vd.varDims.end(), iCDim) != vd.varDims.end()))
+        vd.entLoc = ReadNC::ENTLOCNSEDGE;
+      else if ((std::find(vd.varDims.begin(), vd.varDims.end(), jCDim) != vd.varDims.end()) &&
+          (std::find(vd.varDims.begin(), vd.varDims.end(), iDim) != vd.varDims.end()))
+        vd.entLoc = ReadNC::ENTLOCEWEDGE;
+    }
+
+    vd.numLev = 1;
+    if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
+      vd.numLev = nLevels;
   }
 
   std::vector<std::string> ijdimNames(4);
@@ -452,8 +460,9 @@ ErrorCode NCHelperFV::init_mesh_vals()
       dbgOut.tprintf(2, "Tag created for variable %s\n", tag_name.c_str());
   }
 
-  // Hack: create dummy tags, if needed, for dimensions with no corresponding coordinate variables
-  init_dims_with_no_coord_vars_info();
+  // Hack: create dummy variables, if needed, for dimensions with no corresponding coordinate variables
+  rval = create_dummy_variables();
+  ERRORR(rval, "Failed to create dummy variables.");
 
   return MB_SUCCESS;
 }

diff --git a/src/io/NCHelperHOMME.cpp b/src/io/NCHelperHOMME.cpp
index be4d93f..25c4441 100644
--- a/src/io/NCHelperHOMME.cpp
+++ b/src/io/NCHelperHOMME.cpp
@@ -151,17 +151,25 @@ ErrorCode NCHelperHOMME::init_mesh_vals()
       tVals.push_back((double)t);
   }
 
-  // Determine the entity location type of a variable
+  // For each variable, determine the entity location type and number of levels
   std::map<std::string, ReadNC::VarData>::iterator mit;
   for (mit = varInfo.begin(); mit != varInfo.end(); ++mit) {
     ReadNC::VarData& vd = (*mit).second;
-    if ((std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end()) && (std::find(vd.varDims.begin(),
-        vd.varDims.end(), levDim) != vd.varDims.end()))
-      vd.entLoc = ReadNC::ENTLOCVERT;
+
+    vd.entLoc = ReadNC::ENTLOCSET;
+    if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+      if (std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end())
+        vd.entLoc = ReadNC::ENTLOCVERT;
+    }
+
+    vd.numLev = 1;
+    if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
+      vd.numLev = nLevels;
   }
 
-  // Hack: create dummy tags for dimensions (like ncol) with no corresponding coordinate variables
-  init_dims_with_no_coord_vars_info();
+  // Hack: create dummy variables for dimensions (like ncol) with no corresponding coordinate variables
+  rval = create_dummy_variables();
+  ERRORR(rval, "Failed to create dummy variables.");
 
   return MB_SUCCESS;
 }
@@ -540,11 +548,9 @@ ErrorCode NCHelperHOMME::read_ucd_variable_to_nonset_allocate(std::vector<ReadNC
       vdatas[i].readStarts[t].push_back(tstep_nums[t]);
       vdatas[i].readCounts[t].push_back(1);
 
-      // Next: numLev
-      if (vdatas[i].numLev != 1) {
-        vdatas[i].readStarts[t].push_back(0);
-        vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
-      }
+      // Next: numLev, even if it is 1
+      vdatas[i].readStarts[t].push_back(0);
+      vdatas[i].readCounts[t].push_back(vdatas[i].numLev);
 
       // Finally: nVertices
       switch (vdatas[i].entLoc) {

diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index a326e52..c803bf3 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -26,8 +26,22 @@ NCHelperMPAS::NCHelperMPAS(ReadNC* readNC, int fileId, const FileOptions& opts,
 , numCellGroups(0)
 , createGatherSet(false)
 {
-  // Hack: ignore 4D variable tracers(Time, nCells, nVertLevels, nTracers)
-  ignoredVarNames.insert("tracers");
+  // Ignore variables containing topological information
+  ignoredVarNames.insert("nEdgesOnEdge");
+  ignoredVarNames.insert("nEdgesOnCell");
+  ignoredVarNames.insert("edgesOnVertex");
+  ignoredVarNames.insert("cellsOnVertex");
+  ignoredVarNames.insert("verticesOnEdge");
+  ignoredVarNames.insert("edgesOnEdge");
+  ignoredVarNames.insert("cellsOnEdge");
+  ignoredVarNames.insert("verticesOnCell");
+  ignoredVarNames.insert("edgesOnCell");
+  ignoredVarNames.insert("cellsOnCell");
+
+  // Ignore variables for index conversion
+  ignoredVarNames.insert("indexToVertexID");
+  ignoredVarNames.insert("indexToEdgeID");
+  ignoredVarNames.insert("indexToCellID");
 }
 
 bool NCHelperMPAS::can_read_file(ReadNC* readNC)
@@ -144,42 +158,41 @@ ErrorCode NCHelperMPAS::init_mesh_vals()
     }
   }
 
-  // Determine the entity location type of a variable
+  // For each variable, determine the entity location type and number of levels
   for (vmit = varInfo.begin(); vmit != varInfo.end(); ++vmit) {
     ReadNC::VarData& vd = (*vmit).second;
-    vd.entLoc = ReadNC::ENTLOCSET;
 
-    if ((std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) &&
-      (std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end()))
-      vd.entLoc = ReadNC::ENTLOCVERT;
-    else if ((std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) &&
-      (std::find(vd.varDims.begin(), vd.varDims.end(), eDim) != vd.varDims.end()))
-      vd.entLoc = ReadNC::ENTLOCEDGE;
-    else if ((std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) &&
-      (std::find(vd.varDims.begin(), vd.varDims.end(), cDim) != vd.varDims.end()))
-      vd.entLoc = ReadNC::ENTLOCFACE;
-  }
+    vd.entLoc = ReadNC::ENTLOCSET;
+    if (std::find(vd.varDims.begin(), vd.varDims.end(), tDim) != vd.varDims.end()) {
+      if (std::find(vd.varDims.begin(), vd.varDims.end(), vDim) != vd.varDims.end())
+        vd.entLoc = ReadNC::ENTLOCVERT;
+      else if (std::find(vd.varDims.begin(), vd.varDims.end(), eDim) != vd.varDims.end())
+        vd.entLoc = ReadNC::ENTLOCEDGE;
+      else if (std::find(vd.varDims.begin(), vd.varDims.end(), cDim) != vd.varDims.end())
+        vd.entLoc = ReadNC::ENTLOCFACE;
+    }
 
-  // Determine number of levels of a variable
-  for (vmit = varInfo.begin(); vmit != varInfo.end(); ++vmit) {
-    ReadNC::VarData& vd = (*vmit).second;
     vd.numLev = 1;
-
-    if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end()) {
+    if (std::find(vd.varDims.begin(), vd.varDims.end(), levDim) != vd.varDims.end())
       vd.numLev = nLevels;
-      continue;
-    }
-
-    for (unsigned int i = 0; i < opt_lev_dims.size(); i++) {
-      if (std::find(vd.varDims.begin(), vd.varDims.end(), opt_lev_dims[i]) != vd.varDims.end()) {
-        vd.numLev = dimLens[opt_lev_dims[i]];
-        break;
+    else {
+      // If nVertLevels dimension is not found, try other optional levels such as nVertLevelsP1
+      for (unsigned int i = 0; i < opt_lev_dims.size(); i++) {
+        if (std::find(vd.varDims.begin(), vd.varDims.end(), opt_lev_dims[i]) != vd.varDims.end()) {
+          vd.numLev = dimLens[opt_lev_dims[i]];
+          break;
+        }
       }
     }
+
+    // Hack: ignore variables with more than 3 dimensions, e.g. tracers(Time, nCells, nVertLevels, nTracers)
+    if (vd.varDims.size() > 3)
+      ignoredVarNames.insert(vd.varName);
   }
 
-  // Hack: create dummy tags for dimensions (like nCells) with no corresponding coordinate variables
-  init_dims_with_no_coord_vars_info();
+  // Hack: create dummy variables for dimensions (like nCells) with no corresponding coordinate variables
+  rval = create_dummy_variables();
+  ERRORR(rval, "Failed to create dummy variables.");
 
   return MB_SUCCESS;
 }

diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index e930930..a0e02b4 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -132,16 +132,16 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
       return rval;
   }
   else {
-    // Read dimension variable by default, the ones that are also variables
-    std::vector<std::string> filteredDimNames;
+    // Read dimension variables by default (the dimensions that are also variables)
+    std::vector<std::string> dim_var_names;
     for (unsigned int i = 0; i < dimNames.size(); i++) {
       std::map<std::string, VarData>::iterator mit = varInfo.find(dimNames[i]);
       if (mit != varInfo.end())
-        filteredDimNames.push_back(dimNames[i]);
+        dim_var_names.push_back(dimNames[i]);
     }
 
-    if (!filteredDimNames.empty()) {
-      rval = myHelper->read_variables(filteredDimNames, tstep_nums);
+    if (!dim_var_names.empty()) {
+      rval = myHelper->read_variables(dim_var_names, tstep_nums);
       if (MB_FAILURE == rval)
         return rval;
     }
@@ -302,7 +302,7 @@ ErrorCode ReadNC::read_header()
   ERRORR(result, "Getting attributes.");
   dbgOut.tprintf(1, "Read %u attributes\n", (unsigned int) globalAtts.size());
 
-  // Read in dimensions into dimVals
+  // Read in dimensions into dimNames and dimLens
   result = get_dimensions(fileId, dimNames, dimLens);
   ERRORR(result, "Getting dimensions.");
   dbgOut.tprintf(1, "Read %u dimensions\n", (unsigned int) dimNames.size());

diff --git a/src/io/ReadNC.hpp b/src/io/ReadNC.hpp
index fc75140..c452716 100644
--- a/src/io/ReadNC.hpp
+++ b/src/io/ReadNC.hpp
@@ -165,9 +165,6 @@ private:
   //! Dimension lengths
   std::vector<int> dimLens;
 
-  //! These should be taken out when we fix the dummy var info things
-  std::set<std::string> dummyVarNames;
-
   //! Global attribs
   std::map<std::string, AttData> globalAtts;

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