2012-10-20 16:52:29 -04:00
|
|
|
subroutine sync9(ss,tstep,df3,ntol,nfqso,sync,snr,fpk,ccfred)
|
2012-10-01 16:37:05 -04:00
|
|
|
|
|
|
|
parameter (NSMAX=22000) !Max length of saved spectra
|
|
|
|
real ss(184,NSMAX)
|
2012-10-10 16:40:46 -04:00
|
|
|
real ccfred(NSMAX)
|
2012-10-01 16:37:05 -04:00
|
|
|
|
2012-10-02 14:08:44 -04:00
|
|
|
integer ii(16) !Locations of sync half-symbols
|
|
|
|
data ii/1,11,21,31,41,51,61,77,89,101,113,125,137,149,161,169/
|
|
|
|
integer isync(85) !Sync vector for half-symbols
|
2012-10-01 16:37:05 -04:00
|
|
|
data isync/ &
|
|
|
|
1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0, &
|
|
|
|
1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0, &
|
|
|
|
0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0, &
|
|
|
|
0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0, &
|
|
|
|
1,0,0,0,1/
|
|
|
|
|
2012-10-16 15:44:41 -04:00
|
|
|
ipk=0
|
|
|
|
ipkbest=0
|
2012-10-10 16:40:46 -04:00
|
|
|
ia=1
|
|
|
|
ib=min(1000,nint(1000.0/df3))
|
2012-10-01 16:37:05 -04:00
|
|
|
|
2012-10-10 16:40:46 -04:00
|
|
|
if(ntol.lt.1000) then
|
|
|
|
ia=nint((nfqso-1000-ntol)/df3)
|
|
|
|
ib=nint((nfqso-1000+ntol)/df3)
|
|
|
|
if(ia.lt.1) ia=1
|
|
|
|
if(ib.gt.NSMAX) ib=NSMAX
|
|
|
|
endif
|
|
|
|
|
|
|
|
sbest=0.
|
2012-10-02 11:56:18 -04:00
|
|
|
lagmax=2.5/tstep + 0.9999
|
2012-10-10 16:40:46 -04:00
|
|
|
ccfred=0.
|
|
|
|
|
|
|
|
do i=ia,ib
|
|
|
|
smax=0.
|
2012-10-01 16:37:05 -04:00
|
|
|
do lag=-lagmax,lagmax
|
|
|
|
sum=0.
|
2012-10-10 16:40:46 -04:00
|
|
|
do j=1,16
|
|
|
|
k=ii(j) + lag
|
|
|
|
if(k.ge.1) sum=sum + ss(k,i)
|
2012-10-01 16:37:05 -04:00
|
|
|
enddo
|
|
|
|
if(sum.gt.smax) then
|
|
|
|
smax=sum
|
2012-10-10 16:40:46 -04:00
|
|
|
ipk=i
|
2012-10-02 11:56:18 -04:00
|
|
|
lagpk=lag
|
2012-10-01 16:37:05 -04:00
|
|
|
endif
|
|
|
|
enddo
|
2012-10-10 16:40:46 -04:00
|
|
|
if(smax.gt.sbest) then
|
|
|
|
sbest=smax
|
|
|
|
ipkbest=ipk
|
2012-10-16 15:44:41 -04:00
|
|
|
! lagpkbest=lagpk
|
2012-10-10 16:40:46 -04:00
|
|
|
endif
|
|
|
|
ccfred(i)=smax
|
2012-10-01 16:37:05 -04:00
|
|
|
enddo
|
|
|
|
|
2012-10-20 16:52:29 -04:00
|
|
|
sum=0.
|
|
|
|
nsum=0
|
|
|
|
do i=ia,ib
|
|
|
|
if(abs(i-ipkbest).ge.2) then
|
|
|
|
sum=sum+ccfred(i)
|
|
|
|
nsum=nsum+1
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
ave=sum/nsum
|
|
|
|
snr=10.0*log10(sbest/ave) - 10.0*log10(2500.0/df3)
|
|
|
|
sync=sbest/ave - 2.0
|
|
|
|
if(sync.lt.0.0) sync=0.0
|
|
|
|
if(sync.gt.10.0) sync=10.0
|
2012-10-16 16:58:03 -04:00
|
|
|
fpk=(ipkbest-1)*df3
|
2012-10-01 16:37:05 -04:00
|
|
|
|
|
|
|
return
|
|
|
|
end subroutine sync9
|