COSMOS v7.655  COSMOSv7655
(AirShowerMC)
rnd.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine rndc (u)
 
subroutine rnd1u (ua, n)
 
subroutine rnd2u (ua, n)
 
subroutine rnde (ua, n)
 
subroutine rnd3ix (ijkl)
 

Function/Subroutine Documentation

◆ rnd1u()

subroutine rnd1u ( real*8, dimension(n ua,
integer  n 
)

Definition at line 161 of file rnd.f.

References d.

Referenced by rndc().

161 ! random number generator given by L'ecuyer in
162 ! comm. acm vol 31, p.742, 1988
163 ! modified by f. James to return a vector of numbers
164 ! modified by K.K
165 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
166 ! calling sequences for rnd1u: ++
167 ! call rnd1u (ua, n) returns a vector ua of n ++
168 ! 64-bit random floating point numbers between ++
169 ! zero and one. ++
170 ! call rnd1i(irin) initializes the generator from two ++
171 ! 32-bit integer array irin ++
172 ! call rnd1s(irout) outputs the current values of the ++
173 ! two integer seeds, to be used for restarting ++
174 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
175  implicit none
176  integer n
177  real*8 ua(n)
178 !
179  integer irin(2), irout(2), iseed1, iseed2, i, k, iz
180  save iseed1,iseed2
181  data iseed1,iseed2 /12345,67890/
182 !
183  do i= 1, n
184  k = iseed1/53668
185  iseed1 = 40014*(iseed1 - k*53668) - k*12211
186  if(iseed1 .lt. 0) iseed1=iseed1+2147483563
187 !
188  k = iseed2/52774
189  iseed2 = 40692*(iseed2 - k*52774) - k* 3791
190  if(iseed2 .lt. 0) iseed2=iseed2+2147483399
191 !
192  iz = iseed1 - iseed2
193  if(iz .lt. 1) iz = iz + 2147483562
194 !
195  ua(i) = iz * 4.656613d-10
196  enddo
197  return
198 ! ****************
199  entry rnd1i(irin)
200 ! ****************
201  iseed1 = irin(1)
202  iseed2 = irin(2)
203  return
204 !
205 ! ****************
206  entry rnd1s(irout)
207 ! ****************
208  irout(1)= iseed1
209  irout(2)= iseed2
nodes i
dE dx *! Nuc Int sampling table d
Definition: cblkMuInt.h:130
integer n
Definition: Zcinippxc.h:1
Here is the caller graph for this function:

◆ rnd2u()

subroutine rnd2u ( real*8, dimension(n ua,
integer  n 
)

Definition at line 212 of file rnd.f.

References d0, and parameter().

Referenced by rndc().

212 ! add-and-carry random number generator proposed by
213 ! Marsaglia and Zaman in siam j. scientific and statistical
214 ! computing, to appear probably 1990.
215 ! modified with enhanced initialization by F. James, 1990
216 ! modified by K.K
217 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
218 ! calling sequences for rnd2u: ++
219 ! call rnd2u (ua, n) returns a vector ua of n ++
220 ! 64-bit random floating point numbers between ++
221 ! zero and one. ++
222 ! call rnd2ix(int) initializes the generator from one ++
223 ! 32-bit integer int ++
224 ! call rnd2rx(ivec) restarts the generator from vector ++
225 ! ivec of 25 32-bit integers (see rnd2s) ++
226 ! call rnd2s(ivec) outputs the current values of the 25 ++
227 ! 32-bit integer seeds, to be used for restarting ++
228 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
229  implicit none
230  integer n
231  real*8 ua(n)
232 !
233  integer ns, ns1, i, isd, k
234  parameter(ns=24, ns1=ns+1)
235  real*8 seeds(ns), uni
236  integer iseeds(ns), isdin(ns1), isdout(ns1), icarry
237  real*8 twop24, twom24
238  integer itwo24, icons, i24, j24, ivec, jseed, inseed
239  parameter(twop24=2.**24)
240  parameter(twom24=2.**(-24), itwo24=2**24, icons=2147483563)
241  real*8 carry
242  save i24, j24, carry, seeds
243  data i24, j24, carry/ns, 10, 0./
244 !
245 ! the generator proper: "subtract-with-borrow",
246 ! as proposed by Marsaglia and Zaman,
247 ! Florida state university, march, 1989
248 !
249  do ivec= 1, n
250  uni = seeds(i24) - seeds(j24) - carry
251  if(uni .lt. 0.d0) then
252  uni = uni + 1.0d0
253  carry = twom24
254  else
255  carry = 0.
256  endif
257 ! avoid exact zero
258  if(uni .eq. 0.d0) then
259  uni = twom24
260  endif
261  seeds(i24) = uni
262  i24 = i24 - 1
263  if(i24 .eq. 0) i24 = ns
264  j24 = j24 - 1
265  if(j24 .eq. 0) j24 = ns
266  ua(ivec) = uni
267  enddo
268  return
269 ! entry to restore the previous run
270 ! ******************
271  entry rnd2rx(isdin)
272 ! ******************
273  do i= 1, ns
274  seeds(i) =isdin(i)*twom24
275  enddo
276  carry = mod(isdin(ns1),10)*twom24
277  isd = isdin(ns1)/10
278  i24 = mod(isd,100)
279  isd = isd/100
280  j24 = isd
281  return
282 ! entry to get current status
283 ! ******************
284  entry rnd2s(isdout)
285 ! ******************
286  do i= 1, ns
287  isdout(i) = int(seeds(i)*twop24)
288  enddo
289  if(carry .gt. 0.) then
290  icarry=1
291  else
292  icarry=0
293  endif
294  isdout(ns1) = 1000*j24 + 10*i24 + icarry
295  return
296 ! entry to initialize from one integer
297 ! ******************
298  entry rnd2ix(inseed)
299 ! ******************
300  jseed = inseed
301  do i= 1, ns
302  k = jseed/53668
303  jseed = 40014*(jseed-k*53668) -k*12211
304  if(jseed .lt. 0) jseed = jseed+icons
305  iseeds(i) = mod(jseed,itwo24)
306  enddo
307  do i= 1,ns
308  seeds(i) =iseeds(i)*twom24
309  enddo
310  i24 = ns
311  j24 = 10
312  carry = 0.
313  if(seeds(ns) .lt. seeds(14)) carry = twom24
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
nodes i
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
integer n
Definition: Zcinippxc.h:1
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rnd3ix()

subroutine rnd3ix ( integer  ijkl)

Definition at line 363 of file rnd.f.

References parameter().

Referenced by rnde().

363 ! the standard values in marsaglia's paper, ijkl=54217137
364  implicit none
365 ! integer n
366  integer,intent(in):: n
367 ! If next is used Gfortran on Mac gets mad.
368 ! real*8 ua(n), u(97), uni, s, t, zuni
369 ! So we devide it next two. ua(*) is essential
370 !
371  real(8):: ua(*)
372  real(8):: u(97), uni, s, t, zuni
373  real*8 sina(102), sout(102)
374  integer jj, m
375  integer ns, ijkl, i97, j97, ij, kl, i, j, k, l, ii, ivec
376  real*8 twom24, c, cd, cm
377  parameter(ns=24, twom24=2.**(-24))
378  save c, cd, cm, i97, j97
379 !
380  ij = ijkl/30082
381  kl = ijkl - 30082*ij
382  i = mod(ij/177, 177) + 2
383  j = mod(ij, 177) + 2
384  k = mod(kl/169, 178) + 1
385  l = mod(kl, 169)
386  do ii= 1, 97
387  s = 0.
388  t = .5
389  do jj= 1, ns
390  m = mod(mod(i*j,179)*k, 179)
391  i = j
392  j = k
393  k = m
394  l = mod(53*l+1, 169)
395  if(mod(l*m,64) .ge. 32) s = s+t
396  t = 0.5*t
397  enddo
398  u(ii) = s
399  enddo
400  c = 362436.*twom24
401  cd = 7654321.*twom24
402  cm = 16777213.*twom24
403  i97 = 97
404  j97 = 33
405  return
406 ! ****************
407  entry rnd3x(ua, n)
408 ! ****************
409  do ivec= 1, n
410  uni = u(i97)-u(j97)
411  if(uni .lt. 0.) uni=uni+1.
412  u(i97) = uni
413  i97 = i97-1
414  if(i97 .eq. 0) i97=97
415  j97 = j97-1
416  if(j97 .eq. 0) j97=97
417  c = c - cd
418  if(c .lt. 0.) c=c+cm
419  uni = uni-c
420  if(uni .lt. 0.) uni=uni+1.
421  ua(ivec) = uni
422 ! replace exact zeros by uniform distr. *2**-24
423  if(uni .eq. 0.) then
424  zuni = twom24*u(2)
425 ! an exact zero here is very unlikely, but let's be safe.
426  if(zuni .eq. 0.) zuni= twom24*twom24
427  ua(ivec) = zuni
428  endif
429  enddo
430  return
431 ! ****************** to get current status
432  entry rnd3s(sout)
433 ! ***********
434  do i=1, 97
435  sout(i)=u(i)
436  enddo
437  sout(98)=c
438  sout(99)=cd
439  sout(100)=cm
440  sout(101)=i97
441  sout(102)=j97
442  return
443 ! **************** to restore the old status
444  entry rnd3rx(sina)
445  do i=1, 97
446  u(i)=sina(i)
447  enddo
448  c=sina(98)
449  cd=sina(99)
450  cm=sina(100)
451  i97=sina(101)
452  j97=sina(102)
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
nodes i
********************block data cblkHeavy ********************integer j data *HeavyG2symbol *data *HeavyG2code kiron data j
Definition: cblkHeavy.h:36
block data include Zlatfit h c fitting region data data data data data d0 data data d0 data data m
Definition: ZlatfitBD.h:35
nodes t
integer n
Definition: Zcinippxc.h:1
dE dx *! Nuc Int sampling table c
Definition: cblkMuInt.h:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rndc()

subroutine rndc ( real*8  u)

Definition at line 91 of file rnd.f.

References false, rnd1u(), and rnd2u().

Referenced by __reducebinsize.f__(), __reduceeachsize.bin.f__(), __reduceeachsize.binbyl.f__(), __reduceeachsize.f__(), __reducesize.f__(), __test.f__(), c2bdc0(), c2bdcy(), canihiea(), canihipath(), cbhabhaea(), cbhabhapath(), cbomegadcy(), cbrcsampe(), cbremerglpm(), cbremspath(), cbrlsampe(), cbrssampe(), ccapnu(), ccheckx(), cchg0(), cchg0c(), cchgopposit(), ccomptea(), ccomptpath(), cconsvchg(), cddbdc(), cddecay(), cddecay1(), cdecayleng(), cdecaywel(), cdeltadecay(), cdsdecay(), cetadecay(), cetapdecay(), cexcesslen(), cfakegh(), cfclp(), cfixtarget(), cfixvectormeson(), cfxtgtchg(), cghcolltype(), cghpath(), chncol(), chookobs(), cifcutoff(), cinirn(), cintemuon(), softenpik::cjudgesplit(), ckchgdcy(), ckf2cos(), cklongdecay(), ckmuneupidcy(), ckmuneupidcy2(), ckno(), cknockea(), cknockp(), cknonarrow(), ckpieneudecay(), ckshortdecay(), clambdacdcy(), clambdadcy(), cmbreme(), cmbreme1(), cmbreme2(), cmoliere(), cmollerea(), cmollerpath(), cmpair(), cmpaire(), cmubrsmpe(), cmubrsmpp(), cmulscat2(), cmunsmpe(), cmunsmpp(), cmuprsmp0(), cmuprsmpp(), cmydecay(), cnbdc1(), cnbdcy(), cnnbdc(), comgdc(), cpair(), cpairerglpm(), cpairpath(), cpbang(), cphidc(), cphotoeepath(), cpi0decay(), cprap(), cprap0(), cprcsampe(), cprlsampe(), cprtsampe(), cresetposang(), crhodc(), csampcollina(), csampcolln(), csampeintl(), csampfermim(), csampfragments(), csampfragpt(), csampgintl(), csamphadint(), csampmol(), csampmuekl3(), csampneueemu(), csampneuekl3(), csamppolang(), csampprm0(), csampprm1(), csetthinwgt(), csigmapdcy(), cskchg(), cslp(), cslpx(), csmpcolina2(), csneumuemu(), softenpik::csoftenpik(), softenpik::csoftenpik1(), cspipm(), softenpik::csplitmeson(), csprimang(), csprimapsang(), csprimisoang(), csprimpsang(), cspt(), cspwpt(), ctauneudcy(), cuonsphere(), cxrayp(), drangen(), kbetar(), kbinom(), kcossn(), kgauss(), knbino(), kpoisn(), ksampaf(), ksamplin(), ksamppeang(), ksamppw(), ksamppw2(), ksamprsa(), ksbwig(), ksgamn(), ksgmis(), ksgmrs(), ksmpconexp(), main(), memoforcpu(), psran(), qsran(), rndcsng(), and xbgrun().

91  implicit none
92  real*8 u
93  integer n
94  real*8 ua(n)
95  real(8)::u1(1)
96 !
97  integer iseed(25), ir1(2), ir2, jold, jnew
98  logical first2/.true./
99  integer jsw/1/
100  save jsw, first2
101 !
102  if(jsw .eq. 1) then
103 !! call rnd1u(u, 1) ! jaxa complains at execution time
104  ! since u is not array
105  call rnd1u(u1, 1)
106  u = u1(1)
107  elseif(jsw .eq. 2) then
108  if(first2) then
109  first2=.false.
110  call rnd2ix(31415926)
111  endif
112 !! call rnd2u(u, 1)
113  call rnd2u(u1, 1)
114  u = u1(1)
115  else
116  write(*,*) ' switch value error=',jsw, ' in rndc '
117  stop 9999
118  endif
119  return
120 ! ***********
121  entry rnd1r(ir1)
122 ! **********
123  call rnd1i(ir1)
124  return
125 ! ***********
126  entry rndd(ua, n)
127 ! **********
128  if(jsw .eq. 1) then
129  call rnd1u(ua, n)
130  elseif(jsw .eq. 2) then
131  if(first2) then
132  first2=.false.
133  call rnd2ix(31415926)
134  endif
135  call rnd2u(ua, n)
136  else
137  write(*,*) ' switch value error=',jsw, ' in rndd '
138  stop 9999
139  endif
140  return
141 ! ***********
142  entry rnd2i(ir2)
143 ! ***********
144  call rnd2ix(ir2)
145  first2=.false.
146  return
147 ! ***********
148  entry rnd2r(iseed)
149 ! ***********
150  call rnd2rx(iseed)
151  first2=.false.
152  return
153 ! ***********
154  entry rndsw(jold, jnew)
155 ! ***********
156  jold=jsw
157  jsw=jnew
158  return
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon true
Definition: cblkElemag.h:7
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon ! knockon is considered Obsolete *PhotoProd false
Definition: cblkElemag.h:7
integer n
Definition: Zcinippxc.h:1
subroutine rnd1u(ua, n)
Definition: rnd.f:161
subroutine rnd2u(ua, n)
Definition: rnd.f:212
Here is the call graph for this function:

◆ rnde()

subroutine rnde ( real*8, dimension(n ua,
integer, intent(in)  n 
)

Definition at line 316 of file rnd.f.

References false, and rnd3ix().

316 ! random number generator proposed by marsaglia and zaman
317 ! in report fsu-scri-87-50
318 ! modified by f. james, 1988 and 1989, to generate a vector
319 ! of pseudorandom numbers ua of length n.
320 ! modified by k.k
321 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
322 ! calling sequences for rnde: ++
323 ! call rnde(ua, n) returns a vector ua of n ++
324 ! 32-bit random floating point numbers between ++
325 ! zero and one. ++
326 ! call rnd3i(i1) initializes the generator from one ++
327 ! 32-bit integer i1
328 ! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
329  implicit none
330 ! integer n
331  integer,intent(in):: n
332  real*8 ua(n), sina(102)
333  logical first/.true./
334  save first
335  integer ijkl, ijklin
336 !
337  if(first) then
338  first=.false.
339 ! default initialization. user has called rnde without rnd3i.
340  ijkl = 54217137
341  call rnd3ix(ijkl)
342  endif
343  call rnd3x(ua, n)
344  return
345 ! initializing routine for rnde, may be called before
346 ! generating pseudorandom numbers with rnde. the input
347 ! values should be in the ranges: 0<=ijklin<=900 ooo ooo
348 ! **************
349  entry rnd3i(ijklin)
350 ! *************
351  first=.false.
352  call rnd3ix(ijklin)
353  return
354 ! ************
355  entry rnd3r(sina)
356 ! ************
357  first=.false.
358  call rnd3rx(sina)
logical, save first
Definition: cNRLAtmos.f:8
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon true
Definition: cblkElemag.h:7
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon ! knockon is considered Obsolete *PhotoProd false
Definition: cblkElemag.h:7
integer n
Definition: Zcinippxc.h:1
subroutine rnd3ix(ijkl)
Definition: rnd.f:363
Here is the call graph for this function: