summaryrefslogtreecommitdiff
path: root/lib/fqso_first.f90
blob: e553e3e44be2f4f272f10a5788361ccda18ba0b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
subroutine fqso_first(nfqso,ntol,ca,ncand)

! If a candidate was found within +/- ntol of nfqso, move it into ca(1).

  type candidate
     real freq
     real dt
     real sync
     real flip
  end type candidate
  type(candidate) ca(300),cb

  dmin=1.e30
  i0=0
  do i=1,ncand
     d=abs(ca(i)%freq-nfqso)
     if(d.lt.dmin) then
        i0=i
        dmin=d
     endif
  enddo

  if(dmin.lt.float(ntol)) then
     cb=ca(i0)
     do i=i0,2,-1
        ca(i)=ca(i-1)
     enddo
     ca(1)=cb
  endif

  return
end subroutine fqso_first