Dear ferret users, Problem:Our climate model output has many variables of the type "float" = single precision. Reading this data into double-precision ferret caused "-1.E34" not to be recognized by ferret anymore as missing/bad value. "-1.E34" had been written as data into the files where data was missing/bad, but had not be explicitly defined among the variable attributes in the netCDF header.
Solution:1) "missing_value" or "_FillValue" has to be defined explicitly as a variable attribute for single-precision variables.
2) The safest way to do this is to specify the "_FillValue", best if specified explicitly with a type "f" as "-1.E+34f", even
though "_FillValue" also works without specifying the type. If "missing_value" is preferred, it HAS to be specified with a type as given above. Example: float press(time) ; press:long_name = "pressure" ; press:_FillValue = -1.E+34f ; OR: press:missing_value = -1.E+34f ; Best wishes, Hella More info from Ansley and Russ:
It turns out that the NetCDF library decides to read the attribute missing_value as a double-precision attribute, but it reads the _FillValue as a single-precision attribute. So, the internal bad-value that is stored by Ferret matches what is in the single-precision variable when using ex_float_fill.nc but does not match it in ex_float_missing.nc. The correct way to specify the value for an attribute is with*-1.E+34f*; to explicitly give the value a data type. It seems that because _FillValue has a standardized meaning, the library matches the attribute's type with the variable it is associated with. It is not only the CF standard, but also the NetCDF library conventions which gives the _FillValue a special meaning. Here, http://www.unidata.ucar.edu/software/netcdf/docs/netcdf/Attribute-Conventions.html the description says that _Fillvalue "should be scalar and of the same type as the variable." In fact, it seems it is automatically interpreted as having the same type. A missing_value attribute is described as a useful attribute whose use may be determined by applications.
Adding the missing value attribute with nco may or may not be a quick task. If there isn't sufficient space in the definition part of the file nco may have to make a temporary copy of each file. Still, in the long term it will probably be worth it to have CF compliant files.