From 851b658298afb9bafeda98ffbfa2ade612c656be Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Sun, 2 Jun 2019 22:17:11 +0200 Subject: New upstream version 2.1.0~rc6+repack --- lib/azdist.f90 | 11 +--- lib/decoder.f90 | 8 +-- lib/freqcal.f90 | 48 ++++++++------- lib/ft4/averaged_mf.f90 | 64 ++++++++++++++++++++ lib/ft4/ft4_baseline.f90 | 49 +++++++++++++++ lib/ft4/ft4_downsample.f90 | 4 +- lib/ft4/ft4_params.f90 | 12 ++-- lib/ft4/ft4sim.f90 | 9 +-- lib/ft4/ft4sim_mult.f90 | 8 +-- lib/ft4/gen_ft4wave.f90 | 6 +- lib/ft4/getcandidates4.f90 | 24 +++----- lib/ft4/subtractft4.f90 | 10 ++-- lib/ft4/sync4d.f90 | 23 ++++++- lib/ft4/syncft4.f90 | 145 --------------------------------------------- lib/ft4_decode.f90 | 89 ++++++++++++++++++++-------- lib/ft8/sync8.f90 | 7 ++- lib/jt4_decode.f90 | 3 +- lib/jt9.f90 | 10 ++-- 18 files changed, 277 insertions(+), 253 deletions(-) create mode 100644 lib/ft4/averaged_mf.f90 create mode 100644 lib/ft4/ft4_baseline.f90 delete mode 100644 lib/ft4/syncft4.f90 (limited to 'lib') diff --git a/lib/azdist.f90 b/lib/azdist.f90 index 2fd26c3d..41a8fc5b 100644 --- a/lib/azdist.f90 +++ b/lib/azdist.f90 @@ -1,7 +1,7 @@ -subroutine azdist(grid1,grid2,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter) +subroutine azdist(MyGrid,HisGrid,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter) - character*(*) grid1,grid2 - character*6 MyGrid,HisGrid,mygrid0,hisgrid0 + character(len=*) :: MyGrid,HisGrid + character*6 mygrid0,hisgrid0 real*8 utch,utch0 logical HotABetter,IamEast real eltab(22),daztab(22) @@ -12,11 +12,6 @@ subroutine azdist(grid1,grid2,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter) data mygrid0/" "/,hisgrid0/" "/,utch0/-999.d0/ save - MyGrid=grid1//' ' - HisGrid=grid2//' ' - if(ichar(MyGrid(5:5)).eq.0) MyGrid(5:6)=' ' - if(ichar(HisGrid(5:5)).eq.0) HisGrid(5:6)=' ' - if(MyGrid.eq.HisGrid) then naz=0 nel=0 diff --git a/lib/decoder.f90 b/lib/decoder.f90 index 8ca7e316..d3f1153f 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -133,8 +133,8 @@ subroutine multimode_decoder(ss,id2,params,nfsample) n30fox(j)=n m=n30max-n if(len(trim(g2fox(j))).eq.4) then - call azdist(mygrid,g2fox(j),0.d0,nAz,nEl,nDmiles,nDkm, & - nHotAz,nHotABetter) + call azdist(mygrid,g2fox(j)//' ',0.d0,nAz,nEl,nDmiles, & + nDkm,nHotAz,nHotABetter) else nDkm=9999 endif @@ -152,8 +152,8 @@ subroutine multimode_decoder(ss,id2,params,nfsample) if(params%nmode.eq.5) then call timer('decft4 ',0) call my_ft4%decode(ft4_decoded,id2,params%nQSOProgress,params%nfqso, & - params%nutc,params%nfa,params%nfb,params%ndepth,ncontest, & - mycall,hiscall) + params%nutc,params%nfa,params%nfb,params%ndepth, & + logical(params%lapcqonly),ncontest,mycall,hiscall) call timer('decft4 ',1) go to 800 endif diff --git a/lib/freqcal.f90 b/lib/freqcal.f90 index 540237f6..80ce90c6 100644 --- a/lib/freqcal.f90 +++ b/lib/freqcal.f90 @@ -41,6 +41,7 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line) endif smax=0. s=0. + ipk=-99 do i=ia,ib s(i)=real(cx(i))**2 + aimag(cx(i))**2 if(s(i).gt.smax) then @@ -48,25 +49,32 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line) ipk=i endif enddo - - call peakup(s(ipk-1),s(ipk),s(ipk+1),dx) - fpeak=df * (ipk+dx) - ap=(fpeak/fs+1.0/(2.0*NFFT)) - an=(fpeak/fs-1.0/(2.0*NFFT)) - sp=sum(id2((k-NFFT):k-1)*cmplx(cos(xi*ap),-sin(xi*ap))) - sn=sum(id2((k-NFFT):k-1)*cmplx(cos(xi*an),-sin(xi*an))) - fpeak=fpeak+fs*(abs(sp)-abs(sn))/(abs(sp)+abs(sn))/(2*NFFT) - xsum=0. - nsum=0 - do i=ia,ib - if(abs(i-ipk).gt.10) then - xsum=xsum+s(i) - nsum=nsum+1 - endif - enddo - ave=xsum/nsum - snr=db(smax/ave) - pave=db(ave) + 8.0 + + if(ipk.ge.1) then + call peakup(s(ipk-1),s(ipk),s(ipk+1),dx) + fpeak=df * (ipk+dx) + ap=(fpeak/fs+1.0/(2.0*NFFT)) + an=(fpeak/fs-1.0/(2.0*NFFT)) + sp=sum(id2((k-NFFT):k-1)*cmplx(cos(xi*ap),-sin(xi*ap))) + sn=sum(id2((k-NFFT):k-1)*cmplx(cos(xi*an),-sin(xi*an))) + fpeak=fpeak+fs*(abs(sp)-abs(sn))/(abs(sp)+abs(sn))/(2*NFFT) + xsum=0. + nsum=0 + do i=ia,ib + if(abs(i-ipk).gt.10) then + xsum=xsum+s(i) + nsum=nsum+1 + endif + enddo + ave=xsum/nsum + snr=db(smax/ave) + pave=db(ave) + 8.0 + else + snr=-99.9 + pave=-99.9 + fpeak=-99.9 + ferr=-99.9 + endif cflag=' ' if(snr.lt.20.0) cflag='*' n=n+1 @@ -77,7 +85,7 @@ subroutine freqcal(id2,k,nkhz,noffset,ntol,line) ncal=1 ferr=fpeak-noffset write(line,1100) nhr,nmin,nsec,nkhz,ncal,noffset,fpeak,ferr,pave, & - snr,cflag,char(0) + snr,cflag,char(0) 1100 format(i2.2,':',i2.2,':',i2.2,i7,i3,i6,2f10.3,2f7.1,2x,a1,a1) 900 return diff --git a/lib/ft4/averaged_mf.f90 b/lib/ft4/averaged_mf.f90 new file mode 100644 index 00000000..2986572b --- /dev/null +++ b/lib/ft4/averaged_mf.f90 @@ -0,0 +1,64 @@ +program averaged_mf + + parameter (nsps=32) + complex cgfsk(3*nsps,64) + complex clin(3*nsps,64) + complex cavg(3*nsps,4) + complex cavl(3*nsps,4) + real pulse(3*nsps) + real dphi(3*nsps) + + do i=1,3*NSPS + t=(i-1.5*nsps)/real(nsps) + pulse(i)=gfsk_pulse(1.0,t) + enddo + + twopi=8.0*atan(1.0) + hmod=1.0 + dphi_peak=twopi*hmod/real(nsps) + + do iwf=1,64 + i0=mod((iwf-1)/16,4) + i1=mod((iwf-1)/4,4) + i2=mod(iwf-1,4) + dphi=0.0 + dphi(1:64)=dphi_peak*pulse(33:96)*i1 + dphi(1:96)=dphi(1:96)+dphi_peak*pulse(1:96)*i0 + dphi(33:96)=dphi(33:96)+dphi_peak*pulse(1:64)*i2 + phi=0.0 + do j=1,96 + cgfsk(j,iwf)=cmplx(cos(phi),sin(phi)) + phi=mod(phi+dphi(j),twopi) + enddo + cgfsk(:,iwf)=cgfsk(:,iwf)*conjg(cgfsk(48,iwf)) + enddo + + do iwf=1,64 + i0=mod((iwf-1)/16,4) + i1=mod((iwf-1)/4,4) + i2=mod(iwf-1,4) + dphi=0.0 + dphi(1:32)=dphi_peak*i1 + dphi(33:64)=dphi_peak*i0 + dphi(65:96)=dphi_peak*i2 + phi=0.0 + do j=1,96 + clin(j,iwf)=cmplx(cos(phi),sin(phi)) + phi=mod(phi+dphi(j),twopi) + enddo + enddo + + + do i=1,4 + ib=(i-1)*16+1 + ie=ib+15 + cavg(:,i)=sum(cgfsk(:,ib:ie),2)/16.0 + cavl(:,i)=sum(clin(:,ib:ie),2)/16.0 + do j=1,96 +write(*,*) j +write(21,*) i,j,real(cavg(j,i)),imag(cavg(j,i)),real(cavl(j,i)),imag(cavl(j,i)) + enddo + enddo + +end program averaged_mf + diff --git a/lib/ft4/ft4_baseline.f90 b/lib/ft4/ft4_baseline.f90 new file mode 100644 index 00000000..85a60d9e --- /dev/null +++ b/lib/ft4/ft4_baseline.f90 @@ -0,0 +1,49 @@ +subroutine ft4_baseline(s,nfa,nfb,sbase) + +! Fit baseline to spectrum +! Input: s(npts) Linear scale in power +! Output: sbase(npts) Baseline + + include 'ft4_params.f90' + implicit real*8 (a-h,o-z) + real*4 s(NH1) + real*4 sbase(NH1) + real*4 base + real*8 x(1000),y(1000),a(5) + data nseg/10/,npct/10/ + + df=12000.0/NFFT1 !5.21 Hz + ia=max(nint(200.0/df),nfa) + ib=min(NH1,nfb) + do i=ia,ib + s(i)=10.0*log10(s(i)) !Convert to dB scale + enddo + + nterms=5 + nlen=(ib-ia+1)/nseg !Length of test segment + i0=(ib-ia+1)/2 !Midpoint + k=0 + do n=1,nseg !Loop over all segments + ja=ia + (n-1)*nlen + jb=ja+nlen-1 + call pctile(s(ja),nlen,npct,base) !Find lowest npct of points + do i=ja,jb + if(s(i).le.base) then + if (k.lt.1000) k=k+1 !Save all "lower envelope" points + x(k)=i-i0 + y(k)=s(i) + endif + enddo + enddo + kz=k + a=0. + call polyfit(x,y,y,kz,nterms,0,a,chisqr) !Fit a low-order polynomial + do i=ia,ib + t=i-i0 + sbase(i)=a(1)+t*(a(2)+t*(a(3)+t*(a(4)+t*(a(5))))) + 0.65 +! write(51,3051) i*df,s(i),sbase(i) +!3051 format(3f12.3) + sbase(i)=10**(sbase(i)/10.0) + enddo + return +end subroutine ft4_baseline diff --git a/lib/ft4/ft4_downsample.f90 b/lib/ft4/ft4_downsample.f90 index 819b10fb..ed55fb9a 100644 --- a/lib/ft4/ft4_downsample.f90 +++ b/lib/ft4/ft4_downsample.f90 @@ -4,7 +4,7 @@ subroutine ft4_downsample(dd,newdata,f0,c) ! Output: Complex data in c(), sampled at 1200 Hz include 'ft4_params.f90' - parameter (NFFT2=NMAX/16) + parameter (NFFT2=NMAX/NDOWN) real dd(NMAX) complex c(0:NMAX/NDOWN-1) complex c1(0:NFFT2-1) @@ -38,7 +38,7 @@ subroutine ft4_downsample(dd,newdata,f0,c) endif i0=nint(f0/df) c1=0. - c1(0)=cx(i0) + if(i0.ge.0 .and. i0.le.NMAX/2) c1(0)=cx(i0) do i=1,NFFT2/2 if(i0+i.le.NMAX/2) c1(i)=cx(i0+i) if(i0-i.ge.0) c1(NFFT2-i)=cx(i0-i) diff --git a/lib/ft4/ft4_params.f90 b/lib/ft4/ft4_params.f90 index 46630cc2..2914260d 100644 --- a/lib/ft4/ft4_params.f90 +++ b/lib/ft4/ft4_params.f90 @@ -6,11 +6,11 @@ parameter (ND=87) !Data symbols parameter (NS=16) !Sync symbols parameter (NN=NS+ND) !Sync and data symbols (103) parameter (NN2=NS+ND+2) !Total channel symbols (105) -parameter (NSPS=512) !Samples per symbol at 12000 S/s -parameter (NZ=NSPS*NN) !Sync and Data samples (52736) -parameter (NZ2=NSPS*NN2) !Total samples in shaped waveform (53760) -parameter (NMAX=18*3456) !Samples in iwave -parameter (NFFT1=2048, NH1=NFFT1/2) !Length of FFTs for symbol spectra +parameter (NSPS=576) !Samples per symbol at 12000 S/s +parameter (NZ=NSPS*NN) !Sync and Data samples (59328) +parameter (NZ2=NSPS*NN2) !Total samples in shaped waveform (60480) +parameter (NMAX=21*3456) !Samples in iwave (72576) +parameter (NFFT1=2304, NH1=NFFT1/2) !Length of FFTs for symbol spectra parameter (NSTEP=NSPS) !Coarse time-sync step size parameter (NHSYM=(NMAX-NFFT1)/NSTEP) !Number of symbol spectra (1/4-sym steps) -parameter (NDOWN=16) !Downsample factor +parameter (NDOWN=18) !Downsample factor diff --git a/lib/ft4/ft4sim.f90 b/lib/ft4/ft4sim.f90 index 94ab8218..959cf423 100644 --- a/lib/ft4/ft4sim.f90 +++ b/lib/ft4/ft4sim.f90 @@ -6,7 +6,7 @@ program ft4sim use packjt77 include 'ft4_params.f90' !Set various constants parameter (NWAVE=NN*NSPS) - parameter (NZZ=18*3456) !62208 + parameter (NZZ=21*3456) !72576 type(hdr) h !Header for .wav file character arg*12,fname*17 character msg37*37,msgsent37*37 @@ -51,12 +51,11 @@ program ft4sim hmod=1.0 !Modulation index (0.5 is MSK, 1.0 is FSK) tt=NSPS*dt !Duration of symbols (s) baud=1.0/tt !Keying rate (baud) - txt=NZ*dt !Transmission length (s) + txt=NZ2*dt !Transmission length (s) bandwidth_ratio=2500.0/(fs/2.0) sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb) if(snrdb.gt.90.0) sig=1.0 - txt=NN*NSPS/12000.0 ! Source-encode, then get itone() i3=-1 @@ -111,8 +110,10 @@ program ft4sim c0((NN+1)*NSPS:(NN+2)*NSPS-1)=c0((NN+1)*NSPS:(NN+2)*NSPS-1)*(1.0+cos(twopi*(/(i,i=0,NSPS-1)/)/(2.0*NSPS) ))/2.0 c0((NN+2)*NSPS:)=0. - k=nint((xdt+0.5)/dt) + k=nint((xdt+0.5)/dt)-NSPS c0=cshift(c0,-k) + if(k.gt.0) c0(0:k-1)=0.0 + if(k.lt.0) c0(NZZ+k:NZZ-1)=0.0 do ifile=1,nfiles c=c0 diff --git a/lib/ft4/ft4sim_mult.f90 b/lib/ft4/ft4sim_mult.f90 index 31309328..d93978e5 100644 --- a/lib/ft4/ft4sim_mult.f90 +++ b/lib/ft4/ft4sim_mult.f90 @@ -6,7 +6,7 @@ program ft4sim_mult use packjt77 include 'ft4_params.f90' !FT4 protocol constants parameter (NWAVE=NN*NSPS) - parameter (NZZ=65760) !Length of .wav file (4.48+1.0)*12000 + parameter (NZZ=72576) !Length of .wav file (21*3456) type(hdr) h !Header for .wav file character arg*12,fname*17,cjunk*4 character msg37*37,msgsent37*37,c77*77 @@ -17,8 +17,6 @@ program ft4sim_mult integer itone(NN) integer*1 msgbits(77) integer*2 iwave(NZZ) !Generated full-length waveform - integer icos4(4) - data icos4/0,1,3,2/ ! Get command-line argument(s) nargs=iargc() @@ -55,8 +53,8 @@ program ft4sim_mult read(10,1003,end=100) cjunk,isnr,xdt0,ifreq,msg37 1003 format(a4,30x,i3,f5.1,i5,1x,a37) if(cjunk.eq.'File') go to 100 - if(isnr.lt.-16) isnr=-16 - f0=ifreq*93.75/50.0 + if(isnr.lt.-17) isnr=-17 + f0=ifreq*960.0/576.0 call random_number(r) xdt=r-0.5 ! Source-encode, then get itone() diff --git a/lib/ft4/gen_ft4wave.f90 b/lib/ft4/gen_ft4wave.f90 index 410e8340..82399361 100644 --- a/lib/ft4/gen_ft4wave.f90 +++ b/lib/ft4/gen_ft4wave.f90 @@ -2,8 +2,8 @@ subroutine gen_ft4wave(itone,nsym,nsps,fsample,f0,cwave,wave,icmplx,nwave) real wave(nwave) complex cwave(nwave) - real pulse(6144) !512*4*3 - real dphi(0:240000-1) + real pulse(6912) !576*4*3 + real dphi(0:250000-1) integer itone(nsym) logical first data first/.true./ @@ -13,7 +13,7 @@ subroutine gen_ft4wave(itone,nsym,nsps,fsample,f0,cwave,wave,icmplx,nwave) twopi=8.0*atan(1.0) dt=1.0/fsample hmod=1.0 -! Compute the frequency-smoothing pulse +! Compute the smoothed frequency-deviation pulse do i=1,3*nsps tt=(i-1.5*nsps)/real(nsps) pulse(i)=gfsk_pulse(1.0,tt) diff --git a/lib/ft4/getcandidates4.f90 b/lib/ft4/getcandidates4.f90 index 5d42ca74..f7cef02e 100644 --- a/lib/ft4/getcandidates4.f90 +++ b/lib/ft4/getcandidates4.f90 @@ -10,7 +10,6 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, & complex cx(0:NH1) real candidate(3,maxcand) real dd(NMAX) - integer indx(NH1) integer ipk(1) equivalence (x,cx) logical first @@ -26,7 +25,6 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, & ! Compute symbol spectra, stepping by NSTEP steps. savg=0. - tstep=NSTEP/12000.0 df=12000.0/NFFT1 fac=1.0/300.0 do j=1,NHSYM @@ -40,28 +38,21 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, & enddo savg=savg + s(1:NH1,j) !Average spectrum enddo + savg=savg/NHSYM savsm=0. do i=8,NH1-7 savsm(i)=sum(savg(i-7:i+7))/15. enddo + nfa=fa/df - if(nfa.lt.1) nfa=1 + if(nfa.lt.nint(200.0/df)) nfa=nint(200.0/df) nfb=fb/df if(nfb.gt.nint(5000.0/df)) nfb=nint(5000.0/df) - n300=300/df - n2500=2500/df -! np=nfb-nfa+1 - np=n2500-n300+1 - indx=0 - call indexx(savsm(n300:n2500),np,indx) - xn=savsm(n300+indx(nint(0.3*np))) ncand=0 - if(xn.le.1.e-8) return - savsm=savsm/xn -! call ft4_baseline(savg,nfa,nfb,sbase) -! savsm=savsm/sbase - - f_offset = -1.5*12000/512 + call ft4_baseline(savg,nfa,nfb,sbase) + if(any(sbase(nfa:nfb).le.0)) return + savsm(nfa:nfb)=savsm(nfa:nfb)/sbase(nfa:nfb) + f_offset = -1.5*12000.0/NSPS do i=nfa+1,nfb-1 if(savsm(i).ge.savsm(i-1) .and. savsm(i).ge.savsm(i+1) .and. & savsm(i).ge.syncmin) then @@ -69,6 +60,7 @@ subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, & del=0. if(den.ne.0.0) del=0.5*(savsm(i-1)-savsm(i+1))/den fpeak=(i+del)*df+f_offset + if(fpeak.lt.0.0 .or. fpeak.gt.4910.0) cycle speak=savsm(i) - 0.25*(savsm(i-1)-savsm(i+1))*del ncand=ncand+1 if(ncand.gt.maxcand) then diff --git a/lib/ft4/subtractft4.f90 b/lib/ft4/subtractft4.f90 index 83470d7e..ae104ddb 100644 --- a/lib/ft4/subtractft4.f90 +++ b/lib/ft4/subtractft4.f90 @@ -9,8 +9,8 @@ subroutine subtractft4(dd,itone,f0,dt) use timer_module, only: timer - parameter (NMAX=18*3456,NFRAME=(103+2)*512) - parameter (NFFT=NMAX,NFILT=1400) + parameter (NMAX=21*3456,NSPS=576,NFFT=NMAX,NFILT=1400) + parameter (NFRAME=(103+2)*NSPS) real*4 dd(NMAX), window(-NFILT/2:NFILT/2), xjunk complex cref,camp,cfilt,cw integer itone(103) @@ -19,13 +19,13 @@ subroutine subtractft4(dd,itone,f0,dt) common/heap8/cref(NFRAME),camp(NMAX),cfilt(NMAX),cw(NMAX),xjunk(NFRAME) save first - nstart=dt*12000+1-512 + nstart=dt*12000+1-NSPS nsym=103 - nsps=512 fs=12000.0 icmplx=1 bt=1.0 - call gen_ft4wave(itone,nsym,nsps,fs,f0,cref,xjunk,icmplx,NFRAME) + nss=NSPS + call gen_ft4wave(itone,nsym,nss,fs,f0,cref,xjunk,icmplx,NFRAME) camp=0. do i=1,nframe id=nstart-1+i diff --git a/lib/ft4/sync4d.f90 b/lib/ft4/sync4d.f90 index bda7ed4a..28cb10b9 100644 --- a/lib/ft4/sync4d.f90 +++ b/lib/ft4/sync4d.f90 @@ -60,7 +60,16 @@ subroutine sync4d(cd0,i0,ctwk,itwk,sync) z4=0. if(itwk.eq.1) csync2=ctwk*csynca !Tweak the frequency - if(i1.ge.0 .and. i1+4*NSS-1.le.NP-1) z1=sum(cd0(i1:i1+4*NSS-1:2)*conjg(csync2)) + if(i1.ge.0 .and. i1+4*NSS-1.le.NP-1) then + z1=sum(cd0(i1:i1+4*NSS-1:2)*conjg(csync2)) + elseif( i1.lt.0 ) then + npts=(i1+4*NSS-1)/2 + if(npts.le.8) then + z1=0. + else + z1=sum(cd0(0:i1+4*NSS-1:2)*conjg(csync2(2*NSS-npts:))) + endif + endif if(itwk.eq.1) csync2=ctwk*csyncb !Tweak the frequency if(i2.ge.0 .and. i2+4*NSS-1.le.NP-1) z2=sum(cd0(i2:i2+4*NSS-1:2)*conjg(csync2)) @@ -69,8 +78,16 @@ subroutine sync4d(cd0,i0,ctwk,itwk,sync) if(i3.ge.0 .and. i3+4*NSS-1.le.NP-1) z3=sum(cd0(i3:i3+4*NSS-1:2)*conjg(csync2)) if(itwk.eq.1) csync2=ctwk*csyncd !Tweak the frequency - if(i4.ge.0 .and. i4+4*NSS-1.le.NP-1) z4=sum(cd0(i4:i4+4*NSS-1:2)*conjg(csync2)) - + if(i4.ge.0 .and. i4+4*NSS-1.le.NP-1) then + z4=sum(cd0(i4:i4+4*NSS-1:2)*conjg(csync2)) + elseif( i4+4*NSS-1.gt.NP-1 ) then + npts=(NP-1-i4+1)/2 + if(npts.le.8) then + z4=0. + else + z4=sum(cd0(i4:i4+2*npts-1:2)*conjg(csync2(1:npts))) + endif + endif sync = p(z1) + p(z2) + p(z3) + p(z4) return diff --git a/lib/ft4/syncft4.f90 b/lib/ft4/syncft4.f90 deleted file mode 100644 index 4841c560..00000000 --- a/lib/ft4/syncft4.f90 +++ /dev/null @@ -1,145 +0,0 @@ -subroutine syncft4(iwave,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, & - ncand,sbase) - - include 'ft4_params.f90' -! Search over +/- 2.5s relative to 0.5s TX start time. - parameter (JZ=20) - complex cx(0:NH1) - real s(NH1,NHSYM) - real savg(NH1) - real sbase(NH1) - real x(NFFT1) - real sync2d(NH1,-JZ:JZ) - real red(NH1) - real candidate0(3,maxcand) - real candidate(3,maxcand) - real dd(NMAX) - integer jpeak(NH1) - integer indx(NH1) - integer ii(1) - integer*2 iwave(NMAX) - integer icos4(0:3) - data icos4/0,1,3,2/ !Costas 4x4 tone pattern - equivalence (x,cx) - - dd=iwave/1e3 -! Compute symbol spectra, stepping by NSTEP steps. - savg=0. - tstep=NSTEP/12000.0 - df=12000.0/NFFT1 - fac=1.0/300.0 - do j=1,NHSYM - ia=(j-1)*NSTEP + 1 - ib=ia+NSPS-1 - x(1:NSPS)=fac*dd(ia:ib) - x(NSPS+1:)=0. - call four2a(x,NFFT1,1,-1,0) !r2c FFT - do i=1,NH1 - s(i,j)=real(cx(i))**2 + aimag(cx(i))**2 - enddo - savg=savg + s(1:NH1,j) !Average spectrum - enddo - - call baseline(savg,nfa,nfb,sbase) - - ia=max(1,nint(nfa/df)) - ib=nint(nfb/df) - nssy=NSPS/NSTEP ! # steps per symbol - nfos=NFFT1/NSPS ! # frequency bin oversampling factor - jstrt=0.25/tstep - candidate0=0. - k=0 - - do i=ia,ib - do j=-JZ,+JZ - ta=0. - tb=0. - tc=0. - t0a=0. - t0b=0. - t0c=0. - do n=0,3 - m=j+jstrt+nssy*n - if(m.ge.1.and.m.le.NHSYM) then - ta=ta + s(i+nfos*icos4(n),m) - t0a=t0a + sum(s(i:i+nfos*3:nfos,m)) - endif - tb=tb + s(i+nfos*icos4(n),m+nssy*36) - t0b=t0b + sum(s(i:i+nfos*3:nfos,m+nssy*36)) - if(m+nssy*72.le.NHSYM) then - tc=tc + s(i+nfos*icos4(n),m+nssy*72) - t0c=t0c + sum(s(i:i+nfos*3:nfos,m+nssy*72)) - endif - enddo - t=ta+tb+tc - t0=t0a+t0b+t0c - t0=(t0-t)/3.0 - sync_abc=t/t0 - t=tb+tc - t0=t0b+t0c - t0=(t0-t)/3.0 - sync_bc=t/t0 - sync2d(i,j)=max(sync_abc,sync_bc) - enddo - enddo - - red=0. - do i=ia,ib - ii=maxloc(sync2d(i,-JZ:JZ)) - 1 - JZ - j0=ii(1) - jpeak(i)=j0 - red(i)=sync2d(i,j0) - enddo - iz=ib-ia+1 - call indexx(red(ia:ib),iz,indx) - ibase=indx(nint(0.40*iz)) - 1 + ia - if(ibase.lt.1) ibase=1 - if(ibase.gt.nh1) ibase=nh1 - base=red(ibase) - red=red/base - do i=1,min(maxcand,iz) - n=ia + indx(iz+1-i) - 1 - if(red(n).lt.syncmin.or.isnan(red(n)).or.k.eq.maxcand) exit - k=k+1 -! candidate0(1,k)=n*df+37.5*1.5 - candidate0(1,k)=n*df - candidate0(2,k)=(jpeak(n)-1)*tstep - candidate0(3,k)=red(n) - enddo - ncand=k - -! Put nfqso at top of list, and save only the best of near-dupe freqs. - do i=1,ncand - if(abs(candidate0(1,i)-nfqso).lt.10.0) candidate0(1,i)=-candidate0(1,i) - if(i.ge.2) then - do j=1,i-1 - fdiff=abs(candidate0(1,i))-abs(candidate0(1,j)) - if(abs(fdiff).lt.4.0) then - if(candidate0(3,i).ge.candidate0(3,j)) candidate0(3,j)=0. - if(candidate0(3,i).lt.candidate0(3,j)) candidate0(3,i)=0. - endif - enddo - endif - enddo - - fac=20.0/maxval(s) - s=fac*s - -! Sort by sync -! call indexx(candidate0(3,1:ncand),ncand,indx) -! Sort by frequency - call indexx(candidate0(1,1:ncand),ncand,indx) - k=1 -! do i=ncand,1,-1 - do i=1,ncand - j=indx(i) -! if( candidate0(3,j) .ge. syncmin .and. candidate0(2,j).ge.-1.5 ) then - if( candidate0(3,j) .ge. syncmin ) then - candidate(2:3,k)=candidate0(2:3,j) - candidate(1,k)=abs(candidate0(1,j)) - k=k+1 - endif - enddo - ncand=k-1 - return -end subroutine syncft4 diff --git a/lib/ft4_decode.f90 b/lib/ft4_decode.f90 index b217dbb2..50c9fa47 100644 --- a/lib/ft4_decode.f90 +++ b/lib/ft4_decode.f90 @@ -24,14 +24,13 @@ module ft4_decode contains subroutine decode(this,callback,iwave,nQSOProgress,nfqso, & - nutc,nfa,nfb,ndepth,ncontest,mycall,hiscall) + nutc,nfa,nfb,ndepth,lapcqonly,ncontest,mycall,hiscall) use timer_module, only: timer use packjt77 include 'ft4/ft4_params.f90' class(ft4_decoder), intent(inout) :: this procedure(ft4_decode_callback) :: callback - parameter (NSS=NSPS/NDOWN) - parameter (NZZ=18*3456) + parameter (NSS=NSPS/NDOWN,NDMAX=NMAX/NDOWN) character message*37,msgsent*37 character c77*77 character*37 decodes(100) @@ -42,8 +41,8 @@ contains character*6 hhmmss character*4 cqstr,cqstr0 - complex cd2(0:NZZ/NDOWN-1) !Complex waveform - complex cb(0:NZZ/NDOWN-1+NN*NSS) + complex cd2(0:NDMAX-1) !Complex waveform + complex cb(0:NDMAX-1) complex cd(0:NN*NSS-1) !Complex waveform complex ctwk(2*NSS),ctwk2(2*NSS,-16:16) complex csymb(NSS) @@ -52,7 +51,7 @@ contains real bmeta(2*NN),bmetb(2*NN),bmetc(2*NN) real a(5) - real dd(NZZ) + real dd(NMAX) real llr(2*ND),llra(2*ND),llrb(2*ND),llrc(2*ND),llrd(2*ND) real s2(0:255) real candidate(3,100) @@ -61,7 +60,7 @@ contains integer apbits(2*ND) integer apmy_ru(28),aphis_fd(28) integer icos4a(0:3),icos4b(0:3),icos4c(0:3),icos4d(0:3) - integer*2 iwave(NZZ) !Raw received data + integer*2 iwave(NMAX) !Raw received data integer*1 message77(77),rvec(77),apmask(2*ND),cw(2*ND) integer*1 hbits(2*NN) integer graymap(0:3) @@ -75,7 +74,8 @@ contains logical nohiscall,unpk77_success logical one(0:255,0:7) ! 256 4-symbol sequences, 8 bits logical first, dobigfft - logical dosubtract + logical dosubtract,doosd + logical, intent(in) :: lapcqonly data icos4a/0,1,3,2/ data icos4b/1,0,2,3/ @@ -95,6 +95,9 @@ contains this%callback => callback hhmmss=cdatetime0(8:13) + dxcall13=hiscall + mycall13=mycall + if(first) then fs=12000.0/NDOWN !Sample rate after downsampling dt=1/fs !Sample interval after downsample (s) @@ -208,21 +211,33 @@ contains fb=nfb dd=iwave -! ndepth=3: 2 passes, subtract on each pass -! ndepth=2: 1 pass, no subtraction -! ndepth=1: 1 pass, no subtraction, fewer candidates +! ndepth=3: 3 passes, bp+osd +! ndepth=2: 3 passes, bp only +! ndepth=1: 1 pass, no subtraction max_iterations=40 syncmin=1.2 dosubtract=.true. - nsp=2 - if(ndepth.lt.3) then + doosd=.true. + nsp=3 + if(ndepth.eq.2) then + doosd=.false. + endif + if(ndepth.eq.1) then nsp=1 dosubtract=.false. + doosd=.false. endif - if(ndepth.eq.1) syncmin=2.0 do isp = 1,nsp + if(isp.eq.2) then + if(ndecodes.eq.0) exit + nd1=ndecodes + elseif(isp.eq.3) then + nd2=ndecodes-nd1 + if(nd2.eq.0) exit + endif + candidate=0.0 ncand=0 call timer('getcand4',0) @@ -237,23 +252,23 @@ contains call ft4_downsample(dd,dobigfft,f0,cd2) !Downsample to 32 Sam/Sym call timer('ft4_down',1) if(dobigfft) dobigfft=.false. - sum2=sum(cd2*conjg(cd2))/(real(NZZ)/real(NDOWN)) + sum2=sum(cd2*conjg(cd2))/(real(NMAX)/real(NDOWN)) if(sum2.gt.0.0) cd2=cd2/sqrt(sum2) -! Sample rate is now 12000/16 = 750 samples/second +! Sample rate is now 12000/18 = 666.67 samples/second do isync=1,2 if(isync.eq.1) then idfmin=-12 idfmax=12 idfstp=3 - ibmin=0 - ibmax=800 + ibmin=-344 + ibmax=1012 ibstp=4 else idfmin=idfbest-4 idfmax=idfbest+4 idfstp=1 - ibmin=max(0,ibest-5) - ibmax=min(ibest+5,NZZ/NDOWN-1) + ibmin=ibest-5 + ibmax=ibest+5 ibstp=1 endif ibest=-1 @@ -279,7 +294,14 @@ contains call timer('ft4down ',1) sum2=sum(abs(cb)**2)/(real(NSS)*NN) if(sum2.gt.0.0) cb=cb/sqrt(sum2) - cd=cb(ibest:ibest+NN*NSS-1) + cd=0. + if(ibest.ge.0) then + it=min(NDMAX-1,ibest+NN*NSS-1) + np=it-ibest+1 + cd(0:np-1)=cb(ibest:it) + else + cd(-ibest:ibest+NN*NSS-1)=cb(0:NN*NSS+2*ibest-1) + endif call timer('four2a ',0) do k=1,NN i1=(k-1)*NSS @@ -386,6 +408,7 @@ contains apmag=maxval(abs(llra))*1.1 npasses=3+nappasses(nQSOProgress) + if(lapcqonly) npasses=4 if(ndepth.eq.1) npasses=3 if(ncontest.ge.5) npasses=3 ! Don't support Fox and Hound do ipass=1,npasses @@ -400,6 +423,7 @@ contains if(ipass .gt. 3) then llrd=llra iaptype=naptypes(nQSOProgress,ipass-3) + if(lapcqonly) iaptype=1 ! ncontest=0 : NONE ! 1 : NA_VHF @@ -465,10 +489,22 @@ contains llr=llrd endif message77=0 + dmin=0.0 call timer('bpdec174',0) call bpdecode174_91(llr,apmask,max_iterations,message77, & cw,nharderror,niterations) call timer('bpdec174',1) + + if(doosd .and. nharderror.lt.0) then + ndeep=3 + if(abs(nfqso-f1).le.napwid) then + ndeep=4 + endif + call timer('osd174_91 ',0) + call osd174_91(llr,apmask,ndeep,message77,cw,nharderror,dmin) + call timer('osd174_91 ',1) + endif + if(sum(message77).eq.0) cycle if( nharderror.ge.0 ) then message77=mod(message77+rvec,2) ! remove rvec scrambling @@ -476,7 +512,7 @@ contains call unpack77(c77,1,message,unpk77_success) if(unpk77_success.and.dosubtract) then call get_ft4_tones_from_77bits(message77,i4tone) - dt=real(ibest)/750.0 + dt=real(ibest)/666.67 call timer('subtract',0) call subtractft4(dd,i4tone,f0,dt) call timer('subtract',1) @@ -489,12 +525,13 @@ contains ndecodes=ndecodes+1 decodes(ndecodes)=message if(snr.gt.0.0) then - xsnr=10*log10(snr)-14.0 + xsnr=10*log10(snr)-14.8 else - xsnr=-20.0 + xsnr=-21.0 endif - nsnr=nint(max(-20.0,xsnr)) - xdt=ibest/750.0 - 0.5 + nsnr=nint(max(-21.0,xsnr)) + xdt=ibest/666.67 - 0.5 +!write(21,'(i6.6,i5,2x,f4.1,i6,2x,a37,2x,f4.1,3i3,f5.1)') nutc,nsnr,xdt,nint(f0),message,sync,iaptype,ipass,isp,dmin call this%callback(sync,nsnr,xdt,f0,message,iaptype,qual) exit endif diff --git a/lib/ft8/sync8.f90 b/lib/ft8/sync8.f90 index 3924f1ba..219c6ebf 100644 --- a/lib/ft8/sync8.f90 +++ b/lib/ft8/sync8.f90 @@ -89,7 +89,12 @@ subroutine sync8(dd,nfa,nfb,syncmin,nfqso,maxcand,s,candidate, & enddo iz=ib-ia+1 call indexx(red(ia:ib),iz,indx) - ibase=indx(nint(0.40*iz)) - 1 + ia + npctile=nint(0.40*iz) + if(npctile.lt.1) then ! something is wrong; bail out + ncand=0 + return; + endif + ibase=indx(npctile) - 1 + ia if(ibase.lt.1) ibase=1 if(ibase.gt.nh1) ibase=nh1 base=red(ibase) diff --git a/lib/jt4_decode.f90 b/lib/jt4_decode.f90 index da0fbda6..ff0b33c4 100644 --- a/lib/jt4_decode.f90 +++ b/lib/jt4_decode.f90 @@ -156,7 +156,7 @@ contains nfreqz=nint(dfx) call timer('sync4 ',1) - nsnr=nint(snrx) + nsnr=-26 if(sync.lt.syncmin) then if (associated (this%decode_callback)) then call this%decode_callback(nsnr,dtxz,nfreqz,.false.,csync, & @@ -166,6 +166,7 @@ contains endif ! We have achieved sync + nsnr=nint(snrsync - 22.9) decoded=blank deepmsg=blank special=' ' diff --git a/lib/jt9.f90 b/lib/jt9.f90 index aff2844e..67e7ac31 100644 --- a/lib/jt9.f90 +++ b/lib/jt9.f90 @@ -22,7 +22,8 @@ program jt9 !### ndepth was defined as 60001. Why??? integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, & fhigh=4000,nrxfreq=1500,ntrperiod=1,ndepth=1,nexp_decode=0 - logical :: read_files = .true., tx9 = .false., display_help = .false. + logical :: read_files = .true., tx9 = .false., display_help = .false., & + bLowSidelobes = .false. type (option) :: long_options(26) = [ & option ('help', .false., 'h', 'Display this help message', ''), & option ('shmem',.true.,'s','Use shared memory for sample data','KEY'), & @@ -156,7 +157,7 @@ program jt9 end do go to 999 endif - + iret=fftwf_init_threads() !Initialize FFTW threading ! Default to 1 thread, but use nthreads for the big ones @@ -178,6 +179,7 @@ program jt9 go to 999 endif + if(mode.eq.5) ndepth=3 allocate(shared_data) nflatten=0 @@ -224,7 +226,7 @@ program jt9 endif shared_data%id2=0 !??? Why is this necessary ??? - if(mode.eq.5) npts=62208 + if(mode.eq.5) npts=21*3456 do iblk=1,npts/kstep k=iblk*kstep if(mode.eq.8 .and. k.gt.179712) exit @@ -242,7 +244,7 @@ program jt9 ingain=0 call timer('symspec ',0) nminw=1 - call symspec(shared_data,k,ntrperiod,nsps,ingain,nminw,pxdb, & + call symspec(shared_data,k,ntrperiod,nsps,ingain,bLowSidelobes,nminw,pxdb, & s,df3,ihsym,npts8,pxdbmax) call timer('symspec ',1) endif -- cgit v1.2.3