[MOAB-dev] commit/MOAB: danwu: For NC reader, dimensions (coordinate variables) can be excluded from user specified variables as they are read to the file set by default.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon May 19 14:16:01 CDT 2014
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/05cc593b26bb/
Changeset: 05cc593b26bb
Branch: master
User: danwu
Date: 2014-05-19 21:15:46
Summary: For NC reader, dimensions (coordinate variables) can be excluded from user specified variables as they are read to the file set by default.
Affected #: 1 file
diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index 98bf6b3..cd2c004 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -131,9 +131,10 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
rval = mbImpl->tag_get_data(convTagsCreated, &tmp_set, 1, &create_conv_tags_flag);
// The first read to the file set
if (0 == create_conv_tags_flag) {
- // Read dimension variables to create tags like __<var_name>_DIMS
+ // Read dimensions (coordinate variables) by default to create tags like __<var_name>_DIMS
+ // This is done only once (assume that all files read to the file set have the same dimensions)
rval = myHelper->read_variables(dimNames, tstep_nums);
- ERRORR(rval, "Trouble reading dimension variables.");
+ ERRORR(rval, "Trouble reading dimensions.");
rval = myHelper->create_conventional_tags(tstep_nums);
ERRORR(rval, "Trouble creating NC conventional tags.");
@@ -161,8 +162,24 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
// Read specified variables onto grid
if (!noVars) {
- rval = myHelper->read_variables(var_names, tstep_nums);
- ERRORR(rval, "Trouble reading specified variables.");
+ if (var_names.empty()) {
+ // If VARIABLE option is missing, read all variables
+ rval = myHelper->read_variables(var_names, tstep_nums);
+ ERRORR(rval, "Trouble reading all variables.");
+ }
+ else {
+ // Exclude dimensions that are read to the file set by default
+ std::vector<std::string> non_dim_var_names;
+ for (unsigned int i = 0; i < var_names.size(); i++) {
+ if (std::find(dimNames.begin(), dimNames.end(), var_names[i]) == dimNames.end())
+ non_dim_var_names.push_back(var_names[i]);
+ }
+
+ if (!non_dim_var_names.empty()) {
+ rval = myHelper->read_variables(non_dim_var_names, tstep_nums);
+ ERRORR(rval, "Trouble reading specified variables.");
+ }
+ }
}
#ifdef USE_MPI
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