concept event wait in category fortran

This is an excerpt from Manning's book Modern Fortran: Building efficient parallel applications.
You can read this diagram in any order. An alert event is an instance of
event_type. Image 1 triggers the alert on image 2 by issuingevent post(alert[2]). This statement is nonblocking, which means that image 1 can immediately move on with whatever code follows. All instances ofevent_typekeep count of posted events internally. This count is incremented on everyevent poststatement, from any image. Image 2 issuesevent wait(alert). This is a blocking statement, which means that image 2 will wait until the alert is posted. When it finally happens,event waitdecrements the internal event count. Alternatively, image 2 can also poll the number of alerts in a nonblocking fashion with the built-in subroutineevent_query.
In a nutshell,
event waitblocks the image that executes it until some other image posts an event to it. Ifuntil_countis provided and greater than 1, the image will wait until that many events have been posted. On successful execution ofevent wait, the internal event count is decremented byuntil_count, if provided, and by 1 otherwise. For example, this statement:event wait(notification, until_count=100)blocks the executing image until 100 events have been posted to the
notificationvariable from any other image. Once executed, the internal event count is decremented by exactly 100. Note that this doesn’t mean that the event count is always reduced to zero, because remote event posts can keep incrementing the event count beforeevent waithas time to return.Using
event waittogether with theuntil_countparameter allows you to not block on every posted event, but only on some number of events. However, it also illustrates a restriction toevent wait: it’s impossible for the image that listens for events to know how many have been posted without explicitly blocking execution withevent wait. This is indeed rather limiting. To poll events without blocking the current image, Fortran provides a built-in subroutineevent_query, which we’ll explore in the next subsection.