Skip to content

Commit

Permalink
Fixed #3046 - Failures converting data to VDC format
Browse files Browse the repository at this point in the history
  • Loading branch information
clyne committed Feb 22, 2022
1 parent a94337e commit ff4790d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions apps/cfvdccreate/cfvdccreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ int main(int argc, char **argv)
if (rc < 0) return (1);

for (int i = 0; i < datanames.size(); i++) {
if (find(coordnames.begin(), coordnames.end(), datanames[i])!=coordnames.end()) continue;

DC::DataVar dvar;
dccf.GetDataVarInfo(datanames[i], dvar);

Expand Down
26 changes: 14 additions & 12 deletions lib/vdc/VDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,13 @@ int VDC::DefineCoordVar(string varname, vector<string> dim_names, string time_di
return (-1);
}

if (_mode == A) {
if (_coordVars.find(varname) != _coordVars.end()) {
SetErrMsg("Variable \"%s\" already defined", varname.c_str());
return (-1);
}
}
// No dulicates. Overwrite previous definition
//
auto ditr = _dataVars.find(varname);
if (ditr != _dataVars.end()) _dataVars.erase(ditr);

auto citr = _coordVars.find(varname);
if (citr != _coordVars.end()) _coordVars.erase(citr);

if (axis == 3 && units.empty()) units = "seconds";

Expand Down Expand Up @@ -448,12 +449,13 @@ int VDC::_DefineDataVar(string varname, vector<string> dim_names, vector<string>
return (-1);
}

if (_mode == A) {
if (_dataVars.find(varname) != _dataVars.end()) {
SetErrMsg("Variable \"%s\" already defined", varname.c_str());
return (-1);
}
}
// No dulicates. Overwrite previous definition
//
auto ditr = _dataVars.find(varname);
if (ditr != _dataVars.end()) _dataVars.erase(ditr);

auto citr = _coordVars.find(varname);
if (citr != _coordVars.end()) _coordVars.erase(citr);

int rc = _DefineImplicitCoordVars(dim_names, coord_vars, coord_vars);
if (rc < 0) return (-1);
Expand Down

0 comments on commit ff4790d

Please sign in to comment.