The Elk Code
Loading...
Searching...
No Matches
modrandom.f90
Go to the documentation of this file.
1
2
! Copyright (C) 2012 J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3
! This file is distributed under the terms of the GNU General Public License.
4
! See the file COPYING for license details.
5
6
module
modrandom
7
8
! random number generator state
9
integer(8)
::
rndstate
(0:5)=[799047353, 1322018920, 1014372120, 1198189977, &
10
832907020, 5678910]
11
12
contains
13
14
!BOP
15
! !ROUTINE: randomu
16
! !INTERFACE:
17
real(8)
function
randomu
()
18
! !DESCRIPTION:
19
! Generates random numbers with a uniform distribution in the interval $[0,1]$
20
! using the fifth-order multiple recursive generator of P. L'Ecuyer,
21
! F. Blouin, and R. Coutre, {\it ACM Trans. Modeling Comput. Simulation}
22
! {\bf 3}, 87 (1993). The sequence of numbers $r_i$ is produced from
23
! $$ x_i=(a_1 x_{i-1}+a_5 x_{i-5})\mod m $$
24
! with $r_i=x_i/m$. The period is about $2^{155}$.
25
!
26
! !REVISION HISTORY:
27
! Created January 2012 (JKD)
28
! Changed initial state, April 2017 (JKD)
29
!EOP
30
!BOC
31
implicit none
32
! local variables
33
! parameters taken from the GNU Scientific Library (GSL)
34
integer(8)
,
parameter
:: a1=107374182, a5=104480, m=2147483647
35
integer(8)
:: i=0
36
integer(8)
i1,i5
37
!$OMP CRITICAL(randomu_)
38
i=modulo(i+1,6_8)
39
i1=modulo(i-1,6_8)
40
i5=modulo(i-5,6_8)
41
rndstate
(i)=mod(a1*
rndstate
(i1)+a5*
rndstate
(i5),m)
42
randomu
=dble(
rndstate
(i))/dble(m)
43
!$OMP END CRITICAL(randomu_)
44
end function
45
!EOC
46
47
end module
48
modrandom
Definition
modrandom.f90:6
modrandom::randomu
real(8) function randomu()
Definition
modrandom.f90:18
modrandom::rndstate
integer(8), dimension(0:5) rndstate
Definition
modrandom.f90:9
modrandom.f90
Generated by
1.9.8