m_random Module

module~~m_random~~UsesGraph module~m_random m_random module~prng_class Prng_Class module~prng_class->module~m_random module~variablekind variableKind module~variablekind->module~m_random module~variablekind->module~prng_class module~m_strings m_strings module~variablekind->module~m_strings module~m_errors m_errors module~variablekind->module~m_errors module~m_allocate m_allocate module~variablekind->module~m_allocate module~m_deallocate m_deallocate module~variablekind->module~m_deallocate module~m_unittester m_unitTester module~variablekind->module~m_unittester module~m_indexing m_indexing module~variablekind->module~m_indexing module~m_time m_time module~variablekind->module~m_time module~m_parameters m_parameters module~variablekind->module~m_parameters module~m_strings->module~m_random module~m_strings->module~prng_class module~m_errors->module~m_random module~m_errors->module~prng_class module~m_errors->module~m_strings module~m_errors->module~m_allocate module~m_errors->module~m_deallocate module~m_errors->module~m_unittester module~m_allocate->module~m_random module~m_allocate->module~prng_class module~m_deallocate->module~m_random iso_fortran_env iso_fortran_env iso_fortran_env->module~m_random iso_fortran_env->module~prng_class iso_fortran_env->module~variablekind iso_fortran_env->module~m_strings iso_fortran_env->module~m_errors iso_fortran_env->module~m_unittester module~m_unittester->module~m_random module~m_unittester->module~m_allocate module~m_indexing->module~prng_class module~m_time->module~prng_class module~m_parameters->module~m_strings
Help

Random number generation - Not parallel safe

This module has been comprised using different sources. The first was a public domain pseudo-random number generator using the xorshift1024* and xorshift128+ methods. See Prng_Class for more details on those methods.

The secound source are the functions inside http://www.netlib.org/random/random.f90. These are used to generate random numbers from distributions other than a uniform distribution.

This module contains subroutines to generate numbers randomly from different distributions. They do so by instantiating a globally available Prng_Class and making calls into its type bound procedures. Since the Prng for these routines is globally available, you should not use it for any random number generation in parallel, whether using OpenMP or MPI! Instead, refer to Prng_Class to see how to use the Prng in a thread safe manner.

Example Usage:

program randomTest

use m_random, only: setPRNG, rngInteger, rngUniform, rngNormal, rngExponential, rngrngWeibull

implicit none




end program

Original Netlib random.f90 Author: Alan Miller

Updated coretran version: Version 2.00, 11 November 2016 Increased precision to double Added seed setters Added overloaded operations for single number, nD arrays

Used By

module~~m_random~~UsedByGraph module~m_random m_random module~m_array1d m_array1D module~m_random->module~m_array1d module~m_tests m_tests module~m_random->module~m_tests program~scaletest_coretran scaleTest_coretran module~m_random->program~scaletest_coretran program~test_coretran test_coretran module~m_random->program~test_coretran module~m_array1d->module~m_tests module~m_array1d->program~scaletest_coretran module~m_kdtree m_KdTree module~m_array1d->module~m_kdtree module~m_maths m_maths module~m_array1d->module~m_maths module~m_tests->program~test_coretran module~m_kdtree->module~m_tests module~m_kdtree->program~scaletest_coretran module~m_maths->module~m_tests module~m_maths->program~scaletest_coretran module~m_maths->module~m_kdtree
Help


Variables

TypeVisibility AttributesNameInitial
type(Prng), public :: globalPrng

Interfaces

public interface setPrng

  • public subroutine setPrng_withSeed(seed, big)

    Interfaced to setPrng() Sets the seed of the random number generator with a specified seed

    Arguments

    Type IntentOptional AttributesName
    integer(kind=i64), intent(in) :: seed(:)
    logical, intent(in), optional :: big
  • public subroutine setPrng_WOseed(big, display)

    Interfaced to setPrng() 'Randomly' sets the seed of the random number generator

    Arguments

    Type IntentOptional AttributesName
    logical, intent(in), optional :: big
    logical, intent(in), optional :: display

public interface rngExponential

  • public subroutine rngExponential_d1(this, lambda)

    Interfaced with rngExponential

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64) :: this

    Random number

    real(kind=r64) :: lambda

    Inverse scale > 0

  • public subroutine rngExponential_d1D(this, lambda)

    Interfaced with rngExponential

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64) :: this(:)

    Random numbers

    real(kind=r64) :: lambda

    Inverse scale > 0

  • public subroutine rngExponential_d2D(this, lambda)

    Interfaced with rngExponential

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64) :: this(:,:)

    Random numbers

    real(kind=r64) :: lambda

    Inverse scale > 0

  • public subroutine rngExponential_d3D(this, lambda)

    Interfaced with rngExponential

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64) :: this(:,:,:)

    Random numbers

    real(kind=r64) :: lambda

    Inverse scale > 0

public interface rngInteger

Generate size(this) random integers starting from imin

  • public subroutine rngInteger_i1(this, imin, imax)

    Interfaced with rngInteger

    Arguments

    Type IntentOptional AttributesName
    integer(kind=i32), intent(inout) :: this
    integer(kind=i32), intent(in) :: imin
    integer(kind=i32), intent(in) :: imax
  • public subroutine rngInteger_i1D(this, imin, imax)

    Interfaced with rngInteger

    Arguments

    Type IntentOptional AttributesName
    integer(kind=i32), intent(inout) :: this(:)
    integer(kind=i32), intent(in) :: imin
    integer(kind=i32), intent(in) :: imax
  • public subroutine rngInteger_i2D(this, imin, imax)

    Interfaced with rngInteger

    Arguments

    Type IntentOptional AttributesName
    integer(kind=i32), intent(inout) :: this(:,:)
    integer(kind=i32), intent(in) :: imin
    integer(kind=i32), intent(in) :: imax
  • public subroutine rngInteger_i3D(this, imin, imax)

    Interfaced with rngInteger

    Arguments

    Type IntentOptional AttributesName
    integer(kind=i32), intent(inout) :: this(:,:,:)
    integer(kind=i32), intent(in) :: imin
    integer(kind=i32), intent(in) :: imax

public interface rngNormal

  • public subroutine rngNormal_d1(this, mean, std)

    Interfaced with rngNormal

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this
    real(kind=r64), intent(in), optional :: mean
    real(kind=r64), intent(in), optional :: std
  • public subroutine rngNormal_d1D(this, mean, std)

    Interfaced with rngNormal

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this(:)
    real(kind=r64), intent(in), optional :: mean
    real(kind=r64), intent(in), optional :: std
  • public subroutine rngNormal_d2D(this, mean, std)

    Interfaced with rngNormal

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this(:,:)
    real(kind=r64), intent(in), optional :: mean
    real(kind=r64), intent(in), optional :: std
  • public subroutine rngNormal_d3D(this, mean, std)

    Interfaced with rngNormal

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this(:,:,:)
    real(kind=r64), intent(in), optional :: mean
    real(kind=r64), intent(in), optional :: std

public interface rngUniform

  • public subroutine rngUniform_d1(this, rmin, rmax)

    Interfaced with rngUniform

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this
    real(kind=r64), intent(in), optional :: rmin
    real(kind=r64), intent(in), optional :: rmax
  • public subroutine rngUniform_d1D(this, rmin, rmax)

    Interfaced with rngUniform

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this(:)
    real(kind=r64), intent(in), optional :: rmin
    real(kind=r64), intent(in), optional :: rmax
  • public subroutine rngUniform_d2D(this, rmin, rmax)

    Interfaced with rngUniform

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this(:,:)
    real(kind=r64), intent(in), optional :: rmin
    real(kind=r64), intent(in), optional :: rmax
  • public subroutine rngUniform_d3D(this, rmin, rmax)

    Interfaced with rngUniform

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this(:,:,:)
    real(kind=r64), intent(in), optional :: rmin
    real(kind=r64), intent(in), optional :: rmax

public interface rngWeibull

  • public subroutine rngWeibull_d1(this, lambda, k)

    Interfaced with rngWeibull

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this

    Draw from Weibull distribution

    real(kind=r64), intent(in) :: lambda

    Scale of the distribution

    real(kind=r64), intent(in) :: k

    Shape of the distribution

  • public subroutine rngWeibull_d1D(this, lambda, k)

    Interfaced with rngWeibull

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this(:)

    Draw from Weibull distribution

    real(kind=r64), intent(in) :: lambda

    Scale of the distribution

    real(kind=r64), intent(in) :: k

    Shape of the distribution

  • public subroutine rngWeibull_d2D(this, lambda, k)

    Interfaced with rngWeibull

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this(:,:)

    Draw from Weibull distribution

    real(kind=r64), intent(in) :: lambda

    Scale of the distribution

    real(kind=r64), intent(in) :: k

    Shape of the distribution

  • public subroutine rngWeibull_d3D(this, lambda, k)

    Interfaced with rngWeibull

    Arguments

    Type IntentOptional AttributesName
    real(kind=r64), intent(inout) :: this(:,:,:)

    Draw from Weibull distribution

    real(kind=r64), intent(in) :: lambda

    Scale of the distribution

    real(kind=r64), intent(in) :: k

    Shape of the distribution


Subroutines

public subroutine setPrng_withSeed(seed, big)

Interfaced to setPrng() Sets the seed of the random number generator with a specified seed

Arguments

Type IntentOptional AttributesName
integer(kind=i64), intent(in) :: seed(:)
logical, intent(in), optional :: big

public subroutine setPrng_WOseed(big, display)

Interfaced to setPrng() 'Randomly' sets the seed of the random number generator

Arguments

Type IntentOptional AttributesName
logical, intent(in), optional :: big
logical, intent(in), optional :: display

public subroutine rngExponential_d1(this, lambda)

Interfaced with rngExponential

Arguments

Type IntentOptional AttributesName
real(kind=r64) :: this

Random number

real(kind=r64) :: lambda

Inverse scale > 0

public subroutine rngExponential_d1D(this, lambda)

Interfaced with rngExponential

Arguments

Type IntentOptional AttributesName
real(kind=r64) :: this(:)

Random numbers

real(kind=r64) :: lambda

Inverse scale > 0

public subroutine rngExponential_d2D(this, lambda)

Interfaced with rngExponential

Arguments

Type IntentOptional AttributesName
real(kind=r64) :: this(:,:)

Random numbers

real(kind=r64) :: lambda

Inverse scale > 0

public subroutine rngExponential_d3D(this, lambda)

Interfaced with rngExponential

Arguments

Type IntentOptional AttributesName
real(kind=r64) :: this(:,:,:)

Random numbers

real(kind=r64) :: lambda

Inverse scale > 0

public subroutine rngInteger_i1(this, imin, imax)

Interfaced with rngInteger

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout) :: this
integer(kind=i32), intent(in) :: imin
integer(kind=i32), intent(in) :: imax

public subroutine rngInteger_i1D(this, imin, imax)

Interfaced with rngInteger

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout) :: this(:)
integer(kind=i32), intent(in) :: imin
integer(kind=i32), intent(in) :: imax

public subroutine rngInteger_i2D(this, imin, imax)

Interfaced with rngInteger

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout) :: this(:,:)
integer(kind=i32), intent(in) :: imin
integer(kind=i32), intent(in) :: imax

public subroutine rngInteger_i3D(this, imin, imax)

Interfaced with rngInteger

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(inout) :: this(:,:,:)
integer(kind=i32), intent(in) :: imin
integer(kind=i32), intent(in) :: imax

public subroutine rngNormal_d1(this, mean, std)

Interfaced with rngNormal

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this
real(kind=r64), intent(in), optional :: mean
real(kind=r64), intent(in), optional :: std

public subroutine rngNormal_d1D(this, mean, std)

Interfaced with rngNormal

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this(:)
real(kind=r64), intent(in), optional :: mean
real(kind=r64), intent(in), optional :: std

public subroutine rngNormal_d2D(this, mean, std)

Interfaced with rngNormal

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this(:,:)
real(kind=r64), intent(in), optional :: mean
real(kind=r64), intent(in), optional :: std

public subroutine rngNormal_d3D(this, mean, std)

Interfaced with rngNormal

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this(:,:,:)
real(kind=r64), intent(in), optional :: mean
real(kind=r64), intent(in), optional :: std

public subroutine rngUniform_d1(this, rmin, rmax)

Interfaced with rngUniform

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this
real(kind=r64), intent(in), optional :: rmin
real(kind=r64), intent(in), optional :: rmax

public subroutine rngUniform_d1D(this, rmin, rmax)

Interfaced with rngUniform

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this(:)
real(kind=r64), intent(in), optional :: rmin
real(kind=r64), intent(in), optional :: rmax

public subroutine rngUniform_d2D(this, rmin, rmax)

Interfaced with rngUniform

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this(:,:)
real(kind=r64), intent(in), optional :: rmin
real(kind=r64), intent(in), optional :: rmax

public subroutine rngUniform_d3D(this, rmin, rmax)

Interfaced with rngUniform

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this(:,:,:)
real(kind=r64), intent(in), optional :: rmin
real(kind=r64), intent(in), optional :: rmax

public subroutine rngWeibull_d1(this, lambda, k)

Interfaced with rngWeibull

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this

Draw from Weibull distribution

real(kind=r64), intent(in) :: lambda

Scale of the distribution

real(kind=r64), intent(in) :: k

Shape of the distribution

public subroutine rngWeibull_d1D(this, lambda, k)

Interfaced with rngWeibull

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this(:)

Draw from Weibull distribution

real(kind=r64), intent(in) :: lambda

Scale of the distribution

real(kind=r64), intent(in) :: k

Shape of the distribution

public subroutine rngWeibull_d2D(this, lambda, k)

Interfaced with rngWeibull

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this(:,:)

Draw from Weibull distribution

real(kind=r64), intent(in) :: lambda

Scale of the distribution

real(kind=r64), intent(in) :: k

Shape of the distribution

public subroutine rngWeibull_d3D(this, lambda, k)

Interfaced with rngWeibull

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(inout) :: this(:,:,:)

Draw from Weibull distribution

real(kind=r64), intent(in) :: lambda

Scale of the distribution

real(kind=r64), intent(in) :: k

Shape of the distribution