MOM_random module reference

Provides gridded random number capability

Data Types

randomNumberSequence

(0xefc60000UL)

PRNG

Container for pseudo-random number generators

Functions/Subroutines

random_01

Returns a random number between 0 and 1

random_01_CB

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...

random_norm

Returns an approximately normally distributed random number with mean 0 and variance 1

random_2d_01

Generates random numbers between 0 and 1 for each cell of the model grid

random_2d_norm

Returns an approximately normally distributed random number with mean 0 and variance 1 for each cell of the model grid

random_0d_constructor

Constructor for scalar PRNG. Can be used to reset the sequence.

random_2d_constructor

Constructor for gridded PRNG. Can be used to reset the sequence.

seed_from_time

Return a seed derived as hash of values in Time

seed_from_index

Create seed from position index

random_destruct

Destructor for PRNG

new_RandomNumberSequence

Return an initialized twister using seed

getRandomInt

Return a random integer on interval [0,0xffffffff]

getRandomReal

Return a random real number on interval [0,1]

mixbits

Merge bits of u and v

twist

Twist bits of u and v

nextState

Update internal state of twister to the next state in the sequence

temper

Tempering of bits in y

random_unit_tests

Runs some statistical tests on the PRNG

test_fn

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

Callees call graph
Callees of mom_random::random_01 calls cluster_mom_random MOM_random mom_random::getrandomreal getRandomReal [private/internal] mom_random::random_01 random_01 mom_random::random_01->mom_random::getrandomreal
Text view
Callers call graph
Callers of mom_random::random_01 calls cluster_mom_random MOM_random mom_random::random_01 random_01 mom_random::random_unit_tests random_unit_tests mom_random::random_unit_tests->mom_random::random_01
Text view
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

Callees call graph
Callees of mom_random::random_norm calls cluster_mom_random MOM_random mom_random::getrandomreal getRandomReal [private/internal] mom_random::random_norm random_norm mom_random::random_norm->mom_random::getrandomreal
Text view
Callers call graph
Callers of mom_random::random_norm calls cluster_mom_random MOM_random mom_random::random_norm random_norm mom_random::random_unit_tests random_unit_tests mom_random::random_unit_tests->mom_random::random_norm
Text view
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]

Callees call graph
Callees of mom_random::random_2d_01 calls cluster_mom_random MOM_random mom_random::getrandomreal getRandomReal [private/internal] mom_random::random_2d_01 random_2d_01 mom_random::random_2d_01->mom_random::getrandomreal
Text view
Callers call graph
Callers of mom_random::random_2d_01 calls cluster_mom_random MOM_random mom_random::random_2d_01 random_2d_01 mom_random::random_unit_tests random_unit_tests mom_random::random_unit_tests->mom_random::random_2d_01
Text view
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]

Callees call graph
Callees of mom_random::random_2d_norm calls cluster_mom_random MOM_random mom_random::getrandomreal getRandomReal [private/internal] mom_random::random_2d_norm random_2d_norm mom_random::random_2d_norm->mom_random::getrandomreal
Text view
Callers call graph
Callers of mom_random::random_2d_norm calls cluster_mom_random MOM_random cluster_mom_stoch_eos MOM_stoch_eos mom_random::random_2d_norm random_2d_norm mom_random::random_unit_tests random_unit_tests mom_random::random_unit_tests->mom_random::random_2d_norm mom_stoch_eos::mom_stoch_eos_init MOM_stoch_eos_init mom_stoch_eos::mom_stoch_eos_init->mom_random::random_2d_norm mom_stoch_eos::mom_stoch_eos_run MOM_stoch_eos_run mom_stoch_eos::mom_stoch_eos_run->mom_random::random_2d_norm
Text view
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
Callees of mom_random::random_0d_constructor calls cluster_mom_random MOM_random mom_random::new_randomnumbersequence new_RandomNumberSequence [private/internal] mom_random::random_0d_constructor random_0d_constructor mom_random::random_0d_constructor->mom_random::new_randomnumbersequence mom_random::seed_from_time seed_from_time [private/internal] mom_random::random_0d_constructor->mom_random::seed_from_time
Text view
Callers call graph
Callers of mom_random::random_0d_constructor calls cluster_mom_random MOM_random mom_random::random_0d_constructor random_0d_constructor mom_random::random_unit_tests random_unit_tests mom_random::random_unit_tests->mom_random::random_0d_constructor
Text view
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
Callees of mom_random::random_2d_constructor calls cluster_mom_random MOM_random mom_random::new_randomnumbersequence new_RandomNumberSequence [private/internal] mom_random::random_2d_constructor random_2d_constructor mom_random::random_2d_constructor->mom_random::new_randomnumbersequence mom_random::seed_from_index seed_from_index [private/internal] mom_random::random_2d_constructor->mom_random::seed_from_index mom_random::seed_from_time seed_from_time [private/internal] mom_random::random_2d_constructor->mom_random::seed_from_time
Text view
Callers call graph
Callers of mom_random::random_2d_constructor calls cluster_mom_random MOM_random cluster_mom_stoch_eos MOM_stoch_eos mom_random::random_2d_constructor random_2d_constructor mom_random::random_unit_tests random_unit_tests mom_random::random_unit_tests->mom_random::random_2d_constructor mom_stoch_eos::mom_stoch_eos_init MOM_stoch_eos_init mom_stoch_eos::mom_stoch_eos_init->mom_random::random_2d_constructor mom_stoch_eos::mom_stoch_eos_run MOM_stoch_eos_run mom_stoch_eos::mom_stoch_eos_run->mom_random::random_2d_constructor
Text view
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
Callers of mom_random::seed_from_time calls cluster_mom_random MOM_random mom_random::random_0d_constructor random_0d_constructor mom_random::seed_from_time seed_from_time [private/internal] mom_random::random_0d_constructor->mom_random::seed_from_time mom_random::random_2d_constructor random_2d_constructor mom_random::random_2d_constructor->mom_random::seed_from_time mom_random::random_unit_tests random_unit_tests mom_random::random_unit_tests->mom_random::seed_from_time
Text view

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
Callers of mom_random::seed_from_index calls cluster_mom_random MOM_random mom_random::random_2d_constructor random_2d_constructor mom_random::seed_from_index seed_from_index [private/internal] mom_random::random_2d_constructor->mom_random::seed_from_index mom_random::random_unit_tests random_unit_tests mom_random::random_unit_tests->mom_random::seed_from_index
Text view
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
Callers of mom_random::new_randomnumbersequence calls cluster_mom_random MOM_random mom_random::new_randomnumbersequence new_RandomNumberSequence [private/internal] mom_random::random_0d_constructor random_0d_constructor mom_random::random_0d_constructor->mom_random::new_randomnumbersequence mom_random::random_2d_constructor random_2d_constructor mom_random::random_2d_constructor->mom_random::new_randomnumbersequence
Text view
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
Callees of mom_random::getrandomint calls cluster_mom_random MOM_random mom_random::getrandomint getRandomInt [private/internal] mom_random::nextstate nextState [private/internal] mom_random::getrandomint->mom_random::nextstate mom_random::temper temper [private/internal] mom_random::getrandomint->mom_random::temper
Text view
Callers call graph
Callers of mom_random::getrandomint calls cluster_mom_random MOM_random mom_random::getrandomint getRandomInt [private/internal] mom_random::getrandomreal getRandomReal [private/internal] mom_random::getrandomreal->mom_random::getrandomint
Text view
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

Callees call graph
Callees of mom_random::getrandomreal calls cluster_mom_random MOM_random mom_random::getrandomint getRandomInt [private/internal] mom_random::getrandomreal getRandomReal [private/internal] mom_random::getrandomreal->mom_random::getrandomint
Text view
Callers call graph
Callers of mom_random::getrandomreal calls cluster_mom_random MOM_random mom_random::getrandomreal getRandomReal [private/internal] mom_random::random_01 random_01 mom_random::random_01->mom_random::getrandomreal mom_random::random_2d_01 random_2d_01 mom_random::random_2d_01->mom_random::getrandomreal mom_random::random_2d_norm random_2d_norm mom_random::random_2d_norm->mom_random::getrandomreal mom_random::random_norm random_norm mom_random::random_norm->mom_random::getrandomreal
Text view
integer function mixbits(u, v)

Merge bits of u and v

Parameters
  • u [in]

    An integer

  • v [in]

    An integer

Callers call graph
Callers of mom_random::mixbits calls cluster_mom_random MOM_random mom_random::mixbits mixbits [private/internal] mom_random::twist twist [private/internal] mom_random::twist->mom_random::mixbits
Text view
integer function twist(u, v)

Twist bits of u and v

Parameters
  • u [in]

    An integer

  • v [in]

    An integer

Callees call graph
Callees of mom_random::twist calls cluster_mom_random MOM_random mom_random::mixbits mixbits [private/internal] mom_random::twist twist [private/internal] mom_random::twist->mom_random::mixbits
Text view
Callers call graph
Callers of mom_random::twist calls cluster_mom_random MOM_random mom_random::nextstate nextState [private/internal] mom_random::twist twist [private/internal] mom_random::nextstate->mom_random::twist
Text view
subroutine nextState(twister)

Update internal state of twister to the next state in the sequence

Parameters
  • twister [inout]

    Container for the Mersenne Twister

Callees call graph
Callees of mom_random::nextstate calls cluster_mom_random MOM_random mom_random::nextstate nextState [private/internal] mom_random::twist twist [private/internal] mom_random::nextstate->mom_random::twist
Text view
Callers call graph
Callers of mom_random::nextstate calls cluster_mom_random MOM_random mom_random::getrandomint getRandomInt [private/internal] mom_random::nextstate nextState [private/internal] mom_random::getrandomint->mom_random::nextstate
Text view
elemental integer function temper(y)

Tempering of bits in y

Parameters
  • y [in]

    An integer

Callers call graph
Callers of mom_random::temper calls cluster_mom_random MOM_random mom_random::getrandomint getRandomInt [private/internal] mom_random::temper temper [private/internal] mom_random::getrandomint->mom_random::temper
Text view
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
Callees of mom_random::random_unit_tests calls cluster_mom_random MOM_random mom_random::random_01 random_01 mom_random::random_0d_constructor random_0d_constructor mom_random::random_2d_01 random_2d_01 mom_random::random_2d_constructor random_2d_constructor mom_random::random_2d_norm random_2d_norm mom_random::random_norm random_norm mom_random::random_unit_tests random_unit_tests mom_random::random_unit_tests->mom_random::random_01 mom_random::random_unit_tests->mom_random::random_0d_constructor mom_random::random_unit_tests->mom_random::random_2d_01 mom_random::random_unit_tests->mom_random::random_2d_constructor mom_random::random_unit_tests->mom_random::random_2d_norm mom_random::random_unit_tests->mom_random::random_norm mom_random::seed_from_index seed_from_index [private/internal] mom_random::random_unit_tests->mom_random::seed_from_index mom_random::seed_from_time seed_from_time [private/internal] mom_random::random_unit_tests->mom_random::seed_from_time mom_random::test_fn test_fn [private/internal] mom_random::random_unit_tests->mom_random::test_fn
Text view
Callers call graph
Callers of mom_random::random_unit_tests calls cluster_mom_random MOM_random cluster_mom_unit_tests MOM_unit_tests mom_random::random_unit_tests random_unit_tests mom_unit_tests::unit_tests unit_tests mom_unit_tests::unit_tests->mom_random::random_unit_tests
Text view

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

Callers call graph
Callers of mom_random::test_fn calls cluster_mom_random MOM_random mom_random::random_unit_tests random_unit_tests mom_random::test_fn test_fn [private/internal] mom_random::random_unit_tests->mom_random::test_fn
Text view
API generated with Flint · Rendered from reStructuredText