CCPP SciDoc v7.0.0  v7.0.0
Common Community Physics Package Developed at DTC
 
Loading...
Searching...
No Matches
mersenne_twister Module Reference

This module calculates random numbers using the Mersenne twister. More...

Data Types

interface  random_gauss
 
interface  random_index
 
interface  random_number
 
interface  random_setseed
 
type  random_stat
 Generator state. More...
 

Functions/Subroutines

subroutine, public random_seed (size, put, get, stat)
 This subroutine sets and gets state; overloads Fortran 90 standard.
 
subroutine random_setseed_s (inseed)
 This subroutine sets seed in saved mode.
 
subroutine random_setseed_t (inseed, stat)
 This subroutine sets seed in thread-safe mode.
 
real(kind_dbl_prec) function, public random_number_f ()
 This function generates random numbers in functional mode.
 
subroutine random_number_i (harvest, inseed)
 This subroutine generates random numbers in interactive mode.
 
subroutine random_number_s (harvest)
 This subroutine generates random numbers in saved mode; overloads Fortran 90 standard.
 
subroutine random_number_t (harvest, stat)
 This subroutine generates random numbers in thread-safe mode.
 
real(kind_dbl_prec) function, public random_gauss_f ()
 This subrouitne generates Gaussian random numbers in functional mode.
 
subroutine random_gauss_i (harvest, inseed)
 This subrouitne generates Gaussian random numbers in interactive mode.
 
subroutine random_gauss_s (harvest)
 This subroutine generates Gaussian random numbers in saved mode.
 
subroutine random_gauss_t (harvest, stat)
 This subroutine generates Gaussian random numbers in thread-safe mode.
 
integer function, public random_index_f (imax)
 This subroutine generates random indices in functional mode.
 
subroutine random_index_i (imax, iharvest, inseed)
 This subroutine generates random indices in interactive mode.
 
subroutine random_index_s (imax, iharvest)
 This subroutine generates random indices in saved mode.
 
subroutine random_index_t (imax, iharvest, stat)
 This subroutine generates random indices in thread-safe mode.
 

Variables

integer, parameter n =624
 
integer, parameter m =397
 
integer, parameter mata =-1727483681
 constant vector a
 
integer, parameter umask =-2147483648
 most significant w-r bits
 
integer, parameter lmask =2147483647
 least significant r bits
 
integer, parameter tmaskb =-1658038656
 tempering parameter
 
integer, parameter tmaskc =-272236544
 tempering parameter
 
integer, dimension(0:1), parameter mag01 =(/0,mata/)
 
integer, parameter iseed =4357
 
integer, parameter nrest =n+6
 
type(random_stat), save sstat
 

Detailed Description

(It has been adapted to a Fortran 90 module from open source software. The comments from the original software are given below in the remarks.) The Mersenne twister (aka MT19937) is a state-of-the-art random number generator based on Mersenne primes and originally developed in 1997 by Matsumoto and Nishimura. It has a period before repeating of 2^19937-1, which certainly should be good enough for geophysical purposes. :-) Considering the algorithm's robustness, it runs fairly speedily. (Some timing statistics are given below in the remarks.) This adaptation uses the standard Fortran 90 random number interface, which can generate an arbitrary number of random numbers at one time. The random numbers generated are uniformly distributed between 0 and 1. The module also can generate random numbers from a Gaussian distribution with mean 0 and standard deviation 1, using a Numerical Recipes algorithm. The module also can generate uniformly random integer indices. There are also thread-safe versions of the generators in this adaptation, necessitating the passing of generator states which must be kept private.