Returns a single pseudorandom number or an array of pseudorandom numbers from the uniform distribution over the range .
The runtime-library implements George Marsaglia’s KISS (Keep It Simple Stupid) random number generator (RNG). This RNG combines:
The congruential generator with a period of ,
A 3-shift shift-register generator with a period of ,
Two 16-bit multiply-with-carry generators with a period of .
The overall period exceeds .
Please note, this RNG is thread safe if used within OpenMP directives, i.e., its state will be consistent while called from multiple threads. However, the KISS generator does not create random numbers in parallel from multiple sources, but in sequence from a single source. If an OpenMP-enabled application heavily relies on random numbers, one should consider employing a dedicated parallel random number generator instead.
Fortran 95 and later
harvest- Shall be a scalar or an array of type
program test_random_number real :: r(5,5) call init_random_seed() ! see example of random_seed call random_number(r) end program