source: trunk/MagicSoft/Simulation/Corsika/Mmcs/sobseq.f@ 18280

Last change on this file since 18280 was 286, checked in by harald, 25 years ago
This is the start point for further developments of the Magic Monte Carlo Simulation written by Jose Carlos Gonzales. Now it is under control of one CVS repository for the whole collaboration. Everyone should use this CVS repository for further developments.
File size: 1.7 KB
Line 
1 SUBROUTINE SOBSEQ(N,X)
2
3C-----------------------------------------------------------------------
4C SOB(OL) SEQ(UENCE)
5C
6C SOBOL QUASI RANDOM NUMBER GENERATOR
7C REFERENCE : NUMERICAL RECIPES, W.H. PRESS ET AL.,
8C CAMBRIDGE UNIVERSITY PRESS, 1992 ISBN 0 521 43064 X
9C THIS SUBROUTINE IS CALLED FROM SELCOR
10C-----------------------------------------------------------------------
11
12 INTEGER N,MAXBIT,MAXDIM
13 REAL X(*),FAC
14 PARAMETER (MAXBIT=30,MAXDIM=6)
15 INTEGER I,IM,IN,IPP,J,K,L,IP(MAXDIM),IU(MAXDIM,MAXBIT),
16 * IV(MAXBIT*MAXDIM),IX(MAXDIM),MDEG(MAXDIM)
17 SAVE IP,MDEG,IX,IV,IN,FAC
18 EQUIVALENCE (IV,IU)
19 DATA IP /0,1,1,2,1,4/, MDEG /1,2,3,3,4,4/, IX /6*0/
20 DATA IV /6*1,3,1,3,3,1,1,5,7,7,3,3,5,15,11,5,15,13,9,156*0/
21C-----------------------------------------------------------------------
22
23 IF (N.LT.0) THEN
24 DO 14 K=1,MAXDIM
25 DO 11 J=1,MDEG(K)
26 IU(K,J)=IU(K,J)*2**(MAXBIT-J)
27 11 CONTINUE
28 DO 13 J=MDEG(K)+1,MAXBIT
29 IPP=IP(K)
30 I=IU(K,J-MDEG(K))
31 I=IEOR(I,I/2**MDEG(K))
32 DO 12 L=MDEG(K)-1,1,-1
33 IF(IAND(IPP,1).NE.0)I=IEOR(I,IU(K,J-L))
34 IPP=IPP/2
35 12 CONTINUE
36 IU(K,J)=I
37 13 CONTINUE
38 14 CONTINUE
39 FAC=1./2.**MAXBIT
40 IN=0
41 ELSE
42 IM=IN
43 DO 15 J=1,MAXBIT
44 IF(IAND(IM,1).EQ.0)GOTO 1
45 IM=IM/2
46 15 CONTINUE
47 PAUSE 'MAXBIT TOO SMALL IN SOBSEQ'
48 1 IM=(J-1)*MAXDIM
49 DO 16 K=1,MIN(N,MAXDIM)
50 IX(K)=IEOR(IX(K),IV(IM+K))
51 X(K)=IX(K)*FAC
52 16 CONTINUE
53 IN=IN+1
54 ENDIF
55 RETURN
56 END
Note: See TracBrowser for help on using the repository browser.