Skip to content

Commit

Permalink
now setting deflate_level to zero does not turn on deflate
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Nov 27, 2021
1 parent 0a00163 commit b7b4e53
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
22 changes: 14 additions & 8 deletions libhdf5/hdf5var.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
if ((stat = nc_def_var_extra(ncid, varid, &shuffle, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL)))
return stat;

done:
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;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions nc_perf/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,14 +42,15 @@ 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
# not all HPC systems have easy internet access, plus it's very slow
# 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

Expand Down
2 changes: 1 addition & 1 deletion nc_perf/run_gfs_test.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b7b4e53

Please sign in to comment.