subroutine fill_spawn_rdm_singles(spawn, nI, Ex, full_sign)
use rdm_data_utils, only: add_to_rdm_spawn_t
use SystemData, only: nel
type(rdm_spawn_t), intent(inout) :: spawn
integer, intent(in) :: nI(nel), Ex(2, maxExcit)
real(dp), intent(in) :: full_sign(spawn%rdm_send%sign_length)
integer :: iel
! Looking at elements of the type Gamma(a,k,i,k).
do iel = 1, nel
associate(k => nI(iel))
if (k < Ex(1, 1) .and. k < Ex(2, 1)) then
call add_to_rdm_spawn_t(spawn, k, Ex(2, 1), k, Ex(1, 1), full_sign, .false.)
else if (k < Ex(1, 1) .and. k > Ex(2, 1)) then
call add_to_rdm_spawn_t(spawn, Ex(2, 1), k, k, Ex(1, 1), -full_sign, .false.)
else if (k > Ex(1, 1) .and. k < Ex(2, 1)) then
call add_to_rdm_spawn_t(spawn, k, Ex(2, 1), Ex(1, 1), k, -full_sign, .false.)
else if (k > Ex(1, 1) .and. k > Ex(2, 1)) then
call add_to_rdm_spawn_t(spawn, Ex(2, 1), k, Ex(1, 1), k, full_sign, .false.)
end if
end associate
end do
end subroutine fill_spawn_rdm_singles