Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nc_redef() - when called twice on netcdf-4 file, it should return no error #1781

Merged
merged 3 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release

## 4.8.0 - TBD

* [Bug Fix] Don't return error for extra calls to nc_redef() for netCDF/HDF5 files, unless classic model is in use. See [https://github.com/Unidata/netcdf-c/issues/1779].
* [Bug Fix] Now allow szip to be used on variables with unlimited dimension [https://github.com/Unidata/netcdf-c/issues/1774].
* [Enhancement] Add support for cloud storage using a variant of the Zarr storage format. Warning: this feature is highly experimental and is subject to rapid evolution [https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in].
* [Bug Fix] Fix nccopy to properly set default chunking parameters when not otherwise specified. This can significantly improve performance in selected cases. Note that if seeing slow performance with nccopy, then, as a work-around, specifically set the chunking parameters. [https://github.com/Unidata/netcdf-c/issues/1763].
Expand Down
5 changes: 3 additions & 2 deletions libhdf5/hdf5file.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,10 @@ NC4_redef(int ncid)
return retval;
assert(nc4_info);

/* If we're already in define mode, return an error. */
/* If we're already in define mode, return an error for classic
* files, or netCDF/HDF5 files when classic mode is in use. */
if (nc4_info->flags & NC_INDEF)
return NC_EINDEFINE;
return (nc4_info->cmode & NC_CLASSIC_MODEL) ? NC_EINDEFINE : NC_NOERR;

/* If the file is read-only, return an error. */
if (nc4_info->no_write)
Expand Down
14 changes: 14 additions & 0 deletions nc_test4/tst_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,20 @@ test_redef(int format)
if (strcmp(var_name, REDEF_VAR2_NAME) || xtype_in != NC_BYTE || ndims != REDEF_NDIMS ||
dimids_in[0] != dimids[0] || dimids_in[1] != dimids[1]) ERR;

/* Try enddef/redef. */
if (nc_enddef(ncid)) ERR;
if (nc_redef(ncid)) ERR;

/* NetCDF/HDF5 files ignore the repeated redef(). */
if (format != NC_FORMAT_NETCDF4)
{
if (nc_redef(ncid) != NC_EINDEFINE) ERR;
}
else
{
if (nc_redef(ncid)) ERR;
}

/* Close it up. */
if (format != NC_FORMAT_NETCDF4)
if (nc_enddef(ncid)) ERR;
Expand Down