mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-24 16:04:40 +08:00
rely completely on nc_def_var_filter for setting szip
This commit is contained in:
parent
517ef4f257
commit
1817790c6b
@ -213,9 +213,6 @@ typedef struct NC_VAR_INFO
|
||||
int deflate_level; /**< If deflate is true, this is the deflate level, between 0 and 9. */
|
||||
nc_bool_t shuffle; /**< True if var has shuffle filter applied */
|
||||
nc_bool_t fletcher32; /**< True if var has fletcher32 filter applied */
|
||||
nc_bool_t szip; /**< True if szip filter is in use. */
|
||||
int options_mask; /**< Setting for szip filter, NC_SZIP_EC or NC_SZIP_NN. */
|
||||
int pixels_per_block; /**< Setting for szip filter, even and <= 32. */
|
||||
size_t chunk_cache_size, chunk_cache_nelems;
|
||||
float chunk_cache_preemption;
|
||||
void *format_var_info; /**< Pointer to any binary format info. */
|
||||
|
@ -950,55 +950,13 @@ NC4_def_var_deflate(int ncid, int varid, int shuffle, int deflate,
|
||||
int
|
||||
nc_def_var_szip(int ncid, int varid, int options_mask, int pixels_per_block)
|
||||
{
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_FILE_INFO_T *h5;
|
||||
NC_VAR_INFO_T *var;
|
||||
int built = 0;
|
||||
int ret;
|
||||
|
||||
LOG((2, "%s: ncid 0x%x varid %d", __func__, ncid, varid));
|
||||
|
||||
/* /\* If HDF5 was not built with szip, then return error. *\/ */
|
||||
/* #ifdef HAVE_H5Z_SZIP */
|
||||
/* built = 1; */
|
||||
/* #endif /\* HAVE_H5Z_SZIP *\/ */
|
||||
/* if (!built) */
|
||||
/* return NC_EFILTER; */
|
||||
|
||||
/* Find info for this file and group, and set pointer to each. */
|
||||
if ((ret = nc4_find_nc_grp_h5(ncid, NULL, &grp, &h5)))
|
||||
return ret;
|
||||
assert(grp && h5);
|
||||
|
||||
/* Trying to write to a read-only file? No way, Jose! */
|
||||
if (h5->no_write)
|
||||
return NC_EPERM;
|
||||
|
||||
/* /\* Can't turn on parallel and szip before HDF5 1.10.2. *\/ */
|
||||
/* #ifdef USE_PARALLEL */
|
||||
/* #ifndef HDF5_SUPPORTS_PAR_FILTERS */
|
||||
/* if (h5->parallel == NC_TRUE) */
|
||||
/* return NC_EINVAL; */
|
||||
/* #endif /\* HDF5_SUPPORTS_PAR_FILTERS *\/ */
|
||||
/* #endif /\* USE_PARALLEL *\/ */
|
||||
|
||||
/* /\* Find the var. *\/ */
|
||||
/* if (!(var = (NC_VAR_INFO_T *)ncindexith(grp->vars, varid))) */
|
||||
/* return NC_ENOTVAR; */
|
||||
/* assert(var && var->hdr.id == varid); */
|
||||
|
||||
/* #ifdef USE_PARALLEL */
|
||||
/* /\* Switch to collective access. HDF5 requires collevtive access */
|
||||
/* * for filter use with parallel I/O. *\/ */
|
||||
/* if (h5->parallel) */
|
||||
/* var->parallel_access = NC_COLLECTIVE; */
|
||||
/* #endif /\* USE_PARALLEL *\/ */
|
||||
|
||||
/* This will cause H5Pset_szip to be called when the var is
|
||||
* created. */
|
||||
unsigned int *params;
|
||||
if (!(params = malloc(2 * sizeof(unsigned int))))
|
||||
return NC_ENOMEM;
|
||||
unsigned int params[2];
|
||||
params[0] = options_mask;
|
||||
params[1] = pixels_per_block;
|
||||
if ((ret = nc_def_var_filter(ncid, varid, HDF5_FILTER_SZIP, 2, params)))
|
||||
|
@ -918,15 +918,10 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
|
||||
if (H5Pset_deflate(plistid, var->deflate_level) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
else if (var->szip)
|
||||
{
|
||||
/* Turn on szip compression. */
|
||||
if (H5Pset_szip(plistid, var->options_mask, var->pixels_per_block) < 0)
|
||||
BAIL(NC_EFILTER);
|
||||
}
|
||||
else if(var->filterid)
|
||||
{
|
||||
/* Handle szip set via nc_def_var_filter() case here. */
|
||||
/* Since szip is a built-in filter for HDF5, it is activated
|
||||
* with a special function. */
|
||||
if (var->filterid == H5Z_FILTER_SZIP)
|
||||
{
|
||||
if (var->nparams != 2)
|
||||
@ -967,7 +962,7 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
|
||||
/* If there are no unlimited dims, and no filters, and the user
|
||||
* has not specified chunksizes, use contiguous variable for
|
||||
* better performance. */
|
||||
if (!var->shuffle && !var->deflate && !var->szip && !var->fletcher32 &&
|
||||
if (!var->shuffle && !var->deflate && !var->filterid && !var->fletcher32 &&
|
||||
(var->chunksizes == NULL || !var->chunksizes[0]) && !unlimdim)
|
||||
var->contiguous = NC_TRUE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user