summaryrefslogtreecommitdiff
path: root/lib/decode9w.f90
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-10-09 14:12:35 +0200
committerChristoph Berg <myon@debian.org>2026-10-09 14:12:35 +0200
commitffc62c792c9a5196cb4ce7a353287dfe20db6524 (patch)
tree1269efa852935b183daae4bb33a58d1b4d2ffb53 /lib/decode9w.f90
parent059831534c7e884f0a607ed86b582fd00d821731 (diff)
New upstream version 3.3.0~beta1+dfsgupstream/3.3.0_beta1+dfsg
Diffstat (limited to 'lib/decode9w.f90')
-rw-r--r--lib/decode9w.f9040
1 files changed, 31 insertions, 9 deletions
diff --git a/lib/decode9w.f90 b/lib/decode9w.f90
index 2c043c72..f9a681eb 100644
--- a/lib/decode9w.f90
+++ b/lib/decode9w.f90
@@ -1,4 +1,4 @@
-subroutine decode9w(nfqso,ntol,nsubmode,ss,id2,sync,nsnr,xdt1,f0,decoded)
+subroutine decode9w(nfqso,ntol,nsubmode,ss,nzhsym,id2,sync,nsnr,xdt1,f0,decoded)
! Decode a weak signal in a wide/slow JT9 submode.
@@ -9,26 +9,44 @@ subroutine decode9w(nfqso,ntol,nsubmode,ss,id2,sync,nsnr,xdt1,f0,decoded)
real a(5) !Fitted Lorentzian params
integer*2 id2(NZMAX) !Raw 16-bit data
integer*1 i1SoftSymbols(207) !Binary soft symbols
+ logical :: valid,narrow
character*22 decoded !Decoded message
+ decoded=' '
+ sync=0.
+ nsnr=-99
+ xdt1=0.
+ f0=nfqso
+
df=12000.0/16384.0 !Bin spacing in ss()
nsps=6912 !Samples per 9-FSK symbol
tstep=nsps*0.5/12000.0 !Half-symbol duration
npts=52*12000
limit=10000 !Fano timeout parameter
- ia=max(1,nint((nfqso-ntol)/df)) !Start frequency bin
- ib=min(NSMAX,nint((nfqso+ntol)/df)) !End frequency bin
+ ia=max(1,nint((nfqso-ntol)/df)+1) !Start frequency bin
+ ib=min(NSMAX,nint((nfqso+ntol)/df)+1) !End frequency bin
+ if(ib.lt.ia) return
+ narrow=ib-ia+1.lt.20
+ ifita=ia
+ ifitb=ib
+ if(narrow) then
+ ! Fit both 20-bin baseline flanks without widening candidate selection.
+ ifita=max(1,min(NSMAX-40,nint(nfqso/df)+1-20))
+ ifitb=ifita+40
+ endif
lag1=-int(2.5/tstep + 0.9999) !Start lag
lag2=int(5.0/tstep + 0.9999) !End lag
- nhsym=184 !Number of half-symbols
+ nhsym=max(0,min(184,nzhsym))
+ if(nhsym.eq.0) return
! First sync pass finds approximate Doppler spread; second pass does a
! good Lorentzian fit to determine frequency f0.
do iter=1,2
nadd=3
if(iter.eq.2) nadd=2*nint(0.375*a(4)) + 1
- call sync9w(ss,nhsym,lag1,lag2,ia,ib,ccfred,ccfblue,ipk,lagpk,nadd)
+ call sync9w(ss,nhsym,lag1,lag2,ifita,ifitb,ia,ib,ccfred,ccfblue,ipk,lagpk,nadd)
+ if(ipk.eq.0) return
s=0.
sq=0.
ns=0
@@ -40,15 +58,19 @@ subroutine decode9w(nfqso,ntol,nsubmode,ss,id2,sync,nsnr,xdt1,f0,decoded)
endif
enddo
base=s/ns
- rms=sqrt(sq/ns - base**2)
+ rms=sqrt(max(0.,sq/ns - base**2))
+ if(rms.le.0.) return
sync=(ccfblue(lagpk)-base)/rms
xdt0=lagpk*tstep
- call lorentzian(ccfred(ia),ib-ia+1,a)
- f0=(ia+a(3))*df
+ call lorentzian(ccfred(ifita),ifitb-ifita+1,a)
+ f0=(ifita+a(3)-2)*df
enddo
+ if(narrow .and. abs(f0-nfqso).gt.ntol) return
ccfblue=(ccfblue-base)/rms
- call softsym9w(id2,npts,xdt0,f0,a(4)*df,nsubmode,xdt1-1.05,snrdb,i1softsymbols)
+ call softsym9w(id2,npts,xdt0,f0,a(4)*df,nsubmode,xdt1,snrdb,i1softsymbols,valid)
+ if(.not.valid) return
+ xdt1=xdt1-1.05
nsnr=nint(snrdb)
call jt9fano(i1softsymbols,limit,nlim,decoded)