调试相当老的Fortran程序,有NaN输出,想在有NaN运算的地方引起异常让程序立即core dump。测试显示ifort明显比gfortran功能好很多。
program test
use,intrinsic::&
&ieee_arithmetic,only:ieee_value,ieee_quiet_nan,ieee_signaling_nan
real::x,y
!x=ieee_value(x,ieee_signaling_nan)
x=ieee_value(x,ieee_quiet_nan)
y=10.0
write(*,*) x+y
write(*,*) x*y
write(*,*) y/x
stop
end
!----------------------------------------------------------------------------------------------------------------------------------
! gfortran 抓不到snan异常
! gfortran -finit-real=snan -Wall -fcheck=all -fbacktrace -ffpe-trap=invalid,zero,overflow,underflow,denormal
!
!
! ifort -fpe0 可以抓到snan异常
! ifort -Ofast -fpe0 可以抓到snan异常
! ifort -g -traceback -Ofast -fpe0
! ifort -g -traceback -init=snan -Ofast -fpe0
!------------------------------------------------------------------------------------------------------------------------------------