<EVENT POST Example Program>
Program event_post_example
Use iso_fortran_env
Type(event_type) ev[*]
If (num_images()<2) Error Stop 'Not enough images'
If (this_image()==1) Then
! Post an event to every other image.
Do i=2,num_images()
! (A real program would store some data for the other image first.)
Event Post (ev[i])
End Do
! Wait for them to post back.
Event Wait (ev,Until_Count=num_images()-1)
Print *,'All events processed.'
Else
! Wait for the event (from image one).
Event Wait (ev)
! (A real program would process the data from image one first.)
! Send image one an event to say we have finished.
Event Post (ev[1])
End If
End Program
■ Execution Results
All events processed.