MONC
maths.F90
Go to the documentation of this file.
1 module maths_mod
3  implicit none
4 
5 #ifndef TEST_MODE
6  private
7 #endif
8 
9  integer, parameter :: k4b=selected_int_kind(9)
10  integer(k4b), parameter :: ia=16807,im=2147483647
11  integer(k4b), parameter :: iq=127773,ir=2836
12 
13  public random
14 contains
15 
22  real(kind=default_precision) function random(idum)
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)
41  end function random
42 end module maths_mod
maths_mod::k4b
integer, parameter k4b
Definition: maths.F90:9
maths_mod::ir
integer(k4b), parameter ir
Definition: maths.F90:11
maths_mod::ia
integer(k4b), parameter ia
Definition: maths.F90:10
maths_mod::random
real(kind=default_precision) function, public random(idum)
returns a scalar random number, the initial seed idum must be negative usage: idum = -k !...
Definition: maths.F90:23
maths_mod::iq
integer(k4b), parameter iq
Definition: maths.F90:11
maths_mod::im
integer(k4b), parameter im
Definition: maths.F90:10
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
maths_mod
Definition: maths.F90:1
datadefn_mod::default_precision
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17