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

Allow szip to be used with unlimited dim #1775

Merged
merged 6 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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] 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].
* [Bug Fix] Fix some protocol bugs/differences between the netcdf-c library and the OPeNDAP Hyrax server. Also cleanup checksum handling [https://github.com/Unidata/netcdf-c/issues/1712].
Expand Down
3 changes: 2 additions & 1 deletion libhdf5/hdf5filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ NC4_filter_actions(int ncid, int varid, int op, void* args)
size_t num_elem = 1;
int d;
for (d = 0; d < var->ndims; d++)
num_elem *= var->dim[d]->len;
if (var->dim[d]->len)
num_elem *= var->dim[d]->len;
/* Pixels per block must be <= number of elements. */
if (params[1] > num_elem)
{stat = THROW(NC_EINVAL); goto done;}
Expand Down
122 changes: 119 additions & 3 deletions nc_test4/tst_parallel_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "err_macros.h"
#include <mpi.h>

#define FILE_NAME "tst_parallel_zlib2.nc"
#define FILE_NAME "tst_parallel_compress.nc"
#define NDIMS 3
#define DIMSIZE 24
#define QTR_DATA (DIMSIZE * DIMSIZE / 4)
Expand All @@ -43,7 +43,7 @@ main(int argc, char **argv)
int ncid, v1id, dimids[NDIMS];
size_t start[NDIMS], count[NDIMS];

int f, i, res;
int f, i, s, res;
int *slab_data; /* one slab */

/* Initialize MPI. */
Expand All @@ -62,7 +62,6 @@ main(int argc, char **argv)
if (!mpi_rank)
printf("\n*** Testing parallel writes with compression filters.\n");
{
int s;
for (f = 0; f < NUM_COMPRESSION_FILTERS; f++)
{
for (s = 0; s < NUM_SHUFFLE_SETTINGS; s++)
Expand Down Expand Up @@ -177,6 +176,123 @@ main(int argc, char **argv)
SUMMARIZE_ERR;
} /* next shuffle filter test */
} /* next compression filter (zlib and szip) */

/* Now run tests with unlimited dim. */
/* for (f = 0; f < NUM_COMPRESSION_FILTERS; f++) */
for (f = 1; f < NUM_COMPRESSION_FILTERS; f++)
{
for (s = 0; s < NUM_SHUFFLE_SETTINGS; s++)
{
if (!mpi_rank)
{
printf("*** testing write along unlim dim with %s shuffle %d...",
(f ? "szip" : "zlib"), s);
}

/* nc_set_log_level(3); */
/* Create a parallel netcdf-4 file. */
if (nc_create_par(FILE_NAME, NC_NETCDF4, comm, info, &ncid)) ERR;

/* Create three dimensions. */
if (nc_def_dim(ncid, "d1", DIMSIZE, &dimids[1])) ERR;
if (nc_def_dim(ncid, "d2", DIMSIZE, &dimids[2])) ERR;
if (nc_def_dim(ncid, "d3", NC_UNLIMITED, &dimids[0])) ERR;

/* Create one var. Turn on deflation. */
if ((res = nc_def_var(ncid, "v1", NC_INT, NDIMS, dimids, &v1id))) ERR;

/* Setting any filter only will work for HDF5-1.10.3 and later
* versions. */
if (!f)
res = nc_def_var_deflate(ncid, 0, s, 1, 1);
else
{
res = nc_def_var_deflate(ncid, 0, s, 0, 0);
if (!res)
res = nc_def_var_szip(ncid, 0, 32, 32);
}
#ifdef HDF5_SUPPORTS_PAR_FILTERS
if (res) ERR;
#else
if (res != NC_EINVAL) ERR;
#endif

/* Setting fletcher32 only will work for HDF5-1.10.3 and later
* versions. */
res = nc_def_var_fletcher32(ncid, 0, 1);
#ifdef HDF5_SUPPORTS_PAR_FILTERS
if (res) ERR;
#else
if (res != NC_EINVAL) ERR;
#endif

/* Write metadata to file. */
if (nc_enddef(ncid)) ERR;

/* Set up slab for this process. */
start[1] = mpi_rank * DIMSIZE/mpi_size;
start[2] = 0;
count[1] = DIMSIZE/mpi_size;
count[2] = DIMSIZE;
count[0] = 1;
/*printf("mpi_rank=%d start[0]=%d start[1]=%d count[0]=%d count[1]=%d\n",
mpi_rank, start[0], start[1], count[0], count[1]);*/

/* Should not be allowed to change access to independent,
* because filters are in use. */
if (nc_var_par_access(ncid, v1id, NC_INDEPENDENT) != NC_EINVAL) ERR;

/* Write slabs of data. */
for (start[0] = 0; start[0] < NUM_SLABS; start[0]++)
if (nc_put_vara_int(ncid, v1id, start, count, slab_data)) ERR;

/* Close the netcdf file. */
if (nc_close(ncid)) ERR;

/* Check file. */
{
int shuffle_in, deflate_in, deflate_level_in;
int options_mask_in, pixels_per_block_in;
int *slab_data_in;

/* Allocate data. */
if (!(slab_data_in = malloc(sizeof(int) * DIMSIZE * DIMSIZE / mpi_size))) ERR;

/* Reopen the file for parallel access. */
if (nc_open_par(FILE_NAME, NC_NOWRITE, comm, info, &ncid)) ERR;

/* Check state of compression. */
if (!f)
{
if (nc_inq_var_deflate(ncid, 0, &shuffle_in, &deflate_in, &deflate_level_in)) ERR;
if ((s && !shuffle_in) || (!s && shuffle_in)) ERR;
if (!deflate_in || deflate_level_in != 1) ERR;
}
else
{
if (nc_inq_var_deflate(ncid, 0, &shuffle_in, NULL, NULL)) ERR;
if ((s && !shuffle_in) || (!s && shuffle_in)) ERR;
if (nc_inq_var_szip(ncid, 0, &options_mask_in, &pixels_per_block_in)) ERR;
}

/* Use parallel I/O to read the data. */
for (start[0] = 0; start[0] < NUM_SLABS; start[0]++)
{
if (nc_get_vara_int(ncid, 0, start, count, slab_data_in)) ERR;
for (i = 0; i < DIMSIZE * DIMSIZE / mpi_size; i++)
if (slab_data_in[i] != mpi_rank) ERR;
}

/* Close the netcdf file. */
if (nc_close(ncid)) ERR;

free(slab_data_in);
}

if (!mpi_rank)
SUMMARIZE_ERR;
} /* next shuffle filter test */
} /* next compression filter (zlib and szip) */
free(slab_data);
}

Expand Down