      program main
      implicit none
      real*8, parameter :: C1 = -0.1666666666666666d0  ! =1/6
      real*8, parameter :: C2 =  0.8333333333333333d-2 ! =1/120
      real*8, parameter :: C3 = -0.1984126984126984d-3 ! =1/5040
      real*8, parameter :: C4 =  2.7557319223985890d-6 ! =1/362880
      real*8, allocatable :: x(:), y(:)
      real*8 time
      integer*8 time0, time1, dtime
      integer i, j, n, m
c
      n = 10000
      m = 100000

c Initialization
      allocate(x(n), y(n))
      do i=1,n
        x(i) = rand()
      end do

c Start time
      call system_clock(time0)

c Main calculation
      do j=1,m
        do i=1,n
          y(i) = x(i) * (1d0 + x(i)**2 * (C1 + x(i)**2
     &       * (C2 + x(i)**2 * (C3 + C4 * x(i)**2))))
        end do
      end do

c Finish time
      call system_clock(time1, dtime)

c Output time
      time = 1d0*(time1-time0)/dtime
      write(*,"(a7,f16.7)")"Time = ",time

      deallocate(x, y)
      end program
