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

Updated Description: problem with viewing global variables when in debug mode

lan0907
Beginner
815 Views
Dear all,

Firstly, I am 'semi-new' to Fortran so I can't describe my problem clearly and provide enough information, just let me know. I can explain it later again.

So here is the problem:
I am now working on a huge Fortran project (code) which contains numerous variables and subroutines. I made a copy of the original project, and changed several lines in one subroutine. Then I started debugging. Everything runs correctly from beginning to the end. The only thing is now I cannot view the variables defined in the module file. However, in the original project (code), this does not happen.

When I tried to debug the my COPIED Fortran code using breakpoint in the one of the subroutine, I can only view the local variables for the global ones (defined in the module) the debugger gave me message as 'cannot view register variables'.
Example:
module A
integer:: x
end module
subroutine B
use A
integer:: y
.....
end subroutine B
So I set some breakpoints in subroutine B. I can view values for y, but for x the debugger gave me the error message.
Solutions Tried so far:
1. I compared 'project/property' for the original project and the copied one for everything. They are the SAME!
2. Then I tried to create a new project, and add all the source files into that. The code run correctly, but still I can't view the variables defined in the module?!
I am using Fortran Complier 10.0.027 and Visual Studio 2005.
Thank you in advance.
--
Lan
0 Kudos
7 Replies
mecej4
Honored Contributor III
815 Views
First of all, there are no "global variables" in Fortran. Subprograms may share variables through COMMON blocks or modules, and a compiler may provide methods to access external variables declared as global in C/C++ programs linked to Fortran subprograms.

Secondly, if you want to be able to view in the debugger all variables in the source code, you have to prevent the optimizer from eliminating superfluous variables and allocating variables to registers, by choosing suitable compiler options.

It would help if you were to provide a short example source code that illustrates what you are trying to accomplish.
0 Kudos
abhimodak
New Contributor I
815 Views
As mecej4 said, a short example is always useful.

Meanwhile, if you are referring to module variables, see if the following works:

ModuleName:: ModuleVariableName

The debugger should be able to show it. Of course, once again as mecej4 said, you also need to have correct compiler options enabled. For example, in this case of "parameters" you will need to enable the corresponding option -- /debug:parameters

Abhi
0 Kudos
lan0907
Beginner
815 Views
Thanks for the reply.
Ok, there is one module where I defined all the variables to be shared with all subroutines.
I can make up the one simple example.
say:
module A
integer:: x
end module
subroutine B
use A
integer:: y
.....
end subroutine B
So I set some breakpoints in subroutine B. I can view values for y, but for x the debugger gave me the error message.
My guess is I did not choose the suitable complier options.
0 Kudos
abhimodak
New Contributor I
815 Views
Hello Ian0907

Is " A::x" also failing to show it? Are you building the project in a debug mode?

Abhi
0 Kudos
lan0907
Beginner
815 Views
I am sure that I used debug mode.
A is defined as module, just todeclareall the variables. I tried to set a breakpoint in A, but it never stop at that part.
Thanks
0 Kudos
abhimodak
New Contributor I
815 Views
Hi Ian0907

If the module has only variables, you can't set any breakpoints there. Please see the attached screenshot fiel ModuleVar.png. At the breakpoint, in the watch window, variables j and k can be seen as OM:: J, OM:: K.
That the variable J is accessible directly is, I think, because the main program is using it.

The snapshot is created with IVF 11.1.065 with VS2005 on WinXP64. I used the default debug setting.

Abhi
0 Kudos
lan0907
Beginner
815 Views
Hi Abhi,
Thanks for help. However, I can't open your attached files.
To make my problem clear, I am now working on a huge Fortran project (code) which contains numerous variables and subroutines. I made a copy of the original project, and changed several lines in one subroutine. Then I started debugging. Everything runs correctly from beginning to the end. The only thing is now I cannot view the variables defined in the module file. However, in the original project (code), this does not happen.
--
Lan
0 Kudos
Reply