now setting deflate_level to zero does not turn on deflate

This commit is contained in:
Edward Hartnett 2021-11-27 07:40:02 -07:00
parent 0a00163b05
commit b7b4e53687
3 changed files with 20 additions and 12 deletions

View File

@ -777,17 +777,23 @@ int
NC4_def_var_deflate(int ncid, int varid, int shuffle, int deflate,
int deflate_level)
{
int stat = NC_NOERR;
int stat;
unsigned int level = (unsigned int)deflate_level;
/* Set shuffle first */
if((stat = nc_def_var_extra(ncid, varid, &shuffle, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL))) goto done;
if(deflate) {
if((stat = nc_def_var_filter(ncid, varid, H5Z_FILTER_DEFLATE,1,&level))) goto done;
} /* else ignore */
done:
return stat;
/* Set shuffle first */
if ((stat = nc_def_var_extra(ncid, varid, &shuffle, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL)))
return stat;
/* Don't turn on deflate if deflate_level = 0. It's a valid zlib
* setting, but results in a write slowdown, and a file that is
* larger than the uncompressed file would be. So when
* deflate_level is 0, don't use compression. */
if (deflate && deflate_level)
if ((stat = nc_def_var_filter(ncid, varid, H5Z_FILTER_DEFLATE, 1, &level)))
return stat;
return NC_NOERR;
}
/**

View File

@ -26,7 +26,8 @@ LDADD = ${top_builddir}/liblib/libnetcdf.la
check_PROGRAMS = tst_create_files bm_file tst_chunks3 tst_ar4 \
tst_ar4_3d tst_ar4_4d bm_many_objs tst_h_many_atts bm_many_atts \
tst_files2 tst_files3 tst_mem tst_mem1 tst_knmi bm_netcdf4_recs \
tst_wrf_reads tst_attsperf bigmeta openbigmeta tst_bm_rando
tst_wrf_reads tst_attsperf bigmeta openbigmeta tst_bm_rando \
tst_compress
bm_file_SOURCES = bm_file.c tst_utils.c
bm_file_LDFLAGS = -no-install
@ -41,6 +42,7 @@ tst_h_many_atts_SOURCES = tst_h_many_atts.c tst_utils.c
tst_knmi_SOURCES = tst_knmi.c tst_utils.c
tst_wrf_reads_SOURCES = tst_wrf_reads.c tst_utils.c
tst_bm_rando_SOURCES = tst_bm_rando.c tst_utils.c
tst_compress_SOURCES = tst_compress.c tst_utils.c
# Removing tst_mem1 because it sometimes fails on very busy system.
# Removing run_knmi_bm.sh because it fetches files from a server and
@ -48,7 +50,7 @@ tst_bm_rando_SOURCES = tst_bm_rando.c tst_utils.c
# in CI.
TESTS = tst_ar4_3d tst_create_files tst_files3 tst_mem tst_wrf_reads \
tst_attsperf perftest.sh run_tst_chunks.sh run_bm_elena.sh \
tst_bm_rando
tst_bm_rando tst_compress
run_bm_elena.log: tst_create_files.log

View File

@ -7,6 +7,6 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
echo "*** Running tst_gfs_1..."
@MPIEXEC@ -n 4 ./tst_gfs_data_1
@MPIEXEC@ -n 4 ./tst_compress_par
exit 0