C     Testing floating-point performance with Horner's rule

      program arithorn

      parameter (n=512)		! Dimension of square array
      parameter (it=200)	! Iterations for experiments

      real, array(n,n) :: A, B, C, D, E, F, G, S

      A = 1.7736 + spread([1:n], 1, n) + spread([1:n], 2, n) - n
      A = A/1000.0
      B = (-2.445 - A)/1000.0
      C = 0.1334 + A
      D = (8.99443E-3)*A
      E = 1.1415*A
      F = (3.14159 + D)/100.0
      G = -.71828*C
      A = A/1000.0
      S = A

      print *, 'Each experiment is ', n*n*10*it, ' flops.'

      do i = 1, 5			! Do five experiments
        print *
        call CM_timer_clear(1)
        call CM_timer_start(1)
        do j = 1, it
	  S = ((((A*S + B)*S + C)*S + D)*S + E)*S + F
        end do
        call CM_timer_stop(1)
        call CM_timer_print(1)
      end do
      print *, A(1,1), S(1,1), A(1,2), S(1,2)
      end program arithorn
