program Hello_World
implicit none
integer :: i ! Local variable
character(len=20) :: name[*] ! scalar coarray, one "name" for each image.
! Note: "name" is the local variable while "name[<index>]" accesses the
! variable in a specific image; "name[this_image()]" is the same as "name".
! Interact with the user on Image 1; execution for all others pass by.
if (this_image() == 1) then
write(*,'(a)',advance='no') 'Enter your name: '
read(*,'(a)') name
! Distribute information to other images
do i = 2, num_images()
name[i] = name
end do
end if
sync all ! Barrier to make sure the data have arrived.
! I/O from all images, executing in any order, but each record written is intact.
write(*,'(3a,i0)') 'Hello ',trim(name),' from image ', this_image()
end program Hello_world
I think it's basically just the coarray index syntax (name[*]) and the new keyword statements (sync all)
Example from wikipedia:
I think it's basically just the coarray index syntax (
name[*]
) and the new keyword statements (sync all
)