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

Not seeing Array element values.

IM13
Beginner
2,553 Views
Greetings,

I am having difficulty using the Watch box in visual studios to view the value of an array element for my Fortran program. The variable is recognized, however, it does not display the value for any elements (ie array(1)). I was wondering if anyone knew a remedey for this problem.

Thanks
0 Kudos
10 Replies
Wendy_Doerner__Intel
Valued Contributor I
2,553 Views

For data breakpoints you have to use the underlying Microsoft* Visual Studio data breakpoints, but it only allows you to look at memory not intepret it. I have included the details on how to do this below from the documentation.

------

Wendy

Attaching or including files in a post

Using Visual C++ Data Breakpoint Support

The Visual Studio IDE does not provide data breakpoint support specifically for Fortran. Nevertheless, you can still use data breakpoints in a Fortran program; they are handled using the existing mechanism provided by Microsoft Visual C++. This means that you must use Visual C++ syntax; yo u cannot enter the variable name or condition using Fortran syntax. The following guidelines apply:

  • For scalar variables, enter the variable name in upper case. This allows Visual C++ to find the variable in the debug information and apply the correct breakpoint.

  • For arrays and types, use the Fortran LOC intrinsic function in a Watch window or the Immediate window to obtain the address of the variable. Use this address in the variable name edit box.

For example, to prepare to set a data breakpoint at an array element a(5), do the following:


  1. Select Debug>Windows>Immediate.

  2. Enter loc(a(5)) in the immediate window and press Enter.

    The result displayed is the address of the array element. The address may be displayed as a decimal number or a hexadecimal number, depending upon your current display mode. For a decimal number, you will enter it in the Address: field (Visual Studio 2005 and Visual Studio 2008). For a hexadecimal number, you will use the Visual C++ hexadecimal syntax (0xnnnnnnnn) rather than the Fortran syntax (#nnnnnnnn) in the fields.

The following procedure applies to debugging the current routine (current scope).

To set a data breakpoint (Visual Studio 2005 and Visual Studio 2008):


  1. Start debugging.

  2. In the Debug menu, select New Breakpoint, then New Data Breakpoint...

  3. Enter the desired address. Also enter the Byte Count and Language (be sure to specify C++).

If you want to associate a condition with this breakpoint, right-click on the breakpoint in the Breakpoints window and choose Condition....

To disable, enable, or remove a data breakpoint:


  1. In the Debug menu, select Windows>Breakpoints.

  2. To disable or enable the data breakpoint, use the check box to the left of the data breakpoint (check indicates enabled).

  3. To remove a data breakpoint, click (select) the data breakpoint and click the Delete button.

0 Kudos
IanH
Honored Contributor III
2,553 Views
(Assuming here that you are debugging a debug build...)

Occasionally (and I don't know why) I also get arrays that refuse to expand (you don't get a little plus next to the array name, or you get a plus, but when you click it the plus disappears). Somewhat bizarrely, in some cases, simply adding another variable below (perhaps a scalar) in the watch list fixes the problem. Othertimes, adding "(:)" to the end of the array fixes it. Othertimes, no matter what I do it doesn't work. The only consistency I find is that it is only the arrays that I really want to look at that have the problem.

I've seen this with VS2005, and playing around as I write this I can get this with VS2010 too - see below for proof...

Plus not working (I clicked on it and it ran away) :(



Add (:) to the watch, array expansion in the watch window now works (same debugging session)!



(The debugger appears to be somewhat confused about the type of the array here too... it has picked up something from an unrelated module.)
0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
2,553 Views
I would like to reproduce. Do you have a test case you could post? Note one thing to check when you get odddities in the IDE is that the version of the IDE you are using matches the compiler version you are using. You can find this in Microsoft Visual Studio under

Tools => Options => Intel Fortran => Compilers => Selected Compiler

Can you post the compiler and IDE version here?

Thanks,

------

Wendy

Attaching or including files in a post

0 Kudos
IM13
Beginner
2,553 Views
Wendy,

I don't believe that I would like to set up a data breakpoint (I am not sure though). All I would really like to do is look at the current values contained within an array without having to litter my code with a ton of write(6,*) statements. i.e., does Array(6) = 4.3 or Array(6) = 2.3.

I was wondering if you were familiar with a way to see this value during the debugging process.

Thanks

Isaac
0 Kudos
IM13
Beginner
2,553 Views
Wendy,

I don't believe that I would like to set up a data breakpoint (I am not sure though). All I would really like to do is look at the current values contained within an array without having to litter my code with a ton of write(6,*) statements. i.e., does Array(6) = 4.3 or Array(6) = 2.3.

I was wondering if you were familiar with a way to see this value during the debugging process.

Thanks

Isaac
0 Kudos
IM13
Beginner
2,553 Views
Wendy,

I don't believe that I would like to set up a data breakpoint (I am not sure though). All I would really like to do is look at the current values contained within an array without having to litter my code with a ton of write(6,*) statements. i.e., does Array(6) = 4.3 or Array(6) = 2.3.

I was wondering if you were familiar with a way to see this value during the debugging process.

Thanks

Isaac
0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
2,553 Views
Debugger+locals+window.one

Isaac,

I am including a screen shot for a small program that shows the array displayed in locals window with the debugger. Your locals and autos are displayed in the debugger on breakpoint. If you are not able to see this I wonder if you do not have a debug configuration. If the code is optimized you may see variables optimized away and this would cause the debugger to not be able to display them.

------

Wendy

Attaching or including files in a post



0 Kudos
IM13
Beginner
2,553 Views
Wendy,

That is the type of information I am trying to display, however, am not able. I recreated your little program to show the output that I am getting. The first thing that I notice is the different icon next to the "a"variable and the description under the Type column in the Watch window.

I then change the type of the variable from integer to real (See Fortranreal.png).

Finally I tried to fill values into the array and got the output shown in filledarray.png.

As always grateful for your help

Isaac

0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
2,553 Views
Isaac,

Checking with a debbuger expert. I have not seen that behavior before.

------

Wendy

Attaching or including files in a post

0 Kudos
IM13
Beginner
2,553 Views
Greetings Wendy,

I was wondering if your debugger expert had an opportunity to examine this problem. And if there is any information I could provide that would be of use in solving this problem and how to provide it let me know.

Thanks

Isaac
0 Kudos
Reply