Skip to content

Commit

Permalink
Issue 2947 - regression introduced by PR #2845 (#2948)
Browse files Browse the repository at this point in the history
* Fixed #2947 - Regression introduced by #2845

* clang-format pre-push hook
  • Loading branch information
clyne committed Dec 28, 2021
1 parent 9529a84 commit b214384
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion apps/cf2vdc/cf2vdc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ int CopyVar2d3dMask(DC &dc, VDCNetCDF &vdc, size_t ts, string varname, int lod)
if (fdr < 0) return (fdr);

int fdw = vdc.OpenVariableWrite(ts, maskvar, lod);
if (fdw < 0) return (fdw);
if (fdw < 0) {
dc.CloseVariable(fdr);
return (fdw);
}

size_t bufsize = vproduct(buffer_dims);
float *buffer = (float *)dataBuffer.Alloc(bufsize * sizeof(*buffer));
Expand Down
5 changes: 5 additions & 0 deletions lib/vdc/DCCF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,11 @@ int DCCF::initDataVars(NetCDFCFCollection *ncdfc, std::map<string, DC::DataVar>
// For each variable add a member to dataVarsMap
//
for (auto varName : vars) {
// A variable can't be both a data variable and a coordinate variable
//
auto itr = _coordVarsMap.find(varName);
if (itr != _coordVarsMap.end()) continue;

// variable type must be float or int
//
int type = ncdfc->GetXType(varName);
Expand Down
5 changes: 4 additions & 1 deletion lib/vdc/NetCDFCFCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ int NetCDFCFCollection::Initialize(const vector<string> &files)
} else if (_IsVertCoordVar(varinfo)) {
_vertCoordVars.push_back(varName);
_auxCoordinateVars.push_back(varName);
} else if (_IsTimeCoordVar(varinfo)) {
//
// Only support CF "Coordinate" variables as time coord variables
//
} else if (_IsCoordinateVar(varinfo) && _IsTimeCoordVar(varinfo)) {
_timeCoordVars.push_back(varName);
_auxCoordinateVars.push_back(varName);
}
Expand Down
1 change: 1 addition & 0 deletions lib/vdc/NetCDFCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,7 @@ int NetCDFCollection::TimeVaryingVar::Insert(const NetCDFSimple *netcdf, const N
space_dim_names.erase(space_dim_names.begin());
}
}

if (!time_varying) {
key = "constant";
} else if (file_org == 1 || file_org == 2) {
Expand Down
5 changes: 4 additions & 1 deletion lib/vdc/VDCNetCDF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,10 @@ int VDCNetCDF::CopyVar(DC &dc, size_t ts, string varname, int srclod, int dstlod
if (fdr < 0) return (fdr);

int fdw = OpenVariableWrite(ts, varname, dstlod);
if (fdw < 0) return (fdw);
if (fdw < 0) {
dc.CloseVariable(fdr);
return (fdw);
}

if (varInfo.GetXType() == FLOAT || varInfo.GetXType() == DOUBLE) {
size_t bufsize = vproduct(buffer_dims);
Expand Down

0 comments on commit b214384

Please sign in to comment.