summaryrefslogtreecommitdiff
path: root/lib/ft4_decode.f90
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ft4_decode.f90')
-rw-r--r--lib/ft4_decode.f9089
1 files changed, 63 insertions, 26 deletions
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