randint Function

public function randint(a, b)

sample a random integer between [a, b]

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: a

lower bound

integer, intent(in) :: b

higher bound

Return Value integer


Source Code

        integer function randint(a, b)
        !! sample a random integer between [a, b]
            !> lower bound
            integer, intent(IN) :: a
            !> higher bound
            integer, intent(IN) :: b

            randint = a + floor((b + 1 - a)*ran2()) 

        end function randint