2016-07-21 11:23:32 -04:00
|
|
|
subroutine qra64a(dd0,nutc,nf1,nf2,nfqso,ntol,mycall_12,hiscall_12, &
|
|
|
|
hisgrid_6,sync,nsnr,dtx,nfreq,decoded,nft)
|
2016-06-30 16:38:36 -04:00
|
|
|
|
|
|
|
use packjt
|
2016-07-21 16:30:04 -04:00
|
|
|
parameter (NFFT=2*6912,NZ=5760,NMAX=60*12000)
|
2016-07-19 09:16:10 -04:00
|
|
|
character decoded*22
|
|
|
|
character*12 mycall_12,hiscall_12
|
|
|
|
character*6 mycall,hiscall,hisgrid_6
|
|
|
|
character*4 hisgrid
|
2016-06-30 16:38:36 -04:00
|
|
|
logical ltext
|
2016-07-19 11:24:15 -04:00
|
|
|
integer*8 count0,count1,clkfreq
|
2016-06-30 16:38:36 -04:00
|
|
|
integer icos7(0:6)
|
2016-07-01 11:16:00 -04:00
|
|
|
integer dat4(12)
|
2016-07-21 11:23:32 -04:00
|
|
|
real dd0(NMAX),dd(NMAX)
|
2016-06-30 16:38:36 -04:00
|
|
|
real s(NZ)
|
|
|
|
real savg(NZ)
|
2016-07-21 11:23:32 -04:00
|
|
|
real blue(0:25)
|
2016-06-30 16:38:36 -04:00
|
|
|
real red(NZ)
|
2016-07-22 15:52:20 -04:00
|
|
|
real ss(NZ,194)
|
|
|
|
real ccf(NZ,0:25)
|
|
|
|
real s3(0:63,1:63)
|
|
|
|
real s3a(0:63,1:63)
|
2016-06-30 16:38:36 -04:00
|
|
|
data icos7/2,5,6,0,4,1,3/ !Costas 7x7 pattern
|
2016-07-20 11:38:29 -04:00
|
|
|
data nc1z/-1/,nc2z/-1/,ng2z/-1/
|
2016-07-22 15:52:20 -04:00
|
|
|
! common/qra64com/ss(NZ,194),ccf(NZ,0:25),s3(0:63,1:63),s3a(0:63,1:63)
|
2016-06-30 16:38:36 -04:00
|
|
|
save
|
|
|
|
|
2016-07-21 16:30:04 -04:00
|
|
|
! write(60) dd0
|
|
|
|
|
2016-07-01 11:16:00 -04:00
|
|
|
decoded=' '
|
2016-07-01 11:25:41 -04:00
|
|
|
nft=99
|
2016-07-01 11:16:00 -04:00
|
|
|
nsnr=-30
|
2016-06-30 16:38:36 -04:00
|
|
|
nsps=6912
|
|
|
|
istep=nsps/2
|
|
|
|
nsteps=52*12000/istep - 2
|
|
|
|
df=12000.0/NFFT
|
2016-07-21 11:23:32 -04:00
|
|
|
call spec64(dd0,-1,s,savg,ss)
|
2016-06-30 16:38:36 -04:00
|
|
|
fa=max(nf1,nfqso-ntol)
|
|
|
|
fb=min(nf2,nfqso+ntol)
|
2016-07-23 09:22:34 -04:00
|
|
|
ia=max(1,nint(fa/df))
|
|
|
|
ib=min(NZ,nint(fb/df))
|
2016-07-07 15:27:03 -04:00
|
|
|
call pctile(savg(ia),ib-ia+1,45,base)
|
|
|
|
savg=savg/base - 1.0
|
|
|
|
ss=ss/base
|
|
|
|
|
2016-07-19 09:16:10 -04:00
|
|
|
red=-99.
|
2016-07-11 16:38:31 -04:00
|
|
|
fac=1.0/sqrt(21.0)
|
2016-07-18 08:59:33 -04:00
|
|
|
sync=0.
|
2016-06-30 16:38:36 -04:00
|
|
|
do if0=ia,ib
|
|
|
|
do j=0,25
|
2016-07-18 08:59:33 -04:00
|
|
|
t=-3.0
|
2016-06-30 16:38:36 -04:00
|
|
|
do n=0,6
|
|
|
|
i=if0 + 2*icos7(n)
|
2016-07-18 08:59:33 -04:00
|
|
|
t=t + ss(i,1+2*n+j) + ss(i,1+2*n+j+78) + ss(i,1+2*n+j+154)
|
2016-06-30 16:38:36 -04:00
|
|
|
enddo
|
2016-07-18 08:59:33 -04:00
|
|
|
ccf(if0,j)=fac*t
|
2016-07-19 09:16:10 -04:00
|
|
|
if(ccf(if0,j).gt.red(if0)) then
|
|
|
|
red(if0)=ccf(if0,j)
|
|
|
|
if(red(if0).gt.sync) then
|
|
|
|
sync=red(if0)
|
2016-07-18 08:59:33 -04:00
|
|
|
f0=if0*df
|
2016-07-21 11:23:32 -04:00
|
|
|
! dtx=j*istep/12000.0 - 1.0
|
2016-07-18 08:59:33 -04:00
|
|
|
i0=if0
|
|
|
|
j0=j
|
|
|
|
endif
|
|
|
|
endif
|
2016-06-30 16:38:36 -04:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
2016-07-19 09:16:10 -04:00
|
|
|
write(17) ia,ib,red(ia:ib)
|
2016-07-06 10:18:23 -04:00
|
|
|
close(17)
|
|
|
|
|
2016-07-18 08:59:33 -04:00
|
|
|
if0=nint(f0/df)
|
|
|
|
nfreq=nint(f0)
|
2016-07-21 11:23:32 -04:00
|
|
|
blue(0:25)=ccf(if0,0:25)
|
|
|
|
dj=0.
|
|
|
|
if(j0.ge.1 .and. j0.le.24) call peakup(blue(j0-1),blue(j0),blue(j0+1),dj)
|
|
|
|
xpk=j0 + dj
|
|
|
|
dtx=xpk*istep/12000.0 - 1.0
|
|
|
|
i=nint(dj*istep)
|
|
|
|
if(i.lt.0) then
|
|
|
|
dd(1-i:NMAX)=dd0(1:NMAX+i)
|
|
|
|
dd(1:-i)=0.0
|
|
|
|
else
|
|
|
|
dd(1:NMAX-i)=dd0(1+i:NMAX)
|
|
|
|
dd(NMAX-i+1:NMAX)=0.0
|
|
|
|
endif
|
|
|
|
|
|
|
|
! Recompute the symbol spectra, this time aligned for best DT estimate.
|
|
|
|
ss=0.
|
|
|
|
call spec64(dd,j0,s,savg,ss)
|
2016-07-01 11:16:00 -04:00
|
|
|
|
2016-07-19 16:52:51 -04:00
|
|
|
do i=0,63 !Copy symbol spectra into s3()
|
2016-06-30 16:38:36 -04:00
|
|
|
k=i0 + 2*i
|
2016-07-18 08:59:33 -04:00
|
|
|
jj=j0+13
|
2016-06-30 16:38:36 -04:00
|
|
|
do j=1,63
|
|
|
|
jj=jj+2
|
2016-07-18 08:59:33 -04:00
|
|
|
s3(i,j)=ss(k,jj)
|
2016-06-30 16:38:36 -04:00
|
|
|
if(j.eq.32) jj=jj+14 !Skip over the middle Costas array
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
2016-07-19 16:52:51 -04:00
|
|
|
if(sync.gt.1.0) snr1=10.0*log10(sync) - 39.0
|
2016-07-19 09:16:10 -04:00
|
|
|
nsnr=nint(snr1)
|
2016-07-22 15:52:20 -04:00
|
|
|
! write(*,5001) dtx,nint(f0),0,snr1
|
|
|
|
!5001 format(f6.3,2i6,f7.1)
|
|
|
|
maxf1=10
|
2016-07-24 08:32:14 -04:00
|
|
|
! call sync64(dd0,nf1,nf2,nfqso,ntol,maxf1,dtx,f0,kpk,snr,s3a)
|
2016-07-22 15:52:20 -04:00
|
|
|
! write(*,5001) dtx,nint(f0),kpk,snr
|
2016-06-30 16:38:36 -04:00
|
|
|
|
|
|
|
mycall=mycall_12(1:6) !### May need fixing ###
|
2016-07-19 09:16:10 -04:00
|
|
|
hiscall=hiscall_12(1:6)
|
|
|
|
hisgrid=hisgrid_6(1:4)
|
2016-07-20 11:38:29 -04:00
|
|
|
call packcall(mycall,nc1,ltext)
|
|
|
|
call packcall(hiscall,nc2,ltext)
|
|
|
|
call packgrid(hisgrid,ng2,ltext)
|
|
|
|
|
|
|
|
if(nc1.ne.nc1z .or. nc2.ne.nc2z .or. ng2.ne.ng2z) then
|
2016-07-21 08:38:26 -04:00
|
|
|
do naptype=0,5
|
2016-07-20 11:38:29 -04:00
|
|
|
call qra64_dec(s3,nc1,nc2,ng2,naptype,1,dat4,snr2,irc)
|
|
|
|
enddo
|
|
|
|
nc1z=nc1
|
|
|
|
nc2z=nc2
|
|
|
|
ng2z=ng2
|
|
|
|
endif
|
2016-07-19 11:49:06 -04:00
|
|
|
|
2016-07-19 09:16:10 -04:00
|
|
|
snr2=-99.
|
2016-07-19 16:52:51 -04:00
|
|
|
naptype=4
|
2016-07-20 11:38:29 -04:00
|
|
|
call system_clock(count0,clkfreq)
|
|
|
|
call qra64_dec(s3,nc1,nc2,ng2,naptype,0,dat4,snr2,irc)
|
|
|
|
if(irc.ge.0) then
|
|
|
|
call unpackmsg(dat4,decoded) !Unpack the user message
|
|
|
|
call fmtmsg(decoded,iz)
|
|
|
|
nft=100 + irc
|
|
|
|
nsnr=nint(snr2)
|
|
|
|
else
|
|
|
|
snr2=0.
|
|
|
|
endif
|
|
|
|
call system_clock(count1,clkfreq)
|
|
|
|
tsec=float(count1-count0)/float(clkfreq)
|
|
|
|
write(78,3900) nutc,sync,snr1,snr2,dtx,nfreq,1,irc,tsec,decoded
|
2016-07-19 16:52:51 -04:00
|
|
|
3900 format(i4.4,3f6.1,f6.2,i5,i2,i3,f6.3,1x,a22)
|
2016-07-20 11:38:29 -04:00
|
|
|
flush(78)
|
2016-07-19 09:16:10 -04:00
|
|
|
|
2016-07-20 11:38:29 -04:00
|
|
|
return
|
2016-07-02 08:15:41 -04:00
|
|
|
end subroutine qra64a
|
2016-07-21 11:23:32 -04:00
|
|
|
|
|
|
|
subroutine spec64(dd,j0,s,savg,ss)
|
|
|
|
|
|
|
|
parameter (NFFT=2*6912,NH=NFFT/2,NZ=5760)
|
|
|
|
real dd(60*12000)
|
|
|
|
real s(NZ)
|
|
|
|
real savg(NZ)
|
|
|
|
real ss(NZ,194)
|
|
|
|
real x(NFFT)
|
|
|
|
complex cx(0:NH)
|
|
|
|
equivalence (x,cx)
|
|
|
|
|
|
|
|
nsps=6912
|
|
|
|
istep=nsps/2
|
|
|
|
nsteps=52*12000/istep - 2
|
|
|
|
ia=1-istep
|
|
|
|
savg=0.
|
|
|
|
df=12000.0/NFFT
|
|
|
|
mj0=mod(j0,2)
|
|
|
|
do j=1,nsteps
|
|
|
|
ia=ia+istep
|
|
|
|
if(j0.ge.0 .and. mod(j,2).eq.mj0) cycle !Skip half of FFTs in 2nd pass
|
|
|
|
ib=ia+nsps-1
|
|
|
|
x(1:nsps)=1.2e-4*dd(ia:ib)
|
|
|
|
x(nsps+1:)=0.0
|
|
|
|
call four2a(x,nfft,1,-1,0) !r2c FFT
|
|
|
|
do i=1,NZ
|
|
|
|
s(i)=real(cx(i))**2 + aimag(cx(i))**2
|
|
|
|
enddo
|
|
|
|
ss(1:NZ,j)=s
|
|
|
|
savg=savg+s
|
|
|
|
enddo
|
|
|
|
savg=savg/nsteps
|
|
|
|
|
|
|
|
return
|
|
|
|
end subroutine spec64
|