From adc4c3d78aa27b86e816e06da1599bec89b71417 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 30 Nov 2020 14:13:37 -0500 Subject: [PATCH] More Q65 cleanup. Single-digit at end of line. --- lib/decoder.f90 | 4 +- lib/q65_decode.f90 | 14 ++-- lib/qra/q65/q65_loops.f90 | 162 ++++++++++++-------------------------- 3 files changed, 60 insertions(+), 120 deletions(-) diff --git a/lib/decoder.f90 b/lib/decoder.f90 index 011b98aa6..d93f5a73a 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -794,12 +794,12 @@ contains if(ntrperiod.lt.60) then write(*,1001) nutc,nsnr,dt,nint(freq),decoded,idec -1001 format(i6.6,i4,f5.1,i5,' + ',1x,a37,1x,i3.3) +1001 format(i6.6,i4,f5.1,i5,' + ',1x,a37,1x,i1) write(13,1002) nutc,nint(sync),nsnr,dt,freq,0,decoded 1002 format(i6.6,i4,i5,f6.1,f8.0,i4,3x,a37,' Q65') else write(*,1003) nutc,nsnr,dt,nint(freq),decoded,idec -1003 format(i4.4,i4,f5.1,i5,' + ',1x,a37,1x,i3.3) +1003 format(i4.4,i4,f5.1,i5,' + ',1x,a37,1x,i1) write(13,1004) nutc,nint(sync),nsnr,dt,freq,0,decoded 1004 format(i4.4,i4,i5,f6.1,f8.0,i4,3x,a37,' Q65') diff --git a/lib/q65_decode.f90 b/lib/q65_decode.f90 index 5bfcc5215..0473b7119 100644 --- a/lib/q65_decode.f90 +++ b/lib/q65_decode.f90 @@ -63,7 +63,6 @@ contains id1=0 id2=0 - id3=0 mode65=2**nsubmode npts=ntrperiod*12000 nfft1=ntrperiod*12000 @@ -140,19 +139,17 @@ contains endif endif call timer('q65loops',0) - call q65_loops(c00,nutc,npts/2,nsps/2,nmode,mode65,nsubmode, & + call q65_loops(c00,npts/2,nsps/2,nmode,mode65,nsubmode, & nFadingModel,ndepth,jpk0,xdt,f0,iaptype,apmask,apsymbols, & - codewords,snr1,xdt1,f1,snr2,dat4,id2,id3) + xdt1,f1,snr2,dat4,id2) call timer('q65loops',1) snr2=snr2 + db(6912.0/nsps) - if(id2+id3.gt.0) exit + if(id2.gt.0) exit enddo 100 decoded=' ' - idec=100*id1 + 10*id2 + id3 - write(71,3071) nutc,id1,id2,id3,irc -3071 format(5i6) - if(idec.gt.0) then + if(id1.gt.0 .or. id2.gt.0) then + idec=id1+id2 write(c77,1000) dat4(1:12),dat4(13)/2 1000 format(12b6.6,b5.5) call unpack77(c77,0,decoded,unpk77_success) !Unpack to get msgsent @@ -162,6 +159,7 @@ contains else ! Report sync, even if no decode. nsnr=db(snr1) - 35.0 + idec=-1 call this%callback(nutc,sync,nsnr,xdt1,f1,decoded, & idec,ntrperiod) endif diff --git a/lib/qra/q65/q65_loops.f90 b/lib/qra/q65/q65_loops.f90 index 59ba36c0e..b440e076f 100644 --- a/lib/qra/q65/q65_loops.f90 +++ b/lib/qra/q65/q65_loops.f90 @@ -1,23 +1,17 @@ -subroutine q65_loops(c00,nutc,npts2,nsps,mode,mode_q65,nsubmode,nFadingModel, & - ndepth,jpk0,xdt0,f0,iaptype,APmask,APsymbols,codewords,snr1, & - xdt1,f1,snr2,dat4,id2,id3) +subroutine q65_loops(c00,npts2,nsps,mode,mode_q65,nsubmode,nFadingModel, & + ndepth,jpk0,xdt0,f0,iaptype,APmask,APsymbols,xdt1,f1,snr2,dat4,id2) use packjt77 use timer_module, only: timer parameter (NN=63) parameter (LN=1152*63) !LN=LL*NN; LL=64*(mode_q65+2), NN=63 - character*37 decoded - character*77 c77 complex c00(0:npts2-1) !Analytic representation of dd(), 6000 Hz complex ,allocatable :: c0(:) !Ditto, with freq shift real a(3) !twkfreq params f,f1,f2 real s3(LN) !Symbol spectra - real s3avg(LN) !Averaged symbol spectra real s3prob(64*NN) !Symbol-value probabilities - logical unpk77_success integer APmask(13) integer APsymbols(13) - integer codewords(63,64) integer cw4(63) integer dat4(13) !Decoded message (as 13 six-bit integers) integer nap(0:11) !AP return codes @@ -27,10 +21,7 @@ subroutine q65_loops(c00,nutc,npts2,nsps,mode,mode_q65,nsubmode,nFadingModel, & 51,51,42,42,50,25,31,35,57,30, 1,54,54,10,10,22,44,58,57,40, & 21,21,19/ - save nsave,s3avg - - id2=0 - id3=0 + id2=-1 ircbest=9999 allocate(c0(0:npts2-1)) irc=-99 @@ -55,113 +46,64 @@ subroutine q65_loops(c00,nutc,npts2,nsps,mode,mode_q65,nsubmode,nFadingModel, & xdt1=xdt0 f1=f0 - maxavg=0 - if(iand(ndepth,16).ne.0) maxavg=1 - do iavg=0,maxavg - if(iavg.eq.1) then - idfmax=1 - idtmax=1 - endif - do idf=1,idfmax - ndf=idf/2 - if(mod(idf,2).eq.0) ndf=-ndf - a=0. - a(1)=-(f0+0.5*baud*ndf) - call twkfreq(c00,c0,npts2,6000.0,a) - do idt=1,idtmax - ndt=idt/2 - if(iaptype.eq.0 .and. iavg.eq.0) then - if(mod(idt,2).eq.0) ndt=-ndt - jpk=jpk0 + nsps*ndt/16 !tsym/16 - if(jpk.lt.0) jpk=0 - call timer('spec64 ',0) - call spec64(c0,nsps,mode,mode_q65,jpk,s3,LL,NN) - call timer('spec64 ',1) - call pctile(s3,LL*NN,40,base) - s3=s3/base - where(s3(1:LL*NN)>s3lim) s3(1:LL*NN)=s3lim - endif - kavg=0 - if(iavg.eq.1 .and. nsave.ge.2) then - s3(1:LL*NN)=s3avg(1:LL*NN) - kavg=nsave - endif - do ibw=ibwmin,ibwmax - nbw=ibw - ndist=ndf**2 + ndt**2 + ((nbw-2))**2 - if(ndist.gt.maxdist) cycle -! b90=1.728**ibw - b90=3.0**nbw - if(b90.gt.230.0) cycle - call timer('q65_intr',0) - b90ts = b90/baud - call q65_intrinsics_ff(s3,nsubmode,b90ts,nFadingModel,s3prob) - call timer('q65_intr',1) - if(iaptype.eq.4) then - codewords(1:63,4)=cw4 - call timer('q65_apli',0) - call q65_dec_fullaplist(s3,s3prob,codewords,4,esnodb, & - dat4,plog,irc) - call timer('q65_apli',1) - if(irc.ge.0) id2=4 - else - call timer('q65_dec ',0) - call q65_dec(s3,s3prob,APmask,APsymbols,esnodb,dat4,irc) - call timer('q65_dec ',1) - if(irc.ge.0) id2=iaptype - endif -! write(71,3071) 100*nutc,0.0,ndf,ndt,nbw,ndist,irc,iaptype, & -! kavg,nsave -!3071 format(i6.6,f8.4,8i5) - if(irc.ge.0) go to 100 + do idf=1,idfmax + ndf=idf/2 + if(mod(idf,2).eq.0) ndf=-ndf + a=0. + a(1)=-(f0+0.5*baud*ndf) + call twkfreq(c00,c0,npts2,6000.0,a) + do idt=1,idtmax + ndt=idt/2 + if(iaptype.eq.0) then + if(mod(idt,2).eq.0) ndt=-ndt + jpk=jpk0 + nsps*ndt/16 !tsym/16 + if(jpk.lt.0) jpk=0 + call timer('spec64 ',0) + call spec64(c0,nsps,mode,mode_q65,jpk,s3,LL,NN) + call timer('spec64 ',1) + call pctile(s3,LL*NN,40,base) + s3=s3/base + where(s3(1:LL*NN)>s3lim) s3(1:LL*NN)=s3lim + endif + do ibw=ibwmin,ibwmax + nbw=ibw + ndist=ndf**2 + ndt**2 + ((nbw-2))**2 + if(ndist.gt.maxdist) cycle + ! b90=1.728**ibw + b90=3.0**nbw + if(b90.gt.230.0) cycle + call timer('q65_intr',0) + b90ts = b90/baud + call q65_intrinsics_ff(s3,nsubmode,b90ts,nFadingModel,s3prob) + call timer('q65_intr',1) + call timer('q65_dec ',0) + call q65_dec(s3,s3prob,APmask,APsymbols,esnodb,dat4,irc) + call timer('q65_dec ',1) + if(irc.ge.0) id2=iaptype+2 + if(irc.ge.0) go to 100 ! irc > 0 ==> number of iterations required to decode ! -1 = invalid params ! -2 = decode failed ! -3 = CRC mismatch - enddo ! ibw (b90 loop) - enddo ! idt (DT loop) - enddo ! idf (f0 loop) - if(iaptype.eq.0 .and. iavg.eq.0) then - a=0. - a(1)=-f0 - call twkfreq(c00,c0,npts2,6000.0,a) - jpk=3000 !### Are these definitions OK? - if(nsps.ge.3600) jpk=6000 !### TR >= 60 s - call spec64(c0,nsps,mode,mode_q65,jpk,s3,LL,NN) - call pctile(s3,LL*NN,40,base) - s3=s3/base - where(s3(1:LL*NN)>s3lim) s3(1:LL*NN)=s3lim - s3avg(1:LL*NN)=s3avg(1:LL*NN) + s3(1:LL*NN) - nsave=nsave+1 - endif - if(iavg.eq.0 .and. nsave.lt.2) exit - enddo ! iavg + enddo ! ibw (b90 loop) + enddo ! idt (DT loop) + enddo ! idf (f0 loop) + if(iaptype.eq.0) then + a=0. + a(1)=-f0 + call twkfreq(c00,c0,npts2,6000.0,a) + jpk=3000 !### Are these definitions OK? + if(nsps.ge.3600) jpk=6000 !### TR >= 60 s + call spec64(c0,nsps,mode,mode_q65,jpk,s3,LL,NN) + call pctile(s3,LL*NN,40,base) + s3=s3/base + where(s3(1:LL*NN)>s3lim) s3(1:LL*NN)=s3lim + endif 100 if(irc.ge.0) then - navg=nsave snr2=esnodb - db(2500.0/baud) - if(kavg.eq.0) navg=0 xdt1=xdt0 + nsps*ndt/(16.0*6000.0) f1=f0 + 0.5*baud*ndf -!### For tests only: -! open(53,file='fort.53',status='unknown',position='append') -! write(c77,1100) dat4(1:12),dat4(13)/2 -!1100 format(12b6.6,b5.5) -! call unpack77(c77,0,decoded,unpk77_success) !Unpack to get msgsent -! m=nutc -! if(nsps.ge.3600) m=100*m -! ihr=m/10000 -! imin=mod(m/100,100) -! isec=mod(m,100) -! hours=ihr + imin/60.0 + isec/3600.0 -! write(53,3053) m,hours,ndf,ndt,nbw,ndist,irc,iaptype,kavg,snr1, & -! xdt1,f1,snr2,trim(decoded) -!3053 format(i6.6,f8.4,4i3,i4,2i3,f6.1,f6.2,f7.1,f6.1,1x,a) -! close(53) -!### - nsave=0 - s3avg=0. - irc=irc + 100*navg endif return