[UP]


Manual Reference Pages  - random_int (3)

NAME

random_int(3f) - [M_random] return an integer between low and high value inclusive (LICENSE:MIT)

CONTENTS

Synopsis
Description
Options
Returns
Example
Author
License

SYNOPSIS

function random_int(first,last) result(rand_int)

   integer,intent(in) :: first,last
   integer            :: rand_int

DESCRIPTION

Return an integer uniformly distributed from the set {first,,first+1,...,last-1,last}.

OPTIONS

first lowest value of range of integer values to randomly return
last highest value of range of integer values to randomly return

RETURNS

rand_int
  a random integer value between FIRST LAST inclusive

EXAMPLE

Sample program

   program demo_random_int
   use M_random, only : random_int
   write(*,’(*(i0:,1x))’)(random_int(1,10),i=1,20)
   write(*,’(*(i0:,1x))’)(random_int(-5,5),i=1,20)
   end program demo_random_int

Sample 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

AUTHOR

John S. Urban

LICENSE

MIT License


random_int (3) October 17, 2020
Generated by manServer 1.08 from 00a844bb-2b95-46d2-a3b0-596d81572b44 using man macros.