SRAND

Portability Subroutine: Seeds the random number generator used with IRAND and RAND.

Module: USE IFPORT

Syntax

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.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also

RAND, IRAND, RANDOM_NUMBER, RANDOM_SEED

Example

 !  How many random numbers out of 100 will be between .5 and .6?
    USE DFPORT
    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