! ===================================================  
 ! Subroutinbe returns a + (a+1) + ... + b
 ! ===================================================  
   SUBROUTINE SerieSum(a, b, sum)
      IMPLICIT NONE                     ! Recommended  
      INTEGER, INTENT(IN) :: a
      INTEGER, INTENT(IN) :: b
      INTEGER, INTENT(OUT) :: sum
   
      INTEGER :: i

      sum = 0

      DO i = a, b
         sum = sum + i
      END DO

      RETURN
   END	



   PROGRAM Demo
      IMPLICIT NONE

      INTEGER :: x, y, sum

      read*, x
      read*, y
   
      CALL SerieSum(x,y,sum)   ! Invoke a subroutine

      print*, "Serie sum = ", sum
      print*
      STOP
   END
