Visible to Intel only — GUID: GUID-CFE58123-DD1C-4297-8E45-812F20366531
Visible to Intel only — GUID: GUID-CFE58123-DD1C-4297-8E45-812F20366531
IRAND, IRANDM
Portability Functions: Return random numbers in the range 0 through (2**31)-1, or 0 through (2**15)-1 if called without an argument.
Module
USE IFPORT
result = IRAND ([iflag])
result = IRANDM ([iflag])
iflag |
(Input) INTEGER(4). Optional for IRAND. Controls the way the returned random number is chosen. If iflag is omitted, it is assumed to be 0, and the return range is 0 through (2**15)-1 (inclusive). |
Results
The result type is INTEGER(4). If iflag is 1, the generator is restarted and the first random value is returned. If iflag is 0, the next random number in the sequence is returned. If iflag is neither zero nor 1, it is used as a new seed for the random number generator, and the functions return the first new random value.
IRAND and IRANDM are equivalent and return the same random numbers. Both functions are included to ensure portability of existing code that references one or both of them.
You can use SRAND to restart the pseudorandom number generator used by these functions.
Example
USE IFPORT
INTEGER(4) istat, flag_value, r_nums(20)
flag_value=1
r_nums(1) = IRAND (flag_value)
flag_value=0
do istat=2,20
r_nums(istat) = irand(flag_value)
end do