Skip to content

Backward-incompatible nc_inq_var_filter() change in netCDF 4.7.4 #1693

@czender

Description

@czender

Hola compadres,

I am trying to identify and workaround a backward-incompatible behavior change in 4.7.4. Please correct me if I am wrong about the following, @DennisHeimbigner and others. As of 4.7.4, nc_inq_var_filter() called on a chunked and shuffled though not compressed variable in a netCDF4 dataset (CDL below) returns error -136, "NetCDF: Filter error: filter not defined for variable". Prior to 4.7.4, nc_inq_var_filter() returns NC_NOERR on this variable, and sets the filter ID to 0. This new behavior in 4.7.4 breaks the strategy that NCO uses to identify which filters are used on a variable. Currently NCO uses nc_inq_var_filter() on all chunked variables to assess whether any filters have been employed on them. If the returned filter ID != 0 then NCO delves deeper into the filter. As this example points out, that strategy no longer works on variables that are chunked and shuffled but not compressed. What is the recommended strategy to learn whether a variable has had a filter applied?

This also serves as notice of the backwards incompatibility. I am happy to modify NCO to make calls that depend on the netCDF library version if necessary, though I would prefer one strategy that works with all netCDF libraries (greater than 4.6.0, when nc_inq_var_filter() was introduced, in this particular case).

netcdf foo {
dimensions:
	lat = 2 ;
variables:
	float lat(lat) ;
		lat:units = "degrees_north" ;
		lat:_Storage = "chunked" ;
		lat:_ChunkSizes = 2 ;
		lat:_Shuffle = "true" ;
		lat:_Endianness = "little" ;

// global attributes:
		:history = "Wed Apr  8 10:17:42 2020: ncks -O -4 -L 0 --cnk_dmn lat,1 -v /lat /Users/zender/nco/data/in_grp.nc /Users/zender/foo.nc\nHistory global attribute.\n" ;
		:NCO = "netCDF Operators version 4.9.3-alpha05 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)" ;
		:_NCProperties = "version=2,netcdf=4.7.4,hdf5=1.10.6" ;
		:_SuperblockVersion = 0 ;
		:_IsNetcdf4 = 1 ;
		:_Format = "netCDF-4" ;
data:

 lat = -90, 90 ;
}

Interrogating this file with NCO using netCDF 4.7.3:

zender@firn:~$ ncks -D 1 -C -m --trd --hdn -v /lat ~/foo.nc
lat: type NC_FLOAT, 1 dimension, 1 attribute, compressed? no, chunked? yes, packed? no
lat size (RAM) = 2*sizeof(NC_FLOAT) = 2*4 = 8 bytes
lat dimension 0: lat, size = 2 NC_FLOAT, chunksize = 2 (Coordinate is lat)
lat attribute 0: units, size = 13 NC_CHAR, value = degrees_north
lat attribute 1: _Storage, size = 7 NC_CHAR, value = chunked
lat attribute 2: _ChunkSizes, size = 1 NC_INT, value = 2
lat attribute 3: _Filter, size = 2 NC_CHAR, value = 0,
lat attribute 4: _Shuffle, size = 4 NC_CHAR, value = true
lat attribute 5: _Endianness, size = 6 NC_CHAR, value = little

Interrogate this file with NCO using netCDF 4.7.4:

zender@sastrugi:~$ ncks -D 1 -C -m --trd --hdn -v /lat ~/foo.nc
lat: type NC_FLOAT, 1 dimension, 1 attribute, compressed? no, chunked? yes, packed? no
lat size (RAM) = 2*sizeof(NC_FLOAT) = 2*4 = 8 bytes
lat dimension 0: lat, size = 2 NC_FLOAT, chunksize = 2 (Coordinate is lat)
nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): nco_inq_var_filter()
nco_err_exit(): ERROR Error code is -136. Translation into English with nc_strerror(-136) is "NetCDF: Filter error: filter not defined for variable"
nco_err_exit(): ERROR NCO will now exit with system call exit(EXIT_FAILURE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions