mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
Fix 1D variables with an unlimited dimension taking DEFAULT_CHUNK_SIZE (4MiB), by default, in netCDF-4 files
This commit is contained in:
parent
8515ece987
commit
d3d442537d
@ -266,8 +266,22 @@ nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
|
||||
var->chunksizes[d] = 1; /* overwritten below, if all dims are unlimited */
|
||||
}
|
||||
}
|
||||
|
||||
if (var->ndims > 0 && var->ndims == num_unlim) { /* all dims unlimited */
|
||||
/* Special case to avoid 1D vars with unlim dim taking huge amount
|
||||
of space (DEFAULT_CHUNK_SIZE bytes). Instead we limit to about
|
||||
4KB */
|
||||
#define DEFAULT_1D_UNLIM_SIZE (4096) /* TODO: make build-time parameter? */
|
||||
if (var->ndims == 1 && num_unlim == 1) {
|
||||
if (DEFAULT_CHUNK_SIZE / type_size <= 0)
|
||||
suggested_size = 1;
|
||||
else if (DEFAULT_CHUNK_SIZE / type_size > DEFAULT_1D_UNLIM_SIZE)
|
||||
suggested_size = DEFAULT_1D_UNLIM_SIZE;
|
||||
else
|
||||
suggested_size = DEFAULT_CHUNK_SIZE / type_size;
|
||||
var->chunksizes[0] = suggested_size / type_size;
|
||||
LOG((4, "%s: name %s dim %d DEFAULT_CHUNK_SIZE %d num_values %f type_size %d "
|
||||
"chunksize %ld", __func__, var->name, d, DEFAULT_CHUNK_SIZE, num_values, type_size, var->chunksizes[0]));
|
||||
}
|
||||
if (var->ndims > 1 && var->ndims == num_unlim) { /* all dims unlimited */
|
||||
suggested_size = pow((double)DEFAULT_CHUNK_SIZE/type_size, 1.0/(double)(var->ndims));
|
||||
for (d = 0; d < var->ndims; d++)
|
||||
{
|
||||
@ -878,7 +892,7 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate,
|
||||
var->contiguous = NC_FALSE;
|
||||
}
|
||||
|
||||
/* Fltcher32 checksum error protection? */
|
||||
/* Fletcher32 checksum error protection? */
|
||||
if (fletcher32)
|
||||
{
|
||||
var->fletcher32 = *fletcher32;
|
||||
@ -995,7 +1009,7 @@ NC4_def_var_fletcher32(int ncid, int varid, int fletcher32)
|
||||
and before nc_enddef.
|
||||
|
||||
Chunking is required in any dataset with one or more unlimited
|
||||
dimension in HDF5, or any dataset using a filter.
|
||||
dimensions in HDF5, or any dataset using a filter.
|
||||
|
||||
Where chunksize is a pointer to an array of size ndims, with the
|
||||
chunksize in each dimension.
|
||||
|
Loading…
Reference in New Issue
Block a user