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

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

corr. bug dans distrir.f

File size: 1.9 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
20
21c------- correction Guy Le Meur 24-09-2012
22        do 10 i=1,nbin
23           n(i)=0
24 10     continue
25
26        do 20 i=1,nbin
27          if(fac.lt.0.5) then
28c  distribution uniforme
29              n(i)=int(const1*(i-0.5)*pas*pas+0.5)
30              ntot=ntot+n(i)
31              if(ntot.gt.npoints) then
32                 n(i)=n(i)-ntot+npoints
33                 ntot=npoints
34                 go to 21
35              endif
36          else
37c  distribution gaussienne
38              n(i)=int(const2*exp(-((i-0.5)*pas)**2/(2*sigsq))
39     1             *(i-0.5)*pas*pas+0.5)
40     
41              ntot=ntot+n(i)
42              if(ntot.gt.npoints) then
43                 n(i)=n(i)-ntot+npoints
44                 ntot=npoints
45                 go to 21
46              endif
47          endif
48  20    continue
49c-------
50        if(ntot.lt.npoints)then
51          nextra=npoints-ntot
52          do 25 l=1,nextra
53             n(l)=n(l)+1
54  25      continue
55        endif
56  21    continue
57        k=0
58        do 30 i=1,nbin
59          if(n(i).eq.0) go to 30
60          theta=twopi/n(i)
61          theta0=i*twopi/nbin
62          do 35,j=k+1,k+n(i)
63              xr(j)=(i-0.5)*pas*cos((j-1)*theta+theta0)
64              yr(j)=(i-0.5)*pas*sin((j-1)*theta+theta0)
65  35      continue
66          k=k+n(i)
67  30      continue
68        return
69        end
70c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
Note: See TracBrowser for help on using the repository browser.