[MOAB-dev] commit/MOAB: danwu: Fix assertion failures from read_ucd_nc and read_mpas_nc unit tests. In NCHelper::read_variable_to_set(), we should not convert or set tag data for a dummy variable.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Oct 31 15:40:28 CDT 2013
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/89df62b92b05/
Changeset: 89df62b92b05
Branch: master
User: danwu
Date: 2013-10-31 21:40:09
Summary: Fix assertion failures from read_ucd_nc and read_mpas_nc unit tests. In NCHelper::read_variable_to_set(), we should not convert or set tag data for a dummy variable.
Affected #: 1 file
diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index b5e4df7..bc8da0f 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -316,8 +316,8 @@ 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, we don't have it; we created it for the dummy tag
- // No need to read tag data for it
+ // 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;
@@ -358,21 +358,20 @@ ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, s
if (success)
ERRORR(MB_FAILURE, "Trouble reading variable.");
- if (vdatas[i].varDims.size() <= 1)
- break;
- }
- }
- for (unsigned int i = 0; i < vdatas.size(); i++) {
- for (unsigned int t = 0; t < tstep_nums.size(); t++) {
dbgOut.tprintf(2, "Converting variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
- ErrorCode tmp_rval = convert_variable(vdatas[i], t);
- if (MB_SUCCESS != tmp_rval)
- rval = tmp_rval;
+ rval = convert_variable(vdatas[i], t);
+ ERRORR(rval, "Failed to convert variable.");
+
+ dbgOut.tprintf(2, "Setting data for variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
+ rval = mbImpl->tag_set_by_ptr(vdatas[i].varTags[t], &_fileSet, 1, &(vdatas[i].varDatas[t]), &vdatas[i].sz);
+ ERRORR(rval, "Failed to set data for variable.");
+
if (vdatas[i].varDims.size() <= 1)
break;
}
}
+
// Debug output, if requested
if (1 == dbgOut.get_verbosity()) {
dbgOut.printf(1, "Read variables: %s", vdatas.begin()->varName.c_str());
@@ -381,17 +380,6 @@ ErrorCode NCHelper::read_variable_to_set(std::vector<ReadNC::VarData>& vdatas, s
dbgOut.tprintf(1, "\n");
}
- for (unsigned int i = 0; i < vdatas.size(); i++) {
- for (unsigned int t = 0; t < tstep_nums.size(); t++) {
- dbgOut.tprintf(2, "Setting data for variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
- ErrorCode tmp_rval = mbImpl->tag_set_by_ptr(vdatas[i].varTags[t], &_fileSet, 1, &(vdatas[i].varDatas[t]), &vdatas[i].sz);
- if (MB_SUCCESS != tmp_rval)
- rval = tmp_rval;
- if (vdatas[i].varDims.size() <= 1)
- break;
- }
- }
-
return rval;
}
@@ -695,8 +683,8 @@ ErrorCode NCHelper::read_variable_to_set_allocate(std::vector<ReadNC::VarData>&
ErrorCode rval = MB_SUCCESS;
for (unsigned int i = 0; i < vdatas.size(); i++) {
- // This is a dummy variable, we don't have it; we created it for the dummy tag
- // No need to allocate tag space for it
+ // 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]);
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