root / synthbench / euroben-dm / mod2as / .svn / text-base / dran0.f.svn-base @ 0:839f52ef7657
History | View | Annotate | Download (1.3 kB)
1 |
Function dran0() Result( ran ) |
---|---|
2 |
! ----------------------------------------------------------------- |
3 |
Use numerics |
4 |
Use ran_module |
5 |
Implicit None |
6 |
|
7 |
! ----------------------------------------------------------------- |
8 |
! --- dran0 returns a uniform deviate in [0,1). |
9 |
! |
10 |
! --- The algorithm is loosely based on an algorithm from |
11 |
! Press & Teukolsky et.al. and based on the linear congruential |
12 |
! method with choices for M, A, and C that are given by |
13 |
! D. Knuth in "Semi-numerical algorithms". |
14 |
! --- Input parameters: |
15 |
! Integer - a1, c1, m1, a2, c2, m2. The parameters of the two |
16 |
! linear congruent relations used. They are passed |
17 |
! via module 'ran_module'. |
18 |
! Integer - x1, x2. Seeds for the two linear congruences. |
19 |
! Passed via module 'ran_module'. |
20 |
! |
21 |
! --- Output-parameters: |
22 |
! Real(l_) - ran. Uniform deviate in [0,1) |
23 |
! ------------------------------------------------------------------ |
24 |
! |
25 |
Real(l_) :: ran |
26 |
! ------------------------------------------------------------------ |
27 |
x1 = Mod( a1*x1 + c1, m1 ) |
28 |
x2 = Mod( a2*x2 + c2, m2 ) |
29 |
ran = ( Real( x1, l_ ) + Real( x2, l_ )*rm2 )*rm1 |
30 |
! ----------------------------------------------------------------- |
31 |
End Function dran0 |