Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646
26864 Discussions

Co-Simulation debug does not stop on floating point exceptions

marinoni__andrea_mas
222 Views

Dear all,

I am running the debug of a fortran code in co-simulation with matlab/simulink. The simulink model contains an s-function which uses fortran.

To do this co-simuation I compile the solution, select 'attach to process' from the debug menu and then select the matlab process. Then I start the simulation of my simulink model and if i placed brakpoints on the fortran solution i can debug it.

The problem is that during debug I can stop on the fortran code and see variables values but floating point exceptions are not hitted: simulation continues on division by zero or square root of negative numbers. Of course the value of the result of these fpe are shown and are NaN or infinity. The issue is that execution does not stop.

This only happens in this co-simulation framework: as standalone the execution correctly fails on fpe.

I hope someone has experience with this advanced debugging techniques. if you can suggest any options or procdure to effectly debug the code it would be usefule.

I add that I also tried to enable 'all exceptions' from the VS windows 'runtime exceptions'.

Unfortunately i cannot share something to reproduce this.

Using: Windows10, VS 2019 enterprise (latest release) and Intel classic fortran compiler (base + hpc toolkits 2021.1)

Thank you.

0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
206 Views

Try setting the Intel Fortran project property Fortran > Command Line > Additional Options to:

/fpe-all:0

There is not a regular property for this option. What this does is, on entry to every Fortran routine, enable an exception on floating point overflow and zerodivides. This won't help if the NaN or Inf comes from a math library call.

 

View solution in original post

3 Replies
FortranFan
Honored Contributor II
218 Views

@marinoni__andrea_mas ,

Would you have a reasonably good guesstimate of the section of the call stack, say the Fortran library (is it a DLL?) and preferably the subprogram (subroutines?) call tree where the floating-point exception might get raised such as via an instruction involving a square root of a negative number?  If yes, I can suggest something you can try.

Steve_Lionel
Black Belt Retired Employee
207 Views

Try setting the Intel Fortran project property Fortran > Command Line > Additional Options to:

/fpe-all:0

There is not a regular property for this option. What this does is, on entry to every Fortran routine, enable an exception on floating point overflow and zerodivides. This won't help if the NaN or Inf comes from a math library call.

 

View solution in original post

marinoni__andrea_mas
185 Views

Thank you @Steve_Lionel  ! It works! Now the execution stops on divisions by zero.

@FortranFan I intentionally placed a line with a division by zero as a test to see if debug was actually stopping on fpe. The issue was that the execution didn't stop even if I could hit the breakpoint on the same line and see the result was infinity. I attach a image to explain better what happened.

Now, with the additional compiler option suggested by Lionel, the execution stops throwing the exception as expected.

I really appreciate your help. Thank you.

Reply