Skip to content

Invalid argument error with libnetcdf 4.5.0 but not 4.4.1 #657

@spencerkclark

Description

@spencerkclark

Per the recommendation of @dopplershift (cc: @spencerahill), I am migrating an issue (Unidata/netcdf4-python#742) initially posted in netcdf4-python over to here.

Environment Information

  • I have reproduced this behavior on my local machine (using Mac OS version 10.13)
  • This behavior was first identified with our test suite run using Travis CI (see here for the platform information)
  • On both platforms libnetcdf was installed from the conda-forge channel (e.g. conda install -c conda-forge libnetcdf).

Summary of Issue

Since libnetcdf version 4.5.0 appeared on conda-forge, we have encountered some puzzling errors in our CI test suite. Namely, some files that we used to be able to open with xarray using netCDF4 now lead to errors like the following:

aospy/test/test_calc_basic.py:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
aospy/test/test_calc_basic.py:35: in _test_files_and_attrs
    _test_output_attrs(calc, dtype_out)
aospy/test/test_calc_basic.py:18: in _test_output_attrs
    data = xr.open_dataset(calc.path_out[dtype_out])
../../../miniconda/envs/test_env/lib/python3.6/site-packages/xarray/backends/api.py:282: in open_dataset
    autoclose=autoclose)
../../../miniconda/envs/test_env/lib/python3.6/site-packages/xarray/backends/netCDF4_.py:210: in __init__
    self.ds = opener()
../../../miniconda/envs/test_env/lib/python3.6/site-packages/xarray/backends/netCDF4_.py:185: in _open_netcdf4_group
    ds = nc4.Dataset(filename, mode=mode, **kwargs)
netCDF4/_netCDF4.pyx:2015: in netCDF4._netCDF4.Dataset.__init__
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   OSError: [Errno -36] NetCDF: Invalid argument: b'/home/travis/build/spencerahill/aospy/aospy/test/data/objects/test-files/example_proj/example_model/example_run/condensation_rain/condensation_rain.ann.av.from_monthly_ts.example_model.example_run.0004-0006.nc'

In doing some investigation offline, it seems that the command line tool ncdump provided by libnetcdf version 4.5.0 is also unable to open these files. E.g. I get the following response:

$ ncdump sphum.ann.reg.av.vert_int.from_monthly_ts_sigma.example_model.example_run.0006.nc
ncdump: sphum.ann.reg.av.vert_int.from_monthly_ts_sigma.example_model.example_run.0006.nc: NetCDF: Invalid argument

However, using libnetcdf version 4.4.1.1, ncdump is able to handle the file (and using version 4.4.1.1 also enables downstream tools like netcdf4-python to work):

$ ncdump -h sphum.ann.reg.av.vert_int.from_monthly_ts_sigma.example_model.example_run.0006.nc
netcdf sphum.ann.reg.av.vert_int.from_monthly_ts_sigma.example_model.example_run.0006 {
variables:
	double raw_data_start_date ;
		raw_data_start_date:units = "days since 1673-01-01" ;
		raw_data_start_date:long_name = "time axis boundaries" ;
		raw_data_start_date:calendar = "NOLEAP" ;
		raw_data_start_date:_FillValue = 1.e+20 ;
	int subset_end_date ;
		subset_end_date:units = "days since 1678-01-31 00:00:00" ;
		subset_end_date:calendar = "proleptic_gregorian" ;
	double globe ;
		globe:units = "(vertical integral of quantity with unspecified units)" ;
		globe:_FillValue = NaN ;
		globe:description = "specific humidity" ;
	double raw_data_end_date ;
		raw_data_end_date:units = "days since 1673-01-01" ;
		raw_data_end_date:long_name = "time axis boundaries" ;
		raw_data_end_date:calendar = "NOLEAP" ;
		raw_data_end_date:_FillValue = 1.e+20 ;
	int subset_start_date ;
		subset_start_date:units = "days since 1678-01-01 00:00:00" ;
		subset_start_date:calendar = "proleptic_gregorian" ;

// global attributes:
		:coordinates = "raw_data_start_date subset_end_date raw_data_end_date subset_start_date" ;
}

I have posted a link to this file as an example. It would be helpful to know if you can reproduce the issues we've encountered here with files like the one provided, and what about them led to this problem. Thanks in advance for your help!

Steps to reproduce the behavior

Using the latest version of libnetcdf from the conda-forge channel, download the linked file and try to run ncdump.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions