Is it possible to set a watch on a variable to see when and where in the program a variable is changed?
In Visual Studio, you can just right click on a variable and select 'Add Watch' or 'Add Quick Watch' and it will appear in the Watch window while debugging.
What front end are you using? And do you want the program to break when the variable changes?
in general you set watchpoints in Fortran just as you do in C/C++. This is true for the Linux* hosted Intel Debugger (IDB) as well s for Visual Studio as was just pointed out.
The problem with Fortran watchpoints is that the concept of global variables is not a Fortran concept. Thus you have to be more careful with the scope of the variable you set your watchpoint on than in C/C++.
Let's assume yo are using IDB on the command line. Thus you are basically following GDB syntax for watchpoints.
The question then becomes - What sort of variable are you trying to set your watchpoint on and how is it declared? (E.g. in a module, in a common block, locally, ...). Depending on circumstances, you may need to specify the module name, e.g.
(idb) watch module_name%%variable_name
- yes, I want the program to breakwhen a specific varaiable has beenchanged.(sometimes a variable is changed unexpected - the the debug/watchis helpful)
I am not familiar with C/C++,nor the IDB command line....
The background for my question is of course that it happened again: Somewhere in my program a variable has been changed, and I do not undrestand why.When we used the VAX/VMS system (1983..)you could just write "WATCH " (or something similar)and then the program stopped and displayed the code segment where the variable was changed.But I have never managed to do this in CVF or VS2005
The variable can be of any type, of course the most troublesome might be the globalvariables, and I use modules rather than common blocks.
From what I understand from you I may achieve what I want by using the command line?
Reidar, I see, you are looking to set what VS/IVF now refers to as a 'Data Breakpoint.' Here is a pretty good description of how to do that in Visual Studio from Intel. Setting Data Breakpoints.
My coworker and I do this/use these ALL the time, so if something in there isn't clear let me know and I'll see if I can help you clear it up.