2021-01-13 11:21:59 -05:00
|
|
|
subroutine q65_loops(c00,npts2,nsps2,nsubmode,ndepth,jpk0, &
|
2020-12-30 15:05:02 -05:00
|
|
|
xdt0,f0,iaptype,xdt1,f1,snr2,dat4,idec)
|
2020-10-27 13:08:07 -04:00
|
|
|
|
|
|
|
use packjt77
|
|
|
|
use timer_module, only: timer
|
2021-01-08 09:42:07 -05:00
|
|
|
use q65
|
|
|
|
|
2020-11-29 10:00:33 -05:00
|
|
|
parameter (NN=63)
|
2021-01-27 13:19:39 -05:00
|
|
|
parameter (LN=2176*63) !LN=LL*NN; LL=64*(mode_q65+2), NN=63
|
2020-10-27 13:08:07 -04:00
|
|
|
complex c00(0:npts2-1) !Analytic representation of dd(), 6000 Hz
|
|
|
|
complex ,allocatable :: c0(:) !Ditto, with freq shift
|
2020-12-28 15:27:10 -05:00
|
|
|
character decoded*37
|
2020-10-27 13:08:07 -04:00
|
|
|
real a(3) !twkfreq params f,f1,f2
|
2021-04-15 13:52:18 -04:00
|
|
|
real,allocatable :: s3(:) !Symbol spectra
|
2020-11-03 15:49:11 -05:00
|
|
|
integer dat4(13) !Decoded message (as 13 six-bit integers)
|
2020-10-27 13:08:07 -04:00
|
|
|
integer nap(0:11) !AP return codes
|
2020-12-27 15:27:26 -05:00
|
|
|
data nap/0,2,3,2,3,4,2,3,6,4,6,6/
|
2020-11-23 14:30:36 -05:00
|
|
|
|
2021-04-15 13:52:18 -04:00
|
|
|
LL=64*(mode_q65+2)
|
|
|
|
allocate(s3(LL*NN))
|
|
|
|
allocate(c0(0:npts2-1))
|
2020-12-30 15:05:02 -05:00
|
|
|
idec=-1
|
2020-11-02 15:59:10 -05:00
|
|
|
ircbest=9999
|
2020-10-27 13:08:07 -04:00
|
|
|
irc=-99
|
|
|
|
s3lim=20.
|
2021-01-13 11:07:20 -05:00
|
|
|
baud=6000.0/nsps2
|
2020-11-20 17:07:11 -05:00
|
|
|
|
2021-04-21 15:57:54 -04:00
|
|
|
idfmax=1
|
|
|
|
idtmax=1
|
|
|
|
maxdist=4
|
2020-12-30 15:05:02 -05:00
|
|
|
ibw0=(ibwa+ibwb)/2
|
2021-04-21 15:57:54 -04:00
|
|
|
if(iand(ndepth,3).eq.2) then
|
|
|
|
idfmax=3
|
|
|
|
idtmax=3
|
|
|
|
maxdist=5
|
|
|
|
endif
|
|
|
|
if(iand(ndepth,3).eq.3) then
|
2020-11-20 17:07:11 -05:00
|
|
|
idfmax=5
|
|
|
|
idtmax=5
|
2021-04-21 15:57:54 -04:00
|
|
|
maxdist=15
|
2020-11-20 17:07:11 -05:00
|
|
|
endif
|
2021-01-08 09:42:07 -05:00
|
|
|
|
2020-10-27 13:08:07 -04:00
|
|
|
napmin=99
|
2020-11-13 13:40:16 -05:00
|
|
|
xdt1=xdt0
|
|
|
|
f1=f0
|
2021-02-25 12:45:07 -05:00
|
|
|
idfbest=0
|
|
|
|
idtbest=0
|
|
|
|
ndistbest=0
|
2020-11-29 10:00:33 -05:00
|
|
|
|
2020-11-30 14:13:37 -05:00
|
|
|
do idf=1,idfmax
|
|
|
|
ndf=idf/2
|
|
|
|
if(mod(idf,2).eq.0) ndf=-ndf
|
|
|
|
a=0.
|
|
|
|
a(1)=-(f0+0.5*baud*ndf)
|
2021-05-29 13:18:11 -04:00
|
|
|
! Variable 'drift' is frequency increase over full TxT. Therefore we want:
|
2021-05-27 12:20:20 -04:00
|
|
|
a(2)=-0.5*drift
|
2020-11-30 14:13:37 -05:00
|
|
|
call twkfreq(c00,c0,npts2,6000.0,a)
|
|
|
|
do idt=1,idtmax
|
|
|
|
ndt=idt/2
|
2021-01-01 15:28:41 -05:00
|
|
|
if(mod(idt,2).eq.0) ndt=-ndt
|
2021-01-13 11:07:20 -05:00
|
|
|
jpk=jpk0 + nsps2*ndt/16 !tsym/16
|
2021-06-29 17:35:07 -04:00
|
|
|
jpk=max(0,jpk)
|
|
|
|
jpk=min(29000,jpk)
|
2021-06-30 10:40:38 -04:00
|
|
|
call spec64(c0,npts2,nsps2,mode_q65,jpk,s3,LL,NN)
|
2021-01-01 15:28:41 -05:00
|
|
|
call pctile(s3,LL*NN,40,base)
|
|
|
|
s3=s3/base
|
|
|
|
where(s3(1:LL*NN)>s3lim) s3(1:LL*NN)=s3lim
|
2021-02-12 13:26:22 -05:00
|
|
|
call q65_bzap(s3,LL) !Zap birdies
|
2020-12-30 15:05:02 -05:00
|
|
|
do ibw=ibwa,ibwb
|
2021-02-23 16:13:46 -05:00
|
|
|
ndist=ndf**2 + ndt**2 + (ibw-ibw0)**2
|
2020-11-30 14:13:37 -05:00
|
|
|
if(ndist.gt.maxdist) cycle
|
2020-12-30 15:05:02 -05:00
|
|
|
b90=1.72**ibw
|
2020-12-20 21:43:30 -05:00
|
|
|
if(b90.gt.345.0) cycle
|
2020-11-30 14:13:37 -05:00
|
|
|
b90ts = b90/baud
|
2021-01-01 10:47:22 -05:00
|
|
|
call timer('dec2 ',0)
|
2020-12-28 15:27:10 -05:00
|
|
|
call q65_dec2(s3,nsubmode,b90ts,esnodb,irc,dat4,decoded)
|
2021-01-01 10:47:22 -05:00
|
|
|
call timer('dec2 ',1)
|
2020-10-27 15:51:32 -04:00
|
|
|
! irc > 0 ==> number of iterations required to decode
|
|
|
|
! -1 = invalid params
|
|
|
|
! -2 = decode failed
|
|
|
|
! -3 = CRC mismatch
|
2021-02-25 12:45:07 -05:00
|
|
|
if(irc.ge.0) then
|
|
|
|
idfbest=idf
|
|
|
|
idtbest=idt
|
|
|
|
ndistbest=ndist
|
|
|
|
nrc=irc
|
|
|
|
go to 100
|
|
|
|
endif
|
2020-11-30 14:13:37 -05:00
|
|
|
enddo ! ibw (b90 loop)
|
|
|
|
enddo ! idt (DT loop)
|
|
|
|
enddo ! idf (f0 loop)
|
2020-12-27 15:27:26 -05:00
|
|
|
|
2020-11-29 10:00:33 -05:00
|
|
|
100 if(irc.ge.0) then
|
2021-01-14 13:13:40 -05:00
|
|
|
idec=iaptype
|
2020-10-30 14:52:58 -04:00
|
|
|
snr2=esnodb - db(2500.0/baud)
|
2021-01-13 11:07:20 -05:00
|
|
|
xdt1=xdt0 + nsps2*ndt/(16.0*6000.0)
|
2020-11-13 13:40:16 -05:00
|
|
|
f1=f0 + 0.5*baud*ndf
|
2020-10-27 13:08:07 -04:00
|
|
|
endif
|
2020-11-02 15:59:10 -05:00
|
|
|
|
2020-10-27 13:08:07 -04:00
|
|
|
return
|
|
|
|
end subroutine q65_loops
|