MOM_random module reference
Provides gridded random number capability
Data Types
(0xefc60000UL) |
|
Container for pseudo-random number generators |
Functions/Subroutines
Returns a random number between 0 and 1 |
|
Returns a random number between 0 and 1 See https://arxiv.org/abs/2004.06278. Not an exact reproduction of "squares" because Fortran doesn't have a uint64 type, and not all compilers provide integers with > 64 bits... |
|
Returns an approximately normally distributed random number with mean 0 and variance 1 |
|
Generates random numbers between 0 and 1 for each cell of the model grid |
|
Returns an approximately normally distributed random number with mean 0 and variance 1 for each cell of the model grid |
|
Constructor for scalar PRNG. Can be used to reset the sequence. |
|
Constructor for gridded PRNG. Can be used to reset the sequence. |
|
Return a seed derived as hash of values in Time |
|
Create seed from position index |
|
Destructor for PRNG |
|
Return an initialized twister using seed |
|
Return a random integer on interval [0,0xffffffff] |
|
Return a random real number on interval [0,1] |
|
Merge bits of u and v |
|
Twist bits of u and v |
|
Update internal state of twister to the next state in the sequence |
|
Tempering of bits in y |
|
Runs some statistical tests on the PRNG |
|
Convenience function for reporting result of test |
Type Documentation
- type randomNumberSequence
(0xefc60000UL)
A private type used by the Mersenne Twistor
- Parameters
currentElement
Index into state vector
state
State vector
- type, public :: PRNG
Container for pseudo-random number generators
- Parameters
stream0d
Random number generator for each cell on horizontal grid
Functions/Subroutine Documentation
- real function random_01(CS)
Returns a random number between 0 and 1
- Parameters
CS [inout]
Container for pseudo-random number generators
- real function random_01_CB(ctr, key)
Returns a random number between 0 and 1 See https://arxiv.org/abs/2004.06278. Not an exact reproduction of "squares" because Fortran doesn't have a uint64 type, and not all compilers provide integers with > 64 bits...
- Parameters
ctr [in]
ctr should be incremented each time you call the function
key [in]
key is like a seed: use a different key for each random stream
- real function random_norm(CS)
Returns an approximately normally distributed random number with mean 0 and variance 1
- Parameters
CS [inout]
Container for pseudo-random number generators
- subroutine random_2d_01(CS, HI, rand)
Generates random numbers between 0 and 1 for each cell of the model grid
- Parameters
CS [inout]
Container for pseudo-random number generators
HI [in]
Horizontal index structure
rand [out]
Random numbers between 0 and 1 [nondim]
- subroutine random_2d_norm(CS, HI, rand)
Returns an approximately normally distributed random number with mean 0 and variance 1 for each cell of the model grid
- Parameters
CS [inout]
Container for pseudo-random number generators
HI [in]
Horizontal index structure
rand [out]
Random numbers between 0 and 1 [nondim]
- subroutine random_0d_constructor(CS, Time, seed)
Constructor for scalar PRNG. Can be used to reset the sequence.
- Parameters
CS [inout]
Container for pseudo-random number generators
Time [in]
Current model time
seed [in]
Seed for PRNG
Callees call graph
- subroutine random_2d_constructor(CS, HI, Time, seed)
Constructor for gridded PRNG. Can be used to reset the sequence.
- Parameters
CS [inout]
Container for pseudo-random number generators
HI [in]
Horizontal index structure
Time [in]
Current model time
seed [in]
Seed for PRNG
Callees call graph
- integer function seed_from_time(Time)
Return a seed derived as hash of values in Time
- Parameters
Time [in]
Current model time
Callers call graph
External calls
- time_manager_mod
get_date (time_manager_mod::get_date)
- integer function seed_from_index(HI, i, j)
Create seed from position index
- Parameters
HI [in]
Horizontal index structure
i [in]
i-index (of h-cell)
j [in]
j-index (of h-cell)
Callers call graph
- subroutine random_destruct(CS)
Destructor for PRNG
- Parameters
CS
Container for pseudo-random number generators
- function new_RandomNumberSequence(seed) result(twister)
Return an initialized twister using seed
Code was based on initialize_scaler() from the FMS implementation of the Mersenne Twistor
- Parameters
seed [in]
Seed to initialize twister
twister
The Mersenne Twister container
Callers call graph
- integer function getRandomInt(twister)
Return a random integer on interval [0,0xffffffff]
Code was based on getRandomInt() from the FMS implementation of the Mersenne Twistor
- Parameters
twister [inout]
The Mersenne Twister container
Callees call graph
- double precision function getRandomReal(twister)
Return a random real number on interval [0,1]
Code was based on getRandomReal() from the FMS implementation of the Mersenne Twistor
- integer function mixbits(u, v)
Merge bits of u and v
- Parameters
u [in]
An integer
v [in]
An integer
- integer function twist(u, v)
Twist bits of u and v
- Parameters
u [in]
An integer
v [in]
An integer
- subroutine nextState(twister)
Update internal state of twister to the next state in the sequence
- Parameters
twister [inout]
Container for the Mersenne Twister
- elemental integer function temper(y)
Tempering of bits in y
- Parameters
y [in]
An integer
- logical function random_unit_tests(verbose)
Runs some statistical tests on the PRNG
- Parameters
verbose
True if results should be written to stdout
HI
Not the real HI
Callees call graph
External calls
- time_manager_mod
set_date (time_manager_mod::set_date)
- logical function test_fn(verbose, good, label, rvalue, ivalue)
Convenience function for reporting result of test
- Parameters
verbose [in]
Verbosity
good [in]
True if pass, false otherwise
label [in]
Label for messages
rvalue [in]
Result of calculation [nondim]
ivalue [in]
Result of calculation