function count_double_orbs(ilut) result(n_double_orbs)
! returns the number of doubly occupied orbitals for a given
! determinant.
use DetBitOps, only: count_open_orbs
integer(n_int), intent(in) :: ilut(0:niftot)
integer :: n_double_orbs
character(*), parameter :: this_routine = "count_double_occupancy"
integer :: n_open_orbs
n_open_orbs = count_open_orbs(ilut(0:nifd))
! the doubly occupied orbitals are just the number of electrons
! minus the number of open orbitals divided by 2
n_double_orbs = (nel - n_open_orbs) / 2
end function count_double_orbs