Intel® Fortran Compiler 16.0 User and Reference Guide

RAN

Nonelemental Intrinsic Function (Specific): Returns the next number from a sequence of pseudorandom numbers of uniform distribution over the range 0 to 1. This is a specific function that has no generic function associated with it. It cannot be passed as an actual argument.

result = RAN (i)

i

(Input; output) Must be an INTEGER(4) variable or array element.

It should initially be set to a large, odd integer value. The RAN function stores a value in the argument that is later used to calculate the next random number.

There are no restrictions on the seed, although it should be initialized with different values on separate runs to obtain different random numbers.

Results

The result type is REAL(4). The result is a floating-point number that is uniformly distributed in the range between 0.0 inclusive and 1.0 exclusive. It is set equal to the value associated with the argument i.

RAN is not a pure function.

Example

In RAN (I), if variable I has the value 3, RAN has the value 4.8220158E-05.

See Also