2012-08-30 14:47:41 -04:00
|
|
|
subroutine s3avg(nsave,mode65,nutc,nhz,xdt,npol,ntol,s3,nsum,nkv,decoded)
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2012-08-30 10:22:30 -04:00
|
|
|
! Save the current synchronized spectra, s3(64,63), for possible
|
|
|
|
! decoding of average.
|
|
|
|
|
|
|
|
real s3(64,63) !Synchronized spectra for 63 symbols
|
2012-08-30 14:21:41 -04:00
|
|
|
real s3a(64,63,64) !Saved spectra
|
|
|
|
real s3b(64,63) !Average spectra
|
|
|
|
integer iutc(64),ihz(64),ipol(64)
|
|
|
|
real dt(64)
|
2012-05-22 13:09:48 -04:00
|
|
|
character*22 decoded
|
2012-08-30 14:21:41 -04:00
|
|
|
logical ltext,first
|
|
|
|
data first/.true./
|
2012-05-22 13:09:48 -04:00
|
|
|
save
|
2012-08-30 14:21:41 -04:00
|
|
|
|
|
|
|
if(first) then
|
|
|
|
iutc=-1
|
|
|
|
ihz=0
|
|
|
|
ipol=0
|
|
|
|
first=.false.
|
2012-08-30 14:47:41 -04:00
|
|
|
ihzdiff=min(100,ntol)
|
2012-08-30 14:21:41 -04:00
|
|
|
dtdiff=0.2
|
|
|
|
endif
|
|
|
|
|
|
|
|
do i=1,64
|
|
|
|
if(nutc.eq.iutc(i) .and. abs(nhz-ihz(i)).lt.ihzdiff) then
|
|
|
|
nsave=mod(nsave-1+64,64)+1
|
2012-08-30 15:17:49 -04:00
|
|
|
go to 10
|
2012-08-30 14:21:41 -04:00
|
|
|
endif
|
|
|
|
enddo
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2012-08-30 10:22:30 -04:00
|
|
|
iutc(nsave)=nutc !Save UTC
|
2012-08-30 14:21:41 -04:00
|
|
|
ihz(nsave)=nhz !Save freq in Hz
|
2012-08-30 10:22:30 -04:00
|
|
|
ipol(nsave)=npol !Save pol
|
|
|
|
dt(nsave)=xdt !Save DT
|
|
|
|
s3a(1:64,1:63,nsave)=s3 !Save the spectra
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2012-08-30 15:17:49 -04:00
|
|
|
10 s3b=0.
|
2012-08-30 14:21:41 -04:00
|
|
|
do i=1,64 !Accumulate avg spectra
|
|
|
|
if(iutc(i).lt.0) cycle
|
|
|
|
if(mod(iutc(i),2).ne.mod(nutc,2)) cycle !Use only same sequence
|
|
|
|
if(abs(nhz-ihz(i)).gt.ihzdiff) cycle !Freq must match
|
2012-08-30 10:22:30 -04:00
|
|
|
if(abs(xdt-dt(i)).gt.dtdiff) cycle !DT must match
|
2012-05-22 13:09:48 -04:00
|
|
|
s3b=s3b + s3a(1:64,1:63,i)
|
|
|
|
nsum=nsum+1
|
|
|
|
enddo
|
2012-08-30 14:21:41 -04:00
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
decoded=' '
|
2012-08-30 10:22:30 -04:00
|
|
|
if(nsum.ge.2) then !Try decoding the sverage
|
2012-05-22 13:09:48 -04:00
|
|
|
nadd=mode65*nsum
|
|
|
|
call extract(s3b,nadd,ncount,nhist,decoded,ltext) !Extract the message
|
|
|
|
nkv=nsum
|
|
|
|
if(ncount.lt.0) then
|
|
|
|
nkv=0
|
|
|
|
decoded=' '
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2012-08-30 15:17:49 -04:00
|
|
|
return
|
2012-05-22 13:09:48 -04:00
|
|
|
end subroutine s3avg
|