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

Possible to search for variables in locals window

awa5114
Beginner
627 Views

Hello

I am currently debugging a large third party program which contains a great number of variables and types (several hundreds at a time). While debugging I have a need for coming up with local variables to watch on the fly. I don't necessarily know what these variables are going to be prior to stepping through the code. I just know keywords (for example "time") which can lead me to scores of variables ("TotalTime", "TimeIncrement" "TotalRealTime"...) which may or may not contain the information I need.

Is it possible to somehow search through the Locals window using a Ctrl+F type feature using keywords? If not, how else to search for variables/derived types containing a specific keyword?

Please note doing this manually is simply not an option. There are WAY too many variables...

 

 

0 Kudos
7 Replies
Steve_Lionel
Honored Contributor III
627 Views

This is more readily done by adding the variables you care about to a Watch window.

0 Kudos
awa5114
Beginner
627 Views

Right... but to add them to the watch window I need to find them first. Like I said, there are several hundreds that I need to sift through. Do I need to memorize them all so I can use the watch window or is there an easier way?

0 Kudos
jimdempseyatthecove
Honored Contributor III
627 Views

Why not Ctrl-F in the source window? Then Right-Click (in source) the variable of interest, then click add to watch.

Jim Dempsey

0 Kudos
mecej4
Honored Contributor III
627 Views

Amine, I have been reading this thread and your other thread, and I think that your goals and methods are not well-planned and that this line of approach is going to lead to failure. There is something to be said to allow a beginner to have the opportunity to fail and learn from the failure, but there are other ways of learning effective techniques.

First of all, why are you "debugging" a large program that someone else wrote? Do you know that it is not working correctly, and do you understand the underlying discipline (physics, economics, engineering, etc.) well enough to debug the program?

The very name "debugger" is, in my opinion, misleading as applied to large programs. A symbolic debugger is useful when the part of the code that contains the suspected bug has been narrowed down, and other methods (of instrumenting the program to make the computer check and catch bugs) have not succeeded. 

A large program with thousands of variables may run for, say, 99 percent of its total run time with no bug. During this time, each of those variables may have changed value thousands of times. Do you plan to read a variables watch window and check all those values? Will you know how to distinguished changed but incorrect values from changed and correct values?

Not all bugs manifest themselves by the presence of incorrect variable values. For instance, as Knuth observed in "The Art of Computer Programming", written in the 1970s, some bugs were detected only when the previous month's computer services bill arrived (there were no personal computers in those times).

0 Kudos
andrew_4619
Honored Contributor II
627 Views

mecej4's comments echo my own, I am not sure why you need to do what you want to do and what use it will be. However to answer the direct question you can search any source file in a text editor using wild cards and extract a list of variables by whatever method (by list I mean one variable name per line in a text file). In the debugger you can paste such a list into the watch window.

 

0 Kudos
Steve_Lionel
Honored Contributor III
627 Views

You can also generate a listing file when you compile - the listing includes a cross-reference of all variables in each routine, with line numbers on which they are defined or referenced.

0 Kudos
FortranFan
Honored Contributor II
627 Views

@Amine A.,

When it comes to Visual Studio, an option is to figure how a task of interest, whatever that be, is accomplished with either using .NET (C# or Visual Basic .NET projects) or C++ projects.  Note there is a voluminous amount of information available online with these other environments and once you know how to do something in Visual Studio in general, you can then investigate if the same approach is supported by Intel Fortran integration in Visual Studio.

0 Kudos
Reply