![]() |
(git:b77b4be)
|
Parallel (pseudo)random number generator (RNG) for multiple streams and substreams of random numbers. More...
Data Types | |
type | rng_stream_p_type |
interface | rng_stream_type |
Functions/Subroutines | |
subroutine | advance (self, e, c) |
Advance the state by n steps, i.e. jump n steps forward, if n > 0, or backward if n < 0. | |
subroutine, public | check_rng (output_unit, ionode) |
... | |
type(rng_stream_type) function, public | rng_stream_type_from_record (rng_record) |
Create a RNG stream from a record given as an internal file (string). | |
real(kind=dp) function, dimension(3, 2), public | next_rng_seed (seed) |
Get the seed for the next RNG stream w.r.t. a given seed. | |
subroutine, public | write_rng_matrices (output_unit) |
Write the transformation matrices of the two MRG components (raised to the specified output) | |
Variables | |
integer, parameter, public | rng_record_length = 433 |
integer, parameter, public | rng_name_length = 40 |
integer, parameter, public | gaussian = 1 |
integer, parameter, public | uniform = 2 |
Parallel (pseudo)random number generator (RNG) for multiple streams and substreams of random numbers.
In detail, this RNG provides 2**64 random number streams each with a length of 2**127 resulting in a length of 2**191 for the total RNG. Moreover, each stream is divided in 2**51 substream of length 2**76. The stream lengths refer to the default precision of 32 bit random number, but also an extended precision of 53 bit per random number can be requested. In this case, two 32 bit random numbers are used to generate a 53 bit random number and therefore the stream length is halved when extended precision are requested.
Usage hint:
type(rng_stream_type) :: rng_stream rng_stream = rng_stream_type(name, ..., error=error)
to generate the first stream. Optionally, you may define a different seed or create a stream of extended precision (53 bits). Then
type(rng_stream_type) :: next_rng_stream next_rng_stream = rng_stream_type(name, last_rng_stream=rng_stream)
to create all the following RNG streams w.r.t. the previous stream. The command line
x = rng_streamnext(error=error)
will provide the next real random number x between 0 and 1 and
ix = rng_streamnext(low, high, error=error)
the next integer random number ix between low and high from stream rng_stream. The default distribution type is a uniform distribution [0,1], but also other distribution types are available (see below).
subroutine parallel_rng_types::advance | ( | class(rng_stream_type), intent(inout) | self, |
integer, intent(in) | e, | ||
integer, intent(in) | c | ||
) |
Advance the state by n steps, i.e. jump n steps forward, if n > 0, or backward if n < 0.
self | ... |
e | IF e > 0, let n = 2**e + c, IF e < 0, let n = -2**(-e) + c, IF e = 0, let n = c |
c | ... |
Definition at line 227 of file parallel_rng_types.F.
subroutine, public parallel_rng_types::check_rng | ( | integer, intent(in) | output_unit, |
logical, intent(in) | ionode | ||
) |
...
output_unit | ... |
ionode | ... |
Definition at line 278 of file parallel_rng_types.F.
type(rng_stream_type) function, public parallel_rng_types::rng_stream_type_from_record | ( | character(len=rng_record_length), intent(in) | rng_record | ) |
Create a RNG stream from a record given as an internal file (string).
rng_record | ... |
Definition at line 563 of file parallel_rng_types.F.
real(kind=dp) function, dimension(3, 2), public parallel_rng_types::next_rng_seed | ( | real(kind=dp), dimension(3, 2), intent(in), optional | seed | ) |
Get the seed for the next RNG stream w.r.t. a given seed.
seed | If the optional argument seed is missing, then the default seed is returned. |
Definition at line 852 of file parallel_rng_types.F.
subroutine, public parallel_rng_types::write_rng_matrices | ( | integer, intent(in) | output_unit | ) |
Write the transformation matrices of the two MRG components (raised to the specified output)
output_unit | ... |
Definition at line 1085 of file parallel_rng_types.F.
integer, parameter, public parallel_rng_types::rng_record_length = 433 |
Definition at line 65 of file parallel_rng_types.F.
integer, parameter, public parallel_rng_types::rng_name_length = 40 |
Definition at line 66 of file parallel_rng_types.F.
integer, parameter, public parallel_rng_types::gaussian = 1 |
Definition at line 73 of file parallel_rng_types.F.
integer, parameter, public parallel_rng_types::uniform = 2 |
Definition at line 73 of file parallel_rng_types.F.