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
|
2020-03-20 10:11:08 -04:00
|
|
|
|
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, &
|
2020-02-13 15:05:37 -05:00
|
|
|
nutc,nfa,nfb,nzhsym,ndepth,ncontest,nagain,lft8apon,lapcqonly, &
|
2020-03-19 11:00:21 -04:00
|
|
|
napwid,mycall12,hiscall12,ldiskdat)
|
2020-03-16 10:27:22 -04:00
|
|
|
use iso_c_binding, only: c_bool, c_int
|
2017-07-08 10:06:48 -04:00
|
|
|
use timer_module, only: timer
|
2020-03-16 10:27:22 -04:00
|
|
|
use shmem, only: shmem_lock, shmem_unlock
|
|
|
|
|
2017-10-30 17:30:14 -04:00
|
|
|
include 'ft8/ft8_params.f90'
|
2017-07-08 10:06:48 -04:00
|
|
|
|
|
|
|
class(ft8_decoder), intent(inout) :: this
|
|
|
|
procedure(ft8_decode_callback) :: callback
|
2020-02-13 15:05:37 -05:00
|
|
|
parameter (MAXCAND=300,MAX_EARLY=100)
|
2020-03-16 12:11:56 -04:00
|
|
|
real*8 tsec,tseq
|
2017-07-08 10:06:48 -04:00
|
|
|
real s(NH1,NHSYM)
|
2017-08-26 12:30:47 -04:00
|
|
|
real sbase(NH1)
|
2018-11-05 11:59:48 -05:00
|
|
|
real candidate(3,MAXCAND)
|
2020-03-06 10:38:24 -05:00
|
|
|
real dd(15*12000),dd1(15*12000)
|
2018-11-05 15:40:55 -05:00
|
|
|
logical, intent(in) :: lft8apon,lapcqonly,nagain
|
2020-03-06 12:54:28 -05:00
|
|
|
logical newdat,lsubtract,ldupe,lrefinedt
|
2020-03-12 15:07:56 -04:00
|
|
|
logical*1 ldiskdat
|
2020-03-06 10:38:24 -05:00
|
|
|
logical lsubtracted(MAX_EARLY)
|
2020-02-03 11:48:51 -05:00
|
|
|
character*12 mycall12,hiscall12
|
2017-07-08 10:06:48 -04:00
|
|
|
integer*2 iwave(15*12000)
|
2020-02-03 11:48:51 -05:00
|
|
|
integer apsym2(58),aph10(10)
|
2018-07-25 15:19:57 -04:00
|
|
|
character datetime*13,msg37*37
|
2018-07-04 17:20:12 -04:00
|
|
|
character*37 allmessages(100)
|
2020-03-16 12:11:56 -04:00
|
|
|
character*12 ctime
|
2017-07-20 17:08:36 -04:00
|
|
|
integer allsnrs(100)
|
2020-02-13 15:05:37 -05:00
|
|
|
integer itone(NN)
|
|
|
|
integer itone_save(NN,MAX_EARLY)
|
|
|
|
real f1_save(MAX_EARLY)
|
|
|
|
real xdt_save(MAX_EARLY)
|
|
|
|
|
2020-04-17 10:56:24 -04:00
|
|
|
save s,dd,dd1,ndec_early,itone_save,f1_save,xdt_save,lsubtracted,allmessages
|
|
|
|
|
2017-07-08 10:06:48 -04:00
|
|
|
this%callback => callback
|
|
|
|
write(datetime,1001) nutc !### TEMPORARY ###
|
|
|
|
1001 format("000000_",i6.6)
|
|
|
|
|
2020-02-03 11:48:51 -05:00
|
|
|
call ft8apset(mycall12,hiscall12,ncontest,apsym2,aph10)
|
2020-04-17 10:56:24 -04:00
|
|
|
if(nzhsym.le.47) then
|
|
|
|
dd=iwave
|
|
|
|
dd1=dd
|
|
|
|
endif
|
2020-03-05 15:37:31 -05:00
|
|
|
if(nzhsym.eq.41) then
|
2020-02-13 15:05:37 -05:00
|
|
|
ndecodes=0
|
|
|
|
allmessages=' '
|
|
|
|
allsnrs=0
|
|
|
|
else
|
|
|
|
ndecodes=ndec_early
|
|
|
|
endif
|
2020-03-06 10:38:24 -05:00
|
|
|
if(nzhsym.eq.47 .and. ndec_early.ge.1) then
|
|
|
|
lsubtracted=.false.
|
2020-03-06 12:54:28 -05:00
|
|
|
lrefinedt=.true.
|
|
|
|
if(ndepth.le.2) lrefinedt=.false.
|
2020-03-06 10:38:24 -05:00
|
|
|
call timer('sub_ft8b',0)
|
2020-02-13 15:05:37 -05:00
|
|
|
do i=1,ndec_early
|
2020-03-06 10:38:24 -05:00
|
|
|
if(xdt_save(i)-0.5.lt.0.396) then
|
2020-03-12 13:00:42 -04:00
|
|
|
call subtractft8(dd,itone_save(1,i),f1_save(i),xdt_save(i), &
|
|
|
|
lrefinedt)
|
2020-03-06 10:38:24 -05:00
|
|
|
lsubtracted(i)=.true.
|
|
|
|
endif
|
2020-03-16 12:11:56 -04:00
|
|
|
call timestamp(tsec,tseq,ctime)
|
|
|
|
if(.not.ldiskdat .and. tseq.ge.14.3d0) then !Bail out before done
|
2020-03-12 13:00:42 -04:00
|
|
|
call timer('sub_ft8b',1)
|
2020-03-12 16:36:03 -04:00
|
|
|
dd1=dd
|
2020-03-19 14:46:41 -04:00
|
|
|
go to 800
|
2020-03-12 13:00:42 -04:00
|
|
|
endif
|
2020-03-06 10:38:24 -05:00
|
|
|
enddo
|
|
|
|
call timer('sub_ft8b',1)
|
|
|
|
dd1=dd
|
|
|
|
go to 900
|
|
|
|
endif
|
|
|
|
if(nzhsym.eq.50 .and. ndec_early.ge.1) then
|
|
|
|
n=47*3456
|
|
|
|
dd(1:n)=dd1(1:n)
|
2020-03-06 20:02:41 -05:00
|
|
|
dd(n+1:)=iwave(n+1:)
|
2020-03-06 10:38:24 -05:00
|
|
|
call timer('sub_ft8c',0)
|
|
|
|
do i=1,ndec_early
|
|
|
|
if(lsubtracted(i)) cycle
|
2020-02-24 16:18:42 -05:00
|
|
|
call subtractft8(dd,itone_save(1,i),f1_save(i),xdt_save(i),.true.)
|
2020-02-13 15:05:37 -05:00
|
|
|
enddo
|
2020-03-06 10:38:24 -05:00
|
|
|
call timer('sub_ft8c',1)
|
2020-02-13 15:05:37 -05:00
|
|
|
endif
|
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:
|
2020-03-17 09:51:37 -04:00
|
|
|
! ndepth=1: subtraction, 3 passes, bp (no subtract refinement)
|
2020-03-06 12:54:28 -05:00
|
|
|
! ndepth=2: subtraction, 3 passes, bp+osd (no subtract refinement)
|
2017-08-31 16:16:38 -04:00
|
|
|
! ndepth=3: subtraction, 3 passes, bp+osd
|
2020-03-17 09:51:37 -04:00
|
|
|
npass=3
|
2017-07-12 17:49:39 -04:00
|
|
|
do ipass=1,npass
|
2020-03-08 13:03:52 -04:00
|
|
|
newdat=.true.
|
|
|
|
syncmin=1.3
|
2017-07-12 17:49:39 -04:00
|
|
|
if(ipass.eq.1) then
|
|
|
|
lsubtract=.true.
|
2020-03-17 09:51:37 -04:00
|
|
|
ndeep=ndepth
|
|
|
|
if(ndepth.eq.3) ndeep=2
|
2017-08-21 20:14:51 -04:00
|
|
|
elseif(ipass.eq.2) then
|
|
|
|
n2=ndecodes
|
|
|
|
if(ndecodes.eq.0) cycle
|
|
|
|
lsubtract=.true.
|
2020-03-17 09:51:37 -04:00
|
|
|
ndeep=ndepth
|
2017-08-21 20:14:51 -04:00
|
|
|
elseif(ipass.eq.3) then
|
|
|
|
if((ndecodes-n2).eq.0) cycle
|
2020-03-08 13:03:52 -04:00
|
|
|
lsubtract=.true.
|
2020-03-17 09:51:37 -04:00
|
|
|
ndeep=3
|
2017-07-12 17:49:39 -04:00
|
|
|
endif
|
|
|
|
call timer('sync8 ',0)
|
2018-08-08 12:05:21 -04:00
|
|
|
maxc=MAXCAND
|
2018-11-05 15:40:55 -05:00
|
|
|
call sync8(dd,ifa,ifb,syncmin,nfqso,maxc,s,candidate, &
|
2018-11-05 11:59:48 -05:00
|
|
|
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)
|
2017-08-26 12:30:47 -04:00
|
|
|
xbase=10.0**(0.1*(sbase(nint(f1/3.125))-40.0))
|
2020-04-17 10:56:24 -04:00
|
|
|
msg37=' '
|
2017-07-12 17:49:39 -04:00
|
|
|
call timer('ft8b ',0)
|
2020-03-19 11:27:57 -04:00
|
|
|
call ft8b(dd,newdat,nQSOProgress,nfqso,nftx,ndeep,nzhsym,lft8apon, &
|
2018-11-05 11:59:48 -05:00
|
|
|
lapcqonly,napwid,lsubtract,nagain,ncontest,iaptype,mycall12, &
|
2020-03-19 11:27:57 -04:00
|
|
|
hiscall12,f1,xdt,xbase,apsym2,aph10,nharderrors,dmin, &
|
|
|
|
nbadcrc,iappass,msg37,xsnr,itone)
|
2018-11-05 11:59:48 -05:00
|
|
|
call timer('ft8b ',1)
|
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
|
|
|
|
if(nbadcrc.eq.0) then
|
2017-08-09 11:22:54 -04:00
|
|
|
ldupe=.false.
|
|
|
|
do id=1,ndecodes
|
2020-02-17 11:53:52 -05:00
|
|
|
if(msg37.eq.allmessages(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
|
2020-02-13 15:05:37 -05:00
|
|
|
f1_save(ndecodes)=f1
|
2020-02-14 10:15:37 -05:00
|
|
|
xdt_save(ndecodes)=xdt+0.5
|
2020-02-13 15:05:37 -05:00
|
|
|
itone_save(1:NN,ndecodes)=itone
|
2017-08-09 11:22:54 -04:00
|
|
|
endif
|
|
|
|
if(.not.ldupe .and. associated(this%callback)) then
|
|
|
|
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
|
2020-03-16 12:11:56 -04:00
|
|
|
call timestamp(tsec,tseq,ctime)
|
2020-03-12 15:07:56 -04:00
|
|
|
if(.not.ldiskdat .and. nzhsym.eq.41 .and. &
|
2020-03-19 14:46:41 -04:00
|
|
|
tseq.ge.13.4d0) go to 800 !Bail out before done
|
2020-04-17 10:56:24 -04:00
|
|
|
enddo ! icand
|
|
|
|
enddo ! ipass
|
2020-03-16 12:11:56 -04:00
|
|
|
|
2020-03-10 16:26:42 -04:00
|
|
|
800 ndec_early=0
|
2020-02-13 15:05:37 -05:00
|
|
|
if(nzhsym.lt.50) ndec_early=ndecodes
|
|
|
|
|
2020-03-06 10:38:24 -05:00
|
|
|
900 return
|
2020-02-13 15:05:37 -05:00
|
|
|
end subroutine decode
|
2017-07-08 10:06:48 -04:00
|
|
|
|
2020-03-16 12:11:56 -04:00
|
|
|
subroutine timestamp(tsec,tseq,ctime)
|
|
|
|
real*8 tsec,tseq
|
|
|
|
character*12 ctime
|
|
|
|
integer itime(8)
|
|
|
|
call date_and_time(values=itime)
|
|
|
|
tsec=3600.d0*(itime(5)-itime(4)/60.d0) + 60.d0*itime(6) + &
|
|
|
|
itime(7) + 0.001d0*itime(8)
|
|
|
|
tsec=mod(tsec+2*86400.d0,86400.d0)
|
|
|
|
tseq=mod(itime(7)+0.001d0*itime(8),15.d0)
|
|
|
|
if(tseq.lt.10.d0) tseq=tseq+15.d0
|
|
|
|
sec=itime(7)+0.001*itime(8)
|
|
|
|
write(ctime,1000) itime(5)-itime(4)/60,itime(6),sec
|
|
|
|
1000 format(i2.2,':',i2.2,':',f6.3)
|
|
|
|
if(ctime(7:7).eq.' ') ctime(7:7)='0'
|
|
|
|
return
|
|
|
|
end subroutine timestamp
|
|
|
|
|
2017-07-08 10:06:48 -04:00
|
|
|
end module ft8_decode
|