- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
Select Debug>Windows>Immediate.
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):
Start debugging.
In the Debug menu, select New Breakpoint, then New Data Breakpoint...
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:
In the Debug menu, select Windows>Breakpoints.
To disable or enable the data breakpoint, use the check box to the left of the data breakpoint (check indicates enabled).
To remove a data breakpoint, click (select) the data breakpoint and click the Delete button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tools => Options => Intel Fortran => Compilers => Selected Compiler
Can you post the compiler and IDE version here?
Thanks,
------
Wendy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Checking with a debbuger expert. I have not seen that behavior before.
------
Wendy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page