Intel® Fortran Compiler 18.0 Developer Guide and Reference
Portability Subroutine: Seeds the random number generator used with IRAND and RAND.
USE IFPORT
CALL SRAND (iseed)
iseed |
(Input) INTEGER(4). Any value. The default value is 1. |
SRAND seeds the random number generator used with IRAND and RAND. Calling SRAND is equivalent to calling IRAND or RAND with a new seed.
The same value for iseed generates the same sequence of random numbers. To vary the sequence, call SRAND with a different iseed value each time the program is executed.
! How many random numbers out of 100 will be between .5 and .6?
USE IFPORT
ICOUNT = 0
CALL SRAND(123)
DO I = 1, 100
X = RAND(0)
IF ((X>.5).AND.(x<.6)) ICOUNT = ICOUNT + 1
END DO
WRITE(*,*) ICOUNT, "numbers between .5 and .6!"
END