Modern Fortran sample code

Only a code snippet though, but it’s taken from my today’s prototyping, coarray (runtime) parallel code as well. Spin-wait loops are usually inside synchronization routines; here it’s taken to the parallel logic codes to allow the programmer to do some calculation there instead of leaving the coarray image just idle waiting for the synchronization to complete.
Naming conventions are a matter of taste, but Fortran makes it easy to implement features with very few lines of code and keep things readable, I would say.

!*****
  case (Enum_ImageType % ControlImage) ! on the control image
    control_FinishedFragmentedMethod: block
      integer(OOOGglob_kint), dimension (1:intNumberOfExecutingImages, 1:2) :: intA_ExecutingImageAndFMValue
      integer(OOOGglob_kint) :: intNumberOfSuccessfulRemoteNotifys
      !
      ! wait until all the execute images do signal that they are in state FinishedFragmentedMethod:
      spin_wait: do
        !********* local abort timer (time limit) for the spin-wait loop:
        call system_clock(count = intTime2); reaTimeShift = real(intTime2-intTime1) / reaCountRate
        if (reaTimeShift > reaTimeLimitInSec) logNotifyFailure = .true. ! time limit exceeded
        !*********
        if (nofy_SyncFragmentedMethod % IsNotifyWait (intFragmentedMethodNotifyStatus, &
            intNumberOfExecutingImages, intA_ExecutingImageNumbers, &
            intNumberOfSuccessfulRemoteNotifys = intNumberOfSuccessfulRemoteNotifys, &
            intA_RemoteImageAndItsScalarIntegerValueToTransfer = intA_ExecutingImageAndFMValue, &
            logNoSpinWaitLoop = .true.)) then
          ! IsNotifyWait was successfull, no further action is required
        else ! the IsNotifyWait did fail
          logNotifyFailure = .true.
        end if
        if (intNumberOfSuccessfulRemoteNotifys == intNumberOfExecutingImages) exit spin_wait ! successfull
        if (logNotifyFailure) exit spin_wait ! non-successfull
      end do spin_wait
      !
      write(*,*) '==============================================================================='
      write(*,*) 'On the contol image, the newly collected and now adjusted FMValues: ', intA_ExecutingImageAndFMValue(:,2)
      write(*,*) '==============================================================================='
      write(*,*) 'Number Of Successful Remote Notifys: ', intNumberOfSuccessfulRemoteNotifys
      !
      if (logNotifyFailure) return ! non-successfull
    end block control_FinishedFragmentedMethod
  !*****
  end select finished_fragmented_method