NCL Home > Documentation > Functions > Variable manipulators


Changes all occurrences of IEEE NaN to a user-specified value.


	procedure replace_ieeenan (
		x          : float or double,  
		value  [1] : float or double,  
		option [1] : integer           



An array of any dimensionality and of type float or double.


The value to use for replacing the NaN values.


Currently not used. Set to 0.


This procedure replaces all occurrences of NaN in x with the given value value. If value is to become the _FillValue associated with x, it is the user's responsibility to set the _FillValue.

Important note: this function and isnan_ieee use potentially non-portable code to determine whether a value is a NaN. Exercise caution when using these functions.

See Also



Assume the array x has been calculated or has been read from some file. Use the isnan_ieee function along with the any function to determine if x contains any NaNs. If so, then use the replace_ieeenan procedure to change all occurrences of NaN to a user-specified value:

  if (any(isnan_ieee(x))) then
    if(.not.isatt(x,"_FillValue")) then
      x@_FillValue = default_fillvalue(typeof(x))
    end if
    replace_ieeenan (x, x@_FillValue, 0)
  end if