Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: beta1 bug



Jeff Whitaker <jswhit@xxxxxxxxxxx> writes:

> Ed:  The attached C program creates a netcdf4_classic file that is
> unreadable (ncdump'ing it gives an 'HDF Error').
>
> -Jeff
>
> -- 
> Jeffrey S. Whitaker         Phone  : (303)497-6313
> Meteorologist               FAX    : (303)497-6449
> NOAA/OAR/PSD  R/PSD1        Email  : Jeffrey.S.Whitaker@xxxxxxxx
> 325 Broadway                Office : Skaggs Research Cntr 1D-124
> Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg
>
>
> #include <stdio.h>
> #include <string.h>
> #include <netcdf.h>
> #define FILENAME "testfile.nc"
> #define ATT1 "foo"
> #define ATT2 "bar"
> #define LONG_NAME "attribute"
> #define ATT3 "long_name"
> #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); return 2;}
> int
> main()
> {
>        int ncid, retval, att;
>
>        if ((retval = nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL))) ERR(retval);
>
>        if ((retval = nc_create(FILENAME, NC_CLOBBER, &ncid))) ERR(retval);
>        if ((retval = nc_enddef(ncid))) ERR(retval);
>
>        att = 1;
>
>        if ((retval = nc_redef(ncid))) ERR(retval);
>        if ((retval = nc_put_att(ncid, NC_GLOBAL, ATT1, NC_INT, 1, &att))) ERR(retval);
>        if ((retval = nc_enddef(ncid))) ERR(retval);
>
>        att = 2;
>
>        if ((retval = nc_redef(ncid))) ERR(retval);
>        if ((retval = nc_put_att(ncid, NC_GLOBAL, ATT2, NC_INT, 1, &att))) ERR(retval);
>        if ((retval = nc_enddef(ncid))) ERR(retval);
>
>        if ((retval = nc_redef(ncid))) ERR(retval);
>        if ((retval = nc_put_att_text(ncid, NC_GLOBAL, ATT3, strlen(LONG_NAME), LONG_NAME))) ERR(retval);
>        if ((retval = nc_enddef(ncid))) ERR(retval);
>
>        if ((retval = nc_close(ncid))) ERR(retval);
> }
>

Thanks Jeff!

This is not an ncdump bug; nc_open fails on this file!

I have added it to the netCDF-4 tests and will let you know when I get
it solved...

Thanks,

Ed
-- 
Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

===============================================================================
To unsubscribe netcdf-hdf, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
===============================================================================


 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Office of Programs University Corporation for Atmospheric Research (UCAR)   Unidata is a member of the UCAR Office of Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690