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

ifort: Debugging module variables issue

uha
Novice
1,145 Views

I´m trying to debug variable i in the following code:

module m
  implicit none
  save
  private
  integer :: i = -1

  public f
  contains

  logical function f()
    i = 3
    f = .true.
  end function f
end module m

program main
  use m
  if(.not.f()) continue
end program main

The issue is that I cannot easily see the value of the module variable i. Mouse-hovering over it does not show anything. Adding it to a watch window gives "Undefined variable i". Only when I add a watch like "m::i" it will display the value correctly. For local variables debugging works as expected. Visual Studio version is 2022 (17.8.6), oneApi is 2024.0.2, ifort 2021.11.0. Installed components are just gdb support from the base toolkit and the fortran compiler from hpc.

Using ifx debugging works as expected. Unfortunately I cannot switch the real project to ifx now. One of the reasons is that while debugging works fine for the above lines of code in the real project the debugger with ifx will hang after having hit the first breakpoint ("A debugger operation is taking longer than expected").

Btw. I remember having seen this issue many years ago (10+ I think)...

0 Kudos
6 Replies
Steve_Lionel
Honored Contributor III
1,129 Views

That's just the way it works - sorry. You've already found the workaround.

0 Kudos
uha
Novice
1,106 Views

Thanks Steve. I´m surprised though - debugging module variables has been working as described for me before updating from oneAPI 2023 to 2024, and for many versions before that. Also I have found old posts where people claim it only works if the variable is being used in the current function - so this feature must have been dropped at some point then.

0 Kudos
Devorah_H_Intel
Moderator
1,064 Views

Please provide a test case for the hang.

@uha wrote:

 

Using ifx debugging works as expected. Unfortunately I cannot switch the real project to ifx now. One of the reasons is that while debugging works fine for the above lines of code in the real project the debugger with ifx will hang after having hit the first breakpoint ("A debugger operation is taking longer than expected").

 

0 Kudos
JohnNichols
Valued Contributor III
1,054 Views

Screenshot 2024-02-08 174144.png

IFX is ok, IFORT is not good, you need the m::i, it  is gone after the end of the year except for old versions according to what I have read. 

 

All the code I have tested transitions to IFX without problems. 

 

uha
Novice
993 Views

I found that the hanging debugger is related to a C static library project linked to the fortran dll. I have tried to make a minimal reproducer but anything smaller than the production code just worked, so sorry I cannot contribute here. Fortunately I could just remove that C static library as it no longer being used anyway.

I cannot currently make the switch to ifx as it must be aligned with other projects and we need to set aside a bit of time to analyse what to look out for during migration. However, this goes for the release build only, no problem to use ifx for debugging, and with that now everything works as I had hoped!

JohnNichols
Valued Contributor III
978 Views

I am the only one who uses my code, so I never go off debug.  Sorry. 

0 Kudos
Reply