2020-11-15 12:21:08 -05:00
|
|
|
subroutine q65_loops(c00,nutc,npts2,nsps,mode,mode64,nsubmode,nFadingModel, &
|
2020-11-13 13:40:16 -05:00
|
|
|
ndepth,jpk0,xdt0,f0,width,iaptype,APmask,APsymbols,snr1,xdt1,f1, &
|
|
|
|
snr2,irc,dat4)
|
2020-10-27 13:08:07 -04:00
|
|
|
|
|
|
|
use packjt77
|
|
|
|
use timer_module, only: timer
|
|
|
|
parameter (LN=2176*63) !LN=LL*NN; LL = 64*(mode64+2)
|
|
|
|
character*37 decoded
|
|
|
|
character*77 c77
|
|
|
|
complex c00(0:npts2-1) !Analytic representation of dd(), 6000 Hz
|
|
|
|
complex ,allocatable :: c0(:) !Ditto, with freq shift
|
|
|
|
real a(3) !twkfreq params f,f1,f2
|
|
|
|
real s3(LN) !Symbol spectra
|
|
|
|
real s3avg(LN) !Averaged symbol spectra
|
|
|
|
real s3prob(LN) !Symbol-value probabilities
|
|
|
|
logical unpk77_success
|
|
|
|
integer APmask(13)
|
|
|
|
integer APsymbols(13)
|
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
|
|
|
|
data nap/0,2,3,2,3,4,2,3,6,4,6,6/,nsave/0/
|
|
|
|
save nsave,s3avg
|
|
|
|
|
2020-11-02 15:59:10 -05:00
|
|
|
ircbest=9999
|
2020-10-27 13:08:07 -04:00
|
|
|
allocate(c0(0:npts2-1))
|
|
|
|
irc=-99
|
|
|
|
s3lim=20.
|
2020-11-20 17:07:11 -05:00
|
|
|
|
|
|
|
idfmax=3
|
|
|
|
idtmax=3
|
2020-11-11 15:06:24 -05:00
|
|
|
ibwmin=1
|
|
|
|
ibwmax=2
|
|
|
|
maxdist=15
|
2020-11-20 17:07:11 -05:00
|
|
|
if(ndepth.ge.2) then
|
|
|
|
idfmax=5
|
|
|
|
idtmax=5
|
|
|
|
maxdist=25
|
|
|
|
endif
|
|
|
|
if(ndepth.eq.3) then
|
|
|
|
ibwmax=5
|
|
|
|
endif
|
2020-10-27 13:08:07 -04:00
|
|
|
LL=64*(mode64+2)
|
|
|
|
NN=63
|
|
|
|
napmin=99
|
2020-11-02 15:59:10 -05:00
|
|
|
baud=6000.0/nsps
|
2020-11-13 13:40:16 -05:00
|
|
|
xdt1=xdt0
|
|
|
|
f1=f0
|
2020-11-11 11:14:02 -05:00
|
|
|
|
|
|
|
maxavg=0
|
|
|
|
if(iand(ndepth,16).ne.0) maxavg=1
|
|
|
|
do iavg=0,maxavg
|
2020-10-27 13:08:07 -04:00
|
|
|
if(iavg.eq.1) then
|
|
|
|
idfmax=1
|
|
|
|
idtmax=1
|
|
|
|
endif
|
|
|
|
do idf=1,idfmax
|
|
|
|
ndf=idf/2
|
|
|
|
if(mod(idf,2).eq.0) ndf=-ndf
|
|
|
|
a=0.
|
2020-11-02 15:59:10 -05:00
|
|
|
a(1)=-(f0+0.5*baud*ndf)
|
2020-10-27 13:08:07 -04:00
|
|
|
call twkfreq(c00,c0,npts2,6000.0,a)
|
|
|
|
do idt=1,idtmax
|
|
|
|
ndt=idt/2
|
2020-11-11 15:06:24 -05:00
|
|
|
if(iaptype.eq.0 .and. iavg.eq.0) then
|
2020-10-27 13:08:07 -04:00
|
|
|
if(mod(idt,2).eq.0) ndt=-ndt
|
2020-11-02 15:59:10 -05:00
|
|
|
jpk=jpk0 + nsps*ndt/16 !tsym/16
|
2020-10-27 13:08:07 -04:00
|
|
|
if(jpk.lt.0) jpk=0
|
|
|
|
call timer('spec64 ',0)
|
|
|
|
call spec64(c0,nsps,mode,mode64,jpk,s3,LL,NN)
|
|
|
|
call timer('spec64 ',1)
|
|
|
|
call pctile(s3,LL*NN,40,base)
|
|
|
|
s3=s3/base
|
|
|
|
where(s3(1:LL*NN)>s3lim) s3(1:LL*NN)=s3lim
|
2020-11-10 10:14:41 -05:00
|
|
|
endif
|
|
|
|
if(iavg.eq.1) then
|
2020-10-27 13:08:07 -04:00
|
|
|
s3(1:LL*NN)=s3avg(1:LL*NN)
|
|
|
|
endif
|
2020-11-02 15:59:10 -05:00
|
|
|
do ibw=ibwmin,ibwmax
|
|
|
|
nbw=ibw
|
|
|
|
ndist=ndf**2 + ndt**2 + ((nbw-2))**2
|
2020-10-27 13:08:07 -04:00
|
|
|
if(ndist.gt.maxdist) cycle
|
2020-11-02 15:59:10 -05:00
|
|
|
! b90=1.728**ibw
|
|
|
|
b90=3.0**nbw
|
2020-10-27 13:08:07 -04:00
|
|
|
if(b90.gt.230.0) cycle
|
2020-10-27 13:22:02 -04:00
|
|
|
! if(b90.lt.0.15*width) exit
|
2020-10-31 11:33:01 -04:00
|
|
|
call timer('q65_intr',0)
|
2020-10-28 09:28:50 -04:00
|
|
|
call q65_intrinsics_ff(s3,nsubmode,b90,nFadingModel,s3prob)
|
2020-10-31 11:33:01 -04:00
|
|
|
call timer('q65_intr',1)
|
|
|
|
|
|
|
|
call timer('q65_dec ',0)
|
2020-10-30 14:52:58 -04:00
|
|
|
call q65_dec(s3,s3prob,APmask,APsymbols,esnodb,dat4,irc)
|
2020-10-31 11:33:01 -04:00
|
|
|
call timer('q65_dec ',1)
|
2020-11-02 15:59:10 -05:00
|
|
|
if(irc.ge.0) go to 100
|
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
|
2020-10-27 13:08:07 -04:00
|
|
|
enddo ! ibw (b90 loop)
|
|
|
|
enddo ! idt (DT loop)
|
|
|
|
enddo ! idf (f0 loop)
|
2020-11-11 15:06:24 -05:00
|
|
|
if(iaptype.eq.0 .and. iavg.eq.0) then
|
2020-10-27 13:08:07 -04:00
|
|
|
a=0.
|
|
|
|
a(1)=-f0
|
|
|
|
call twkfreq(c00,c0,npts2,6000.0,a)
|
2020-11-02 15:59:10 -05:00
|
|
|
jpk=3000 !### Are these definitions OK?
|
2020-10-30 14:52:58 -04:00
|
|
|
if(nsps.ge.3600) jpk=6000 !### TR >= 60 s
|
2020-10-27 13:08:07 -04:00
|
|
|
call spec64(c0,nsps,mode,mode64,jpk,s3,LL,NN)
|
|
|
|
call pctile(s3,LL*NN,40,base)
|
|
|
|
s3=s3/base
|
|
|
|
where(s3(1:LL*NN)>s3lim) s3(1:LL*NN)=s3lim
|
|
|
|
s3avg(1:LL*NN)=s3avg(1:LL*NN)+s3(1:LL*NN)
|
|
|
|
nsave=nsave+1
|
|
|
|
endif
|
|
|
|
if(iavg.eq.0 .and. nsave.lt.2) exit
|
2020-10-28 12:04:10 -04:00
|
|
|
enddo ! iavg
|
2020-10-27 13:08:07 -04:00
|
|
|
|
2020-11-02 15:59:10 -05:00
|
|
|
100 if(irc.ge.0) then
|
2020-10-27 13:08:07 -04:00
|
|
|
navg=nsave
|
2020-10-30 14:52:58 -04:00
|
|
|
snr2=esnodb - db(2500.0/baud)
|
2020-10-27 13:08:07 -04:00
|
|
|
if(iavg.eq.0) navg=0
|
2020-11-13 13:40:16 -05:00
|
|
|
xdt1=xdt0 + nsps*ndt/(16.0*6000.0)
|
|
|
|
f1=f0 + 0.5*baud*ndf
|
2020-11-02 15:59:10 -05:00
|
|
|
!### For tests only:
|
2020-11-03 15:49:11 -05:00
|
|
|
open(53,file='fort.53',status='unknown',position='append')
|
2020-11-11 15:06:24 -05:00
|
|
|
write(c77,1100) dat4(1:12),dat4(13)/2
|
2020-10-28 12:04:10 -04:00
|
|
|
1100 format(12b6.6,b5.5)
|
2020-10-27 13:08:07 -04:00
|
|
|
call unpack77(c77,0,decoded,unpk77_success) !Unpack to get msgsent
|
2020-11-16 13:49:31 -05:00
|
|
|
m=nutc
|
|
|
|
if(nsps.ge.3600) m=100*m
|
|
|
|
ihr=m/10000
|
|
|
|
imin=mod(m/100,100)
|
|
|
|
isec=mod(m,100)
|
|
|
|
hours=ihr + imin/60.0 + isec/3600.0
|
|
|
|
write(53,3053) m,hours,ndf,ndt,nbw,ndist,irc,iaptype,navg,snr1, &
|
|
|
|
xdt1,f1,snr2,trim(decoded)
|
|
|
|
3053 format(i6.6,f8.4,4i3,i4,2i3,f6.1,f6.2,f7.1,f6.1,1x,a)
|
2020-11-03 15:49:11 -05:00
|
|
|
close(53)
|
2020-11-02 15:59:10 -05:00
|
|
|
!###
|
2020-10-27 13:08:07 -04:00
|
|
|
nsave=0
|
|
|
|
s3avg=0.
|
|
|
|
irc=irc + 100*navg
|
|
|
|
endif
|
2020-11-02 15:59:10 -05:00
|
|
|
|
2020-10-27 13:08:07 -04:00
|
|
|
return
|
|
|
|
end subroutine q65_loops
|