geoslegend / netcdf4-python

Automatically exported from code.google.com/p/netcdf4-python
Other
0 stars 0 forks source link

RuntimeError: NetCDF: Invalid argument when opening Dataset after writing #170

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Valid DAP URL fails to open when attempted after writing a file.

I have a script that does this:

1) open DAP-URL 1
2) do some processing
3) write processed results to netcdf file 1
4) open DAP-URL 2
5) do some processing
6) write processed results to netcdf file 2

For some strange reason, step 4 fails with:
    nc2=netCDF4.Dataset(urls['FVCOM Currents'])
  File "netCDF4.pyx", line 1382, in netCDF4.Dataset.__init__ (netCDF4.c:16672)
RuntimeError: NetCDF: Invalid argument

If I remove step 3, step 4 succeeds.

I'm attaching two version of the workflow:

does_not_work.py    <= the workflow I would like with all 6 steps
works.py <= the workflow with step 3 removed

Original issue reported on code.google.com by rsignell on 13 Mar 2013 at 11:55

Attachments:

GoogleCodeExporter commented 8 years ago
Rich:  Confirmed, error occurs with this simple program:

import netCDF4
nc=netCDF4.Dataset('http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcas
ts/wave_gom3')
nco=netCDF4.Dataset('dummy.nc', 'w', format='NETCDF3_64BIT')
nc2=netCDF4.Dataset('http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindca
sts/30yr_gom3')

It's actually a library bug.  I've uploaded a c program (analagous to the one 
above) that triggers it.  I'll open a ticket with unidata.

Original comment by whitaker.jeffrey@gmail.com on 13 Mar 2013 at 3:14

Attachments:

GoogleCodeExporter commented 8 years ago
Unidata bug tracker:

https://bugtracking.unidata.ucar.edu/browse/NCF-243#comment-12102

In the meantime, I've committed a workaround for this in svn.

Original comment by whitaker.jeffrey@gmail.com on 14 Mar 2013 at 9:20

GoogleCodeExporter commented 8 years ago
From the unidata ticket.  Should be fixed in the 4.3.0 release.  The workaround 
in the python interface is pretty harmless (with very little overhead), so 
using older versions of netcdf should be fine.

Fixed in revision 3069.
Should be in snapshot of 3/16/2013

Problem was that the NC_create
code was not checking for the NC_CLASSIC_MODEL
mode flag in deciding what dispatch table to use.
This meant that it was then defaulting to use
the default format, and if that was changed
to e.g. NC_FORMAT_NETCDF4, then it would try
to create a netcdf-4 format file, even if
NC_CLASSIC_MODEL mode flag was set. 
=Dennis Heimbigner
  Unidata

Original comment by whitaker.jeffrey@gmail.com on 15 Mar 2013 at 8:51

GoogleCodeExporter commented 8 years ago

Original comment by whitaker.jeffrey@gmail.com on 26 Feb 2014 at 2:04