PROGRAM Scope_3
   IMPLICIT NONE
   INTEGER :: i, Max = 5

   DO I = 1, Max
      WRITE(*,*) Sum(i)
   END DO 

CONTAINS

   INTEGER FUNCTION Sum(n)
      IMPLICIT NONE 
      INTEGER, INTENT(IN) :: n
      INTEGER             :: i, s
      s = 0 
      DO i = 1, n
         s = s + i 
      END DO
      Sum = s
   END FUNCTION Sum
END PROGRAM Scope_3
