> On Jun 22, 2017, at 5:39 AM, Anton Shterenlikht <[log in to unmask]> wrote:
>
> Is this program conforming?
Yes.
>
> integer :: i(4)[*]
> i = this_image()
> sync all
> if ( this_image() .gt. 1 ) i(1) = i(3)[ this_image() - 1 ]
> if ( this_image() .lt. num_images() ) i(4) = i(2)[ this_image() + 1 ]
> sync all
> write (*,*) this_image(), i
> end
>
Sometimes it helps to see what is going on by looking at how each image acts independently. Something like:
! Image 1; num_images = 4
integer :: i(4)[*]
i = [1, 1, 1, 1]
sync all
i(4) = i(2)[2] ! Note, i(4) on image 1, i.e. i(4)[1], is defined here.
sync all
write (*,*) 1, i ! expect 1, 1, 1, 1, 2
end
! Image 2; num_images = 4
integer :: i(4)[*]
i = [2,2,2,2]
sync all
i(1) = i(3)[1] ! = 1
i(4) = i(2)[3] ! = 3
sync all
write (*,*) 2, i ! expect 2, 1, 2, 2, 3
end
! Image 3; num_images = 4
integer :: i(4)[*]
i = [3,3,3,3]
sync all
i(1) = i(3)[2] ! = 2
i(4) = i(2)[4] ! = 4
sync all
write (*,*) 3, i ! expect 3, 2, 3, 3, 4
end
! Image 4; num_images = 4
integer :: i(4)[*]
i = [4,4,4,4]
sync all
i(1) = i(3)[3] ! = 3
sync all
write (*,*) 4, i ! expect 4, 3, 4, 4, 4,
end
> ftn test.f90
> srun -n4 ./a.out
srun: job 3195642 queued and waiting for resources
srun: job 3195642 has been allocated resources
4*1, 2
2, 1, 2*2, 3
3, 2, 2*3, 4
4, 3, 3*4
Cheers,
Bill
Bill Long [log in to unmask]
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
|