C     data parallel source program

      program prime
      integer n, s, k
      logical*1 a(:)
!hpf$ distribute a(block)
      print *, 'Input n for counting primes in range 2 to n : '
      read *, n
      allocate (a(1:n))
      call cm_timer_clear (1)
      call cm_timer_start (1)
      a = .true.
      a(1) = .false.
      k = 2
      do while (k*k .le. n)
         a(k*k:n:k) = .false.
         k = k + 1
         do while (.not. a(k))
           k = k + 1
         end do
      end do
      s = count (a)
      call cm_timer_stop (1)
      print *, 'There are ',s,' primes until ', n
      call cm_timer_print (1)
      deallocate (a)
      end

