random_int(3f) - [M_random] return an integer between low and high value inclusive (LICENSE:MIT)
Synopsis
Description
Options
Returns
Example
Author
License
function random_int(first,last) result(rand_int)
integer,intent(in) :: first,last integer :: rand_int
Return an integer uniformly distributed from the set {first,,first+1,...,last-1,last}.
first lowest value of range of integer values to randomly return last highest value of range of integer values to randomly return
rand_int a random integer value between FIRST LAST inclusive
Sample program
program demo_random_int use M_random, only : random_int, init_random_seed_by_system_clock implicit none integer :: i call init_random_seed_by_system_clock() write(*,(*(i0:,1x)))(random_int(1,10),i=1,20) write(*,(*(i0:,1x)))(random_int(-5,5),i=1,20) end program demo_random_intSample output
1 3 8 1 2 6 8 7 4 10 7 3 8 3 10 1 5 2 9 8 4 5 -3 5 2 -5 -4 4 -5 -3 -2 -2 -2 -1 -2 4 -2 -2 4 -4
John S. Urban
MIT License
Nemo Release 3.1 | random_int (3m_random) | April 12, 2023 |