now testing that nc_inq_var_deflate() works for all formats and returns 0 deflate and deflate_level

This commit is contained in:
Edward Hartnett 2020-04-08 08:31:53 -06:00
parent 03b3b89097
commit aab2f998b3
2 changed files with 24 additions and 2 deletions

View File

@ -289,8 +289,10 @@ nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *defla
size_t nparams;
unsigned int params[4];
int deflating = 0;
int stat = NC_check_id(ncid,&ncp);
NC_FILE_INFO_T **h5;
int stat;
stat = NC_check_id(ncid,&ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_var_deflate);
@ -299,6 +301,18 @@ nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *defla
switch (stat) {
case NC_ENOFILTER: deflating = 0; stat = NC_NOERR; break;
case NC_NOERR: deflating = 1; break;
case NC_ENOTNC4:
/* As a special case, to support behavior already coded into user
* applications, handle classic format files by reporting no
* deflation. */
if (shufflep)
*shufflep = 0;
if (deflatep)
*deflatep = 0;
if (deflate_levelp)
*deflate_levelp = 0;
return NC_NOERR;
break;
default: return stat;
}
if(deflatep) *deflatep = deflating;

View File

@ -171,6 +171,7 @@ main(int argc, char **argv)
int data = TEST_VAL_42;
int data_in;
int fill_value = TEST_VAL_42 * 2;
int shuffle_in, deflate_in, deflate_level_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);
@ -178,6 +179,13 @@ main(int argc, char **argv)
if (nc_create(file_name, 0, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME, DIM_LEN, &dimid)) ERR;
if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIM1, &dimid, &varid)) ERR;
/* There is no deflate on this var, and that is true in
* all formats. */
if (nc_inq_var_deflate(ncid, varid, &shuffle_in, &deflate_in,
&deflate_level_in)) ERR;
if (shuffle_in || deflate_in || deflate_level_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