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

Bug in ncgen handling of multidimensional character variables

Hi,

An undocumented feature of ncgen in netCDF-2 was that null padding was
added to strings that were shorter than the last dimension of a
multidimensional character variable, instead of just concatenating them.
This permitted using strings of different lengths in an array in CDL,
for example:

    netcdf bug {
    dimensions:
            scan = 4 ;
            string_len = 10 ;
    variables:
            char name(scan, string_len) ;
    data:

     name
      "Methane",
      "Ammonia",
      "Water",
      "Acetylene" ;
    }

In versions 3.3 and 3.3.1, unfortunately this feature no longer works.
Instead the strings are just concatenated, as they would be with a
1-dimensional variable.  For example, when the above CDL file is
converted to a netCDF file using the "-b" option to ncgen, running
ncdump on the result produces:

    netcdf bug {
    dimensions:
            scan = 4 ;
            string_len = 10 ;
    variables:
            char name(scan, string_len) ;
    data:

     name
      "MethaneAmm",
      "oniaWaterA",
      "cetylene",
      "" ;
    }

A patch is now available that fixes the problem, from

    http://www.unidata.ucar.edu/packages/netcdf/patch-3.3.1-2

The problem description and a link to the patch have been added to the
"Known Problems" page for netCDF at

    http://www.unidata.ucar.edu/packages/netcdf/known_problems.html

The fix will be included in the next minor release.

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
russ@xxxxxxxxxxxxxxxx                     http://www.unidata.ucar.edu

 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community 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