The DO i = 1, some_prime_number would be an example of how some threads end up at an implicit barrier (end do) while others may end up at an explicit barrier (!$omp barrier).There are many reasons for the use of a barrier. One such reason is the application may need to take a snapshot of the data processed by all threads but only when the data is not in flux.
Your description isa condition that I'd not considered, but can easily see being needed. One quibble that I'd have with your solutions, though, is that the Master thread might be one that is given fewer iterations than one ore more of the others. The use of !$OMP MASTER could then lead to deadlock.
Why not use the implicit barrier of the !$OMP SINGLE to solve both your explicit barrier and master thread problems? Something like...
!$OMP PARALLEL DO DO i = 1, some_prime_number call DoWork(i) !! The first SINGLE region acts like an explicit barrier !$OMP SINGLE call DoNothing !$OMP END SINGLE !! Once data has quiesced, one thread takes the snapshot !$OMP SINGLE call TakeSnapshot !$OMP END SINGLE ENDDO !$OMP END PARALLEL DO
With this solution, it won't matter whether or not the master thread participates to the end and it won't matter how many threads are active for a round of iterations (and how many are waiting at the implicit barrier at the end of the parallel region).