Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | nI(nel) | |||
integer, | intent(out) | :: | nOccImp |
function pick_random_occ_impurity(nI, nOccImp) result(i)
integer, intent(in) :: nI(nel)
integer :: i
integer, intent(out) :: nOccImp
real(dp) :: r
r = genrand_real2_dSFMT()
! get the number of occupied imp orbitals in nI
nOccImp = binary_search_first_ge(nI, nImp + 1) - 1
! then, pick one of the occupied impurity orbitals at random
i = nI(int(nOccImp * r) + 1)
end function pick_random_occ_impurity