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

Go to the source code of this file.

Functions/Subroutines

subroutine kgauss (m, v, g1)
 

Function/Subroutine Documentation

◆ kgauss()

subroutine kgauss ( real*8  m,
real*8  v,
real*8  g1 
)

Definition at line 10 of file kgauss.f.

References d0, false, rndc(), and true.

Referenced by __test.f__(), cmpaire(), kbinom(), kpoisn(), and ksgamn().

10 ! kagauss and kgauss2:
11 ! Generate a Gaussian random variable with a given mean
12 ! and variance.
13 ! m: real*8 input. mean of the distribution.
14 ! v: real*8 input. variance of the distribution.
15 ! g1: real*8 output. a gaussian random variable.
16 !
17 ! g2: real*8 output. another gaussian random variable.
18 ! available only via kgauss2
19 !
20 ! subroutine needed: rndc.
21 !
22 ! Since Box-Muler method with a switch to generate one
23 ! variable at a time efficently is not usable for
24 ! Cosmos which uses the skeleton-fleshing method,
25 ! this version generate two varibles at a time and
26 ! returns only one (kgauss), or two (kgauss2).
27 ! (This one is faster than Butcher's method).
28 ! 100000 variable generation: by 90 MHz Pentium and Absoft Fortran.
29 ! kgauss needs (1.29 sec) and
30 ! kgauss2 needs (0.69 sec )
31 ! Butcher's method needs 1.69 sec.
32 !
33 !
34 ! To generate 25000 variables, 0.85 sec is needed on Sparc 2.
35 !
36  implicit none
37  real*8 m, v, g1, g2
38 !
39 ! logical sw/.true./
40  logical more
41  real*8 u1, u2, r
42  real*8 temp
43 ! save sw, temp
44 ! save u2
45  logical entry2
46 !
47  entry2 =.false.
48  goto 10
49 
50 ! ***************
51  entry kgauss2(m, v, g1, g2)
52 ! ***************
53  entry2 = .true.
54 
55 ! integer nt
56 ! -----------------
57 ! if(sw) then
58 ! counter for the loop at the test time.
59 ! nt=0
60 ! nt is distributed like
61 ! exp(-1.57nt) ( nt=1, 2, ...). The average is 1.75.
62  10 continue
63  more=.true.
64  do while (more)
65 ! nt=nt+1
66  call rndc(u1)
67  call rndc(u2)
68  u1=u1*2 - 1.0d0
69  u2=u2*2 - 1.0d0
70  r=u1**2 + u2**2
71  more= r .gt. 1.0d0
72  enddo
73 ! write(*,*) nt
74  temp=sqrt(-2*log(r)/r)
75  g1=u1*temp*v + m
76 ! sw=.false.
77  if(entry2) then
78 ! else
79 ! g1=u2*temp*v + m
80  g2 = u2*temp*v + m
81  endif
82 ! sw=.true.
83 ! endif
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz r
Definition: ZavoidUnionMap.h:1
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
subroutine rndc(u)
Definition: rnd.f:91
real(4), dimension(:), allocatable, save temp
Definition: cNRLAtmos.f:29
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
block data include Zlatfit h c fitting region data data data data data d0 data data d0 data data m
Definition: ZlatfitBD.h:35
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
Here is the call graph for this function:
Here is the caller graph for this function: