Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A newer version of this document is available. Customers should click here to go to the newest version.
Visible to Intel only — GUID: GUID-2FB8ADF6-BBB1-44CE-95C6-C55B6E79825E
Visible to Intel only — GUID: GUID-2FB8ADF6-BBB1-44CE-95C6-C55B6E79825E
SRAND
Portability Subroutine: Seeds the random number generator used with IRAND and RAND.
Module
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.
Example
! 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