! ===================================================	
! Demo Interface to detect type error in function call 
! ===================================================

	   

	PROGRAM Demo
	IMPLICIT NONE										 
        real     x, y      !! <<--- REAL
!       INTEGER  x, y      !! <<--- INTEGER
        INTEGER  sum

	INTERFACE 
	   FUNCTION SerieSum(a,b)
	     INTEGER SerieSum
             INTEGER, INTENT(IN) :: a      !! <<--- Integer
             INTEGER, INTENT(IN) :: b      !! <<--- Integer
	   END FUNCTION
	END INTERFACE


	print*, "Program somputes a + (a+1) + ... + b"
	print*, "Start number a = "
	read*, x
	print*, "End number b = "
	read*, y

	sum = SerieSum(x,y)

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

! ===================================================	
! Function returns a + (a+1) + ... + b
! ===================================================
	FUNCTION SerieSum(a, b)
	IMPLICIT NONE

	INTEGER, INTENT(IN) :: a      !! <<--- Integer
	INTEGER, INTENT(IN) :: b      !! <<--- Integer

	INTEGER  SerieSum
 
	INTEGER :: i

	SerieSum = 0

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

	RETURN
	END
