diff --git a/map65/libm65/synctest.f90 b/map65/libm65/synctest.f90 index 893e659de..5f57ec71d 100644 --- a/map65/libm65/synctest.f90 +++ b/map65/libm65/synctest.f90 @@ -8,25 +8,36 @@ program synctest real candidate(MAX_CANDIDATES,5) !snr1,f0,xdt0,ipol,flip character*8 arg - open(50,file='50.a',form='unformatted',status='old') + nargs=iargc() + if(nargs.ne.5) then + print*,'Usage: synctest iutc nfa nfb nts_jt65 nts_q65' + print*,'Example: synctest 1814 23 83 2 1' + go to 999 + endif call getarg(1,arg) read (arg,*) iutc - - do ifile=1,999 - read(50,end=999) nutc,npol,ss(1:npol,:,:),savg(1:npol,:) + call getarg(2,arg) + read (arg,*) nfa + call getarg(3,arg) + read (arg,*) nfb + call getarg(4,arg) + read (arg,*) nts_jt65 + call getarg(5,arg) + read (arg,*) nts_q65 + + open(50,file='50.a',form='unformatted',status='old') + do ifile=1,9999 + read(50,end=998) nutc,npol,ss(1:npol,:,:),savg(1:npol,:) if(nutc.eq.iutc) exit enddo close(50) call init_timer('timer.out') call timer('synctest',0) - - print*,nutc,npol - nfa=23 !144.100 - nfb=83 !144.16 - nts_jt65=2 !JT65B tone spacing - nts_q65=1 !Q65-60A tone spacing + + call timer('get_cand',0) call get_candidates(ss,savg,nfa,nfb,nts_jt65,nts_q65,candidate,ncand) + call timer('get_cand',1) do k=1,ncand snr1=candidate(k,1) @@ -38,25 +49,22 @@ program synctest 1010 format(i3,4f10.3,2i3,f8.3) enddo -999 call timer('synctest',1) +998 call timer('synctest',1) call timer('synctest',101) call fini_timer() -end program synctest +999 end program synctest -subroutine get_candidates(ss,savg,nfa,nfb,nts_q65,nts_jt65,candidate,ncand) +subroutine get_candidates(ss,savg,nfa,nfb,nts_jt65,nts_q65,candidate,ncand) use wideband2_sync - use timer_module, only: timer parameter (MAX0=1000,MAX_CANDIDATES=20) real ss(4,322,NFFT),savg(4,NFFT) real candidate(MAX_CANDIDATES,5) !snr1,f0,xdt0,ipol,flip integer indx(NFFT) logical skip - call timer('wb_sync ',0) call wb2_sync(ss,savg,nfa,nfb) - call timer('wb_sync ',1) df3=96000.0/NFFT ia=nint(1000*nfa/df3) @@ -74,8 +82,11 @@ subroutine get_candidates(ss,savg,nfa,nfb,nts_q65,nts_jt65,candidate,ncand) j=indx(iz+1-i) + ia - 1 f0=0.001*j*df3 snr1=sync_dat(j,2) - if(snr1.lt.3.0) exit + if(snr1.lt.5.0) exit flip=sync_dat(j,5) + if(flip.ne.0.0 .and. nts_jt65.eq.0) cycle + if(flip.eq.0.0 .and. nts_q65.eq.0) cycle + if(sync_dat(j,6).lt.3.0) cycle bw=nts_q65*108.0 if(flip.ne.0) bw=nts_jt65*177.0 skip=.false. @@ -83,7 +94,6 @@ subroutine get_candidates(ss,savg,nfa,nfb,nts_q65,nts_jt65,candidate,ncand) diffhz=1000.0*(f0-candidate(n,2)) if(diffhz.gt.-10.0 .and. diffhz.lt.bw) skip=.true. enddo - if(sync_dat(j,6).lt.3.0) skip=.true. if(skip) cycle k=k+1 xdt0=sync_dat(j,3) diff --git a/map65/libm65/wideband2_sync.f90 b/map65/libm65/wideband2_sync.f90 index 99725cfd1..0551f91fc 100644 --- a/map65/libm65/wideband2_sync.f90 +++ b/map65/libm65/wideband2_sync.f90 @@ -17,7 +17,7 @@ subroutine wb2_sync(ss,savg,nfa,nfb) real savg(4,NFFT) logical first integer isync0(22) - integer jsync0(63) + integer jsync0(63),jsync1(63) ! Q65 sync symbols data isync0/1,9,12,13,15,22,23,26,27,33,35,38,46,50,55,60,62,66,69,74,76,85/ data jsync0/ & @@ -25,15 +25,14 @@ subroutine wb2_sync(ss,savg,nfa,nfb) 33, 34, 37, 38, 39, 40, 42, 43, 45, 46, 47, 48, 52, 53, 55, 57, & 59, 60, 63, 64, 66, 68, 70, 73, 80, 81, 89, 90, 92, 95, 97, 98, & 100,102,104,107,108,111,114,119,120,121,122,123,124,125,126/ + data jsync1/ & + 2, 3, 6, 7, 8, 15, 17, 19, 20, 21, 23, 26, 27, 29, 30, 31, & + 35, 36, 41, 44, 49, 50, 51, 54, 56, 58, 61, 62, 65, 67, 69, 71, & + 72, 74, 75, 76, 77, 78, 79, 82, 83, 84, 85, 86, 87, 88, 91, 93, & + 94, 96, 99,101,103,105,106,109,110,112,113,115,116,117,118/ data first/.true./ save first - do j=322,1,-1 - if(sum(ss(1,j,1:NFFT)).gt.0.0) exit - enddo - jz=j - - tstep=2048.0/11025.0 !0.185760 s: 0.5*tsym_jt65, 0.3096*tsym_q65 if(first) then fac=0.6/tstep @@ -42,10 +41,17 @@ subroutine wb2_sync(ss,savg,nfa,nfb) enddo do i=1,63 jsync0(i)=2*(jsync0(i)-1) + 1 + jsync1(i)=2*(jsync1(i)-1) + 1 enddo first=.false. endif + do j=322,1,-1 + if(sum(ss(1,j,1:NFFT)).gt.0.0) exit + enddo + jz=j + + df3=96000.0/NFFT ia=nint(1000*nfa/df3) !Flat frequency range for WSE converters ib=nint(1000*nfb/df3) @@ -93,6 +99,19 @@ subroutine wb2_sync(ss,savg,nfa,nfb) flip=1.0 endif + ccf=0. + do j=1,63 + k=jsync1(j) + lag + ccf=ccf + ss(ipol,k,i+1) + ss(ipol,k+1,i+1) + enddo + ccf=ccf - savg(ipol,i+1)*2*63/float(jz) + if(ccf.gt.ccfmax) then + ipolbest=ipol + lagbest=lag + ccfmax=ccf + flip=-1.0 + endif + enddo ! lag enddo !ipol