Bugfix in AliPoints2Memory
[u/mrichter/AliRoot.git] / GEANT321 / gtrak / grndm.F
CommitLineData
fe4da5cc 1*
2* $Id$
3*
4* $Log$
5* Revision 1.2 1998/03/02 15:33:35 japost
6* A significant error on Linux is corrected:
7*
8* Two lines of grndm were not defined for any system that was not listed.
9* In such a system (and Linux was one) the behavior of grndm was incorrect.
10*
11* A default behavior is now defined for all systems. Any system that has
12* a problem with this behavior (using integer division) must be added to
13* the #ifdef together with IBMALL etc.
14*
15* Revision 1.1.1.1 1995/10/24 10:21:42 cernlib
16* Geant
17*
18*
19#include "geant321/pilot.h"
20*CMZ : 3.21/02 29/03/94 15.41.23 by S.Giani
21*-- Author :
22 SUBROUTINE GRNDM(RVEC,LEN)
23C.
24C. ******************************************************************
25C. * *
26C. * To generate a vector RVECV of LEN random numbers *
27C. * Copy of the CERN Library routine RANECU *
28C. * *
29C. * ==>Called by : <USER>, many GEANT routines *
30C. * Author F.Carminati ********* *
31C. * *
32C. ******************************************************************
33C.
34#if defined(CERNLIB_CRAY)
35CDIR$ STACK
36#endif
37 DIMENSION RVEC(*)
38#if defined(CERNLIB_CRAY)
39 REAL ISEED, ISEED1, ISEED2, K, C1, C2, IZ
40#endif
41#if defined(CERNLIB_IBMALL)||defined(CERNLIB_IBMRT)||defined(CERNLIB_APO10K)||defined(CERNLIB_HPUX)||defined(CERNLIB_MSDOS)||defined(CERNLIB_WINNT)
42 DOUBLE PRECISION ISEED, ISEED1, ISEED2, K, C1, C2, IZ
43#endif
44#if defined(CERNLIB_IBMALL)||defined(CERNLIB_IBMRT)||defined(CERNLIB_CRAY)||defined(CERNLIB_APO10K)||defined(CERNLIB_HPUX)||defined(CERNLIB_MSDOS)||defined(CERNLIB_WINNT)
45 PARAMETER (C1=1./53668.,C2=1./52774.)
46#endif
47 PARAMETER (MAXSEQ=215)
48 COMMON / GCRNDM / JSEQ(2), ISEED(2,MAXSEQ)
49C
50 ISEQ = JSEQ(1)
51 ISEED1 = ISEED(1,ISEQ)
52 ISEED2 = ISEED(2,ISEQ)
53 DO 100 I= 1, LEN
54#if defined(CERNLIB_IBMALL)||defined(CERNLIB_IBMRT)||defined(CERNLIB_CRAY)||defined(CERNLIB_APO10K)||defined(CERNLIB_HPUX)||defined(CERNLIB_MSDOS)||defined(CERNLIB_WINNT)
55 K = INT(ISEED1*C1)
56#else
57 K = ISEED1/53668
58#endif
59 ISEED1 = 40014*(ISEED1 - K*53668) - K*12211
60 IF (ISEED1 .LT. 0) ISEED1=ISEED1+2147483563
61C
62#if defined(CERNLIB_IBMALL)||defined(CERNLIB_IBMRT)||defined(CERNLIB_CRAY)||defined(CERNLIB_APO10K)||defined(CERNLIB_HPUX)||defined(CERNLIB_MSDOS)||defined(CERNLIB_WINNT)
63 K = INT(ISEED2*C2)
64#else
65 K = ISEED2/52774
66#endif
67 ISEED2 = 40692*(ISEED2 - K*52774) - K* 3791
68 IF (ISEED2 .LT. 0) ISEED2=ISEED2+2147483399
69C
70 IZ = ISEED1 - ISEED2
71 IF (IZ .LE. 0) IZ = IZ + 2147483562
72C
73 RVEC(I) = IZ * 4.6566128E-10
74 100 CONTINUE
75 ISEED(1,ISEQ) = ISEED1
76 ISEED(2,ISEQ) = ISEED2
77 END