2012-09-30 20:02:36 -04:00
|
|
|
program jt9
|
|
|
|
|
|
|
|
! Decoder for JT9. Can run stand-alone, reading data from *.wav files;
|
|
|
|
! or as the back end of wsjt-x, with data placed in a shared memory region.
|
|
|
|
|
2012-10-02 11:56:18 -04:00
|
|
|
! NB: For unknown reason, ***MUST*** be compiled by g95 with -O0 !!!
|
|
|
|
|
2012-10-01 15:05:22 -04:00
|
|
|
character*80 arg,infile
|
|
|
|
parameter (NMAX=1800*12000) !Total sample intervals per 30 minutes
|
|
|
|
parameter (NDMAX=1800*1500) !Sample intervals at 1500 Hz rate
|
|
|
|
parameter (NSMAX=22000) !Max length of saved spectra
|
|
|
|
integer*4 ihdr(11)
|
|
|
|
real*4 s(NSMAX)
|
2012-11-06 14:49:19 -05:00
|
|
|
real*4 ccfred(NSMAX)
|
2012-09-30 20:02:36 -04:00
|
|
|
logical*1 lstrong(0:1023)
|
2012-10-03 09:26:52 -04:00
|
|
|
integer*1 i1SoftSymbols(207)
|
|
|
|
character*22 msg
|
2012-11-06 15:27:08 -05:00
|
|
|
character*33 line
|
2012-10-01 15:05:22 -04:00
|
|
|
integer*2 id2
|
2012-11-21 12:42:53 -05:00
|
|
|
complex c0
|
2012-11-26 16:06:41 -05:00
|
|
|
complex c1(NDMAX)
|
2012-11-21 12:42:53 -05:00
|
|
|
common/jt9com/ss(184,NSMAX),savg(NSMAX),c0(NDMAX),id2(NMAX),nutc,ndiskdat, &
|
|
|
|
ntr,mousefqso,newdat,nfa,nfb,ntol,kin,nzhsym,nsynced,ndecoded
|
2012-11-21 13:27:49 -05:00
|
|
|
common/tracer/limtrace,lu
|
2012-09-30 20:02:36 -04:00
|
|
|
|
|
|
|
nargs=iargc()
|
|
|
|
if(nargs.lt.1) then
|
2012-10-01 15:05:22 -04:00
|
|
|
print*,'Usage: jt9 TRperiod file1 [file2 ...]'
|
2012-09-30 20:02:36 -04:00
|
|
|
print*,' Reads data from *.wav files.'
|
|
|
|
print*,''
|
|
|
|
print*,' jt9 -s'
|
|
|
|
print*,' Gets data from shared memory region.'
|
|
|
|
go to 999
|
|
|
|
endif
|
|
|
|
call getarg(1,arg)
|
2012-11-21 12:42:53 -05:00
|
|
|
if(arg(1:2).eq.'-s') then
|
|
|
|
call jt9a
|
|
|
|
! call ftnquit
|
|
|
|
go to 999
|
|
|
|
endif
|
2012-10-01 15:05:22 -04:00
|
|
|
read(arg,*) ntrperiod
|
2012-10-02 11:56:18 -04:00
|
|
|
|
2012-10-01 15:05:22 -04:00
|
|
|
ifile1=2
|
|
|
|
|
2012-11-21 13:27:49 -05:00
|
|
|
limtrace=0
|
|
|
|
lu=12
|
2012-10-01 15:05:22 -04:00
|
|
|
nfa=1000
|
|
|
|
nfb=2000
|
2012-11-12 13:28:28 -05:00
|
|
|
ntol=500
|
2012-10-16 15:44:41 -04:00
|
|
|
nfqso=1500
|
2012-10-01 15:05:22 -04:00
|
|
|
newdat=1
|
|
|
|
nb=0
|
|
|
|
nbslider=100
|
2012-11-06 14:49:19 -05:00
|
|
|
limit=20000
|
2012-11-12 16:06:31 -05:00
|
|
|
ndiskdat=1
|
2012-09-30 20:02:36 -04:00
|
|
|
|
|
|
|
do ifile=ifile1,nargs
|
|
|
|
call getarg(ifile,infile)
|
|
|
|
open(10,file=infile,access='stream',status='old',err=998)
|
2012-10-01 15:05:22 -04:00
|
|
|
read(10) ihdr
|
|
|
|
i1=index(infile,'.wav')
|
2012-09-30 20:02:36 -04:00
|
|
|
read(infile(i1-4:i1-1),*,err=1) nutc0
|
|
|
|
go to 2
|
|
|
|
1 nutc0=0
|
2012-10-01 15:05:22 -04:00
|
|
|
2 nsps=0
|
2012-11-21 12:42:53 -05:00
|
|
|
if(ntrperiod.eq.1) then
|
|
|
|
nsps=6912
|
|
|
|
nzhsym=181
|
|
|
|
else if(ntrperiod.eq.2) then
|
|
|
|
nsps=15360
|
|
|
|
nzhsym=178
|
|
|
|
else if(ntrperiod.eq.5) then
|
|
|
|
nsps=40960
|
|
|
|
nzhsym=172
|
|
|
|
else if(ntrperiod.eq.10) then
|
|
|
|
nsps=82944
|
|
|
|
nzhsym=171
|
|
|
|
else if(ntrperiod.eq.30) then
|
|
|
|
nsps=252000
|
|
|
|
nzhsym=167
|
|
|
|
endif
|
2012-11-12 13:28:28 -05:00
|
|
|
if(nsps.eq.0) stop 'Error: bad TRperiod'
|
2012-10-01 15:05:22 -04:00
|
|
|
|
|
|
|
kstep=nsps/2
|
2012-10-02 11:56:18 -04:00
|
|
|
tstep=kstep/12000.0
|
2012-09-30 20:02:36 -04:00
|
|
|
k=0
|
2012-10-01 15:05:22 -04:00
|
|
|
nhsym0=-999
|
|
|
|
npts=(60*ntrperiod-6)*12000
|
2012-11-21 13:27:49 -05:00
|
|
|
if(ifile.eq.ifile1) then
|
|
|
|
open(12,file='timer.out',status='unknown')
|
|
|
|
call timer('jt9 ',0)
|
|
|
|
endif
|
2012-09-30 20:02:36 -04:00
|
|
|
|
2012-10-01 15:05:22 -04:00
|
|
|
! do i=1,npts
|
2012-11-12 16:06:31 -05:00
|
|
|
! id2(i)=100.0*sin(6.283185307*1600.0*i/12000.0)
|
2012-10-01 15:05:22 -04:00
|
|
|
! enddo
|
|
|
|
|
|
|
|
do iblk=1,npts/kstep
|
|
|
|
k=iblk*kstep
|
2012-11-21 12:42:53 -05:00
|
|
|
call timer('read_wav',0)
|
2012-10-16 16:58:03 -04:00
|
|
|
read(10,end=10) id2(k-kstep+1:k)
|
2012-11-21 12:42:53 -05:00
|
|
|
call timer('read_wav',1)
|
|
|
|
|
2012-10-01 15:05:22 -04:00
|
|
|
nhsym=(k-2048)/kstep
|
2012-09-30 20:02:36 -04:00
|
|
|
if(nhsym.ge.1 .and. nhsym.ne.nhsym0) then
|
|
|
|
! Emit signal readyForFFT
|
2012-11-06 14:49:19 -05:00
|
|
|
ingain=0
|
2012-11-21 12:42:53 -05:00
|
|
|
call timer('symspec ',0)
|
2012-11-06 14:49:19 -05:00
|
|
|
call symspec(k,ntrperiod,nsps,ingain,nb,nbslider,pxdb, &
|
2012-11-21 13:27:49 -05:00
|
|
|
s,ccfred,df3,ihsym,nzap,slimit,lstrong,npts8)
|
2012-11-21 12:42:53 -05:00
|
|
|
call timer('symspec ',1)
|
2012-09-30 20:02:36 -04:00
|
|
|
nhsym0=nhsym
|
2012-10-01 15:05:22 -04:00
|
|
|
if(ihsym.ge.184) go to 10
|
2012-09-30 20:02:36 -04:00
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
|
2012-10-16 16:58:03 -04:00
|
|
|
10 close(10)
|
|
|
|
iz=1000.0/df3
|
2012-09-30 20:02:36 -04:00
|
|
|
nutc=nutc0
|
2012-10-10 16:40:46 -04:00
|
|
|
|
2012-11-21 13:27:49 -05:00
|
|
|
call timer('sync9 ',0)
|
2012-11-21 12:42:53 -05:00
|
|
|
call sync9(ss,nzhsym,tstep,df3,ntol,nfqso,ccfred,ia,ib,ipk) !Get sync, freq
|
2012-11-21 13:27:49 -05:00
|
|
|
call timer('sync9 ',1)
|
2012-11-06 14:49:19 -05:00
|
|
|
|
|
|
|
fgood=0.
|
2012-11-26 16:06:41 -05:00
|
|
|
nsps8=nsps/8
|
|
|
|
df8=1500.0/nsps8
|
2012-11-06 14:49:19 -05:00
|
|
|
sbest=0.
|
|
|
|
do i=ia,ib
|
|
|
|
f=(i-1)*df3
|
|
|
|
if((i.eq.ipk .or. ccfred(i).ge.3.0) .and. f.gt.fgood+10.0*df8) then
|
2012-11-26 16:06:41 -05:00
|
|
|
|
|
|
|
call timer('test9 ',0)
|
|
|
|
fpk=1000.0 + df3*(i-1)
|
|
|
|
c1(1:npts8)=conjg(c0(1:npts8))
|
|
|
|
call test9(c1,npts8,nsps8,fpk,syncpk,snrdb,xdt,freq,drift, &
|
|
|
|
i1SoftSymbols)
|
|
|
|
call timer('test9 ',1)
|
|
|
|
|
2012-11-21 13:27:49 -05:00
|
|
|
|
|
|
|
call timer('decode9 ',0)
|
2012-11-06 14:49:19 -05:00
|
|
|
call decode9(i1SoftSymbols,limit,nlim,msg)
|
2012-11-21 13:27:49 -05:00
|
|
|
call timer('decode9 ',1)
|
2012-11-26 16:06:41 -05:00
|
|
|
|
|
|
|
sync=(syncpk-1.0)/2.0
|
2012-11-06 14:49:19 -05:00
|
|
|
if(sync.lt.0.0) sync=0.0
|
|
|
|
nsync=sync
|
|
|
|
if(nsync.gt.10) nsync=10
|
2012-11-26 16:06:41 -05:00
|
|
|
nsnr=nint(snrdb)
|
2012-11-06 14:49:19 -05:00
|
|
|
|
2012-11-26 16:06:41 -05:00
|
|
|
if(sync.gt.sbest .and. fgood.eq.0.0) then
|
|
|
|
sbest=sync
|
|
|
|
write(line,1010) nutc,nsync,nsnr,xdt,freq,drift
|
2012-11-06 14:49:19 -05:00
|
|
|
if(nsync.gt.0) nsynced=1
|
|
|
|
endif
|
|
|
|
|
|
|
|
if(msg.ne.' ') then
|
2012-11-26 16:06:41 -05:00
|
|
|
write(*,1010) nutc,nsync,nsnr,xdt,freq,drift,msg
|
2012-11-06 14:49:19 -05:00
|
|
|
1010 format(i4.4,i4,i5,f6.1,f8.2,f6.2,3x,a22)
|
|
|
|
fgood=f
|
|
|
|
nsynced=1
|
|
|
|
ndecoded=1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
|
|
|
|
if(fgood.eq.0.0) then
|
2012-11-06 16:28:59 -05:00
|
|
|
write(*,1020) line
|
2012-11-06 14:49:19 -05:00
|
|
|
1020 format(a33)
|
|
|
|
endif
|
|
|
|
|
2012-09-30 20:02:36 -04:00
|
|
|
enddo
|
|
|
|
|
2012-11-21 12:42:53 -05:00
|
|
|
call timer('jt9 ',1)
|
|
|
|
call timer('jt9 ',101)
|
|
|
|
! call ftnquit
|
2012-09-30 20:02:36 -04:00
|
|
|
go to 999
|
|
|
|
|
|
|
|
998 print*,'Cannot open file:'
|
|
|
|
print*,infile
|
|
|
|
|
2012-10-01 15:05:22 -04:00
|
|
|
999 end program jt9
|