function get_double_occupancy(ilut, real_sgn) result(double_occ)
! function to get the contribution to the double occupancy for a
! given determinant, by calculating the
! |C_I|^2 *\sum_i <n_iu n_id>/n_spatial_orbs
integer(n_int), intent(in) :: ilut(0:NIfTot)
real(dp), intent(in) :: real_sgn(lenof_sign)
real(dp) :: double_occ
character(*), parameter :: this_routine = "get_double_occupancy"
integer :: n_double_orbs
real(dp) :: frac_double_orbs
integer(n_int) :: sgn(lenof_sign)
#ifdef CMPLX_
complex(dp) :: complex_sgn
#endif
! here i need to be careful, if it is a double or single run and
! stuff
n_double_orbs = count_double_orbs(ilut(0:nifd))
! i only need the fraction of doubly occupied orbitals out of all
! spatial orbitals
frac_double_orbs = 2.0_dp * real(n_double_orbs, dp) / real(nbasis, dp)
! now i want to sum in the walkers from the runs..
! todo: have to figure out how to access the different runs
! extract the walker occupation
#if defined PROG_NUMRUNS_ || defined DOUBLERUN_
! i essentially only need two runs!
double_occ = real_sgn(1) * real_sgn(2) * frac_double_orbs
#else
double_occ = real_sgn(1)**2 * frac_double_orbs
#endif
end function get_double_occupancy