<SYNC IMAGES Example Program>

Program sync_images_example
  Implicit None
  Real :: a[*]
  Integer i
  ! The first image will set the value of the coarray A on every image.
  If (This_Image()==1) Then
    Do i = 1, Num_Images()
      a[i] = i**2
    End Do
    ! Tell the other images (if any) the data is ready.
    Sync Images (*)
  Else
    ! Wait for image one to prepare the data.
    Sync Images (1)
  End If
  ! Each image checks its own results.
  If (a/=This_Image()**2) Error Stop 'FAILed'
  ! Wait for everyone to finishing checking.
  Sync All
  ! The last image will report success.
  If (This_Image()==Num_Images()) Print *,'ok'
End Program

■ Execution Results

 ok