2020-11-30 14:13:37 -05:00
|
|
|
subroutine q65_loops(c00,npts2,nsps,mode,mode_q65,nsubmode,nFadingModel, &
|
2020-12-19 13:25:51 -05:00
|
|
|
ndepth,jpk0,xdt0,f0,width,iaptype,APmask,APsymbols,xdt1,f1,snr2,dat4,id2)
|
2020-10-27 13:08:07 -04:00
|
|
|
|
|
|
|
use packjt77
|
|
|
|
use timer_module, only: timer
|
2020-11-29 10:00:33 -05:00
|
|
|
parameter (NN=63)
|
|
|
|
parameter (LN=1152*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-24 13:07:29 -05:00
|
|
|
! character c77*77,decoded*37
|
|
|
|
! logical unpk77_success
|
2020-10-27 13:08:07 -04:00
|
|
|
real a(3) !twkfreq params f,f1,f2
|
|
|
|
real s3(LN) !Symbol spectra
|
2020-11-29 10:00:33 -05:00
|
|
|
real s3prob(64*NN) !Symbol-value probabilities
|
2020-10-27 13:08:07 -04:00
|
|
|
integer APmask(13)
|
|
|
|
integer APsymbols(13)
|
2020-11-29 10:00:33 -05:00
|
|
|
integer cw4(63)
|
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-29 10:00:33 -05:00
|
|
|
data cw4/0, 0, 0, 0, 8, 4,60,35,17,48,33,25,34,43,43,43,35,15,46,30, &
|
|
|
|
54,24,26,26,57,57,42, 3,23,11,49,49,16, 2, 6, 6,55,21,39,51, &
|
|
|
|
51,51,42,42,50,25,31,35,57,30, 1,54,54,10,10,22,44,58,57,40, &
|
|
|
|
21,21,19/
|
2020-11-23 14:30:36 -05:00
|
|
|
|
2020-11-30 14:13:37 -05:00
|
|
|
id2=-1
|
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-12-20 21:43:30 -05:00
|
|
|
ibwmin=1
|
|
|
|
ibwmax=3
|
2020-11-21 11:34:17 -05:00
|
|
|
maxdist=5
|
|
|
|
if(iand(ndepth,3).ge.2) then
|
2020-11-20 17:07:11 -05:00
|
|
|
idfmax=5
|
|
|
|
idtmax=5
|
2020-11-21 11:34:17 -05:00
|
|
|
maxdist=15
|
2020-11-20 17:07:11 -05:00
|
|
|
endif
|
2020-11-21 11:34:17 -05:00
|
|
|
if(iand(ndepth,3).eq.3) then
|
2020-11-20 17:07:11 -05:00
|
|
|
ibwmax=5
|
|
|
|
endif
|
2020-11-23 14:30:36 -05:00
|
|
|
LL=64*(mode_q65+2)
|
2020-10-27 13:08:07 -04:00
|
|
|
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-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)
|
|
|
|
call twkfreq(c00,c0,npts2,6000.0,a)
|
|
|
|
do idt=1,idtmax
|
|
|
|
ndt=idt/2
|
|
|
|
if(iaptype.eq.0) then
|
|
|
|
if(mod(idt,2).eq.0) ndt=-ndt
|
|
|
|
jpk=jpk0 + nsps*ndt/16 !tsym/16
|
|
|
|
if(jpk.lt.0) jpk=0
|
|
|
|
call timer('spec64 ',0)
|
|
|
|
call spec64(c0,nsps,mode,mode_q65,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
|
|
|
|
endif
|
|
|
|
do ibw=ibwmin,ibwmax
|
2020-12-20 21:43:30 -05:00
|
|
|
nbw=ibw/2
|
|
|
|
if(mod(ibw,2).eq.0) nbw=-nbw
|
|
|
|
ndist=ndf**2 + ndt**2 + nbw**2
|
2020-11-30 14:13:37 -05:00
|
|
|
if(ndist.gt.maxdist) cycle
|
2020-12-20 21:43:30 -05:00
|
|
|
xx=1.885*log(3.0*width)+nbw
|
|
|
|
b90=1.7**xx
|
|
|
|
if(b90.gt.345.0) cycle
|
2020-11-30 14:13:37 -05:00
|
|
|
call timer('q65_intr',0)
|
|
|
|
b90ts = b90/baud
|
|
|
|
call q65_intrinsics_ff(s3,nsubmode,b90ts,nFadingModel,s3prob)
|
|
|
|
call timer('q65_intr',1)
|
|
|
|
call timer('q65_dec ',0)
|
|
|
|
call q65_dec(s3,s3prob,APmask,APsymbols,esnodb,dat4,irc)
|
|
|
|
call timer('q65_dec ',1)
|
2020-12-27 15:27:26 -05:00
|
|
|
print*,'H',ibw,irc,iaptype,sum(s3(1:LL*NN))
|
|
|
|
! rewind 41
|
|
|
|
! write(41) LL*NN,s3(1:LL*NN)
|
2020-11-30 14:13:37 -05:00
|
|
|
if(irc.ge.0) id2=iaptype+2
|
2020-12-24 13:07:29 -05:00
|
|
|
|
|
|
|
!### Temporary ###
|
|
|
|
! if(irc.ge.0) then
|
|
|
|
! write(c77,1000) dat4(1:12),dat4(13)/2
|
|
|
|
!1000 format(12b6.6,b5.5)
|
|
|
|
! call unpack77(c77,0,decoded,unpk77_success) !Unpack to get msgsent
|
|
|
|
! snr2=esnodb - db(2500.0/baud)
|
|
|
|
! xdt1=xdt0 + nsps*ndt/(16.0*6000.0)
|
|
|
|
! f1=f0 + 0.5*baud*ndf
|
|
|
|
! open(56,file='fort.56',status='unknown',position='append')
|
|
|
|
! write(56,3055) idf,idt,ibw,id2,irc,xdt1,f1,snr2,trim(decoded)
|
|
|
|
!3055 format(5i3,3f8.2,2x,a)
|
|
|
|
! close(56)
|
|
|
|
! endif
|
|
|
|
!###
|
|
|
|
|
2020-11-30 14:13:37 -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-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
|
|
|
|
|
|
|
! if(iaptype.eq.0) then
|
|
|
|
! a=0.
|
|
|
|
! a(1)=-f0
|
|
|
|
! call twkfreq(c00,c0,npts2,6000.0,a)
|
|
|
|
! jpk=3000 !### Are these definitions OK?
|
|
|
|
! if(nsps.ge.3600) jpk=6000 !### TR >= 60 s
|
|
|
|
! call spec64(c0,nsps,mode,mode_q65,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
|
|
|
|
! endif
|
2020-10-27 13:08:07 -04:00
|
|
|
|
2020-11-29 10:00:33 -05:00
|
|
|
100 if(irc.ge.0) then
|
2020-10-30 14:52:58 -04:00
|
|
|
snr2=esnodb - db(2500.0/baud)
|
2020-11-13 13:40:16 -05:00
|
|
|
xdt1=xdt0 + nsps*ndt/(16.0*6000.0)
|
|
|
|
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
|