subroutine create_perturbed_ref(perturbed_buf, tmp_totwalkers)
implicit none
integer(n_int), intent(out) :: perturbed_buf(:, :)
integer, intent(out) :: tmp_totwalkers
integer :: nPertRefs
integer(n_int) :: tmpRef(0:NIfTot, 1)
character(*), parameter :: t_r = "create_perturbed_reference"
! create a perturbed reference determinant as overlap state
nPertRefs = 0
! i.e. take the most populated determinant (over all procs)
call generate_space_most_populated(1, .false., 1, tmpRef, nPertRefs, &
GLOBAL_RUN, perturbed_buf, int(tmp_totwalkers, n_int))
! from now on, we treat the perturbed_buf as 1-sized
perturbed_buf = 0
perturbed_buf(:, 1) = tmpRef(:, 1)
tmp_totwalkers = nPertRefs
end subroutine create_perturbed_ref