2020-10-25 13:58:18 -04:00
|
|
|
module q65_decode
|
2020-08-01 09:24:59 -04:00
|
|
|
|
2020-10-25 13:58:18 -04:00
|
|
|
type :: q65_decoder
|
|
|
|
procedure(q65_decode_callback), pointer :: callback
|
2020-08-01 09:24:59 -04:00
|
|
|
contains
|
|
|
|
procedure :: decode
|
2020-10-25 13:58:18 -04:00
|
|
|
end type q65_decoder
|
2020-08-01 09:24:59 -04:00
|
|
|
|
|
|
|
abstract interface
|
2020-10-25 13:58:18 -04:00
|
|
|
subroutine q65_decode_callback (this,nutc,sync,nsnr,dt,freq, &
|
2020-08-01 09:24:59 -04:00
|
|
|
decoded,nap,qual,ntrperiod,fmid,w50)
|
2020-10-25 13:58:18 -04:00
|
|
|
import q65_decoder
|
2020-08-01 09:24:59 -04:00
|
|
|
implicit none
|
2020-10-25 13:58:18 -04:00
|
|
|
class(q65_decoder), intent(inout) :: this
|
2020-08-01 09:24:59 -04:00
|
|
|
integer, intent(in) :: nutc
|
|
|
|
real, intent(in) :: sync
|
|
|
|
integer, intent(in) :: nsnr
|
|
|
|
real, intent(in) :: dt
|
|
|
|
real, intent(in) :: freq
|
|
|
|
character(len=37), intent(in) :: decoded
|
|
|
|
integer, intent(in) :: nap
|
|
|
|
real, intent(in) :: qual
|
|
|
|
integer, intent(in) :: ntrperiod
|
|
|
|
real, intent(in) :: fmid
|
|
|
|
real, intent(in) :: w50
|
2020-10-25 13:58:18 -04:00
|
|
|
end subroutine q65_decode_callback
|
2020-08-01 09:24:59 -04:00
|
|
|
end interface
|
|
|
|
|
|
|
|
contains
|
|
|
|
|
2020-08-09 11:04:49 -04:00
|
|
|
subroutine decode(this,callback,iwave,nutc,ntrperiod,nsubmode,nfqso, &
|
2020-10-29 10:53:30 -04:00
|
|
|
ntol,ndepth,mycall,hiscall,hisgrid,nQSOprogress,ncontest,lapcqonly)
|
2020-08-01 09:24:59 -04:00
|
|
|
|
2020-10-25 13:58:18 -04:00
|
|
|
! Decodes Q65 signals
|
2020-10-09 13:16:25 -04:00
|
|
|
! Input: iwave Raw data, i*2
|
|
|
|
! nutc UTC for time-tagging the decode
|
|
|
|
! ntrperiod T/R sequence length (s)
|
|
|
|
! nsubmode Tone-spacing indicator, 0-4 for A-E
|
|
|
|
! nfqso Target signal frequency (Hz)
|
|
|
|
! ntol Search range around nfqso (Hz)
|
2020-11-11 11:14:02 -05:00
|
|
|
! ndepth Optional decoding level
|
2020-10-09 13:16:25 -04:00
|
|
|
! Output: sent to the callback routine for display to user
|
|
|
|
|
2020-08-01 09:24:59 -04:00
|
|
|
use timer_module, only: timer
|
2020-10-27 13:08:07 -04:00
|
|
|
use packjt77
|
2020-08-01 09:24:59 -04:00
|
|
|
use, intrinsic :: iso_c_binding
|
2020-10-09 13:16:25 -04:00
|
|
|
parameter (NMAX=300*12000) !Max TRperiod is 300 s
|
2020-10-25 13:58:18 -04:00
|
|
|
class(q65_decoder), intent(inout) :: this
|
|
|
|
procedure(q65_decode_callback) :: callback
|
2020-10-09 13:16:25 -04:00
|
|
|
character(len=12) :: mycall, hiscall !Used for AP decoding
|
2020-08-01 09:24:59 -04:00
|
|
|
character(len=6) :: hisgrid
|
2020-10-09 13:16:25 -04:00
|
|
|
character*37 decoded !Decoded message
|
2020-10-27 13:08:07 -04:00
|
|
|
character*77 c77
|
2020-10-30 11:07:44 -04:00
|
|
|
character*78 c78
|
2020-08-08 09:14:12 -04:00
|
|
|
integer*2 iwave(NMAX) !Raw data
|
2020-10-17 13:16:46 -04:00
|
|
|
real, allocatable :: dd(:) !Raw data
|
2020-10-27 13:22:02 -04:00
|
|
|
integer dat4(13) !Decoded message as 12 6-bit integers
|
2020-10-30 11:07:44 -04:00
|
|
|
integer apsym0(58),aph10(10)
|
|
|
|
integer apmask1(78),apsymbols1(78)
|
|
|
|
integer apmask(13),apsymbols(13)
|
2020-10-29 10:33:54 -04:00
|
|
|
logical lapcqonly,unpk77_success
|
2020-10-09 13:16:25 -04:00
|
|
|
complex, allocatable :: c00(:) !Analytic signal, 6000 Sa/s
|
|
|
|
complex, allocatable :: c0(:) !Analytic signal, 6000 Sa/s
|
2020-08-01 12:13:49 -04:00
|
|
|
|
2020-09-25 12:21:57 -04:00
|
|
|
mode65=2**nsubmode
|
2020-11-15 12:21:08 -05:00
|
|
|
npts=ntrperiod*12000
|
2020-08-08 09:14:12 -04:00
|
|
|
nfft1=ntrperiod*12000
|
|
|
|
nfft2=ntrperiod*6000
|
2020-11-15 12:21:08 -05:00
|
|
|
allocate(dd(npts))
|
2020-10-08 16:48:11 -04:00
|
|
|
allocate (c00(0:nfft1-1))
|
2020-08-08 13:57:24 -04:00
|
|
|
allocate (c0(0:nfft1-1))
|
2020-08-09 11:04:49 -04:00
|
|
|
|
2020-08-08 09:14:12 -04:00
|
|
|
if(ntrperiod.eq.15) then
|
|
|
|
nsps=1800
|
|
|
|
else if(ntrperiod.eq.30) then
|
|
|
|
nsps=3600
|
|
|
|
else if(ntrperiod.eq.60) then
|
2020-10-25 14:10:38 -04:00
|
|
|
nsps=7200
|
2020-08-08 09:14:12 -04:00
|
|
|
else if(ntrperiod.eq.120) then
|
|
|
|
nsps=16000
|
|
|
|
else if(ntrperiod.eq.300) then
|
|
|
|
nsps=41472
|
|
|
|
else
|
2020-10-09 14:12:34 -04:00
|
|
|
stop 'Invalid TR period'
|
|
|
|
endif
|
|
|
|
baud=12000.0/nsps
|
|
|
|
df1=12000.0/nfft1
|
2020-10-29 10:53:30 -04:00
|
|
|
this%callback => callback
|
2020-10-09 14:12:34 -04:00
|
|
|
if(nutc.eq.-999) print*,lapdx,nfa,nfb,nfqso !Silence warning
|
|
|
|
nFadingModel=1
|
2020-11-11 15:06:24 -05:00
|
|
|
! call qra_params(ndepth,maxaptype,idfmax,idtmax,ibwmin,ibwmax,maxdist)
|
2020-10-09 14:12:34 -04:00
|
|
|
call timer('sync_q65',0)
|
2020-11-02 15:59:10 -05:00
|
|
|
call sync_q65(iwave,ntrperiod*12000,mode65,nsps,nfqso,ntol,xdt,f0, &
|
|
|
|
snr1,width)
|
2020-10-09 14:12:34 -04:00
|
|
|
call timer('sync_q65',1)
|
|
|
|
|
2020-11-16 16:29:52 -05:00
|
|
|
irc=-9
|
2020-11-03 10:36:19 -05:00
|
|
|
if(snr1.lt.2.8) go to 100
|
2020-11-02 15:59:10 -05:00
|
|
|
jpk0=(xdt+1.0)*6000 !### Is this OK?
|
2020-10-30 11:07:44 -04:00
|
|
|
if(ntrperiod.le.30) jpk0=(xdt+0.5)*6000 !###
|
|
|
|
if(jpk0.lt.0) jpk0=0
|
|
|
|
fac=1.0/32767.0
|
2020-11-15 12:21:08 -05:00
|
|
|
dd=fac*iwave(1:npts)
|
|
|
|
!###
|
|
|
|
! Optionslly write noise level to LU 56
|
|
|
|
! sq=dot_product(dd,dd)/npts
|
|
|
|
! m=nutc
|
|
|
|
! if(ntrperiod.ge.60) m=100*m
|
|
|
|
! ihr=m/10000
|
|
|
|
! imin=mod(m/100,100)
|
|
|
|
! isec=mod(m,100)
|
|
|
|
! hours=ihr + imin/60.0 + isec/3600.0
|
|
|
|
! write(56,3056) m,hours,db(sq)+90.3
|
|
|
|
!3056 format(i6.6,f10.6,f10.3)
|
|
|
|
!###
|
2020-10-30 11:07:44 -04:00
|
|
|
nmode=65
|
|
|
|
call ana64(dd,npts,c00)
|
|
|
|
|
|
|
|
call ft8apset(mycall,hiscall,ncontest,apsym0,aph10)
|
|
|
|
where(apsym0.eq.-1) apsym0=0
|
|
|
|
|
|
|
|
npasses=2
|
|
|
|
if(nQSOprogress.eq.5) npasses=3
|
|
|
|
if(lapcqonly) npasses=1
|
2020-11-11 15:06:24 -05:00
|
|
|
iaptype=0
|
2020-10-30 11:07:44 -04:00
|
|
|
do ipass=0,npasses
|
|
|
|
apmask=0
|
|
|
|
apsymbols=0
|
|
|
|
if(ipass.ge.1) then
|
2020-11-11 15:06:24 -05:00
|
|
|
call q65_ap(nQSOprogress,ipass,ncontest,lapcqonly,iaptype, &
|
|
|
|
apsym0,apmask1,apsymbols1)
|
2020-10-30 11:07:44 -04:00
|
|
|
write(c78,1050) apmask1
|
|
|
|
1050 format(78i1)
|
|
|
|
read(c78,1060) apmask
|
|
|
|
1060 format(13b6.6)
|
|
|
|
write(c78,1050) apsymbols1
|
|
|
|
read(c78,1060) apsymbols
|
|
|
|
endif
|
2020-10-27 13:08:07 -04:00
|
|
|
call timer('q65loops',0)
|
2020-11-23 00:03:59 -05:00
|
|
|
! call q65_loops(c00,nutc,npts/2,nsps/2,nmode,mode65,nsubmode, &
|
|
|
|
! nFadingModel,ndepth,jpk0,xdt,f0,width,iaptype,apmask,apsymbols, &
|
|
|
|
! snr1,xdt1,f1,snr2,irc,dat4)
|
|
|
|
! baud rate required to compute B90TS later
|
2020-11-15 12:21:08 -05:00
|
|
|
call q65_loops(c00,nutc,npts/2,nsps/2,nmode,mode65,nsubmode, &
|
|
|
|
nFadingModel,ndepth,jpk0,xdt,f0,width,iaptype,apmask,apsymbols, &
|
2020-11-23 00:03:59 -05:00
|
|
|
snr1,xdt1,f1,snr2,irc,dat4,baud)
|
2020-10-27 13:08:07 -04:00
|
|
|
call timer('q65loops',1)
|
2020-10-19 15:24:32 -04:00
|
|
|
snr2=snr2 + db(6912.0/nsps)
|
2020-11-13 13:40:16 -05:00
|
|
|
if(irc.ge.0) exit
|
2020-10-30 11:07:44 -04:00
|
|
|
enddo
|
|
|
|
|
|
|
|
100 decoded=' '
|
2020-08-01 09:24:59 -04:00
|
|
|
if(irc.ge.0) then
|
2020-11-02 15:59:10 -05:00
|
|
|
!###
|
2020-10-30 11:07:44 -04:00
|
|
|
navg=irc/100
|
2020-11-11 15:06:24 -05:00
|
|
|
! irc=100*navg + ipass
|
|
|
|
irc=100*navg + iaptype
|
2020-10-30 11:07:44 -04:00
|
|
|
!###
|
2020-11-11 15:06:24 -05:00
|
|
|
write(c77,1000) dat4(1:12),dat4(13)/2
|
2020-10-27 13:08:07 -04:00
|
|
|
1000 format(12b6.6,b5.5)
|
|
|
|
call unpack77(c77,0,decoded,unpk77_success) !Unpack to get msgsent
|
2020-08-01 09:24:59 -04:00
|
|
|
nsnr=nint(snr2)
|
2020-11-13 13:40:16 -05:00
|
|
|
call this%callback(nutc,sync,nsnr,xdt1,f1,decoded, &
|
2020-08-01 12:13:49 -04:00
|
|
|
irc,qual,ntrperiod,fmid,w50)
|
2020-08-01 09:24:59 -04:00
|
|
|
else
|
2020-11-02 15:59:10 -05:00
|
|
|
! Report sync, even if no decode.
|
2020-10-27 16:08:50 -04:00
|
|
|
nsnr=db(snr1) - 35.0
|
2020-11-13 13:40:16 -05:00
|
|
|
call this%callback(nutc,sync,nsnr,xdt1,f1,decoded, &
|
2020-08-01 15:12:37 -04:00
|
|
|
irc,qual,ntrperiod,fmid,w50)
|
2020-08-01 09:24:59 -04:00
|
|
|
endif
|
2020-08-01 15:12:37 -04:00
|
|
|
|
2020-08-01 09:24:59 -04:00
|
|
|
return
|
|
|
|
end subroutine decode
|
|
|
|
|
2020-10-25 13:58:18 -04:00
|
|
|
end module q65_decode
|