diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d136169c2..6751803f2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -8,7 +8,7 @@ This file contains a high-level description of this package's evolution. Release ## 4.8.0 - TBD * [Bug Fix][cmake] Correct an issue with parallel filter test logic in CMake-based builds. -* [Bug Fix] Now allow nc_inq_var_deflate to be called for all formats, not just netCDF-4. This reverts behavior that was changed in the 4.7.4 release. See [https://github.com/Unidata/netcdf-c/issues/1691]. +* [Bug Fix] Now allow nc_inq_var_deflate()/nc_inq_var_szip() to be called for all formats, not just HDF5. Non-HDF5 files return NC_NOERR and report no compression in use. This reverts behavior that was changed in the 4.7.4 release. See [https://github.com/Unidata/netcdf-c/issues/1691]. ## 4.7.4 - March 27, 2020 diff --git a/libdispatch/dvarinq.c b/libdispatch/dvarinq.c index 77ff6208c..7a5e67b04 100644 --- a/libdispatch/dvarinq.c +++ b/libdispatch/dvarinq.c @@ -255,8 +255,14 @@ nc_inq_varnatts(int ncid, int varid, int *nattsp) nattsp); } -/** \ingroup variables -Learn the storage and deflate settings for a variable. +/** +\ingroup variables Learn the storage and deflate settings for a +variable. + +Deflation is compression with the zlib library. Deflation is only +available for netCDF/HDF5 files. For classic and other files, this +function will return shuffle off, deflate off, and a deflate level of +0. \param ncid NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as @@ -277,7 +283,6 @@ use, and deflate_levelp is provided, it will get a zero. (This behavior is expected by the Fortran APIs). \ref ignored_if_null. \returns ::NC_NOERR No error. -\returns ::NC_ENOTNC4 Not a netCDF-4 file. \returns ::NC_EBADID Bad ncid. \returns ::NC_ENOTVAR Invalid variable ID. \author Ed Hartnett, Dennis Heimbigner @@ -289,7 +294,6 @@ nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *defla size_t nparams; unsigned int params[4]; int deflating = 0; - NC_FILE_INFO_T **h5; int stat; stat = NC_check_id(ncid,&ncp); @@ -651,16 +655,20 @@ Learn the szip settings of a variable. This function returns the szip settings for a variable. To turn on szip compression, use nc_def_var_szip(). Szip compression is only -available if HDF5 was built with szip support. The nc_def_var_filter -function may also be used to set szip compression. +available for netCDF/HDF5 files, and only if HDF5 was built with szip +support. -If a variable is not using szip, then a zero will be passed back -for both options_maskp and pixels_per_blockp. +If a variable is not using szip, or if this function is called on a +file that is not a HDF5 file, then a zero will be passed back for both +options_maskp and pixels_per_blockp. For more information on HDF5 and szip see https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetSzip and https://support.hdfgroup.org/doc_resource/SZIP/index.html. +The nc_def_var_filter function may also be used to set szip +compression. + \param ncid NetCDF or group ID, from a previous call to nc_open(), nc_create(), nc_def_grp(), or associated inquiry functions such as nc_inq_ncid(). @@ -681,12 +689,10 @@ szip is not in use for this variable. \ref ignored_if_null. \returns ::NC_NOERR No error. \returns ::NC_EBADID Bad ncid. -\returns ::NC_ENOTNC4 Not a netCDF-4 file. \returns ::NC_ENOTVAR Invalid variable ID. \returns ::NC_EFILTER Filter error. \author Ed Hartnett, Dennis Heimbigner - */ int nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp) @@ -707,7 +713,9 @@ nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp) return NC_EFILTER; /* bad # params */ break; case NC_ENOFILTER: - /* If the szip filter is not in use, return 0 for both parameters. */ + case NC_ENOTNC4: + /* If the szip filter is not in use, of if this is not a + * netCDF/HDF5 file, return 0 for both parameters. */ params[0] = 0; params[1] = 0; stat = NC_NOERR; diff --git a/nc_test/tst_formats.c b/nc_test/tst_formats.c index cbb0bc708..838923cc6 100644 --- a/nc_test/tst_formats.c +++ b/nc_test/tst_formats.c @@ -172,6 +172,7 @@ main(int argc, char **argv) int data_in; int fill_value = TEST_VAL_42 * 2; int shuffle_in, deflate_in, deflate_level_in; + int options_mask_in, pixels_per_block_in; /* Try to set fill mode after data have been written. */ sprintf(file_name, "%s_%d_%d_%d_elatefill.nc", FILE_NAME_BASE, format[f], d, a); @@ -186,6 +187,11 @@ main(int argc, char **argv) &deflate_level_in)) ERR; if (shuffle_in || deflate_in || deflate_level_in) ERR; + /* There is no szip on this var, and that is true in + * all formats. */ + if (nc_inq_var_szip(ncid, varid, &options_mask_in, &pixels_per_block_in)) ERR; + if (options_mask_in || pixels_per_block_in) ERR; + if (nc_enddef(ncid)) ERR; /* For netCDF-4, we don't actually have to write data to * prevent future setting of the fill value. Once the user