Avoid equality checks on doubles.  Use the non-standard isnan function until ieee_arithmetic is supported by gfortran