C マニュアルに載ってたサンプル: test_nan.F90 とでもする program test_nan implicit none real :: x x = -1.0 x = sqrt(x) if (isnan(x)) stop '"x" is a NaN' end program test_nan
% gfortran test_nan.F90 -ffpe-trap=invalid % ./a.out Fortran runtime warning: IEEE 'invalid operation' exception not supported. STOP "x" is a NaN % echo $? 0