【发布时间】:2016-03-14 16:31:31
【问题描述】:
我们在一台新的 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 的其他部分……以此类推……
【问题讨论】:
-
显示至少导致打印此注释的命令。您还应该显示一些代码示例stackoverflow.com/help/mcve
-
请按照我的要求显示完整编译命令。你在
end之前使用stop吗?如果是,请不要这样做。报告您的 gfortran 版本和完整代码,包括end program。
标签: exception floating-point fortran gfortran