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.
The simple way without using the ieee_arithmatic
is to do the following.
Infinity: Define your variable infinity = HUGE(dbl_prec_var)
(or, if you have it, a quad precision variable). Then you can simply check to see if your variable is infinity by if(my_var > infinity)
.
NAN: This is even easier. By definition, NAN is not equal to anything, even itself. Simply compare the variable to itself: if(my_var /= my_var)
.