subroutine create_init_excited_state(ndets_this_proc, trial_vecs, ex_state_labels, ex_state_weights, init_vec)
integer, intent(in) :: ndets_this_proc
HElement_t(dp), intent(in) :: trial_vecs(:, :)
integer, intent(in) :: ex_state_labels(:)
real(dp), intent(in) :: ex_state_weights(:)
HElement_t(dp), allocatable, intent(out) :: init_vec(:, :)
real(dp) :: real_sign(lenof_sign)
integer :: i, j, ierr
character(len=*), parameter :: t_r = "create_init_excited_state"
allocate(init_vec(1, ndets_this_proc), stat=ierr)
if (ierr /= 0) call stop_all(t_r, "Error in MPIScatterV call.")
do i = 1, ndets_this_proc
init_vec(1, i) = h_cast(0.0_dp)
do j = 1, size(ex_state_labels)
init_vec(1, i) = init_vec(1, i) + ex_state_weights(j) * trial_vecs(ex_state_labels(j), i)
end do
end do
end subroutine create_init_excited_state