PROGRAM main

  IMPLICIT NONE
  REAL, DIMENSION(5) :: x = (/ 1.,3.,5.,7.,9. /)

  PRINT *, variance(x)
  
  CONTAINS
  
  REAL FUNCTION variance(array)
  
  REAL, INTENT(in), DIMENSION(:) :: array
  !REAL :: variance, z
  REAL :: z
  
  z = SUM(array)/SIZE(array)
  variance = SUM((array-z)**2)/SIZE(array)

  END FUNCTION variance
    
END PROGRAM main
