Check values of local variables in subroutines from outside
<p>How do you check values in Fortran like in Matlab? For example in the little program under, why does it show <code>c=0</code> in main when it is <code>c=36</code> in the subroutine <code>testing</code>? How do you make it so <code>c=36</code> in the main program?</p>

<p>Can you call on the value <code>c</code> in some sort of way?  I understand that in the main program the variable <code>c</code> is either undefined or has value <code>0</code>, but is there a way to save the value of <code>c</code> in the subroutine so you can use it again in other subroutines, without calculating it again?</p>

<p>When the program is quite large it is handy to check values as you go.</p>

<pre><code>program main

use test

implicit none

integer :: a,b,c

call testing(a,b)

write(*,*)'Test of c in main program',c


end program main



module test

implicit none


contains


subroutine testing(a,b)

integer :: a,b,c

a=2
b=3

c=(a*b)**a

write(*,*)'Value of c in subroutine',c

end subroutine testing

end module test
</code></pre>