Input M, N, K from sfoxtext command line. Correct freq after sync.

This commit is contained in:
Joe Taylor 2024-02-08 12:21:36 -05:00
parent c051168a6b
commit 56d0aac243
2 changed files with 28 additions and 20 deletions

View File

@ -13,6 +13,7 @@ program sfoxtest
complex clo(NMAX) !Complex Local Oscillator
complex cnoise(NMAX) !Complex noise
complex crcvd(NMAX) !Signal as received
real a(3)
integer, allocatable :: msg0(:) !Information symbols
integer, allocatable :: parsym(:) !Parity symbols
@ -20,11 +21,11 @@ program sfoxtest
integer, allocatable :: chansym(:) !Recovered hard-decision symbols
integer, allocatable :: iera(:) !Positions of erasures
character fname*17,arg*12
nargs=iargc()
if(nargs.ne.8) then
print*,'Usage: sfoxtest f0 DT fspread delay width nran nfiles snr'
print*,'Example: sfoxtest 1500.0 0.15 0.5 1.0 100 0 10 -10'
if(nargs.ne.9) then
print*,'Usage: sfoxtest f0 DT fspread delay M N K nfiles snr'
print*,'Example: sfoxtest 1500 0.15 0.5 1.0 8 74 44 10 -10'
go to 999
endif
call getarg(1,arg)
@ -36,15 +37,18 @@ program sfoxtest
call getarg(4,arg)
read(arg,*) delay
call getarg(5,arg)
read(arg,*) syncwidth
read(arg,*) mm0
call getarg(6,arg)
read(arg,*) nran
read(arg,*) nn0
call getarg(7,arg)
read(arg,*) nfiles
read(arg,*) kk0
call getarg(8,arg)
read(arg,*) nfiles
call getarg(9,arg)
read(arg,*) snrdb
call sfox_init
call sfox_init(mm0,nn0,kk0)
syncwidth=100.0
baud=12000.0/NSPS
bw=NQ*baud
@ -125,7 +129,12 @@ program sfoxtest
ferr=f-f1
terr=t-xdt
if(abs(ferr).lt.3.0 .and. abs(terr).lt.0.01) ngoodsync=ngoodsync+1
! if(abs(terr).lt.0.01) ngoodsync=ngoodsync+1
a=0.
a(1)=1500.0-f
call twkfreq(crcvd,crcvd,NMAX,12000.0,a)
f=1500.0
call hard_symbols(crcvd,f,t,chansym) !Get hard symbol values
nera=0
chansym=mod(chansym,nq) !Enforce 0 to nq-1
@ -152,7 +161,8 @@ program sfoxtest
1120 format('Hard errors:',i4)
endif
if(nharderr.le.38) ngood=ngood+1 !(125-49)/2 = 38
maxerr=(nn-kk)/2
if(nharderr.le.maxerr) ngood=ngood+1
! write(13,1200) ifile,snr,ferr,terr,nharderr
!1200 format(i5,3f10.3,i5)
enddo ! ifile

View File

@ -1,36 +1,32 @@
subroutine sync_sf(crcvd,clo,snrdb,f,t)
use sfox_mod
! include "sfox_params.f90"
parameter (MMAX=150,JMAX=300)
real ccf(-MMAX:MMAX,-JMAX:JMAX) !2D CCF: DT, dFreq offsets
real s(-MMAX:MMAX,-JMAX:JMAX) !s(DT,dFreq)
complex clo(NMAX) !Complex Local Oscillator
complex crcvd(NMAX) !Signal as received
complex c(0:NFFT-1)
complex c(0:NFFT-1) !Work array
integer ipk(2)
character*1 line(-30:30),mark(0:5)
data mark/' ','.','-','+','X','$'/
ccf=0.
s=0.
df=12000.0/NFFT !0.366211
i1=ND1*nsps
do m=-MMAX,MMAX
lag=100*m
c(0:nsync-1)=crcvd(i1+1+lag:i1+nsync+lag)*clo(1:nsync)
c(nsync:)=0.
fac=1.e-3
c=fac*c
call four2a(c,NFFT,1,-1,1)
do j=-JMAX,JMAX
k=j
if(k.lt.0) k=k+NFFT
ccf(m,j)=real(c(k))**2 + aimag(c(k))**2
s(m,j)=real(c(k))**2 + aimag(c(k))**2
enddo
enddo
ccf=ccf/maxval(ccf)
ipk=maxloc(ccf)
! print*,i0,ipk(1)
s=s/maxval(s)
ipk=maxloc(s)
ipk(1)=ipk(1)-MMAX-1
ipk(2)=ipk(2)-JMAX-1
if(snrdb.ne.0.0) then
@ -40,7 +36,7 @@ subroutine sync_sf(crcvd,clo,snrdb,f,t)
jb=min(JMAX,ipk(2)+30)
do m=ma,mb
do j=ja,jb
k=5.999*ccf(m,j)
k=5.999*s(m,j)
line(j-ipk(2))=mark(k)
enddo
write(*,1300) m/120.0,line
@ -50,6 +46,8 @@ subroutine sync_sf(crcvd,clo,snrdb,f,t)
t=ipk(1)/120.0
dfreq=ipk(2)*df
f=1500.0+dfreq
! write(*,3001) ipk,t,dfreq,f
!3001 format('B',2i5,f7.3,2f7.1)
return
end subroutine sync_sf