home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
prgramer
/
adaptor
/
examples
/
simple
/
lprime.f
< prev
next >
Wrap
Text File
|
1993-06-28
|
794b
|
35 lines
program prime
integer n, s, k
parameter (n=10000)
logical*1 a(n)
!hpf$ distribute a(block)
call cm_timer_clear (1)
call cm_timer_start (1)
!hpf$ independent, local_access
do i = 2, n
a(i) = .true.
end do
a(1) = .false.
k = 2
do while (k*k .le. n)
!hpf$ independent, local_access
do i = k*k,n,k
c all multiples of k are no primes
a(i) = .false.
end do
k = k + 1
do while (.not. a(k))
k = k + 1
end do
end do
s = 0
!hpf$ independent, local_access
do i = 1, n
reduce (count, s, a(i))
end do
call cm_timer_stop (1)
print *, 'There are ',s,' primes until ', n
call cm_timer_print (1)
end