subroutine handle_local_worker_requests_group(resources, term_queue, term_ids, atom_sets, &
worker_term_map, local_finished_workers)
use mqc_resources, only: resources_t
type(resources_t), intent(in) :: resources
type(queue_t), intent(inout) :: term_queue
integer(int64), intent(in) :: term_ids(:)
integer, intent(in) :: atom_sets(:, :)
integer(int64), intent(inout) :: worker_term_map(:)
integer, intent(inout) :: local_finished_workers
integer(int64) :: local_idx, term_idx
integer(int32) :: local_dummy
type(MPI_Status) :: local_status
logical :: has_pending, has_item
type(request_t) :: req
call iprobe(resources%mpi_comms%node_comm, MPI_ANY_SOURCE, TAG_WORKER_REQUEST, has_pending, local_status)
if (.not. has_pending) return
if (worker_term_map(local_status%MPI_SOURCE) /= 0) return
call irecv(resources%mpi_comms%node_comm, local_dummy, local_status%MPI_SOURCE, TAG_WORKER_REQUEST, req)
call wait(req)
call queue_pop(term_queue, local_idx, has_item)
if (has_item) then
term_idx = term_ids(local_idx)
call send_pie_term_payload(resources%mpi_comms%node_comm, TAG_WORKER_FRAGMENT, term_idx, &
atom_sets(:, local_idx), local_status%MPI_SOURCE)
worker_term_map(local_status%MPI_SOURCE) = term_idx
else
call isend(resources%mpi_comms%node_comm, -1, local_status%MPI_SOURCE, TAG_WORKER_FINISH, req)
call wait(req)
local_finished_workers = local_finished_workers + 1
end if
end subroutine handle_local_worker_requests_group