[MOAB-dev] commit/MOAB: iulian07: enable the gcrm writer test
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sun May 11 21:41:37 CDT 2014
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/f64941b0c1b0/
Changeset: f64941b0c1b0
Branch: master
User: iulian07
Date: 2014-05-12 03:06:13
Summary: enable the gcrm writer test
still to do: check values written to the file
Affected #: 3 files
diff --git a/src/io/NCWriteGCRM.cpp b/src/io/NCWriteGCRM.cpp
index d1a7aaf..36160d2 100644
--- a/src/io/NCWriteGCRM.cpp
+++ b/src/io/NCWriteGCRM.cpp
@@ -42,10 +42,10 @@ ErrorCode NCWriteGCRM::collect_mesh_info()
nTimeSteps = dimLens[tDim];
// Get number of levels
- if ((vecIt = std::find(dimNames.begin(), dimNames.end(), "nVertLevels")) != dimNames.end())
+ if ((vecIt = std::find(dimNames.begin(), dimNames.end(), "layers")) != dimNames.end())
levDim = vecIt - dimNames.begin();
else {
- ERRORR(MB_FAILURE, "Couldn't find 'nVertLevels' dimension.");
+ ERRORR(MB_FAILURE, "Couldn't find 'layers' dimension.");
}
nLevels = dimLens[levDim];
@@ -121,33 +121,6 @@ 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 numbers for other optional levels
- std::vector<unsigned int> opt_lev_dims;
-
- unsigned int lev_idx;
- std::vector<std::string>::iterator vecIt;
-
- // Get number of vertex levels P1
- if ((vecIt = std::find(dimNames.begin(), dimNames.end(), "nVertLevelsP1")) != dimNames.end()) {
- lev_idx = vecIt - dimNames.begin();
- opt_lev_dims.push_back(lev_idx);
- }
-
- // Get number of vertex levels P2
- if ((vecIt = std::find(dimNames.begin(), dimNames.end(), "nVertLevelsP2")) != dimNames.end()) {
- lev_idx = vecIt - dimNames.begin();
- opt_lev_dims.push_back(lev_idx);
- }
-
- // Get number of soil levels
- if ((vecIt = std::find(dimNames.begin(), dimNames.end(), "nSoilLevels")) != 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++) {
@@ -162,20 +135,11 @@ ErrorCode NCWriteGCRM::collect_variable_data(std::vector<std::string>& var_names
if (localEdgesOwned.empty() && currentVarData.entLoc == WriteNC::ENTLOCEDGE)
continue;
- // If nVertLevels dimension is not found, try other optional levels such as nVertLevelsP1
std::vector<int>& varDims = currentVarData.varDims;
- 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;
- }
- }
- }
if (currentVarData.has_tsteps) {
- // Support non-set variables with 3 dimensions like (Time, nCells, nVertLevels), or
- // 2 dimensions like (Time, nCells)
+ // Support non-set variables with 3 dimensions like (Time, cells, layers), or
+ // 2 dimensions like (Time, cells)
assert(3 == varDims.size() || 2 == varDims.size());
// Time should be the first dimension
@@ -189,7 +153,7 @@ ErrorCode NCWriteGCRM::collect_variable_data(std::vector<std::string>& var_names
currentVarData.writeStarts[0] = 0; // This value is timestep dependent, will be set later
currentVarData.writeCounts[0] = 1;
- // Next: nVertices / nCells / nEdges
+ // Next: nVertices / cells / nEdges
switch (currentVarData.entLoc) {
case WriteNC::ENTLOCVERT:
// Vertices
diff --git a/src/io/NCWriteHelper.cpp b/src/io/NCWriteHelper.cpp
index 1a8a7eb..b315637 100644
--- a/src/io/NCWriteHelper.cpp
+++ b/src/io/NCWriteHelper.cpp
@@ -10,6 +10,7 @@
#include "NCWriteFV.hpp"
#include "NCWriteHOMME.hpp"
#include "NCWriteMPAS.hpp"
+#include "NCWriteGCRM.hpp"
#include "moab/WriteUtilIface.hpp"
#include "MBTagConventions.hpp"
@@ -36,6 +37,8 @@ NCWriteHelper* NCWriteHelper::get_nc_helper(WriteNC* writeNC, int fileId, const
return new (std::nothrow) NCWriteHOMME(writeNC, fileId, opts, fileSet);
else if (grid_type == "MPAS")
return new (std::nothrow) NCWriteMPAS(writeNC, fileId, opts, fileSet);
+ else if (grid_type == "GCRM")
+ return new (std::nothrow) NCWriteGCRM(writeNC, fileId, opts, fileSet);
// Unknown NetCDF grid
return NULL;
diff --git a/test/io/write_nc.cpp b/test/io/write_nc.cpp
index c71b6c8..58e203e 100644
--- a/test/io/write_nc.cpp
+++ b/test/io/write_nc.cpp
@@ -8,11 +8,13 @@ static const char example_eul[] = STRINGIFY(MESHDIR) "/io/camEul26x48x96.t3.nc";
static const char example_fv[] = STRINGIFY(MESHDIR) "/io/fv26x46x72.t.3.nc";
static const char example_homme[] = STRINGIFY(MESHDIR) "/io/homme26x3458.t.3.nc";
static const char example_mpas[] = STRINGIFY(MESHDIR) "/io/mpasx1.642.t.2.nc";
+static const char example_gcrm[] = STRINGIFY(MESHDIR) "/io/gcrm_r3.nc";
#else
static const char example_eul[] = "/io/camEul26x48x96.t3.nc";
static const char example_fv[] = "/io/fv26x46x72.t.3.nc";
static const char example_homme[] = "/io/homme26x3458.t.3.nc";
static const char example_mpas[] = "/io/mpasx1.642.t.2.nc";
+static const char example_gcrm[] = "/io/gcrm_r3.nc";
#endif
#ifdef USE_MPI
@@ -46,6 +48,11 @@ void test_homme_check_T();
void test_mpas_read_write_vars();
void test_mpas_check_vars();
+
+// GCRM
+void test_gcrm_read_write_vars();
+//void test_gcrm_check_vars();
+
// Test timestep option
void test_eul_read_write_timestep();
void test_eul_check_timestep();
@@ -89,6 +96,9 @@ int main(int argc, char* argv[])
result += RUN_TEST(test_mpas_read_write_vars);
result += RUN_TEST(test_mpas_check_vars);
+ result += RUN_TEST(test_gcrm_read_write_vars);
+ //result += RUN_TEST(test_gcrm_check_vars);
+
result += RUN_TEST(test_eul_read_write_timestep);
result += RUN_TEST(test_eul_check_timestep);
@@ -715,6 +725,51 @@ void test_mpas_check_vars()
}
}
+// Write vertex variable vorticity, edge variable u and cell veriable ke
+void test_gcrm_read_write_vars()
+{
+ int procs = 1;
+#ifdef USE_MPI
+ MPI_Comm_size(MPI_COMM_WORLD, &procs);
+#endif
+
+// We will not test NC writer in parallel without pnetcdf support
+#ifndef PNETCDF_FILE
+ if (procs > 1)
+ return;
+#endif
+
+ Core moab;
+ Interface& mb = moab;
+
+ std::string read_opts;
+ // we can use the same base options as mpas, because the zoltan can apply too
+ get_mpas_read_options(read_opts);
+
+ EntityHandle set;
+ ErrorCode rval = mb.create_meshset(MESHSET_SET, set);
+ CHECK_ERR(rval);
+
+ // Read non-set variables vorticity (cells) and u (corners)
+ read_opts += ";VARIABLE=vorticity,u;DEBUG_IO=0";
+ if (procs > 1)
+ read_opts += ";PARALLEL_RESOLVE_SHARED_ENTS";
+ rval = mb.load_file(example_gcrm, &set, read_opts.c_str());
+ CHECK_ERR(rval);
+
+ // Write variables vorticity, u
+ std::string write_opts = ";;VARIABLE=vorticity,u;DEBUG_IO=0";
+#ifdef USE_MPI
+ // Use parallel options
+ write_opts += ";PARALLEL=WRITE_PART";
+#endif
+ if (procs > 1)
+ rval = mb.write_file("test_par_gcrm_vars.nc", 0, write_opts.c_str(), &set, 1);
+ else
+ rval = mb.write_file("test_gcrm_vars.nc", 0, write_opts.c_str(), &set, 1);
+ CHECK_ERR(rval);
+}
+
// Read non-set variable T on all 3 timesteps, and write only timestep 2
void test_eul_read_write_timestep()
{
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