This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>From: address@hidden >Subject: ncgen Error when using _FillValue >Organization: Weather.com >Keywords: 200105312053.f4VKrDp24081 ncdump _FillValue C++ Bill, > The following code snippet does produce a correct CDL > in terms of the heading...However when I dump the values > for this field I get the default '-' instead of the > specified value. Am I doing something out of order? > > I did see a post at http://www.unidata.ucar.edu/cgi-bin/mfs/70/2885?33#mfs > and tried the suggestion...Still to no avail. > > hourly_nc_nc->set_fill(); > NcVar* P; > NcDim* dim; > > dim = hourly_nc_nc->get_dim( "max_site_num" ); > P = hourly_nc_nc->add_var( "site_list", ncInt, dim ); > P->add_att( "_FillValue", -999 ); > P->add_att( "long_name", "forecast site list" ); It looks like you're doing everything right, which is why ncdump shows the values of your "max_site_num" variable as "_". That's the way ncdump displays values that are equal to the fill value for any variable. I just checked the man-page documentation for ncdump (the ncdump.1 file that comes with the distribution), and it says: ncdump uses `_' to represent data values that are equal to the `_FillValue' attribute for a variable, intended to represent data that has not yet been written. If a variable has no `_FillValue' attribute, the default fill value for the variable type is used if the variable is not of byte type. --Russ