MONC
Functions/Subroutines | Variables
maths_mod Module Reference

Functions/Subroutines

real(kind=default_precision) function, public random (idum)
 returns a scalar random number, the initial seed idum must be negative usage: idum = -k !(set idum < 0 to initialise) do i=1,nvals my_rand(i) = random(idum) end do More...
 

Variables

integer, parameter k4b =selected_int_kind(9)
 
integer(k4b), parameter ia =16807
 
integer(k4b), parameter im =2147483647
 
integer(k4b), parameter iq =127773
 
integer(k4b), parameter ir =2836
 

Function/Subroutine Documentation

◆ random()

real(kind=default_precision) function, public maths_mod::random ( integer(k4b), intent(inout)  idum)

returns a scalar random number, the initial seed idum must be negative usage: idum = -k !(set idum < 0 to initialise) do i=1,nvals my_rand(i) = random(idum) end do

Parameters
idumInitial seed which must be negative

Definition at line 22 of file maths.F90.

23  integer(k4b),intent(inout) :: idum
24 
25  real,save :: am
26  integer(k4b), save :: ix=-1,iy=-1,k
27 
28  if (idum <=0 .or. iy < 0) then
29  am = nearest(1.0,-1.0)/im
30  iy=ior(ieor(888889999,abs(idum)),1)
31  ix=ieor(777755555,abs(idum))
32  idum=abs(idum)+1
33  end if
34  ix = ieor(ix,ishft(ix,13))
35  ix = ieor(ix,ishft(ix,-17))
36  ix = ieor(ix,ishft(ix,5))
37  k=iy/iq
38  iy=ia*(iy-k*iq)-ir*k
39  if(iy < 0) iy = iy + im
40  random = am*ior(iand(im,ieor(ix,iy)),1)
Here is the caller graph for this function:

Variable Documentation

◆ ia

integer(k4b), parameter maths_mod::ia =16807
private

Definition at line 10 of file maths.F90.

10  integer(k4b), parameter :: ia=16807,im=2147483647

◆ im

integer(k4b), parameter maths_mod::im =2147483647
private

Definition at line 10 of file maths.F90.

◆ iq

integer(k4b), parameter maths_mod::iq =127773
private

Definition at line 11 of file maths.F90.

11  integer(k4b), parameter :: iq=127773,ir=2836

◆ ir

integer(k4b), parameter maths_mod::ir =2836
private

Definition at line 11 of file maths.F90.

◆ k4b

integer, parameter maths_mod::k4b =selected_int_kind(9)
private

Definition at line 9 of file maths.F90.

9  integer, parameter :: k4b=selected_int_kind(9)