From 520a0c7cc0c46d52329613a7ada8563080ed7e0a Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 28 Dec 2020 18:53:13 -0500 Subject: [PATCH] Work in progress for Q65 decoder. --- lib/q65_decode.f90 | 8 ++++---- lib/qra/q65/q65.f90 | 1 + lib/qra/q65/q65_avg.f90 | 34 ++++++++++++++++------------------ lib/qra/q65/q65_loops.f90 | 9 +++------ lib/qra/q65/q65_sync.f90 | 11 +++++------ 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/lib/q65_decode.f90 b/lib/q65_decode.f90 index 2a10b4a67..7ed685da5 100644 --- a/lib/q65_decode.f90 +++ b/lib/q65_decode.f90 @@ -153,16 +153,16 @@ contains endif call timer('q65loops',0) - call q65_loops(c00,npts/2,nsps/2,mode65,nsubmode, & - nFadingModel,ndepth,jpk0,xdt,f0,width,iaptype,apmask,apsymbols, & - xdt1,f1,snr2,dat4,id2) + call q65_loops(c00,npts/2,nsps/2,mode65,nsubmode,ndepth,jpk0, & + xdt,f0,width,iaptype,xdt1,f1,snr2,dat4,id2) call timer('q65loops',1) if(id2.gt.0) exit !Exit main loop after a successful decode enddo ! No single-transmission decode. ! if(iand(ndepth,16).eq.16) call q65_avg2 - +! print*,'AAA: try for avg',navg + 100 decoded=' ' if(id1.gt.0 .or. id2.gt.0) then ! Unpack decoded message for display to user diff --git a/lib/qra/q65/q65.f90 b/lib/qra/q65/q65.f90 index 47849b5af..fcc023d11 100644 --- a/lib/qra/q65/q65.f90 +++ b/lib/qra/q65/q65.f90 @@ -7,6 +7,7 @@ module q65 integer iseq(MAXAVE) integer listutc(10) integer apmask(13),apsymbols(13) + integer navg real f0save(MAXAVE) real xdtsave(MAXAVE) real snr1save(MAXAVE) diff --git a/lib/qra/q65/q65_avg.f90 b/lib/qra/q65/q65_avg.f90 index fdd086313..6a06a36f7 100644 --- a/lib/qra/q65/q65_avg.f90 +++ b/lib/qra/q65/q65_avg.f90 @@ -1,4 +1,4 @@ -subroutine q65_avg(nutc,ntrperiod,mode_q65,LL,nfqso,ntol,lclearave, & +subroutine q65_avg(nutc,ntrperiod,LL,ntol,lclearave, & baud,nsubmode,ibwa,ibwb,codewords,ncw,xdt,f0,snr1,s3) ! Accumulate Q65 spectra s3(LL,63) and associated parameters for @@ -7,15 +7,13 @@ subroutine q65_avg(nutc,ntrperiod,mode_q65,LL,nfqso,ntol,lclearave, & use q65 use packjt77 character*37 avemsg - character*1 csync,cused(MAXAVE) + character*1 cused(MAXAVE) character*6 cutc - character*77 c77 real s3(-64:LL-65,63) !Symbol spectra - real s3prob(0:63,63) !Symbol-value probabilities integer iused(MAXAVE) integer dat4(13) integer codewords(63,206) - logical first,lclearave,unpk77_success + logical first,lclearave data first/.true./ save @@ -71,7 +69,7 @@ subroutine q65_avg(nutc,ntrperiod,mode_q65,LL,nfqso,ntol,lclearave, & snr1sum=0. xdtsum=0. fsum=0. - nsum=0 + navg=0 s3avg=0. ! Find previously saved spectra that should be averaged with this one @@ -90,19 +88,19 @@ subroutine q65_avg(nutc,ntrperiod,mode_q65,LL,nfqso,ntol,lclearave, & snr1sum=snr1sum + snr1save(i) xdtsum=xdtsum + xdtsave(i) fsum=fsum + f0save(i) - nsum=nsum+1 - iused(nsum)=i + navg=navg+1 + iused(navg)=i enddo - if(nsum.lt.MAXAVE) iused(nsum+1)=0 + if(navg.lt.MAXAVE) iused(navg+1)=0 ! Find averages of snr1, xdt, and f0 used in this decoding attempt. snr1ave=0. xdtave=0. fave=0. - if(nsum.gt.0) then - snr1ave=snr1sum/nsum - xdtave=xdtsum/nsum - fave=fsum/nsum + if(navg.gt.0) then + snr1ave=snr1sum/navg + xdtave=xdtsum/navg + fave=fsum/navg endif ! Write parameters for display to User in the Message Averaging (F7) window. @@ -114,9 +112,9 @@ subroutine q65_avg(nutc,ntrperiod,mode_q65,LL,nfqso,ntol,lclearave, & xdtsave(i),f0save(i) 1001 format(a1,i5.4,f6.1,f6.2,f7.1) enddo -! if(nsum.lt.2) go to 900 !Must have at least 2 +! if(navg.lt.2) go to 900 !Must have at least 2 - s3avg=s3avg/nsum + s3avg=s3avg/navg nFadingModel=1 do ibw=ibwa,ibwb b90=1.72**ibw @@ -125,7 +123,7 @@ subroutine q65_avg(nutc,ntrperiod,mode_q65,LL,nfqso,ntol,lclearave, & if(irc.ge.0 .and. plog.ge.PLOG_MIN) then snr2=esnodb - db(2500.0/baud) + 3.0 !Empirical adjustment id1=1 !### - print*,'B dec1 ',ibw,irc,avemsg +! print*,'B dec1 ',ibw,irc,avemsg exit endif enddo @@ -139,10 +137,10 @@ subroutine q65_avg(nutc,ntrperiod,mode_q65,LL,nfqso,ntol,lclearave, & call q65_dec2(s3,nsubmode,b90ts,esnodb,irc,dat4,avemsg) if(irc.ge.0) then id2=iaptype+2 - print*,'C dec2 ',ibw,irc,avemsg +! print*,'C dec2 ',ibw,irc,avemsg exit endif enddo ! ibw (b90 loop) -900 return + return end subroutine q65_avg diff --git a/lib/qra/q65/q65_loops.f90 b/lib/qra/q65/q65_loops.f90 index b89d385ef..2fec7891f 100644 --- a/lib/qra/q65/q65_loops.f90 +++ b/lib/qra/q65/q65_loops.f90 @@ -1,5 +1,5 @@ -subroutine q65_loops(c00,npts2,nsps,mode_q65,nsubmode,nFadingModel, & - ndepth,jpk0,xdt0,f0,width,iaptype,APmask,APsymbols,xdt1,f1,snr2,dat4,id2) +subroutine q65_loops(c00,npts2,nsps,mode_q65,nsubmode,ndepth,jpk0, & + xdt0,f0,width,iaptype,xdt1,f1,snr2,dat4,id2) use packjt77 use timer_module, only: timer @@ -10,9 +10,6 @@ subroutine q65_loops(c00,npts2,nsps,mode_q65,nsubmode,nFadingModel, & character decoded*37 real a(3) !twkfreq params f,f1,f2 real s3(LN) !Symbol spectra - real s3prob(64*NN) !Symbol-value probabilities - integer APmask(13) - integer APsymbols(13) integer cw4(63) integer dat4(13) !Decoded message (as 13 six-bit integers) integer nap(0:11) !AP return codes @@ -82,7 +79,7 @@ subroutine q65_loops(c00,npts2,nsps,mode_q65,nsubmode,nFadingModel, & ! -3 = CRC mismatch if(irc.ge.0) then id2=iaptype+2 - print*,'D dec2 ',ibw,irc,decoded +! print*,'D dec2 ',ibw,irc,id2,decoded go to 100 endif enddo ! ibw (b90 loop) diff --git a/lib/qra/q65/q65_sync.f90 b/lib/qra/q65/q65_sync.f90 index 5459815b9..afe36bf50 100644 --- a/lib/qra/q65/q65_sync.f90 +++ b/lib/qra/q65/q65_sync.f90 @@ -29,7 +29,6 @@ subroutine q65_sync(nutc,iwave,ntrperiod,mode_q65,codewords,ncw,nsps, & real, allocatable :: s3(:,:) !Data-symbol energies s3(LL,63) real, allocatable :: ccf(:,:) !CCF(freq,lag) real, allocatable :: ccf1(:) !CCF(freq) at best lag - real s3prob(0:63,63) !Symbol-value probabilities real sync(85) !sync vector complex, allocatable :: c0(:) !Complex spectrum of symbol data isync/1,9,12,13,15,22,23,26,27,33,35,38,46,50,55,60,62,66,69,74,76,85/ @@ -183,7 +182,7 @@ subroutine q65_sync(nutc,iwave,ntrperiod,mode_q65,codewords,ncw,nsps, & call q65_dec1(s3,nsubmode,b90ts,codewords,ncw,esnodb,irc,dat4,decoded) ! irc=-99 !### TEMPORARY ### if(irc.ge.0) then - print*,'A dec1 ',ibw,irc,decoded +! print*,'A dec1 ',ibw,irc,decoded snr2=esnodb - db(2500.0/baud) + 3.0 !Empirical adjustment id1=1 ic=ia2/4; @@ -191,8 +190,8 @@ subroutine q65_sync(nutc,iwave,ntrperiod,mode_q65,codewords,ncw,nsps, & ccf1=ccf1-base smax=maxval(ccf1) if(smax.gt.10.0) ccf1=10.0*ccf1/smax - go to 100 !### TEMPORARY ### -! go to 200 +! go to 100 !### TEMPORARY ### + go to 200 endif enddo @@ -252,7 +251,7 @@ subroutine q65_sync(nutc,iwave,ntrperiod,mode_q65,codewords,ncw,nsps, & enddo ! write(*,3002) 'B',xdt,f0,sum(s3) !3002 format(a1,f7.2,2f8.1) - call q65_avg(nutc,ntrperiod,mode_q65,LL,nfqso,ntol,lclearave, & + call q65_avg(nutc,ntrperiod,LL,ntol,lclearave, & baud,nsubmode,ibwa,ibwb,codewords,ncw,xdt,f0,snr1,s3) endif endif @@ -266,7 +265,7 @@ subroutine q65_sync(nutc,iwave,ntrperiod,mode_q65,codewords,ncw,nsps, & if(i2.eq.-9999 .and. ccf1(-i).ge.0.5*smax) i2=-i enddo do i=-ia2,ia2 - freq=nfqso + (i-mode_q65)*df + freq=nfqso + i*df write(17,1100) freq,ccf1(i),xdt 1100 format(3f10.3) enddo