8
If I initialize a variable in a Fortran declaration statement, that variable implicitly receives a SAVE attribute and the initialization expression will only be executed once.
For example, the following program
program test
implicit none
call foo()
call foo()
contains
subroutine foo ()
integer :: i = 0
i = i + 1
write(*,*) i
end subroutine foo
end program test
will print
1
2
Since this is different in many other languages I was wondering why the Fortran standard committee chose this behavior?
Thanks a lot! Mike