gfortran IEEE 异常不准确
gfortran IEEE exception inexact
我们在新的 64 b 机器上使用 gfortran (5.3.1)、Fedora 23。使用简单的 gfortran -o 编译(我们没有使用 -ffpe-trap 选项!),激发 "classical- trivial" 警告:
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG
这是由于 INEXACT 异常(类型 2.0/3.0)。 DDD 调试器指向一个实常数(180d0/pi;pi = 3.141518...)。我们不明白为什么会出现这个标志,有了这个基本的编译,因为这些异常一直到达...
这里有一些代码:
Implicit none !real*8(a-h,o-z)
real*8 pi,dpi,radgra,TSI,TOL,xlsol,fi,W
Integer year, T1, k,m
open(10,file='stof-elem.sol')
pi = 4.d0 * datan(1.d0)
dpi = 2.d0 * pi
radgra = 360.d0 / dpi !!!!!!!! HERE POINTS THE EXCEPTION!!!!!!!!!!
T1 = -9998 !800d0 !1450d0 !
TSI = 1360.d0 !1364.5d0 !1367d0
TOL = 0.7d0 / radgra ! dont' use smaller
C...Name of the output file
open(12,file='midmonth-2000.sal')
C-----------------------------------------------------------------------
k = 0 ! outputs counter
write(12,*)T1
DO m = 1, 12 ! select month
IF(T1.lt.0) then
xlsol = (270.d0 - dble(m-1) * 30.d0) / radgra !from Dec
if(xlsol.lt.0d0) xlsol = xlsol + dpi
ELSE
xlsol = dble(m-3) * 30.d0 / radgra !from Jan
if(xlsol.lt.0d0) xlsol = xlsol + dpi
ENDIF
CALL MEANINSOLA(pi,dpi,radgra,TOL,T1,TSI,xlsol,fi,k,W)
rewind(10) ! better rewind...
ENDDO
write(*,*) 'Outputs:', k,'lines'
异常出现在 RADGRA 的定义中...如所示。如果重新定义常量(即,RADGRA = 57.2d0),异常会迁移到使用 RADGRA 的其他部分......等等......
根据 https://gcc.gnu.org/ml/fortran/2013-06/msg00072.html Fortran 标准要求在执行 STOP
语句后打印这些注释。
"If any exception (14) is signaling on that image, the processor shall
issue a warning indicating which exceptions are signaling; this
warning shall be on the unit identified by the named constant ERROR
UNIT (13.8.2.8)."
请注意,即使您通过 -std=f95
请求 Fortran 95 标准,该注释仍会显示。
您可以通过 -ffpe-summary=
控制此行为,请咨询您的编译器 manual。默认情况下,会显示除“不准确”之外的所有异常的摘要。您是否在某处启用了不精确的功能?
为什么异常信号是另一回事,您必须检查您的代码是否是您应该担心的事情。可能你不应该,不精确的浮点运算 很常见 。
因为消息是由 STOP
语句调用的,摆脱这些消息的一个简单方法是不要通过 STOP
语句终止程序,而是让它到达 END PROGRAM
.
我们在新的 64 b 机器上使用 gfortran (5.3.1)、Fedora 23。使用简单的 gfortran -o 编译(我们没有使用 -ffpe-trap 选项!),激发 "classical- trivial" 警告:
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG
这是由于 INEXACT 异常(类型 2.0/3.0)。 DDD 调试器指向一个实常数(180d0/pi;pi = 3.141518...)。我们不明白为什么会出现这个标志,有了这个基本的编译,因为这些异常一直到达...
这里有一些代码:
Implicit none !real*8(a-h,o-z)
real*8 pi,dpi,radgra,TSI,TOL,xlsol,fi,W
Integer year, T1, k,m
open(10,file='stof-elem.sol')
pi = 4.d0 * datan(1.d0)
dpi = 2.d0 * pi
radgra = 360.d0 / dpi !!!!!!!! HERE POINTS THE EXCEPTION!!!!!!!!!!
T1 = -9998 !800d0 !1450d0 !
TSI = 1360.d0 !1364.5d0 !1367d0
TOL = 0.7d0 / radgra ! dont' use smaller
C...Name of the output file
open(12,file='midmonth-2000.sal')
C-----------------------------------------------------------------------
k = 0 ! outputs counter
write(12,*)T1
DO m = 1, 12 ! select month
IF(T1.lt.0) then
xlsol = (270.d0 - dble(m-1) * 30.d0) / radgra !from Dec
if(xlsol.lt.0d0) xlsol = xlsol + dpi
ELSE
xlsol = dble(m-3) * 30.d0 / radgra !from Jan
if(xlsol.lt.0d0) xlsol = xlsol + dpi
ENDIF
CALL MEANINSOLA(pi,dpi,radgra,TOL,T1,TSI,xlsol,fi,k,W)
rewind(10) ! better rewind...
ENDDO
write(*,*) 'Outputs:', k,'lines'
异常出现在 RADGRA 的定义中...如所示。如果重新定义常量(即,RADGRA = 57.2d0),异常会迁移到使用 RADGRA 的其他部分......等等......
根据 https://gcc.gnu.org/ml/fortran/2013-06/msg00072.html Fortran 标准要求在执行 STOP
语句后打印这些注释。
"If any exception (14) is signaling on that image, the processor shall issue a warning indicating which exceptions are signaling; this warning shall be on the unit identified by the named constant ERROR UNIT (13.8.2.8)."
请注意,即使您通过 -std=f95
请求 Fortran 95 标准,该注释仍会显示。
您可以通过 -ffpe-summary=
控制此行为,请咨询您的编译器 manual。默认情况下,会显示除“不准确”之外的所有异常的摘要。您是否在某处启用了不精确的功能?
为什么异常信号是另一回事,您必须检查您的代码是否是您应该担心的事情。可能你不应该,不精确的浮点运算 很常见 。
因为消息是由 STOP
语句调用的,摆脱这些消息的一个简单方法是不要通过 STOP
语句终止程序,而是让它到达 END PROGRAM
.