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

Unable to view some variables during debugging

Wee_Beng_T_
Beginner
1,356 Views
Hi,

I am trying to debug my code in VS2005 sp1 in 64bit win7 with ifort 11. I have an old code written in f77 format with lots of variables declared as "common".

In some areas of the code, when I try to use the watch window to look at the variables, it says variable not defined. However, the variables are being calculated in that region. I can use print to show me the variables though.

I think I have this problem also with some parts of a complicated f90 code as well.

Is this problem due to ifort or vs2005? How can I solve it?

Also, supposed I have an array aa. Is there any way I can get the maxval or sum or this array in the watch window? I tried to use maxval(aa) but it says undefined variable max.

Thank you!
0 Kudos
1 Solution
mecej4
Honored Contributor III
1,356 Views
David White has already shown you that you need to be aware of name decoration when using a debugger. Similarly, when you move to Fortran 9X and use modules, even more variables and objects will be decorated with some version of the module name.

You can find the run-time names of such quantities by running dumpbin (or, if you have it installed, nm) on the .obj file.

Evaluating expressions containing function calls (such as maxval or sum) would require the implementation of a fairly complex Fortran interpreter inside the debugger.

View solution in original post

0 Kudos
8 Replies
DavidWhite
Valued Contributor II
1,356 Views
Note sure if it works with common blocks, but with modules, you can use a format like
module_name:variable to access the variable.

David
0 Kudos
mecej4
Honored Contributor III
1,357 Views
David White has already shown you that you need to be aware of name decoration when using a debugger. Similarly, when you move to Fortran 9X and use modules, even more variables and objects will be decorated with some version of the module name.

You can find the run-time names of such quantities by running dumpbin (or, if you have it installed, nm) on the .obj file.

Evaluating expressions containing function calls (such as maxval or sum) would require the implementation of a fairly complex Fortran interpreter inside the debugger.
0 Kudos
Wee_Beng_T_
Beginner
1,356 Views
Thanks mecej4 and david for your answers!

So may I right to say that it's now not possible to evaluate expressions such as maxval etc?

Also, by using module:variable, I can access the values.

May I know if there's any difference between vs2005 and 2008 when it comes to debugging?

Is it possible that some values that cannot be "seen" by the debugger in vs2005 but are visible under vs2008?

My school has both version but I choose vs2005 cause it's slimmer.

Thanks again.
0 Kudos
Steven_L_Intel1
Employee
1,356 Views
There is no difference between VS2005 and VS2008 in this regard.
0 Kudos
Wee_Beng_T_
Beginner
1,356 Views
Hi,

I tried the module_name:variable suggestions but it can't work. Part of my code is:

MODULE TAI2NPB
USE TIMCOM_GENERAL,ONLY:MPASS
USE CONTROL_NPB,ONLY: DT_NPB => DT
USE CONTROL_TAI,ONLY: DT_TAI => DT, DAODT
REAL,DIMENSION(:,:),PRIVATE,ALLOCATABLE :: &
XPWNPB,UWNPB,U1NPB,V1NPB,S1NPB,T1NPB,U2NPB,V2NPB,S2NPB,T2NPB
REAL,PUBLIC :: FLT1,FLT2
INTEGER,PUBLIC :: MXITN

CONTAINS

subroutines A

....

END MODULE TAI2NPB

When I tried to access the value of FLT1 by entering FLT1 in the watch window, it works when the code is in subroutine A. However, in other areas of the code, using FLT1 or TAI2NPB:FLT1 in the watch window can't work. It says undefined variable TAI2NPB.

Do you know what's wrong? Btw, I'm using 64bit windows7 + VS2005. The code is compiled in 32 bit because I do not have the 64bit version for one of the libraries.

Thanks!

0 Kudos
Les_Neilson
Valued Contributor II
1,356 Views
Quoting quarkz
When I tried to access the value of FLT1 by entering FLT1 in the watch window, it works when the code is in subroutine A. However, in other areas of the code, using FLT1 or TAI2NPB:FLT1 in the watch window can't work. It says undefined variable TAI2NPB.

Do you know what's wrong?

Did you really put just the single colon ?

it should be TAI2NPB::FLT1


Les
0 Kudos
hannahse
Beginner
1,356 Views
I have similar problems with variables declared in common and used in a module. For example, I have a variable, ITT, declared in a common block and included in several subroutines via an include file. The include file is also in one of my modules. I can "see" the value of ITT in all subroutines except those in the module. If I try it in the module, I get undefined variable. Using the module decoration does not seem to help with those variables in common. For example with module "solver"

solver::X works ok because X is local to solver but
solver::ITT does not because (apparently)ITT is in common.

I tried nm *.obj | grep -i itt but did not find any reference to itt that way.
Is there any way to "see" these variables in common while in a module.

By "see", I mean determine the value in a watch statement in the debugger.
0 Kudos
Wee_Beng_T_
Beginner
1,356 Views
Hi Les,

Finally got it working. Thanks!
0 Kudos
Reply