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

Re: 20010531: ncgen Error when using _FillValue



>From: address@hidden
>Subject: ncgen Error when using _FillValue
>Organization: Weather.com
>Keywords: 200105312053.f4VKrDp24081 netCDF 3.4 _FillValue

Hi Bill,

> Noticed a slight quirk that means I maybe doing something wrong.
> 
> When I run the attached cdl through ncgen I get a message about 
> the data type being incorrect.  This only occurs when I have
> the data type defined as a float.  When I change it to a double
> all works fine.
> 
> 
>         netcdf foo {  // an example netCDF specification in CDL
> 
>           dimensions:
>                lat = 10, lon = 5, time = unlimited ;
> 
>           variables:
>                long    lat(lat), lon(lon), time(time);
>                float   Z(time,lat,lon), t(time,lat,lon);
>                double  p(time,lat,lon);
>                long    rh(time,lat,lon);
> 
>                // variable attributes
>                lat:long_name = "latitude";
>                lat:units = "degrees_north";
>                lon:long_name = "longitude";
>                lon:units = "degrees_east";
>                time:units = "seconds since 1992-1-1 00:00:00";
>                Z:units = "geopotential meters";
>                Z:valid_range = 0., 5000.;
>                          Z:_FillValue = -99.0; // Problem is here.
>                p:_FillValue = -9999.;
>                rh:_FillValue = -1;
> }
> 
> ncgen -c foo.cdl
> ncgen: foo.cdl line 20: variable Z: _FillValue type mismatch

This means the type for the Z:_FillValue attribute (double) does not
match the type of the variable Z (float).  _FillValue is used to fill
missing values for Z so it must have the same type, because most
64-bit double values cannot be represented as 32-bit floats.

To fix this, either make the _FillValue attribute a float by using the
"f" suffix, as in:

  Z:_FillValue = -99.0f;

or declare Z to be of type double, as in

  double   Z(time,lat,lon)

--Russ

_____________________________________________________________________

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