subroutine get_exact_spectrum()
integer :: lwork, info, ndets
real(dp), allocatable :: work(:)
! Data for the testsuite to use.
real(dp) :: h_sum, spec_low, spec_high
call init_exact_spectrum(ndets)
h_sum = sum(hamiltonian)
! Create the workspace for dsyev.
lwork = max(1, 3 * ndets - 1)
allocate(work(lwork))
write(stdout, '(1x,a28)', advance='no') "Diagonalising Hamiltonian..."
call neci_flush(stdout)
! Perform the diagonalisation.
call dsyev('V', 'U', ndets, hamiltonian, ndets, eigv_es, work, lwork, info)
write(stdout, '(1x,a9,/)') "Complete."
call neci_flush(stdout)
trans_amps_right = matmul(pert_ground_right, hamiltonian)
trans_amps_left = matmul(pert_ground_left, hamiltonian)
call output_spectrum(ndets, eigv_es, spec_low, spec_high)
call write_exact_spec_testsuite_data(h_sum, spec_low, spec_high)
call end_exact_spectrum()
deallocate(work)
end subroutine get_exact_spectrum