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

Re: 970811: NetCDF v2.4 on Linux



>To: address@hidden
>From: "Nigel O'Brian" <address@hidden>
>Subject: Minor bug in NetCDF 2.4
>Organization: School of Mathematics, University of Sydney
>Keywords: 199708110100.TAA07093

Hi Nigel,

Your bug report was sent to me by mistake while I was on vacation, so
that's why it's taken so long to respond.

> The following illustrates a minor inconsistency in the NetCDF
> interface (v2.4 on Linux). Sorry if this is out of date.
> 
> You can define a variable called "", but accessing the
> variable in the resulting file causes a segmentation
> fault. According to the documentation "" should not be
> accepted. This problem can occur naturally when using a
> Perl or Python interface, as "" is OK as a dictionary key
> or associative array key in these languages (and is also
> a natural default choice for a variable name!).
> 
> % cat netcdftest.c
> #include <netcdf.h>
> int  ncid;                         /* netCDF ID */
> int  lat_dim, lon_dim, time_dim;   /* dimension IDs */
> int  rh_id;                        /* variable ID */
> int  rh_dimids[3];                 /* variable shape */
> 
> main() 
> {
>   ncid = nccreate("foo.nc", NC_CLOBBER);
>   lat_dim = ncdimdef(ncid, "lat", 5L);
>   lon_dim = ncdimdef(ncid, "lon", 10L);
>   time_dim = ncdimdef(ncid, "time", NC_UNLIMITED);
>   rh_dimids[0] = time_dim;
>   rh_dimids[1] = lat_dim;
>   rh_dimids[2] = lon_dim;
>   /* Here's that weird variable... */
>   rh_id = ncvardef (ncid, "", NC_DOUBLE, 3, rh_dimids);
>   ncendef(ncid);
>   ncclose(ncid);   
>   ncid = ncopen("foo.nc", NC_NOWRITE);
>   printf("Getting variable id\n");
>   rh_id = ncvarid (ncid, "");
>   printf("Variable id is %d\n", rh_id);
>   ncclose(ncid);
> }
> % ./netcdftest
> Getting variable id
> Segmentation fault

I've verified that the second problem you report (the segmentation
violation) does not occur with the current version of netCDF (3.3.1):

  $ ./netcdftest
  Getting variable id
  Variable id is 0

However, the current version still permits the definition of a variable
with the name "".  I think we should not continue to permit this as a
variable name, even if the Perl and Python interfaces would support it,
because applications and visualization systems for netCDF data might
have problems with empty names.  Also their is no CDL syntax to declare
a variable with the name "".

Thanks for reporting the bug.

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu