source: PSPA/parmelaPSPA/trunk/distriphase.f @ 496

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

correction de bug distriphase.f

File size: 1.7 KB
Line 
1        subroutine distriphase(xmax,sigma,npoints)
2c       for phase in input10 ran=2 and 3 (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        sqtwopi=sqrt(twopi)
13        fac=xmax/sigma
14        if(fac.lt.0.5)then
15          do 10, i=1,npoints
16            distp(i)=-xmax+(i-1)*2*xmax/npoints
17            distp(i)=-distp(i)
18 10       continue
19        else
20        ech=xmax/1.4142/sigma
21        const=npoints/sqtwopi/erf(ech)/sigma
22        sigsq=2*sigma**2
23        nbin=int(min(npoints/5,100))
24        if (mod(nbin,2).ne.0.)then
25          nbin=nbin+1
26        endif
27        nhbin=nbin/2
28        pas=xmax/nhbin
29        k=0
30        ntot=0
31        do 20,i=1,nhbin
32          n(i)=int(const*exp(-((nhbin-i+0.5)*pas)**2/sigsq)*pas+0.5)
33          ntot=ntot+n(i)
34  20    continue
35        if(ntot.lt.int(npoints/2)+1)then
36          nextra=int(npoints/2)+1-ntot
37          do 25,l=nhbin,nhbin-nextra+1,-1
38             n(l)=n(l)+1
39  25      continue
40        endif
41        nj = 0   ! ajout glm 29/10/2012
42        do 30,i=1,nhbin
43          do 35,j=k+1,k+n(i)
44            if(j.gt.npoints/2+1)then
45              nj=j
46              go to 40
47            endif
48            distp(j)=(n(i)-j+k)*pas/n(i)+(nhbin-i)*pas
49  35      continue
50          k=k+n(i)
51  30      continue
52  40      continue
53          if(nj.eq.0) nj=j
54          do 50, i=nj,npoints
55             distp(i)=-distp(2*nj-i-2)
56  50      continue
57        endif
58        return
59        end
60c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
Note: See TracBrowser for help on using the repository browser.