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.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

 !  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

関連情報


このヘルプトピックについてのフィードバックを送信

© 1996-2011 Intel Corporation. 無断での引用、転載を禁じます。