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

Sometimes Fortran doesn't recognize my variable during a debugging mode

Customer__Intel12
493 Views

In my program, I have 3 files for Main program, module var and module step1

Program Main

Use Var

Use Step1

Implicit none

Call Step1Sub

end program Main

Module Var

REAL(8), Dimension(1:5) :: A, B, C

Contains

Pure Function AInverse (A)

Real(8) :: AInverse

Real(8), Intent(In) :: A

AInverse = 1.0D0/A

End Function AInverse

END Module Var


Module Step1

Use Var

Implicit None

Contains

Subroutine Step1Sub

Integer :: i

A = 1.0D0

B(1:) = 5.0D0

ForAll (i = 1:5)

C(i) = AInverse(10.0D0)

End ForAll

End Subroutine Step1Sub

End Module Step1

During the debugging process of this program, I cannot see the value of B and C. I can see only the value of A.

If I print out the value of A, B, and C, then I get the correct answer.

Can anybody tell me why sometimes Fortran doesnt recognize my variable (B & C) during the debugging? (when I add B & C to a watch parameter during debugging, the value are undefined but I can see A values)

0 Kudos
2 Replies
DavidWhite
Valued Contributor II
493 Views
Inside AInverse, you have a variable A, which has local scope within AInverse.

A is also available globally in Module Var. However, while within AInverse, the A you are looking at is the local variable, not the one in Var. (Since A is a dummy argument, you could rename all of the A's in AInverse to Z without any change to the program.

If you did this, you could find inside AInverse, you cannot access any of A,B, C.

I suggest you try using the module::variable syntax to look at the variables, i.e. Var::A, Var::B and Var::C.

Regards,


David
0 Kudos
Customer__Intel12
493 Views
I try Var::A, Var::B, Var::C and it works.
Is there any way that I can take a look at module variable during debugging without type this syntax in an immediate window? something like module variable window?

what I did in my program normally is to set all variable equal to 0 in one subroutine that call from the main program. I found that if I use A = 0.0 in one subroutine that is called from the main program (or use this in main program) then I can see the variable during debugging. but if I use Forall or index then I cannot see the module variable during debugging. When I did this even though I can see those variable during debugging but my program run slower
0 Kudos
Reply