subroutine update_single_ref_sign(iRef)
! Get the signs of the references from the currentdets. Used both in the final
! output and in generating the product excitations
use bit_reps, only: decode_bit_det, encode_sign
use hash, only: hash_table_lookup
use FciMCData, only: HashIndex
use Parallel_neci, only: MPISumAll
implicit none
integer, intent(in) :: iRef
integer:: nI(nel), hash_val, index
real(dp) :: tmp_sgn(lenof_sign), mpi_sgn(lenof_sign)
logical :: tSuccess
call decode_bit_det(nI, ilutRefAdi(:, iRef))
call hash_table_lookup(nI, ilutRefAdi(:, iRef), nifd, HashIndex, CurrentDets, &
index, hash_val, tSuccess)
if (tSuccess) then
call extract_sign(CurrentDets(:, index), tmp_sgn)
else
tmp_sgn = 0.0_dp
end if
! This does the trick of communication: We need to get the sign to all
! processors, so just sum up the individual ones
call MPISumAll(tmp_sgn, mpi_sgn)
! The sign contains information on all runs, so it is the same on all
call encode_sign(ilutRefAdi(:, iRef), mpi_sgn)
end subroutine update_single_ref_sign