Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Complier options

jhjensen
Beginner
847 Views
Which compiler options must i activate in order to have a traceback when a floating overflow occurs ?
TIA
0 Kudos
7 Replies
mecej4
Honored Contributor III
847 Views
/fpe0 /traceback

0 Kudos
jhjensen
Beginner
847 Views
Don't work.
Result :
forrtl: error (72): floating overflow
and trace back has "unknown"
for every Routine Line and Source 1

Regards
0 Kudos
abhimodak
New Contributor I
847 Views
Hi jhjensen

You may want to try the intrinsic IEEE_EXCEPTIONS module and monitor the exceptions flag. (Below is a very terse snippet.) This will not "generate traceback" per say; but gives you more control.

Yet another possibility, if you are using Visual Studio, is to enable Debug--> Exception --> Win32 exceptions.

Abhi

-------

Program Test_TrapFloatingPoint

Use IEEE_EXCEPTIONS

Implicit None

Real(8) :: x, y, z
Logical :: Exception(5)

Call Random_Seed()
Call Random_number(x)

Write(*,*) "Give a real number"
Read *, y

z = x/y

! Exception = [IEEE_OVERFLOW, IEEE_DIVIDE_BY_ZERO,
! IEEE_INVALID, IEEE_UNDERFLOW, IEEE_INEXACT]
Call IEEE_GET_FLAG(IEEE_ALL, Exception)

if (ANY(Exception)) then
Write(*,*)
Write(*,*) "IEEE exception flags are:-"
Write(*,*)
Write(*,*) "IEEE_OVERFLOW:", Exception(1)
Write(*,*) "IEEE_DIVIDE_BY_ZERO:", Exception(2)
Write(*,*) "IEEE_INVALID:", Exception(3)
Write(*,*) "IEEE_UNDERFLOW:", Exception(4)
Write(*,*) "IEEE_INEXACT:", Exception(5)
else
Write(*,*) "Operation completed successfully."
endif

End Program Test_TrapFloatingPoint
0 Kudos
Steven_L_Intel1
Employee
847 Views
Can you show us a short sample that doesn't work?
0 Kudos
jhjensen
Beginner
847 Views
PROGRAM TESTOVERFLOW
real r
integer i,n
write(*,*) 'Hello world'
read(*,*) i
r=1.
n=45
do i=1,n
r=r*10.
end do
write(*,*) 'r= ',r
read(*,*) i
END


compile and link:
ifort /c /MW /traceback /check:all /warn:nodeclarations /Qzero /fpe0 testoverflow.for
link /subsystem:windows testoverflow

Running will produce overflow error but no traceback line numbers

Regards
JHJ
0 Kudos
Steven_L_Intel1
Employee
847 Views
Interesting. Your use of /subsystem:windows and /MW made me wonder if the traceback was being disabled by that but I can see the same effect with a console application. I'll ask the developers about this. Issue ID is DPD200157968.

I note that compiling with /arch:ia32 allows the traceback to work.
0 Kudos
Steven_L_Intel1
Employee
847 Views
We have found and fixed the cause of this problem, which was improper handling of the exception by the Fortran run-time library. The fix will appear in a future release of the compiler.
0 Kudos
Reply