subroutine cache_sign(sgn, nIEx)
integer, intent(in) :: nIEx(nel)
real(dp), intent(in) :: sgn(lenof_sign)
integer :: hash_value, ind
real(dp) :: sign_tmp(lenof_sign)
integer(n_int) :: ilut(0:NIfTot)
logical :: tSuccess
! encode the determinant into bit representation (ilut)
call EncodeBitDet(nIEx, ilut)
call hash_table_lookup(nIEx, ilut, NIfD, hash_table_ciCoeff, &
ciCoeff_storage, ind, hash_value, tSuccess)
! tSuccess is true when the coeff is found in the hash_table; so it gets updated
if (tSuccess) then
call extract_sign(ciCoeff_storage(:, ind), sign_tmp)
sign_tmp = sign_tmp + sgn
call encode_sign(ciCoeff_storage(:, ind), sign_tmp)
! tSuccess is false, then add a new entry to the CI coeffs storage
else
! it counts the number of entries of different CI coeffs
first_free_entry = first_free_entry + 1
! encode the determinant into bit representation (ilut)
call EncodeBitDet(nIEx, ilut)
! store the encoded determinant in ciCoeff_storage
ciCoeff_storage(:, first_free_entry) = ilut
! store the sign in ciCoeff_storage
call encode_sign(ciCoeff_storage(:, first_free_entry), sgn)
! create a new hashtable entry
call add_hash_table_entry(hash_table_ciCoeff, &
first_free_entry, hash_value)
end if
end subroutine cache_sign