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

Re: 970507: netCDF



>To: address@hidden
>cc: carrie@pemrac
>From: address@hidden (Carrie Gonzalez)
>Organization: .
>Keywords: 199705071848.MAA04257

Hi Carrie,

> I have a question.  I have a float variable and am trying to define an
> attribute (_FillValue) for this variable.  I read in the netCDF users
> guide on page 127 that a flag type can hold values between -3.4+38 and
> 3.4e+38  I need to hold the value -1.0e-31 (minus 31).  What data type
> can I use?  At first, I thought it was because I was printing the value
> %.2e so I changed it to %.0f, but ncgen still gives an error code.

Just guessing, but did you by any chance just specify the attribute as
something like

              x:_FillValue = -1.0e-31;

and get the ncgen error 

    ncgen: ... variable x: _FillValue type mismatch

If so, then the problem is that the type of the _FillValue attribute
must match the type of its variable.  The constant "-1.0e-31" is a
double constant, not a float constant (following the C convention that
floating-point constants are double by default).

To specify a float constant, you actually need to append an "f":

                x:_FillValue = -1.e-31f ;

I believe this is documented in the User's Guide chapter on Utilities,
in the section on syntax for constants in CDL, but perhaps it should be
noted more prominently, since users often think "-1.0d-31" is a double
constant (it is), but "-1.0e-31" is a float constant (it isn't).

--Russ

_____________________________________________________________________

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