I have a sub in a module. the sub have a local variable. the first time the main program call the sub, I initiate the local variable. then I call the sub the second time without initiation, but the local variable value remain the same.
module testmod implicit none type :: testtype integer :: i end type testtype contains subroutine foo(switch) logical, intent(in) :: switch type(testtype) :: t integer :: m if(switch==.TRUE.) then t%i = 10 m = 23 end if write(*,*) t%i, m end subroutine foo end module testmod
program main use testmod implicit none integer :: i call foo(.TRUE.) call foo(.FALSE.) end program main
I didn't turn on the /Qsave. I want to know is this feature just a compiler hidden rule and I should not rely on it?
thank you !!