[Opendap-tech] netcdf_handler and long strings

James Gallagher jgallagher at opendap.org
Tue Feb 3 14:33:26 PST 2009


On Feb 3, 2009, at 3:20 PM, fedor baart wrote:

> Hi,
>
> I was trying out the new string arrays from the latest changes in  
> netcdf_handler. I noticed that when I do a request to a variable  
> which has long strings (char areaname(transect, stringsize) ; in  
> netcdf) that all strings are cut short to the length of 3. I am  
> using revision 20263 build on OS X with netcdf 4.
> I looked in the code of the handler and think that there might be a  
> mix up of dimension ids and dimension sizes
>
> The following line: http://scm.opendap.org:8090/trac/browser/trunk/netcdf_handler/ncdas.cc#L346
> 346                errstat = nc_inq_vardimid(ncid, v, dim_sizes);
> uses dim_sizes as a third argument but the 3rd argument to  
> nc_inq_vardimid returns the dimids.
> (http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c/nc_005finq_005fvar.html#nc_005finq_005fvar 
> )
>
> The same thing can be found in the reading of the data in the  
> NCArray.cc, only the variable is named vdims and passed to the  
> nc_inq_var function.
> (http://scm.opendap.org:8090/trac/browser/trunk/netcdf_handler/NCArray.cc#L166 
> )
>
> I think something like this should be added here:
> +    size_t vdims[MAX_VAR_DIMS];    /* variable dimension sizes */
> +    for (int i = 0; i < num_dim; i++) { /* get num_dim from  
> nc_inq_var ndimps */
> +      size_t len;
> +      errstat = nc_inq_dimlen(ncid, dimids[i], &len);
> +      if (errstat != NC_NOERR)
> +       throw Error(errstat,
> +                   string("Could not read information about the  
> variable `")
> +                   + name() + string("'."));
> +      vdims[i] = len;
> +    }
> +
>
> I tried to create a patch but ran into a segmentation fault on the  
> creating of the new string[nels] which I didn't understand.
>
> Is this the cause for my strings cut short or might there be another  
> reason?

This is likely it - I'll look at this and get back to you soon.

Thanks,
James
>
>
> Kind regards,
>
> Fedor Baart
>
>
>
>
> _______________________________________________
> opendap-tech mailing list
> opendap-tech at opendap.org
> http://mailman.opendap.org/mailman/listinfo/opendap-tech

--
James Gallagher
jgallagher at opendap.org
406.723.8663

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.opendap.org/pipermail/opendap-tech/attachments/20090203/7db64039/attachment.html>


More information about the opendap-tech mailing list