As you work with events, you’ll soon find it useful to query an event variable to find out how many times an event has been posted. The built-in subroutine event_query does exactly this
call event_query(event_var, count[, stat])
where event_var is the input variable of type event_type, and count is the output integer number of events posted. Unlike the event wait statement, calling event _query doesn’t block execution but simply returns the count of posted events. event_query is a read-only operation, so it doesn’t decrement the event count like event wait does. This makes it more suitable for implementation of nonblocking parallel algorithms, as you’ll find out in the “Exercise 2” sidebar.
Exercise 2: Tsunami time step logging using events
In the previous section, we used the coarray time_step_count to communicate the number of time steps between the simulation and logging teams. In this exercise, use events to keep track of the simulation team’s progress and print it to screen from the logging team. For bonus points, implement two solutions, one using an event wait statement, and another using an event_query subroutine.
The solution to this exercise is given in the “Answer key” section near the end of the chapter.