Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.

[netcdfgroup] bug mixing dap reads and netcdf4 writes

Here's a python program that triggers the error:

 import netCDF4
 
nc=netCDF4.Dataset('http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/wave_gom3'
  <http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/wave_gom3%27>)
 nco=netCDF4.Dataset('dummy.nc', 'w', format='NETCDF4')
 
nc2=netCDF4.Dataset('http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3'
  <http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3%27>)

Traceback (most recent call last):
  File "issue170.py", line 4, in <module>
nc2=netCDF4.Dataset('http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3') File "netCDF4.pyx", line 1386, in netCDF4.Dataset.__init__ (netCDF4.c:19186)
    raise RuntimeError((<char *>nc_strerror(ierr)).decode('ascii'))
RuntimeError: NetCDF: Invalid argument

and here's the C counterpart

#include <stdlib.h>
#include <netcdf.h>
#define handle_error(e) {printf("Error: %s\n", nc_strerror(e)); exit(2);}

int main(int *argc, char **argv)
{
char flnm[] = "http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/wave_gom3";; char flnm2[] = "http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3";;
    char flnmo[] = "dummy.nc";
    int status;                        /* error status */
    int ncid, ncid2, ncido;            /* netCDF ID */

    status = nc_set_default_format(NC_NETCDF4, NULL);
    if (status != NC_NOERR) handle_error(status);

    status = nc_open(flnm, NC_NOWRITE, &ncid);
    if (status != NC_NOERR) handle_error(status);

    status = nc_open(flnmo, NC_WRITE | NC_CLOBBER, &ncid);
    if (status != NC_NOERR) handle_error(status);

    status = nc_open(flnm2, NC_NOWRITE, &ncid);
    if (status != NC_NOERR) handle_error(status);

    return ( 0 );
}

which produces

Error: NetCDF: Invalid argument

Note that the file write sandwiched between the DAP reads must be NETCDF4 format to trigger the error. Tested with 4.2.1.1 and 4.3.0rc2.

Regards, Jeff
  • 2013 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: