subroutine end_spectral_lanczos()
deallocate(sl_vecs)
deallocate(full_vec_sl)
deallocate(sl_overlaps)
deallocate(trans_amps_left)
deallocate(trans_amps_right)
deallocate(pert_ground_left)
deallocate(sl_hamil)
deallocate(sl_h_eigv)
deallocate(ndets_sl)
deallocate(disps_sl)
deallocate(sl_ilut_list)
write(stdout, '(/,1x,a30,/)') "Exiting Spectral Lanczos code."
call neci_flush(stdout)
end subroutine end_spectral_lanczos