rndgen_mod Module


Uses

  • module~~rndgen_mod~~UsesGraph module~rndgen_mod rndgen_mod module~rndgen_kinds_mod rndgen_kinds_mod module~rndgen_mod->module~rndgen_kinds_mod iso_fortran_env iso_fortran_env module~rndgen_kinds_mod->iso_fortran_env

Used by

  • module~~rndgen_mod~~UsedByGraph module~rndgen_mod rndgen_mod module~rndgenpl_mod rndgenPL_mod module~rndgenpl_mod->module~rndgen_mod

Variables

Type Visibility Attributes Name Initial
real(kind=dp), private, parameter :: am = 4.656612873077392578d-10

Derived Types

type, public ::  rndSeed

Random seeds object

Components

Type Visibility Attributes Name Initial
integer(kind=i4), private :: mseed(4)

Type-Bound Procedures

procedure, public :: saveToFile => saveToFile_rndSeed
procedure, public :: readFromFile => readFromFile_rndSeed

type, public ::  rndgen

Random number generator object with its procedures

Components

Type Visibility Attributes Name Initial
integer(kind=i4), public :: o_iseed
type(rndSeed), public :: seed

Type-Bound Procedures

procedure, public :: rnd => rnd_rndgen_dp
procedure, public :: int => int_rndgen_i4
procedure, public :: int_i4 => int_rndgen_i4
procedure, public :: int_i8 => int_rndgen_i8
procedure, public :: real => real_rndgen_dp
procedure, public :: real_sp => real_rndgen_sp
procedure, public :: init => init_rndgen
procedure, public :: reset => reset_rndgen
procedure, public :: save_seed => save_seed_rndgen
procedure, public :: read_seed => read_seed_rndgen
generic, public :: rnd_array => rnd_array_rnd, rnd_array_real, rnd_array_int_i4
procedure, public :: rnd_array_i4 => rnd_array_int_i4
procedure, public :: rnd_array_i8 => rnd_array_int_i8
procedure, private :: rnd_array_rnd
procedure, private :: rnd_array_real
procedure, private :: rnd_array_int_i4

Functions

private function rnd_rndgen_dp(this) result(rnd_number)

Generates a random number in the range [0, 1)

Arguments

Type IntentOptional Attributes Name
class(rndgen) :: this

Return Value real(kind=dp)

private function int_rndgen_i8(this, i1, i2) result(rnd_number)

Generates a random integer number in the range [i1, i2], int64

Arguments

Type IntentOptional Attributes Name
class(rndgen) :: this
integer(kind=i8), intent(in) :: i1
integer(kind=i8), intent(in) :: i2

Return Value integer(kind=i8)

private function int_rndgen_i4(this, i1, i2) result(rnd_number)

Generates a random integer number in the range [i1, i2], int32

Arguments

Type IntentOptional Attributes Name
class(rndgen) :: this
integer(kind=i4), intent(in) :: i1
integer(kind=i4), intent(in) :: i2

Return Value integer(kind=i4)

private function real_rndgen_dp(this, r1, r2) result(rnd_number)

Generates a random real number in the range [r1, r2), double

Arguments

Type IntentOptional Attributes Name
class(rndgen) :: this
real(kind=dp), intent(in) :: r1
real(kind=dp), intent(in) :: r2

Return Value real(kind=dp)

private function real_rndgen_sp(this, r1, r2) result(rnd_number)

Generates a random real number in the range [r1, r2), single

Arguments

Type IntentOptional Attributes Name
class(rndgen) :: this
real(kind=sp), intent(in) :: r1
real(kind=sp), intent(in) :: r2

Return Value real(kind=sp)

private function rnd_array_rnd(gen, n) result(arr)

Generates a random array of real numbers in the range [0, 1)

Arguments

Type IntentOptional Attributes Name
class(rndgen), intent(in) :: gen
integer(kind=i4), intent(in) :: n

Return Value real(kind=dp), allocatable, (:)

private function rnd_array_real(gen, n, r1, r2) result(arr)

Generates a random array of real numbers in the range [r1, r2)

Arguments

Type IntentOptional Attributes Name
class(rndgen), intent(in) :: gen
integer(kind=i4), intent(in) :: n
real(kind=dp), intent(in) :: r1
real(kind=dp), intent(in) :: r2

Return Value real(kind=dp), allocatable, (:)

private function rnd_array_int_i4(gen, n, i1, i2) result(arr)

Arguments

Type IntentOptional Attributes Name
class(rndgen), intent(in) :: gen
integer(kind=i4), intent(in) :: n
integer(kind=i4), intent(in) :: i1
integer(kind=i4), intent(in) :: i2

Return Value integer(kind=i4), allocatable, (:)

private function rnd_array_int_i8(gen, n, i1, i2) result(arr)

Arguments

Type IntentOptional Attributes Name
class(rndgen), intent(in) :: gen
integer(kind=i4), intent(in) :: n
integer(kind=i8), intent(in) :: i1
integer(kind=i8), intent(in) :: i2

Return Value integer(kind=i8), allocatable, (:)


Subroutines

private subroutine init_rndgen(this, iseed)

Initializes the random number generator

Read more…

Arguments

Type IntentOptional Attributes Name
class(rndgen) :: this
integer(kind=i4) :: iseed

private subroutine reset_rndgen(this)

Resets the random number generator

Arguments

Type IntentOptional Attributes Name
class(rndgen) :: this

private subroutine save_seed_rndgen(this, u_mseed, und)

Save the current seeds to a seeds object and, optionally, to a file unit

Arguments

Type IntentOptional Attributes Name
class(rndgen) :: this
type(rndSeed), intent(out) :: u_mseed
integer, intent(in), optional :: und

private subroutine read_seed_rndgen(this, u_mseed, und)

Read the seeds from a seeds object or, optionally, from a file unit

Arguments

Type IntentOptional Attributes Name
class(rndgen) :: this
type(rndSeed), intent(in) :: u_mseed
integer, intent(in), optional :: und

private subroutine saveToFile_rndSeed(this, und)

Save the seeds to a file unit

Arguments

Type IntentOptional Attributes Name
class(rndSeed) :: this
integer, intent(in) :: und

private subroutine readFromFile_rndSeed(this, und)

Read the seeds from a file unit

Arguments

Type IntentOptional Attributes Name
class(rndSeed) :: this
integer, intent(in) :: und