Hello,

I have run into an ICE with the program below. The compiler version I use is: Intel Fortran 12.0.3 under Linux. The program may not be correct, but the compiler does not give any message, except for the ICE.

Regards,

Arjen

-----

! primes_coarrays.f90 --

! Determine the first 1000 primes - using coarrays

!

program primes_coarrays

use, intrinsic :: iso_fortran_env, only: lock_type

implicit none

type(lock_type), codimension[*] :: primes_lock

integer, dimension(2), codimension[*] :: range

integer, dimension(1000), codimension[*] :: prime

integer, codimension[*] :: number_primes

logical, codimension[*] :: new_results

logical, codimension[*] :: new_task

logical, codimension[*] :: ready

ready = .false.

new_results = .false.

new_task = .false.

number_primes = 0

range(2) = 0

!

! Create tasks in image 1 and handle them in all images

!

do while ( .not. ready )

if ( this_image() == 1 ) then

call add_task

endif

call get_task

enddo

write(*,'(10i5)') prime

contains

!

! Subroutine to post a new task (consisting of a

! range of integers in which to look for primes)

!

! Loop over the images to see which one wants a

! new task

!

subroutine add_task

integer :: i

do i = 1,num_images()

if ( .not. new_task[i] ) then

range(1) = range(2) + 1

range(2) = range(2) + 100

range[i] = range[1]

new_task[i] = .true.

endif

enddo

end subroutine add_task

!

! Subroutine to get a task and search for

! primes inside the new range

!

subroutine get_task

integer, dimension(100) :: new_prime

integer :: lower

integer :: upper

logical :: isprime

logical :: got_task

integer :: np

integer :: i

integer :: j

integer :: residue

integer :: maxindex

got_task = .false.

np = 0

if ( new_task ) then

lower = range(1)

upper = range(2)

new_task = .false.

got_task = .true.

endif

if ( got_task ) then

write(*,*) 'Range: ',lower, upper, this_image()

do i = lower,upper

isprime = .true.

do j = 2,int(sqrt(real(i)))

residue = mod(i,j)

if ( residue == 0 ) then

isprime = .false.

exit

endif

enddo

if ( isprime ) then

np = np + 1

new_prime(np) = i

endif

enddo

endif

!

! Now put the results in image 1

!

if ( got_task ) then

lock( primes_lock )

maxindex = min( size(prime) - number_primes[1], np )

prime(number_primes+1:number_primes+maxindex)[1] = &

new_prime(1:maxindex)

number_primes[1] = number_primes[1] + maxindex

ready[1] = number_primes[1] >= size(prime)

unlock( primes_lock )

endif

end subroutine get_task

end program primes_coarrays