subroutine create_sparse_ham_from_core(rep)
type(core_space_t), intent(in) :: rep
character(*), parameter :: t_r = "create_sparse_ham_from_core"
integer :: ierr, i
! Create the arrays used by the Davidson routine.
! First, the whole Hamiltonian in sparse form.
if (allocated(sparse_ham)) deallocate(sparse_ham)
if (allocated(SparseHamilTags)) deallocate(SparseHamilTags)
allocate(sparse_ham(rep%determ_sizes(iProcIndex)))
allocate(SparseHamilTags(2, rep%determ_sizes(iProcIndex)))
do i = 1, rep%determ_sizes(iProcIndex)
call allocate_sparse_ham_row(sparse_ham, i, &
rep%sparse_core_ham(i)%num_elements, "sparse_ham", SparseHamilTags(:, i))
sparse_ham(i)%elements = rep%sparse_core_ham(i)%elements
sparse_ham(i)%positions = rep%sparse_core_ham(i)%positions
sparse_ham(i)%num_elements = rep%sparse_core_ham(i)%num_elements
end do
! Next create the diagonal used by Davidson by copying the core one.
if (allocated(hamil_diag)) deallocate(hamil_diag)
allocate(hamil_diag(rep%determ_sizes(iProcIndex)), stat=ierr)
call LogMemAlloc('hamil_diag', int(rep%determ_sizes(iProcIndex)), &
8, t_r, HDiagTag, ierr)
hamil_diag = rep%core_ham_diag
end subroutine create_sparse_ham_from_core