subroutine create_hilbert_space_realspace(n_orbs, n_alpha, n_beta, &
n_states, state_list_ni, state_list_ilut)
integer, intent(in) :: n_orbs, n_alpha, n_beta
integer, intent(out) :: n_states
integer, intent(out), allocatable :: state_list_ni(:, :)
integer(n_int), intent(out), allocatable :: state_list_ilut(:, :)
integer(n_int), allocatable :: all_dets(:)
integer(n_int) :: temp_ilut(0:niftot)
integer :: nJ(nel), i
integer(n_int), allocatable :: temp_dets(:, :)
integer :: save_states
all_dets = create_all_dets(n_orbs, n_alpha, n_beta)
n_states = size(all_dets)
allocate(state_list_ni(nel, n_states))
allocate(state_list_ilut(0:niftot, n_states))
do i = 1, size(all_dets)
temp_ilut = all_dets(i)
call decode_bit_det(nJ, temp_ilut)
state_list_ni(:, i) = nJ
state_list_ilut(:, i) = temp_ilut
end do
if (tHPHF) then
! for hphfs we need to purify the hilbert space!
save_states = n_states
allocate(temp_dets(0:NIfTot, n_states), source=state_list_ilut)
call spin_purify(save_states, temp_dets, n_states, state_list_ilut)
end if
end subroutine create_hilbert_space_realspace