„Roulette-wheel selection via stochastic acceptance”, Physica A 391, 2193 (2012)  (arxiv preprint)

outline of f77 implementation:

c----------------------------- roulette-wheel selection --------------------

c code selects one of n elements with probability proportional to weight(k)
        do while (notaccepted)
            call rndgnrt(r) ! generates a random number r (0<r<1)
            k=int(r*n)+1 ! k - randomly drawn integer number (k=1, 2,..., n)
            call rndgnrt(r)
            if (r.LT.weight(k)/MAX) notaccepted=.FALSE. ! MAX - maximum of weights
       end do
       write(6,*) 'selected number=', k

Comment: Typically,  weight(k) are evolving and one should keep track of the max. However, when weight(k) are known to be bounded, e.g., by definition one has  0<weight(k)<BOUND, then BOUND can be used instead of  MAX. It reduces efficiency but most likely simplifies the algorithm.