1 Reply Latest reply on Nov 27, 2017 8:18 AM by Al Hill

    Internal Procedures and Enclosing Scope


      The following program does not work the way I think it should.


      It always prints out '1,2' instead of '2,2.'  In subroutine ip_test, the function

      ip_print does not use the enclosing scope value of ival=2, but only the global scope value, ival=1.


      Is this is a bug or does this conform to the F90 standard?


              module ip

                integer :: ival=1      !global



                integer function ip_print()

                  ip_print=ival   !always returns global ival

                end function


                subroutine ip_test()

                  integer :: ival=2    !local

                  print*,'%ip_test, ',ip_print(),ival

                end subroutine


              end module


              program test

               use ip

               call ip_test()

              end program