Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 58 lines (51 sloc) 2.168 kb
19ae87b7 »
2008-12-01 initial fortran programs by Ewelina
1
2 Subroutine DBL_COMBO_generator_test
3
4 IMPLICIT NONE
5
6 INTEGER i,Nr
7 parameter(Nr=800)
8 DOUBLE PRECISION random,randy(Nr)
9 common/randomi/randy
10
11 C Create a sequence of Nr random numbers and sotre it in randomsequence.dat
12 c Open(Unit=2,file='rand.dat')
13 c WRITE (*,*) 'How many random numbers to be generated'
14 c READ (*,*) Nr
15 DO i=1,Nr
16 randy(i) =random()
17 c WRITE(2,*) randy(i)
18 ENDDO
19 END
20 ******************************************************************************************
21 FUNCTION random()
22 ******************************************************************************************
23 * This is a radom number generator obtained from Marsaglia, G. in Computers In Physics,
24 * Vol.8, NO.1, 117 (1994). It combines two congruential sequence generators,
25 * one a congruential x_n=69069*x_(n-1)+ oddnumber with modulus 2^32
26 * , and x_n=x_(n-3)-x_(n-1) with modulus 2^31-69
27 *****************************************************************************************
28 * This funcition generates a random number with a uniform probability distribution between
29 * 0 and 1 (not including these values I believe). The file initialrandom.dat contains the
30 * initialization numbers and every time the program is run there are four other random
31 * numbers generated for the initialization strings. The sample program is the following:
32
33 IMPLICIT NONE
34 INTEGER i,j,k,n,mzran,mzranset
35 INTEGER is,js,ks,ns
36 DOUBLE PRECISION random
37 SAVE i,j,k,n
38 DATA i,j,k,n/521288629,36436069,16263801,1131199299/
39
40 mzran=i-k
41 IF (mzran.LT.0) mzran=mzran+214783579
42 i=j
43 j=k
44 k=mzran
45 n=69069*n+101390423
46 mzran=mzran+n
47 random=0.5d0+0.2328306d-9*DBLE(mzran)
48 RETURN
49 ENTRY mzranset(is,js,ks,ns)
50 i=1+iabs(is)
51 j=1+iabs(js)
52 k=1+iabs(ks)
53 n=ns
54 mzranset=n
55 RETURN
56 END
57 **************************************************************************************
Something went wrong with that request. Please try again.