I have a trivial test program that implements one function, INV, which just computes 1/x. Passing 0 for the argument x triggers a zero-division error. When I compile it with ifort (version 2021.3.0), using the flags /fpe-all:0 /traceback/fp:strict /debug
and run it, I get a traceback like this:
forrtl: error (73): floating divide by zero
Image PC Routine Line Source
ifort-tst.exe 00007FF7EB0411F0 F_mp_INV 9 f.f
ifort-tst.exe 00007FF7EB0410A2 MAIN__ 8 tst.f
In my real application, we call Fortran code from a Python process, using f2py. With a bit of tinkering (had to define macros UPPERCASE_FORTRAN and NO_APPEND_FORTRAN) I was able to compile the same code as a Python module. When I run it from Python, the zero-division causes the program to quit but does not produce the backtrace. If I don't set /fpe-all:0 the module just returns a NaN instead of aborting. I want the program to abort on floating-point exceptions, but I want to see the same type of backtrace that is produced when I run the code as a stand-alone executable.
I suspect that some needed signal handler is not getting registered - with GNU Fortran it's necessary to call a few library initialization functions to make FPE exception handling work (_gfortran_set_options, _gfortran_set_fpe) but I was not able to find the equivalent in the Intel Fortran documentation.
I'm working on the Windows 10 platform. I've been able to get backtraces from an f2py module using gfortran in Linux, but for Windows, the libbacktrace supplied with gcc seems to be non-usable, which drove me to try Intel Fortran.