Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
26 Views

How to determine newly assigned variables

I currently use Intel Visual Fortran 2013 with Visual Studio 2012. I am working with a large 3rd party program including dozens of source files with thousands of lines of code. To facilitate understanding/debugging the code, I have two questions:

1) Does there exist a way, while stepping through the code, to determine all NEWLY assigned variables? Currently I use a whole lot of Debug.Print on the command line to determine what such and such variable is. However I would like to determine only the variables updated by the most recent step.

2) Does there exist a way to visualize some of the modular, function and subroutine calls in this large program? Does Visual Studio 2012 coupled with Intel Fortran provide a way to generate, say a flowchart for the call stack or anything visual to help me work with this program?

Thanks.

0 Kudos
11 Replies
Highlighted
Valued Contributor III
26 Views

In the debugger you have a locals watch window and you can assign any variable to user watch window. As you step variables values that have changed go red in the watch windows.

0 Kudos
Highlighted
Beginner
26 Views

Hi Andrew,

I am already familiar with the watch window. However my program contains hundreds if not thousands of variables and derived types. What I was wondering is if there was any programmatic (say using the command window or other) way to determine only the newly assigned variables from one step to another.

0 Kudos
Highlighted
New Contributor II
26 Views

Hello

Such a tool would need to know the address and type of every variable you want to check even for non static ones for which the address is known only at subroutine entry.

0 Kudos
Highlighted
Beginner
26 Views

Well... to simplify it let us say we don't care about non-static, subroutine specific variables. Only the Global ones.

0 Kudos
Highlighted
26 Views

That would be an interesting feature: Memory Changed window (symbolic) and at entry into debugger (step or break).

You could write a trace subroutine that does this, but this would be a lot of editing (maybe not so bad if you restrict the activity to a few places). The subroutine would contain a capture area (user defined type) and a flag to indicate if capture only or display changed variables then capture. The flag can be a global variable that you can set or clear using the debugger. Start with it set to capture-only. Run to break point of interest, edit flag to display and capture, then step through calls.

Jim Dempsey

0 Kudos
Highlighted
Valued Contributor III
26 Views

back to the original post I think the answer to 1] is no. As for 2) the call stack is shown in the drop downs on the tool bar or are you looking for a call 'MAP' of application?

I sounds to me that you have a (badly documented?)  application you have inherited and you are at the stage of trying to understand how it works.

0 Kudos
Highlighted
Beginner
26 Views

The call stack helps but what I could really use is, like you said, a call MAP.

I believe the software is reasonably well documented. It would be more accurate to blame my confusion on my beginner skills in code development....

0 Kudos
Highlighted
Black Belt Retired Employee
26 Views

Do this:

In VS, go to Tools > Options > Text Editor > Fortran > Advanced. Change "Collect Calls/Caller Graph Information to True. (You may also want to set everything on this page except Disable Database to True.) Close and restart VS.

Open your project. Right click on the main program and select Call Browser > Show Call Graph in New Window. The call graph will appear at the first level - you can then expand as desired by clicking on the triangles next to names.

0 Kudos
Highlighted
Beginner
26 Views

Now THATS helpful. Kudos to you!

0 Kudos
Highlighted
Beginner
26 Views

I've also enabled the other features in the Advanced Text Editor Options (except for the "Disable Database" as you mentioned). Just off the top of your head, what other similar/not so similar features to the Caller/Call Graph have I unlocked? It would be helpful to know how else I can facilitate navigating through the Fortran Code....

0 Kudos
Highlighted
Black Belt Retired Employee
26 Views

Find Declarations and Find References for one. See Using Source Editor Enhancements in Visual Studio. (Link is to 17.0 docs, will become invalid when a future major version is released, but you can find it under Getting Started > Using Microsoft Visual Studio.

0 Kudos