title: Is there a standard way to check for Infinite and NaN in Fortran 90/95?
body: <p>I've been trying to find a standards-compliant way to check for Infinite and NaN values in Fortran 90/95 but it proved harder than I thought.</p>
  
  <ul>
  <li>I tried to manually create Inf and NaN variables using the binary representation described in IEEE 754, but I found no such functionality.</li>
  <li>I am aware of the intrinsic <code>ieee_arithmetic</code> module in Fortran 2003 with the <code>ieee_is_nan()</code> and <code>ieee_is_finite()</code> intrinsic functions. However it's not supported by all the compilers (<a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29383" rel="noreferrer">notably gfortran</a> as of version 4.9).</li>
  </ul>
  
  <p>Defining infinity and NaN at the beginning like <code>pinf = 1. / 0</code> and <code>nan = 0. / 0</code> seems hackish to me and IMHO can raise some building problems - for example if some compilers check this in compile time one would have to provide a special flag.</p>
  
  <p>Is there a way I can implement in standard Fortran 90/95?</p>
  
  <pre><code>function isinf(x)
  ! Returns .true. if x is infinity, .false. otherwise
  ...
  end function isinf
  </code></pre>
  
  <p>and <code>isnan()</code>?</p>