Randomly pick an orbital from a pre-arranged pool of possible orbitals @param[inout] tgt array of size 3, contains the target orbitals @param[in] pool array containing the available orbitals to pick from @param[in] nPicked number of already picked orbitals @param[inout] pgen probabaility of choosing this orbital
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | tgt(3) | |||
integer, | intent(in) | :: | pool(:) | |||
integer, | intent(in) | :: | nPicked | |||
real(kind=dp), | intent(inout) | :: | pgen |
subroutine get_orb_from_pool(tgt, pool, nPicked, pgen)
integer, intent(inout) :: tgt(3)
integer, intent(in) :: pool(:), nPicked
real(dp), intent(inout) :: pgen
integer :: iOrb, i, pool_size
real(dp) :: r
! pick a random index
pool_size = size(pool)
if (pool_size > 0) then
r = genrand_real2_dSFMT()
iOrb = pool(int(r * pool_size) + 1)
! assign the orbital
tgt(nPicked + 1) = iOrb
! adjust the probability
pgen = pgen / pool_size
else
tgt(nPicked + 1) = 0
end if
end subroutine get_orb_from_pool