RANDOM_NUMBER (The GNU Fortran Compiler)

### 8.232 `RANDOM_NUMBER` — Pseudo-random number ¶

Synopsis:

  `CALL RANDOM_NUMBER(HARVEST)`

Description:

  For `REAL` argument, returns a single pseudorandom number or an array of pseudorandom numbers from the uniform distribution over the range 0 <= x < 1.

  For `UNSIGNED` argument returns a single pseudorandom number or an array of pseudorandom numbers in over the range of 0 <= x <= HUGE(HARVEST).

  The runtime-library implements the xoshiro256** pseudorandom number generator (PRNG). This generator has a period of 2^{256} - 1, and when using multiple threads up to 2^{128} threads can each generate 2^{128} random numbers before any aliasing occurs.

  Note that in a multi-threaded program (e.g. using OpenMP directives), each thread has its own random number state. For details of the seeding procedure, see the documentation for the `RANDOM_SEED` intrinsic.

Class:

  Subroutine

Arguments:

  HARVEST | Shall be a scalar or an array of type `REAL`.

Example:

      program test_random_number
        REAL :: r(5,5)
        CALL RANDOM_NUMBER(r)
      end program

Standard:

  Fortran 90 and later, extension for `UNSIGNED` (see Unsigned integers)

See also:

  `RANDOM_SEED` — Initialize a pseudo-random number sequence,
  `RANDOM_INIT` — Initialize a pseudo-random number generator