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

Problem debugging using IFX and Visual Studio

FrederikS
Beginner
2,336 Views

When debugging code compiled with IFX it is not always possible to watch variables of derived types in QuickWatch (and it is not possible to set conditional breakpoints).

It seems like the type information of variables of derived types is sometimes wrong.

The attached example shows the problem: It is only possible to see the value of REC in either SUB1 or SUB2.  I have tried different combinations of Visual studio and IFX. 

Using IFORT it works fine.  

 

35 Replies
JohnNichols
Valued Contributor III
432 Views

Screenshot 2025-04-25 154741.png

At 17 it goes gray because it is inaccessible but not yet cleaned up by GC. 

 

0 Kudos
andrew_4619
Honored Contributor III
419 Views

Well you see something entirely different to me. It is working OK on my setup IFX 2025.1.0 VS 2022 17.0.5

It is not clear what result John got because he changed the code but that seems to be working IMO.


 

0 Kudos
IgnazSchiele
Novice
425 Views

Could you try with an up-to-date VS 2022 (17.13.6)?

0 Kudos
andrew_4619
Honored Contributor III
372 Views

No I can't do that, sorry. I  do not do VS updates they can break things in my experience and rarely have anything useful as a Fortran user.  Maybe @JohnNichols could do that test he tends to use latest or preview....

 

0 Kudos
JohnNichols
Valued Contributor III
347 Views

I cannot download test.zip it says, scanning for viruses. So please put the code up as a text block using the standard insert function.  </> Function on second line of the tab bar. 

I made minor changes to the code so I could single step through the code and not lose steps.  This needed the entry put into a subroutine.  And I added implicit none and declared the variables so I knew when they existed. 

When I start the code and stop at first line

Screenshot 2025-04-25 145722.png

jnum is declared and is set to the standard open 0. and ctext is empty as expected.

Screenshot 2025-04-25 150202.png

Now we see text and integer filled in 

then step into dummy

Screenshot 2025-04-25 150534.png

 

CTEXT1 is declared and empty, but jnum1 to 3 are not yet set at line 19

 

Screenshot 2025-04-25 150802.png

Teh next step is to line 24, which shows the declared varaibles set as zero except jnum that comes in as 1. 

 

JohnNichols_0-1745611926037.png

Line 25 sets a few variables

Screenshot 2025-04-25 151412.png

Step to entry dummy_2, and jnum2 is set to zero as declared. 

Screenshot 2025-04-25 151613.png

now it steps to the subroutine, and jnum3 is undefined, but jnum2 is defined, it is a bit weird, the entry declares the varaible. 

Screenshot 2025-04-25 151833.png

now the jnum3 is declared, 

Screenshot 2025-04-25 151833.png

Normal variables, set to proper values, 

Screenshot 2025-04-25 152226.png

more correctness

Screenshot 2025-04-25 152326.png

Even more correctness

Screenshot 2025-04-25 152431.png

now at entry jnum2 is undefined but known

Screenshot 2025-04-25 152551.png

jnum2 is declared and correct, jnum3 is undefined but known

Screenshot 2025-04-25 152701.png

defined. 

Screenshot 2025-04-25 152834.png

Set all values. 

Screenshot 2025-04-25 152943.png

 

but now we get garbage when it returns to the entry point.  

 

 

 

0 Kudos
JohnNichols
Valued Contributor III
344 Views

Now the original

Screenshot 2025-04-25 153246.png

As expected

Screenshot 2025-04-25 153620.png

Now they are unknown to the subroutine

 

Screenshot 2025-04-25 153800.png

You are not at numbers yet so it knows it will need them, but has not set them. 

Screenshot 2025-04-25 153935.png

jnum1 and 3 set to zero as expected and jnum2 is stuck at entry point as undefined, it knows it needs it but it is not set 

 

Screenshot 2025-04-25 154138.png

JNUM2 is never reached

Screenshot 2025-04-25 154323.png

It never stops at 21. 

 

0 Kudos
JohnNichols
Valued Contributor III
340 Views

The IFX debugger is a bit strange, but it does show all you need to know, why the circular arrows are there is strange and they do not return the correct value, but the gray value is the one brought in and it is correct. 

I hope this helps. 

 

0 Kudos
JohnNichols
Valued Contributor III
260 Views
PROGRAM CONSOLE
    implicit none
CHARACTER CTEXT*(5)
integer jnum

JNUM = 1
CTEXT = 'Hallo'

CALL DUMMY (JNUM,CTEXT)

END PROGRAM CONSOLE

SUBROUTINE DUMMY (JNUM_PARAM,CTEXT_PARAM)
implicit none
integer jnum_var, jnum_param
CHARACTER CTEXT_PARAM*(*),CTEXT_VAR*(20)

CTEXT_VAR = CTEXT_PARAM
JNUM_VAR = JNUM_PARAM

PRINT *, CTEXT_PARAM

RETURN

ENTRY DUMMY_2

PRINT *, 'Hallo'

RETURN

END

Please use the 

Screenshot 2025-04-30 114610.png

Button to make the code nice and easy to read, it is a thoughtful thing for the reviewers. 

Your code does not have implicit none or the numbers declared and as such you observe what you observe, but if I bring the code up to modern standards with implicit none then I get 

Screenshot 2025-04-30 115225.png

Correct behaviour.   It has been many years since I failed to use implicit none, it is very dangerous coding not to use implicit none, when you fix old code like ULARC UCB 1973, you see the mistakes, and these are a problem. 

The debugger works it does not have errors, but your code is obsolete, do not expect a modern compiler to fix coding issues well. 

It should be an error in Fortran not to use implicit none - Steve???

 

0 Kudos
Steve_Lionel
Honored Contributor III
244 Views

Default implicit typing has been in the language forever. There is a work item for the next revision to make default implicit typing obsolescent, so if you asked for standards checking it would complain. One can always compile with /warn:declarations and that is the equivalent of putting IMPLICIT NONE in all program units.

0 Kudos
JohnNichols
Valued Contributor III
214 Views

Steve:

I have long memory of learning about implicit none and then finding that one cannot write sound Fortran without using this command.  

It is too easy to type a variable name incorrectly and then you have a problem, it can be a subtle problem if the answers are close on a test case, but then become a problem later on in the code usage. 

Of course it is a personal choice, but clearly the debugger team assumes that implicit none is in place or so it seems to me.  

You only need to translate Old Fortran say 1968 to modern Fortran to know the first thing to do is put in implicit none and then look for the mistakes.   Harrison's 72 is an example.  

Stay cool 

John

0 Kudos
andrew_4619
Honored Contributor III
207 Views

"Of course it is a personal choice, but clearly the debugger team assumes that implicit none is in place or so it seems to me. " Not so, it has no effect on the test case from the tests I made.

0 Kudos
JohnNichols
Valued Contributor III
194 Views

Putting aside all of the interesting stuff we have discussed, there is a clear difference in IFX and IFORT as to how it handles passed arguments once the debugger is inside the subroutine and we want to look at the passed arguments, as was advanced in original posts, if you hit the circular arrows the data for the arguments disappears in IFX and not in IFORT.  

I would at least expect the same functionality in IFX.  Perhaps Intel will make the change or we just learn do not touch the circular arrows.  The popup message is in my humble opinion, incorrect, the values are known as they are passed. 

This is the crux of the original posts.  

Untitled.png

0 Kudos
andrew_4619
Honored Contributor III
184 Views
In my slightly older version of Vs2022 I do not see the circular arrows and it all works fine. My guess is the integration with Vs is broken by a Vs update. This is not uncommon.
0 Kudos
IgnazSchiele
Novice
152 Views

Thank you for your further tests and comments.
I have also tested further in the meantime, namely with different versions of Visual Studio 2022:

17.0.23

17.8.20 and

17.12.4 (17.12.4 is the latest version of Visual Studio 2022, which is specified as ‘supported’ by Intel).

After the installation, I installed Intel® oneAPI HPC Toolkit (version 2025.1.1) from 30.4.2025.
In all tests, the behaviour is as I have already described, regardless of whether ‘implicit none’ is specified or not. In addition, if you only set a single breakpoint in the example code, namely in JohnNichols' code in line 21 (before “PRINT *, CTEXT_PARAM”), then you cannot watch the values of the variables - so the problem cannot be solved by not clicking on the circular arrows.

This thread has become very confusing. Therefore, I will open a new thread and describe the problem there again so that Intel can fix it.
Before that, I would like to know if there are still concerns from your side to report the problem to Intel so that the new thread does not become confusing again.

0 Kudos
JohnNichols
Valued Contributor III
143 Views
0 Kudos
Reply