Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

the local variable is auto save ?

$
0
0

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 !!


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>