2017-07-08 10:06:48 -04:00
|
|
|
module ft8_decode
|
|
|
|
|
2017-10-30 16:47:08 -04:00
|
|
|
parameter (MAXFOX=1000)
|
|
|
|
character*12 c2fox(MAXFOX)
|
|
|
|
character*4 g2fox(MAXFOX)
|
|
|
|
integer nsnrfox(MAXFOX)
|
|
|
|
integer nfreqfox(MAXFOX)
|
2017-12-19 12:01:38 -05:00
|
|
|
integer n30fox(MAXFOX)
|
|
|
|
integer n30z
|
2017-10-30 16:47:08 -04:00
|
|
|
integer nfox
|
|
|
|
|
2017-07-08 10:06:48 -04:00
|
|
|
type :: ft8_decoder
|
|
|
|
procedure(ft8_decode_callback), pointer :: callback
|
|
|
|
contains
|
|
|
|
procedure :: decode
|
|
|
|
end type ft8_decoder
|
|
|
|
|
|
|
|
abstract interface
|
2017-07-22 13:12:48 -04:00
|
|
|
subroutine ft8_decode_callback (this,sync,snr,dt,freq,decoded,nap,qual)
|
2017-07-08 10:06:48 -04:00
|
|
|
import ft8_decoder
|
|
|
|
implicit none
|
|
|
|
class(ft8_decoder), intent(inout) :: this
|
|
|
|
real, intent(in) :: sync
|
|
|
|
integer, intent(in) :: snr
|
|
|
|
real, intent(in) :: dt
|
|
|
|
real, intent(in) :: freq
|
2017-12-19 15:01:06 -05:00
|
|
|
character(len=37), intent(in) :: decoded
|
2017-07-22 13:12:48 -04:00
|
|
|
integer, intent(in) :: nap
|
|
|
|
real, intent(in) :: qual
|
2017-07-08 10:06:48 -04:00
|
|
|
end subroutine ft8_decode_callback
|
|
|
|
end interface
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
2017-12-03 19:46:19 -05:00
|
|
|
subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, &
|
2018-07-27 09:30:00 -04:00
|
|
|
nutc,nfa,nfb,ndepth,ncontest,nagain,lft8apon,lapcqonly,ldecode77, &
|
|
|
|
napwid,mycall12,hiscall12,hisgrid6)
|
2017-07-12 17:49:39 -04:00
|
|
|
! use wavhdr
|
2017-07-08 10:06:48 -04:00
|
|
|
use timer_module, only: timer
|
2017-10-30 17:30:14 -04:00
|
|
|
include 'ft8/ft8_params.f90'
|
2017-07-12 17:49:39 -04:00
|
|
|
! type(hdr) h
|
2017-07-08 10:06:48 -04:00
|
|
|
|
|
|
|
class(ft8_decoder), intent(inout) :: this
|
|
|
|
procedure(ft8_decode_callback) :: callback
|
|
|
|
real s(NH1,NHSYM)
|
2017-08-26 12:30:47 -04:00
|
|
|
real sbase(NH1)
|
2018-06-05 17:37:29 -04:00
|
|
|
real candidate(4,200)
|
2017-07-08 10:06:48 -04:00
|
|
|
real dd(15*12000)
|
2018-07-05 08:51:10 -04:00
|
|
|
logical, intent(in) :: lft8apon,lapcqonly,ldecode77,nagain
|
2018-07-10 15:32:59 -04:00
|
|
|
logical newdat,lsubtract,ldupe
|
2017-07-08 10:06:48 -04:00
|
|
|
character*12 mycall12, hiscall12
|
2018-07-25 15:19:57 -04:00
|
|
|
character*6 hisgrid6
|
2017-07-08 10:06:48 -04:00
|
|
|
integer*2 iwave(15*12000)
|
2018-07-03 12:10:47 -04:00
|
|
|
integer apsym1(KK),apsym2(77)
|
2018-07-25 15:19:57 -04:00
|
|
|
character datetime*13,msg37*37
|
|
|
|
! character message*22
|
2018-07-04 17:20:12 -04:00
|
|
|
character*37 allmessages(100)
|
2017-07-20 17:08:36 -04:00
|
|
|
integer allsnrs(100)
|
2017-07-08 10:06:48 -04:00
|
|
|
save s,dd
|
|
|
|
|
|
|
|
this%callback => callback
|
|
|
|
write(datetime,1001) nutc !### TEMPORARY ###
|
|
|
|
1001 format("000000_",i6.6)
|
|
|
|
|
2018-07-11 16:32:08 -04:00
|
|
|
call ft8apset(mycall12,hiscall12,hisgrid6,apsym1)
|
2018-07-03 16:49:39 -04:00
|
|
|
! For now, turn off apset until we get basic functionality going... AP will
|
|
|
|
! need to be re-thinked for itype=2 messages.
|
2018-07-11 16:32:08 -04:00
|
|
|
! call ft8apset_174_91(mycall12,hiscall12,hisgrid6,apsym2)
|
2018-07-03 16:49:39 -04:00
|
|
|
apsym2=0
|
2017-07-08 10:06:48 -04:00
|
|
|
dd=iwave
|
2017-07-20 17:08:36 -04:00
|
|
|
ndecodes=0
|
2018-07-04 17:20:12 -04:00
|
|
|
allmessages=' '
|
2017-07-20 17:08:36 -04:00
|
|
|
allsnrs=0
|
2017-08-02 10:05:37 -04:00
|
|
|
ifa=nfa
|
|
|
|
ifb=nfb
|
|
|
|
if(nagain) then
|
|
|
|
ifa=nfqso-10
|
|
|
|
ifb=nfqso+10
|
|
|
|
endif
|
2017-07-20 17:08:36 -04:00
|
|
|
|
2017-07-12 17:49:39 -04:00
|
|
|
! For now:
|
|
|
|
! ndepth=1: no subtraction, 1 pass, belief propagation only
|
2017-08-31 16:16:38 -04:00
|
|
|
! ndepth=2: subtraction, 3 passes, belief propagation only
|
|
|
|
! ndepth=3: subtraction, 3 passes, bp+osd
|
2017-07-12 17:49:39 -04:00
|
|
|
if(ndepth.eq.1) npass=1
|
2017-08-21 20:14:51 -04:00
|
|
|
if(ndepth.ge.2) npass=3
|
2017-07-12 17:49:39 -04:00
|
|
|
do ipass=1,npass
|
|
|
|
newdat=.true. ! Is this a problem? I hijacked newdat.
|
2017-08-21 20:14:51 -04:00
|
|
|
syncmin=1.5
|
2017-07-12 17:49:39 -04:00
|
|
|
if(ipass.eq.1) then
|
|
|
|
lsubtract=.true.
|
|
|
|
if(ndepth.eq.1) lsubtract=.false.
|
2017-08-21 20:14:51 -04:00
|
|
|
elseif(ipass.eq.2) then
|
|
|
|
n2=ndecodes
|
|
|
|
if(ndecodes.eq.0) cycle
|
|
|
|
lsubtract=.true.
|
|
|
|
elseif(ipass.eq.3) then
|
|
|
|
if((ndecodes-n2).eq.0) cycle
|
|
|
|
lsubtract=.false.
|
2017-07-12 17:49:39 -04:00
|
|
|
endif
|
|
|
|
call timer('sync8 ',0)
|
2018-07-05 08:51:10 -04:00
|
|
|
call sync8(dd,ifa,ifb,syncmin,nfqso,ldecode77,s,candidate,ncand,sbase)
|
2017-07-12 17:49:39 -04:00
|
|
|
call timer('sync8 ',1)
|
|
|
|
do icand=1,ncand
|
|
|
|
sync=candidate(3,icand)
|
|
|
|
f1=candidate(1,icand)
|
|
|
|
xdt=candidate(2,icand)
|
2018-07-04 17:20:12 -04:00
|
|
|
isync=candidate(4,icand)
|
2017-08-26 12:30:47 -04:00
|
|
|
xbase=10.0**(0.1*(sbase(nint(f1/3.125))-40.0))
|
2017-07-12 17:49:39 -04:00
|
|
|
nsnr0=min(99,nint(10.0*log10(sync) - 25.5)) !### empirical ###
|
|
|
|
call timer('ft8b ',0)
|
2018-07-04 17:20:12 -04:00
|
|
|
if(isync.eq.1) then
|
2018-06-05 17:37:29 -04:00
|
|
|
call ft8b_1(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
|
2018-07-11 16:32:08 -04:00
|
|
|
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12, &
|
2018-07-10 15:32:59 -04:00
|
|
|
hiscall12,sync,f1,xdt,xbase,apsym1,nharderrors,dmin, &
|
2018-06-05 17:37:29 -04:00
|
|
|
nbadcrc,iappass,iera,msg37,xsnr)
|
|
|
|
else
|
|
|
|
call ft8b_2(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
|
2018-07-11 16:32:08 -04:00
|
|
|
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12, &
|
2018-07-10 15:32:59 -04:00
|
|
|
hiscall12,sync,f1,xdt,xbase,apsym2,nharderrors,dmin, &
|
2018-06-05 17:37:29 -04:00
|
|
|
nbadcrc,iappass,iera,msg37,xsnr)
|
|
|
|
endif
|
2018-07-04 17:20:12 -04:00
|
|
|
! message=msg37(1:22) !###
|
2017-07-16 13:08:09 -04:00
|
|
|
nsnr=nint(xsnr)
|
2017-07-18 11:22:20 -04:00
|
|
|
xdt=xdt-0.5
|
2017-07-20 11:15:00 -04:00
|
|
|
hd=nharderrors+dmin
|
2017-07-12 17:49:39 -04:00
|
|
|
call timer('ft8b ',1)
|
2017-07-20 11:15:00 -04:00
|
|
|
if(nbadcrc.eq.0) then
|
2017-08-09 11:22:54 -04:00
|
|
|
! call jtmsg(message,iflag)
|
2018-07-04 17:20:12 -04:00
|
|
|
! This probably needs to be re-visited for the new message type
|
2017-08-09 11:22:54 -04:00
|
|
|
! if(iand(iflag,31).ne.0) message(22:22)='?'
|
|
|
|
ldupe=.false.
|
|
|
|
do id=1,ndecodes
|
2018-07-04 17:20:12 -04:00
|
|
|
if(msg37.eq.allmessages(id).and.nsnr.le.allsnrs(id)) ldupe=.true.
|
2017-08-09 11:22:54 -04:00
|
|
|
enddo
|
|
|
|
if(.not.ldupe) then
|
|
|
|
ndecodes=ndecodes+1
|
2018-07-04 17:20:12 -04:00
|
|
|
allmessages(ndecodes)=msg37
|
2017-08-09 11:22:54 -04:00
|
|
|
allsnrs(ndecodes)=nsnr
|
|
|
|
endif
|
2018-07-11 14:27:53 -04:00
|
|
|
! write(81,1004) nutc,ncand,icand,ipass,iaptype,iappass, &
|
|
|
|
! nharderrors,dmin,hd,min(sync,999.0),nint(xsnr), &
|
2018-07-17 18:48:23 -04:00
|
|
|
! xdt,nint(f1),msg37,isync
|
|
|
|
!1004 format(i6.6,2i4,3i2,i3,3f6.1,i4,f6.2,i5,2x,a37,i4)
|
2018-07-11 14:27:53 -04:00
|
|
|
! flush(81)
|
2017-08-09 11:22:54 -04:00
|
|
|
if(.not.ldupe .and. associated(this%callback)) then
|
2018-07-11 14:27:53 -04:00
|
|
|
! print*,'nharderrors:',nharderrors
|
2017-08-09 11:22:54 -04:00
|
|
|
qual=1.0-(nharderrors+dmin)/60.0 ! scale qual to [0.0,1.0]
|
2017-12-19 15:01:06 -05:00
|
|
|
call this%callback(sync,nsnr,xdt,f1,msg37,iaptype,qual)
|
2017-07-20 11:15:00 -04:00
|
|
|
endif
|
2017-07-14 12:02:01 -04:00
|
|
|
endif
|
2017-07-12 17:49:39 -04:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
return
|
2017-07-08 10:06:48 -04:00
|
|
|
end subroutine decode
|
|
|
|
|
|
|
|
end module ft8_decode
|