module solution_8_2
public  ::  calculate
contains
! Solution 8/2
      subroutine calculate(x, n, mean, variance, ok)
         real, dimension(:), intent(in)  :: x
         integer, intent(in)             :: n
         real, intent(out)               :: mean, variance
         logical, intent(out)            :: ok
         ok = n > 1
         if (ok) then
            mean = sum(x)/n
            variance = sum((x-mean)**2)/(n-1)
         end if
      end subroutine calculate
end module solution_8_2
