Hi
module A
contains
subroutine subA()
real :: x
print *,'before adding',x
x=x+1
print *,'after adding',x
end subroutine subA
end module A
program main
use A
x=100.
call subA()
print *,'first output in main:',x
call subA()
print *,'second output in main:',x
end program main
The results are (CVF6.6c used):
before adding 0
after adding 1
first output in main: 100
before adding 1 <=== why?
after adding 2
second output in main: 100
Why? Isn't x in subA a local variable? I read the Chapman's book,
which shows "the values of all the local variables and arrays in a
procedure become undefined whenever we exit the procedure." I thought
x=0. x doesn't have SAVE attribute in subA.
Mike


|