2012-10-01 00:02:36 +00: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.
|
|
|
|
|
2013-07-08 13:17:22 +00:00
|
|
|
include 'constants.f90'
|
2012-10-01 19:05:22 +00:00
|
|
|
integer*4 ihdr(11)
|
|
|
|
real*4 s(NSMAX)
|
|
|
|
integer*2 id2
|
2013-08-15 17:32:46 +00:00
|
|
|
character*80 arg,ldir,infile
|
2013-08-09 17:22:08 +00:00
|
|
|
common/jt9com/ss(184,NSMAX),savg(NSMAX),id2(NMAX),nutc,ndiskdat,ntr, &
|
|
|
|
mousefqso,newdat,nfa,nfsplit,nfb,ntol,kin,nzhsym,nsynced,ndecoded
|
2012-11-21 18:27:49 +00:00
|
|
|
common/tracer/limtrace,lu
|
2012-10-01 00:02:36 +00:00
|
|
|
|
|
|
|
nargs=iargc()
|
|
|
|
if(nargs.lt.1) then
|
2013-07-16 18:17:20 +00:00
|
|
|
print*,'Usage: jt9 TRperiod ndepth rxfreq file1 [file2 ...]'
|
2012-10-01 00:02:36 +00:00
|
|
|
print*,' Reads data from *.wav files.'
|
|
|
|
print*,''
|
2013-07-19 00:23:40 +00:00
|
|
|
print*,' jt9 -s <key>'
|
|
|
|
print*,' Gets data from shared memory region with key==<key>'
|
2012-10-01 00:02:36 +00:00
|
|
|
go to 999
|
|
|
|
endif
|
|
|
|
call getarg(1,arg)
|
2012-11-21 17:42:53 +00:00
|
|
|
if(arg(1:2).eq.'-s') then
|
2013-07-19 00:23:40 +00:00
|
|
|
! Multiple instances:
|
|
|
|
call getarg(2,arg)
|
2013-08-15 17:32:46 +00:00
|
|
|
call getarg(3,ldir)
|
|
|
|
call jt9a(trim(arg),trim(ldir))
|
2012-11-21 17:42:53 +00:00
|
|
|
go to 999
|
|
|
|
endif
|
2012-10-01 19:05:22 +00:00
|
|
|
read(arg,*) ntrperiod
|
2013-04-16 18:33:38 +00:00
|
|
|
call getarg(2,arg)
|
|
|
|
read(arg,*) ndepth
|
2013-07-16 18:17:20 +00:00
|
|
|
call getarg(3,arg)
|
|
|
|
read(arg,*) nrxfreq
|
|
|
|
ifile1=4
|
2012-10-01 19:05:22 +00:00
|
|
|
|
2012-11-21 18:27:49 +00:00
|
|
|
limtrace=0
|
|
|
|
lu=12
|
2012-10-01 00:02:36 +00:00
|
|
|
|
|
|
|
do ifile=ifile1,nargs
|
|
|
|
call getarg(ifile,infile)
|
|
|
|
open(10,file=infile,access='stream',status='old',err=998)
|
2012-10-01 19:05:22 +00:00
|
|
|
read(10) ihdr
|
2013-05-23 01:05:37 +00:00
|
|
|
nutc0=ihdr(1) !Silence compiler warning
|
2012-10-01 19:05:22 +00:00
|
|
|
i1=index(infile,'.wav')
|
2012-10-01 00:02:36 +00:00
|
|
|
read(infile(i1-4:i1-1),*,err=1) nutc0
|
|
|
|
go to 2
|
|
|
|
1 nutc0=0
|
2012-10-01 19:05:22 +00:00
|
|
|
2 nsps=0
|
2012-11-21 17:42:53 +00:00
|
|
|
if(ntrperiod.eq.1) then
|
|
|
|
nsps=6912
|
2013-04-16 16:25:14 +00:00
|
|
|
nzhsym=173
|
2012-11-21 17:42:53 +00:00
|
|
|
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 18:28:28 +00:00
|
|
|
if(nsps.eq.0) stop 'Error: bad TRperiod'
|
2012-10-01 19:05:22 +00:00
|
|
|
|
|
|
|
kstep=nsps/2
|
2012-10-01 00:02:36 +00:00
|
|
|
k=0
|
2012-10-01 19:05:22 +00:00
|
|
|
nhsym0=-999
|
|
|
|
npts=(60*ntrperiod-6)*12000
|
2012-11-21 18:27:49 +00:00
|
|
|
if(ifile.eq.ifile1) then
|
|
|
|
open(12,file='timer.out',status='unknown')
|
|
|
|
call timer('jt9 ',0)
|
|
|
|
endif
|
2012-10-01 00:02:36 +00:00
|
|
|
|
2013-04-17 14:53:58 +00:00
|
|
|
id2=0 !??? Why is this necessary ???
|
|
|
|
|
2012-10-01 19:05:22 +00:00
|
|
|
do iblk=1,npts/kstep
|
|
|
|
k=iblk*kstep
|
2012-11-21 17:42:53 +00:00
|
|
|
call timer('read_wav',0)
|
2012-10-16 20:58:03 +00:00
|
|
|
read(10,end=10) id2(k-kstep+1:k)
|
2012-11-21 17:42:53 +00:00
|
|
|
call timer('read_wav',1)
|
|
|
|
|
2012-10-01 19:05:22 +00:00
|
|
|
nhsym=(k-2048)/kstep
|
2012-10-01 00:02:36 +00:00
|
|
|
if(nhsym.ge.1 .and. nhsym.ne.nhsym0) then
|
|
|
|
! Emit signal readyForFFT
|
2012-11-06 19:49:19 +00:00
|
|
|
ingain=0
|
2012-11-21 17:42:53 +00:00
|
|
|
call timer('symspec ',0)
|
2013-07-08 13:17:22 +00:00
|
|
|
call symspec(k,ntrperiod,nsps,ingain,slope,pxdb,s,df3,ihsym,npts8)
|
2012-11-21 17:42:53 +00:00
|
|
|
call timer('symspec ',1)
|
2012-10-01 00:02:36 +00:00
|
|
|
nhsym0=nhsym
|
2013-04-16 18:33:38 +00:00
|
|
|
if(ihsym.ge.173) go to 10
|
2012-10-01 00:02:36 +00:00
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
|
2012-10-16 20:58:03 +00:00
|
|
|
10 close(10)
|
2013-07-16 18:17:20 +00:00
|
|
|
call fillcom(nutc0,ndepth,nrxfreq)
|
2013-07-08 13:17:22 +00:00
|
|
|
call decoder(ss,id2)
|
2012-10-01 00:02:36 +00:00
|
|
|
enddo
|
|
|
|
|
2012-11-21 17:42:53 +00:00
|
|
|
call timer('jt9 ',1)
|
|
|
|
call timer('jt9 ',101)
|
2012-10-01 00:02:36 +00:00
|
|
|
go to 999
|
|
|
|
|
|
|
|
998 print*,'Cannot open file:'
|
|
|
|
print*,infile
|
|
|
|
|
2012-10-01 19:05:22 +00:00
|
|
|
999 end program jt9
|