IRAND — Integer pseudo-random number#
-
IRAND(FLAG)#
IRAND(FLAG)
returns a pseudo-random number from a uniform distribution between 0 and a system-dependent limit (which is in most cases 2147483647). IfFLAG
is 0, the next number in the current sequence is returned; ifFLAG
is 1, the generator is restarted byCALL SRAND(0)
; ifFLAG
has any other value, it is used as a new seed withSRAND
.- Parameters
I – Shall be a scalar
INTEGER
of kind 4.- Returns
The return value is of
INTEGER(kind=4)
type.
- Standard:
GNU extension
- Class:
Function
- Syntax:
RESULT = IRAND(I)
- Example:
program test_irand integer,parameter :: seed = 86456 call srand(seed) print *, irand(), irand(), irand(), irand() print *, irand(seed), irand(), irand(), irand() end program test_irand