If you don't have the opportunity to update your gfortran, note that the
following program works with gfortran 4.9.0 and (I suspect but can't prove
because of a disaster yesterday) with earlier versions. It also works with
g95 0.94 and Sun Fortran 95 8.7.
program naninf
character(4) :: infnan(3) = (/'Inf ','-Inf','Nan '/)
real infplus,infminus,nan
read(infnan,*) infplus,infminus,nan
print *, infplus,infminus,nan
end program naninf
By the way, infnan must be a variable not a constant. Declaring it by
character(4),parameter :: infnan(3) = (/'Inf ','-Inf','NaN '/).
and using it in an internal read is contrary to all three of the f95, f2003
and f2008 standards, but only g95 complains if you try it. As the
prohibition is not in a Constraint, it's not a bug but a quality-of-
implementation issue for the other compilers.
Of course Inf and NaN in input are an F2003 feature, but gfortran and g95
both allowed it as an f95 extension even when I used the std=f95 option.