subroutine fill_refinement_bnd(mg, id, nb, nc, iv, dry_run)
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: iv
integer, intent(in) :: nb
logical, intent(in) :: dry_run
real(dp) :: gc(nc)
integer :: p_id, p_nb_id, ix_offset(2)
integer :: i, dsize, p_nb_rank
dsize = nc**(2-1)
p_id = mg%boxes(id)%parent
p_nb_id = mg%boxes(p_id)%neighbors(nb)
p_nb_rank = mg%boxes(p_nb_id)%rank
if (p_nb_rank /= mg%my_rank) then
i = mg%buf(p_nb_rank)%i_recv
if (.not. dry_run) then
gc = reshape(mg%buf(p_nb_rank)%recv(i+1:i+dsize), shape(gc))
end if
mg%buf(p_nb_rank)%i_recv = mg%buf(p_nb_rank)%i_recv + dsize
else if (.not. dry_run) then
ix_offset = mg_get_child_offset(mg, id)
call box_gc_for_fine_neighbor(mg%boxes(p_nb_id), mg_neighb_rev(nb),&
ix_offset, nc, iv, gc)
end if
if (.not. dry_run) then
if (associated(mg%bc(nb, iv)%refinement_bnd)) then
call mg%bc(nb, iv)%refinement_bnd(mg%boxes(id), nc, iv, nb, gc)
else
call sides_rb(mg%boxes(id), nc, iv, nb, gc)
end if
end if
end subroutine fill_refinement_bnd