source: PSPA/parmelaPSPA/trunk/distrir.f @ 13

Last change on this file since 13 was 12, checked in by lemeur, 12 years ago

parmela pspa initial

File size: 1.8 KB
Line 
1        subroutine distrir(xmax,sigma,npoints)
2c       for x-y in input10 ran=2  (LAL)
3c-----------------------------------------------------------------------
4c
5        include 'param_sz.h'
6        include 'constcom.h'
7c
8        common/dist/distp(imaa),xr(imaa),yr(imaa)
9        dimension n(imaa/5)
10c-----------------------------------------------------------------------
11c*
12        fac=xmax/sigma
13        xmaxsq=xmax**2
14        sigsq=sigma**2
15        const1=2*npoints/xmaxsq
16        const2=npoints/(sigsq*(1.-exp(-xmaxsq/(2*sigsq))))
17        nbin=int(min(npoints/5,100))
18        pas=xmax/nbin
19        ntot=0
20c-------
21        do 20 i=1,nbin
22          if(fac.lt.0.5) then
23c  distribution uniforme
24              n(i)=int(const1*(i-0.5)*pas*pas+0.5)
25              ntot=ntot+n(i)
26              if(ntot.gt.npoints) then
27                 n(i)=n(i)-ntot+npoints
28                 ntot=npoints
29                 go to 21
30              endif
31          else
32c  distribution gaussienne
33              n(i)=int(const2*exp(-((i-0.5)*pas)**2/(2*sigsq))
34     1             *(i-0.5)*pas*pas+0.5)
35          ntot=ntot+n(i)
36              if(ntot.gt.npoints) then
37                 n(i)=n(i)-ntot+npoints
38                 ntot=npoints
39                 go to 21
40              endif
41          endif
42  20    continue
43c-------
44        if(ntot.lt.npoints)then
45          nextra=npoints-ntot
46          do 25 l=1,nextra
47             n(l)=n(l)+1
48  25      continue
49        endif
50  21    continue
51        k=0
52        do 30 i=1,nbin
53          if(n(i).eq.0) go to 30
54          theta=twopi/n(i)
55          theta0=i*twopi/nbin
56          do 35,j=k+1,k+n(i)
57              xr(j)=(i-0.5)*pas*cos((j-1)*theta+theta0)
58              yr(j)=(i-0.5)*pas*sin((j-1)*theta+theta0)
59  35      continue
60          k=k+n(i)
61  30      continue
62        return
63        end
64c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
Note: See TracBrowser for help on using the repository browser.