Scoping rules for variable and functions in contained subroutines
I have a problem understanding why a variable ( i ) declared in a subroutine is seen in a contained subroutine, but that this is not true for a function ( fie ) which results in a compilation error. I searched for an answer and also tried to see if I could find something in the Fortran 95 standard but in vain. I wrote a small example program: program pgm call a end subroutine a implicit none integer :: i double precision :: fie i = 7 call b !write(*,*) fie(9) contains subroutine b double precision :: x !double precision :: fie x = i x = x + fie(i) write(*,*) x end subroutine end subroutine