mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-03 14:34:41 -04:00
Get rid of jt9com and npar common blocks
Also use correct C binding and have compilers determine sizes and offsets. The wsjtx.exe program now owns the decoder shared data that is shared with symspec. It is now in struct dec_data, still a global variable for now but hopefully a MainWindow member variable soon. The struct dec_data (in both C/C++ and Fortran) has a sub structure with the decoder parameters which enables copying and manipulating a lot cleaner. New of changed types of shared data must still be modified in commons.h and a new file lib/jt9com.f90, they must stay in sync as a pointer to the structure is passed between C and Fortran. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6290 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
+37
-39
@@ -1,50 +1,47 @@
|
||||
subroutine decoder(ss,id2,nfsample)
|
||||
subroutine decoder(ss,id2,params,nfsample)
|
||||
|
||||
use prog_args
|
||||
!$ use omp_lib
|
||||
|
||||
include 'constants.f90'
|
||||
include 'jt9com.f90'
|
||||
real ss(184,NSMAX)
|
||||
logical baddata
|
||||
integer*2 id2(NTMAX*12000)
|
||||
type(params_block) :: params
|
||||
real*4 dd(NTMAX*12000)
|
||||
character datetime*20,mycall*12,mygrid*6,hiscall*12,hisgrid*6
|
||||
common/npar/nutc,ndiskdat,ntrperiod,nfqso,newdat,npts8,nfa,nfsplit,nfb, &
|
||||
ntol,kin,nzhsym,nsubmode,nagain,ndepth,ntxmode,nmode,minw,nclearave, &
|
||||
minsync,emedelay,dttol,nlist,listutc(10),n2pass,nranera,naggressive, &
|
||||
nrobust,nexp_decode,nspare(9),datetime,mycall,mygrid,hiscall,hisgrid
|
||||
common/tracer/limtrace,lu
|
||||
integer onlevel(0:10)
|
||||
common/tracer_priv/level,onlevel
|
||||
!$omp threadprivate(/tracer_priv/)
|
||||
save
|
||||
|
||||
if(mod(nranera,2).eq.0) ntrials=10**(nranera/2)
|
||||
if(mod(nranera,2).eq.1) ntrials=3*10**(nranera/2)
|
||||
if(nranera.eq.0) ntrials=0
|
||||
if(mod(params%nranera,2).eq.0) ntrials=10**(params%nranera/2)
|
||||
if(mod(params%nranera,2).eq.1) ntrials=3*10**(params%nranera/2)
|
||||
if(params%nranera.eq.0) ntrials=0
|
||||
|
||||
rms=sqrt(dot_product(float(id2(300000:310000)), &
|
||||
float(id2(300000:310000)))/10000.0)
|
||||
if(rms.lt.2.0) go to 800
|
||||
|
||||
if (nagain .eq. 0) then
|
||||
if (params%nagain .eq. 0) then
|
||||
open(13,file=trim(temp_dir)//'/decoded.txt',status='unknown')
|
||||
else
|
||||
open(13,file=trim(temp_dir)//'/decoded.txt',status='unknown', &
|
||||
position='append')
|
||||
end if
|
||||
if(nmode.eq.4 .or. nmode.eq.65) open(14,file=trim(temp_dir)//'/avemsg.txt', &
|
||||
if(params%nmode.eq.4 .or. params%nmode.eq.65) open(14,file=trim(temp_dir)//'/avemsg.txt', &
|
||||
status='unknown')
|
||||
|
||||
if(nmode.eq.4) then
|
||||
if(params%nmode.eq.4) then
|
||||
jz=52*nfsample
|
||||
if(newdat.ne.0) then
|
||||
if(params%newdat.ne.0) then
|
||||
if(nfsample.eq.12000) call wav11(id2,jz,dd)
|
||||
if(nfsample.eq.11025) dd(1:jz)=id2(1:jz)
|
||||
endif
|
||||
call jt4a(dd,jz,nutc,nfqso,ntol,emedelay,dttol,nagain,ndepth, &
|
||||
nclearave,minsync,minw,nsubmode,mycall,hiscall,hisgrid, &
|
||||
nlist,listutc)
|
||||
call jt4a(dd,jz,params%nutc,params%nfqso,params%ntol,params%emedelay,params%dttol, &
|
||||
params%nagain,params%ndepth,params%nclearave,params%minsync,params%minw, &
|
||||
params%nsubmode,params%mycall,params%hiscall,params%hisgrid, &
|
||||
params%nlist,params%listutc)
|
||||
go to 800
|
||||
endif
|
||||
|
||||
@@ -55,48 +52,49 @@ subroutine decoder(ss,id2,nfsample)
|
||||
go to 800
|
||||
endif
|
||||
|
||||
ntol65=ntol !### is this OK? ###
|
||||
newdat65=newdat
|
||||
newdat9=newdat
|
||||
ntol65=params%ntol !### is this OK? ###
|
||||
newdat65=params%newdat
|
||||
newdat9=params%newdat
|
||||
|
||||
!$ call omp_set_dynamic(.true.)
|
||||
!$omp parallel sections num_threads(2) copyin(/tracer_priv/) shared(ndecoded) if(.true.) !iif() needed on Mac
|
||||
|
||||
!$omp section
|
||||
if(nmode.eq.65 .or. (nmode.eq.(65+9) .and. ntxmode.eq.65)) then
|
||||
if(params%nmode.eq.65 .or. (params%nmode.eq.(65+9) .and. params%ntxmode.eq.65)) then
|
||||
! We're in JT65 mode, or should do JT65 first
|
||||
if(newdat65.ne.0) dd(1:npts65)=id2(1:npts65)
|
||||
nf1=nfa
|
||||
nf2=nfb
|
||||
nf1=params%nfa
|
||||
nf2=params%nfb
|
||||
call timer('jt65a ',0)
|
||||
call jt65a(dd,npts65,newdat65,nutc,nf1,nf2,nfqso,ntol65,nsubmode, &
|
||||
minsync,nagain,n2pass,nrobust,ntrials,naggressive,ndepth, &
|
||||
mycall,hiscall,hisgrid,nexp_decode,ndecoded)
|
||||
call jt65a(dd,npts65,newdat65,params%nutc,nf1,nf2,params%nfqso,ntol65,params%nsubmode, &
|
||||
params%minsync,params%nagain,params%n2pass,params%nrobust,ntrials,params%naggressive, &
|
||||
params%ndepth,params%mycall,params%hiscall,params%hisgrid,params%nexp_decode,ndecoded)
|
||||
call timer('jt65a ',1)
|
||||
|
||||
else if(nmode.eq.9 .or. (nmode.eq.(65+9) .and. ntxmode.eq.9)) then
|
||||
else if(params%nmode.eq.9 .or. (params%nmode.eq.(65+9) .and. params%ntxmode.eq.9)) then
|
||||
! We're in JT9 mode, or should do JT9 first
|
||||
call timer('decjt9 ',0)
|
||||
call decjt9(ss,id2,nutc,nfqso,newdat9,npts8,nfa,nfsplit,nfb,ntol,nzhsym, &
|
||||
nagain,ndepth,nmode)
|
||||
call decjt9(ss,id2,params%nutc,params%nfqso,newdat9,params%npts8,params%nfa,params%nfsplit, &
|
||||
params%nfb,params%ntol,params%nzhsym,params%nagain,params%ndepth,params%nmode)
|
||||
call timer('decjt9 ',1)
|
||||
endif
|
||||
|
||||
!$omp section
|
||||
if(nmode.eq.(65+9)) then !Do the other mode (we're in dual mode)
|
||||
if (ntxmode.eq.9) then
|
||||
if(params%nmode.eq.(65+9)) then !Do the other mode (we're in dual mode)
|
||||
if (params%ntxmode.eq.9) then
|
||||
if(newdat65.ne.0) dd(1:npts65)=id2(1:npts65)
|
||||
nf1=nfa
|
||||
nf2=nfb
|
||||
nf1=params%nfa
|
||||
nf2=params%nfb
|
||||
call timer('jt65a ',0)
|
||||
call jt65a(dd,npts65,newdat65,nutc,nf1,nf2,nfqso,ntol65,nsubmode, &
|
||||
minsync,nagain,n2pass,nrobust,ntrials,naggressive,ndepth, &
|
||||
mycall,hiscall,hisgrid,nexp_decode,ndecoded)
|
||||
call jt65a(dd,npts65,newdat65,params%nutc,nf1,nf2,params%nfqso,ntol65,params%nsubmode, &
|
||||
params%minsync,params%nagain,params%n2pass,params%nrobust,ntrials, &
|
||||
params%naggressive,params%ndepth,params%mycall,params%hiscall,params%hisgrid, &
|
||||
params%nexp_decode,ndecoded)
|
||||
call timer('jt65a ',1)
|
||||
else
|
||||
call timer('decjt9 ',0)
|
||||
call decjt9(ss,id2,nutc,nfqso,newdat9,npts8,nfa,nfsplit,nfb,ntol, &
|
||||
nzhsym,nagain,ndepth,nmode)
|
||||
call decjt9(ss,id2,params%nutc,params%nfqso,newdat9,params%npts8,params%nfa,params%nfsplit, &
|
||||
params%nfb,params%ntol,params%nzhsym,params%nagain,params%ndepth,params%nmode)
|
||||
call timer('decjt9 ',1)
|
||||
end if
|
||||
endif
|
||||
@@ -108,7 +106,7 @@ subroutine decoder(ss,id2,nfsample)
|
||||
1010 format('<DecodeFinished>',2i4)
|
||||
call flush(6)
|
||||
close(13)
|
||||
if(nmode.eq.4 .or. nmode.eq.65) close(14)
|
||||
if(params%nmode.eq.4 .or. params%nmode.eq.65) close(14)
|
||||
|
||||
return
|
||||
end subroutine decoder
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
subroutine fillcom(nutc0,ndepth0,nrxfreq,mode,tx9,flow,fsplit,fhigh)
|
||||
integer mode,flow,fsplit,fhigh
|
||||
logical tx9
|
||||
|
||||
character datetime*20,mycall*12,mygrid*6,hiscall*12,hisgrid*6
|
||||
common/npar/nutc,ndiskdat,ntrperiod,nfqso,newdat,npts8,nfa,nfsplit,nfb, &
|
||||
ntol,kin,nzhsym,nsubmode,nagain,ndepth,ntxmode,nmode,minw,nclearave, &
|
||||
minsync,emedelay,dttol,nlist,listutc(10),n2pass,nranera,naggressive, &
|
||||
nrobust,nexp_decode,nspare(9),datetime,mycall,mygrid,hiscall,hisgrid
|
||||
save
|
||||
|
||||
nutc=nutc0
|
||||
ndiskdat=1
|
||||
ntrperiod=60
|
||||
nfqso=nrxfreq
|
||||
newdat=1
|
||||
npts8=74736
|
||||
nfa=flow
|
||||
nfsplit=fsplit
|
||||
nfb=fhigh
|
||||
ntol=20
|
||||
kin=648000
|
||||
nzhsym=181
|
||||
ndepth=ndepth0
|
||||
dttol=3.0
|
||||
minsync=-1 !### TEST ONLY
|
||||
naggressive=1
|
||||
mycall='K1ABC'
|
||||
hiscall='W9XYZ'
|
||||
hisgrid='EN37'
|
||||
|
||||
n2pass=1
|
||||
nranera=8 !ntrials=10000
|
||||
nrobust=0
|
||||
|
||||
if (tx9) then
|
||||
ntxmode=9
|
||||
else
|
||||
ntxmode=65
|
||||
end if
|
||||
if (mode.eq.0) then
|
||||
nmode=65+9
|
||||
else
|
||||
nmode=mode
|
||||
end if
|
||||
datetime="2013-Apr-16 15:13" !### Temp
|
||||
if(mode.eq.9 .and. nfsplit.ne.2700) nfa=nfsplit
|
||||
|
||||
return
|
||||
end subroutine fillcom
|
||||
+4
-6
@@ -3,6 +3,8 @@
|
||||
#include <QSharedMemory>
|
||||
#include <QSystemSemaphore>
|
||||
|
||||
#include "../commons.h"
|
||||
|
||||
// Multiple instances: KK1D, 17 Jul 2013
|
||||
QSharedMemory mem_jt9;
|
||||
|
||||
@@ -16,17 +18,13 @@ extern "C" {
|
||||
bool detach_jt9_();
|
||||
bool lock_jt9_();
|
||||
bool unlock_jt9_();
|
||||
char* address_jt9_();
|
||||
struct jt9com * address_jt9_();
|
||||
int size_jt9_();
|
||||
// Multiple instances: wrapper for QSharedMemory::setKey()
|
||||
bool setkey_jt9_(char* mykey, int mykey_len);
|
||||
|
||||
bool acquire_jt9_();
|
||||
bool release_jt9_();
|
||||
|
||||
extern struct {
|
||||
char c[10];
|
||||
} jt9com_;
|
||||
}
|
||||
|
||||
bool attach_jt9_() {return mem_jt9.attach();}
|
||||
@@ -34,7 +32,7 @@ bool create_jt9_(int nsize) {return mem_jt9.create(nsize);}
|
||||
bool detach_jt9_() {return mem_jt9.detach();}
|
||||
bool lock_jt9_() {return mem_jt9.lock();}
|
||||
bool unlock_jt9_() {return mem_jt9.unlock();}
|
||||
char* address_jt9_() {return (char*)mem_jt9.constData();}
|
||||
struct jt9com * address_jt9_() {return reinterpret_cast<struct jt9com *>(mem_jt9.data());}
|
||||
int size_jt9_() {return (int)mem_jt9.size();}
|
||||
|
||||
// Multiple instances:
|
||||
|
||||
+126
-126
@@ -1,126 +1,126 @@
|
||||
program jt65
|
||||
|
||||
! Test the JT65 decoder for WSJT-X
|
||||
|
||||
use options
|
||||
character c
|
||||
logical :: display_help=.false.
|
||||
parameter (NZMAX=60*12000)
|
||||
integer*4 ihdr(11)
|
||||
integer*2 id2(NZMAX)
|
||||
real*4 dd(NZMAX)
|
||||
character*80 infile
|
||||
character(len=500) optarg
|
||||
character*6 mycall,hiscall,hisgrid
|
||||
common/tracer/limtrace,lu
|
||||
equivalence (lenfile,ihdr(2))
|
||||
type (option) :: long_options(9) = [ &
|
||||
option ('freq',.true.,'f','signal frequency, default FREQ=1270','FREQ'), &
|
||||
option ('help',.false.,'h','Display this help message',''), &
|
||||
option ('ntrials',.true.,'n','number of trials, default TRIALS=10000','TRIALS'), &
|
||||
option ('robust-sync',.false.,'r','robust sync',''), &
|
||||
option ('my-call',.true.,'c','my callsign',''), &
|
||||
option ('his-call',.true.,'d','his callsign',''), &
|
||||
option ('his-grid',.true.,'g','his grid locator',''), &
|
||||
option ('experience-decoding',.true.,'e' &
|
||||
,'experience decoding options (1..n), default FLAGS=0','FLAGS'), &
|
||||
option ('single-signal-mode',.false.,'s','decode at signal frequency only','') ]
|
||||
|
||||
limtrace=0
|
||||
lu=12
|
||||
ntol=10
|
||||
nfqso=1270
|
||||
nagain=0
|
||||
nsubmode=0
|
||||
ntrials=10000
|
||||
nlow=200
|
||||
nhigh=4000
|
||||
n2pass=2
|
||||
nrobust=0
|
||||
nexp_decoded=0
|
||||
|
||||
do
|
||||
call getopt('f:hn:rc:d:g:s',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.)
|
||||
if( nstat .ne. 0 ) then
|
||||
exit
|
||||
end if
|
||||
select case (c)
|
||||
case ('f')
|
||||
read (optarg(:narglen), *) nfqso
|
||||
case ('h')
|
||||
display_help = .true.
|
||||
case ('n')
|
||||
read (optarg(:narglen), *) ntrials
|
||||
case ('r')
|
||||
nrobust=1
|
||||
case ('c')
|
||||
read (optarg(:narglen), *) mycall
|
||||
case ('d')
|
||||
read (optarg(:narglen), *) hiscall
|
||||
case ('g')
|
||||
read (optarg(:narglen), *) hisgrid
|
||||
case ('e')
|
||||
read (optarg(:narglen), *) nexp_decoded
|
||||
case ('s')
|
||||
nlow=nfqso-ntol
|
||||
nhigh=nfqso+ntol
|
||||
n2pass=1
|
||||
end select
|
||||
end do
|
||||
|
||||
if(display_help .or. nstat.lt.0 .or. nremain.lt.1) then
|
||||
print *, ''
|
||||
print *, 'Usage: jt65 [OPTIONS] file1 [file2 ...]'
|
||||
print *, ''
|
||||
print *, ' JT65 decode pre-recorded .WAV file(s)'
|
||||
print *, ''
|
||||
print *, 'OPTIONS:'
|
||||
print *, ''
|
||||
do i = 1, size (long_options)
|
||||
call long_options(i) % print (6)
|
||||
end do
|
||||
go to 999
|
||||
endif
|
||||
|
||||
open(12,file='timer.out',status='unknown')
|
||||
call timer('jt65 ',0)
|
||||
|
||||
ndecoded=0
|
||||
do ifile=noffset+1,noffset+nremain
|
||||
newdat=1
|
||||
nfa=nlow
|
||||
nfb=nhigh
|
||||
call get_command_argument(ifile,optarg,narglen)
|
||||
infile=optarg(:narglen)
|
||||
open(10,file=infile,access='stream',status='old',err=998)
|
||||
call timer('read ',0)
|
||||
read(10) ihdr
|
||||
i1=index(infile,'.wav')
|
||||
if( i1 .eq. 0 ) i1=index(infile,'.WAV')
|
||||
read(infile(i1-4:i1-1),*,err=998) nutc
|
||||
npts=52*12000
|
||||
read(10) id2(1:npts)
|
||||
call timer('read ',1)
|
||||
dd(1:npts)=id2(1:npts)
|
||||
dd(npts+1:)=0.
|
||||
call timer('jt65a ',0)
|
||||
|
||||
! open(56,file='subtracted.wav',access='stream',status='unknown')
|
||||
! write(56) ihdr(1:11)
|
||||
|
||||
call jt65a(dd,npts,newdat,nutc,nfa,nfb,nfqso,ntol,nsubmode, &
|
||||
minsync,nagain,n2pass,nrobust,ntrials, naggressive,ndepth, &
|
||||
mycall,hiscall,hisgrid,nexp_decoded,ndecoded)
|
||||
call timer('jt65a ',1)
|
||||
enddo
|
||||
|
||||
call timer('jt65 ',1)
|
||||
call timer('jt65 ',101)
|
||||
! call four2a(a,-1,1,1,1) !Free the memory used for plans
|
||||
! call filbig(a,-1,1,0.0,0,0,0,0,0) ! (ditto)
|
||||
go to 999
|
||||
|
||||
998 print*,'Cannot read from file:'
|
||||
print*,infile
|
||||
|
||||
999 end program jt65
|
||||
program jt65
|
||||
|
||||
! Test the JT65 decoder for WSJT-X
|
||||
|
||||
use options
|
||||
character c
|
||||
logical :: display_help=.false.
|
||||
parameter (NZMAX=60*12000)
|
||||
integer*4 ihdr(11)
|
||||
integer*2 id2(NZMAX)
|
||||
real*4 dd(NZMAX)
|
||||
character*80 infile
|
||||
character(len=500) optarg
|
||||
character*6 mycall,hiscall,hisgrid
|
||||
common/tracer/limtrace,lu
|
||||
equivalence (lenfile,ihdr(2))
|
||||
type (option) :: long_options(9) = [ &
|
||||
option ('freq',.true.,'f','signal frequency, default FREQ=1270','FREQ'), &
|
||||
option ('help',.false.,'h','Display this help message',''), &
|
||||
option ('ntrials',.true.,'n','number of trials, default TRIALS=10000','TRIALS'), &
|
||||
option ('robust-sync',.false.,'r','robust sync',''), &
|
||||
option ('my-call',.true.,'c','my callsign',''), &
|
||||
option ('his-call',.true.,'x','his callsign',''), &
|
||||
option ('his-grid',.true.,'g','his grid locator',''), &
|
||||
option ('experience-decoding',.true.,'X' &
|
||||
,'experience decoding options (1..n), default FLAGS=0','FLAGS'), &
|
||||
option ('single-signal-mode',.false.,'s','decode at signal frequency only','') ]
|
||||
|
||||
limtrace=0
|
||||
lu=12
|
||||
ntol=10
|
||||
nfqso=1270
|
||||
nagain=0
|
||||
nsubmode=0
|
||||
ntrials=10000
|
||||
nlow=200
|
||||
nhigh=4000
|
||||
n2pass=2
|
||||
nrobust=0
|
||||
nexp_decoded=0
|
||||
|
||||
do
|
||||
call getopt('f:hn:rc:x:g:X',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.)
|
||||
if( nstat .ne. 0 ) then
|
||||
exit
|
||||
end if
|
||||
select case (c)
|
||||
case ('f')
|
||||
read (optarg(:narglen), *) nfqso
|
||||
case ('h')
|
||||
display_help = .true.
|
||||
case ('n')
|
||||
read (optarg(:narglen), *) ntrials
|
||||
case ('r')
|
||||
nrobust=1
|
||||
case ('c')
|
||||
read (optarg(:narglen), *) mycall
|
||||
case ('x')
|
||||
read (optarg(:narglen), *) hiscall
|
||||
case ('g')
|
||||
read (optarg(:narglen), *) hisgrid
|
||||
case ('X')
|
||||
read (optarg(:narglen), *) nexp_decoded
|
||||
case ('s')
|
||||
nlow=nfqso-ntol
|
||||
nhigh=nfqso+ntol
|
||||
n2pass=1
|
||||
end select
|
||||
end do
|
||||
|
||||
if(display_help .or. nstat.lt.0 .or. nremain.lt.1) then
|
||||
print *, ''
|
||||
print *, 'Usage: jt65 [OPTIONS] file1 [file2 ...]'
|
||||
print *, ''
|
||||
print *, ' JT65 decode pre-recorded .WAV file(s)'
|
||||
print *, ''
|
||||
print *, 'OPTIONS:'
|
||||
print *, ''
|
||||
do i = 1, size (long_options)
|
||||
call long_options(i) % print (6)
|
||||
end do
|
||||
go to 999
|
||||
endif
|
||||
|
||||
open(12,file='timer.out',status='unknown')
|
||||
call timer('jt65 ',0)
|
||||
|
||||
ndecoded=0
|
||||
do ifile=noffset+1,noffset+nremain
|
||||
newdat=1
|
||||
nfa=nlow
|
||||
nfb=nhigh
|
||||
call get_command_argument(ifile,optarg,narglen)
|
||||
infile=optarg(:narglen)
|
||||
open(10,file=infile,access='stream',status='old',err=998)
|
||||
call timer('read ',0)
|
||||
read(10) ihdr
|
||||
i1=index(infile,'.wav')
|
||||
if( i1 .eq. 0 ) i1=index(infile,'.WAV')
|
||||
read(infile(i1-4:i1-1),*,err=998) nutc
|
||||
npts=52*12000
|
||||
read(10) id2(1:npts)
|
||||
call timer('read ',1)
|
||||
dd(1:npts)=id2(1:npts)
|
||||
dd(npts+1:)=0.
|
||||
call timer('jt65a ',0)
|
||||
|
||||
! open(56,file='subtracted.wav',access='stream',status='unknown')
|
||||
! write(56) ihdr(1:11)
|
||||
|
||||
call jt65a(dd,npts,newdat,nutc,nfa,nfb,nfqso,ntol,nsubmode, &
|
||||
minsync,nagain,n2pass,nrobust,ntrials, naggressive,ndepth, &
|
||||
mycall,hiscall,hisgrid,nexp_decoded,ndecoded)
|
||||
call timer('jt65a ',1)
|
||||
enddo
|
||||
|
||||
call timer('jt65 ',1)
|
||||
call timer('jt65 ',101)
|
||||
! call four2a(a,-1,1,1,1) !Free the memory used for plans
|
||||
! call filbig(a,-1,1,0.0,0,0,0,0,0) ! (ditto)
|
||||
go to 999
|
||||
|
||||
998 print*,'Cannot read from file:'
|
||||
print*,infile
|
||||
|
||||
999 end program jt65
|
||||
|
||||
+89
-31
@@ -8,7 +8,8 @@ program jt9
|
||||
use, intrinsic :: iso_c_binding
|
||||
use FFTW3
|
||||
|
||||
include 'constants.f90'
|
||||
include 'jt9com.f90'
|
||||
|
||||
integer(C_INT) iret
|
||||
integer*4 ihdr(11)
|
||||
real*4 s(NSMAX)
|
||||
@@ -17,10 +18,10 @@ program jt9
|
||||
character(len=500) optarg, infile
|
||||
character wisfile*80
|
||||
integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, &
|
||||
fhigh=4000,nrxfreq=1500,ntrperiod=1,ndepth=60001
|
||||
fhigh=4000,nrxfreq=1500,ntrperiod0=1,ndepth=60001,nexp_decode=0
|
||||
logical :: shmem = .false., read_files = .false., &
|
||||
tx9 = .false., display_help = .false.
|
||||
type (option) :: long_options(17) = [ &
|
||||
type (option) :: long_options(22) = [ &
|
||||
option ('help', .false., 'h', 'Display this help message', ''), &
|
||||
option ('shmem',.true.,'s','Use shared memory for sample data','KEY'), &
|
||||
option ('tr-period', .true., 'p', 'Tx/Rx period, default MINUTES=1', &
|
||||
@@ -50,22 +51,25 @@ program jt9
|
||||
option ('jt4', .false., '4', 'JT4 mode', ''), &
|
||||
option ('depth', .true., 'd', &
|
||||
'JT9 decoding depth (1-3), default DEPTH=1', 'DEPTH'), &
|
||||
option ('tx-jt9', .false., 'T', 'Tx mode is JT9', '') ]
|
||||
|
||||
character datetime*20,mycall*12,mygrid*6,hiscall*12,hisgrid*6
|
||||
common/jt9com/ss(184,NSMAX),savg(NSMAX),id2(NMAX),nutc,ndiskdat, &
|
||||
ntr,mousefqso,newdat,npts8a,nfa,nfsplit,nfb,ntol,kin,nzhsym, &
|
||||
nsubmode,nagain,ndepth,ntxmode,nmode,minw,nclearave,minsync, &
|
||||
emedelay,dttol,nlist,listutc(10),n2pass,nranera,naggressive, &
|
||||
nrobust,nexp_decode,nspare(9),datetime,mycall,mygrid,hiscall,hisgrid
|
||||
option ('tx-jt9', .false., 'T', 'Tx mode is JT9', ''), &
|
||||
option ('my-call', .true., 'c', 'my callsign', 'CALL'), &
|
||||
option ('my-grid', .true., 'G', 'my grid locator', 'GRID'), &
|
||||
option ('his-call', .true., 'x', 'his callsign', 'CALL'), &
|
||||
option ('his-grid', .true., 'g', 'his grid locator', 'GRID'), &
|
||||
option ('experience-decode', .true., 'X', &
|
||||
'experience based decoding flags (1..n), default FLAGS=0', &
|
||||
'FLAGS') ]
|
||||
|
||||
type(dec_data), allocatable :: shared_data
|
||||
character(len=12) :: mycall, hiscall
|
||||
character(len=6) :: mygrid, hisgrid
|
||||
common/tracer/limtrace,lu
|
||||
common/patience/npatience,nthreads
|
||||
common/decstats/ntry65a,ntry65b,n65a,n65b,num9,numfano
|
||||
data npatience/1/,nthreads/1/
|
||||
|
||||
do
|
||||
call getopt('hs:e:a:r:m:p:d:f:w:t:964TL:S:H:',long_options,c, &
|
||||
call getopt('hs:e:a:r:m:p:d:f:w:t:964TL:S:H:c:G:x:g:X:',long_options,c, &
|
||||
optarg,arglen,stat,offset,remain,.true.)
|
||||
if (stat .ne. 0) then
|
||||
exit
|
||||
@@ -86,7 +90,7 @@ program jt9
|
||||
read (optarg(:arglen), *) nthreads
|
||||
case ('p')
|
||||
read_files = .true.
|
||||
read (optarg(:arglen), *) ntrperiod
|
||||
read (optarg(:arglen), *) ntrperiod0
|
||||
case ('d')
|
||||
read_files = .true.
|
||||
read (optarg(:arglen), *) ndepth
|
||||
@@ -116,6 +120,21 @@ program jt9
|
||||
tx9 = .true.
|
||||
case ('w')
|
||||
read (optarg(:arglen), *) npatience
|
||||
case ('c')
|
||||
read_files = .true.
|
||||
read (optarg(:arglen), *) mycall
|
||||
case ('G')
|
||||
read_files = .true.
|
||||
read (optarg(:arglen), *) mygrid
|
||||
case ('x')
|
||||
read_files = .true.
|
||||
read (optarg(:arglen), *) hiscall
|
||||
case ('g')
|
||||
read_files = .true.
|
||||
read (optarg(:arglen), *) hisgrid
|
||||
case ('X')
|
||||
read_files = .true.
|
||||
read (optarg(:arglen), *) nexp_decode
|
||||
end select
|
||||
end do
|
||||
|
||||
@@ -159,6 +178,7 @@ program jt9
|
||||
go to 999
|
||||
endif
|
||||
|
||||
allocate(shared_data)
|
||||
limtrace=0 !We're running jt9 in stand-alone mode
|
||||
lu=12
|
||||
nflatten=0
|
||||
@@ -169,32 +189,32 @@ program jt9
|
||||
open(10,file=infile,access='stream',status='old',err=998)
|
||||
read(10) ihdr
|
||||
nfsample=ihdr(7)
|
||||
nutc0=ihdr(1) !Silence compiler warning
|
||||
nutc=ihdr(1) !Silence compiler warning
|
||||
i1=index(infile,'.wav')
|
||||
if(i1.lt.1) i1=index(infile,'.WAV')
|
||||
if(infile(i1-5:i1-5).eq.'_') then
|
||||
read(infile(i1-4:i1-1),*,err=1) nutc0
|
||||
read(infile(i1-4:i1-1),*,err=1) nutc
|
||||
else
|
||||
read(infile(i1-6:i1-3),*,err=1) nutc0
|
||||
read(infile(i1-6:i1-3),*,err=1) nutc
|
||||
endif
|
||||
go to 2
|
||||
1 nutc0=0
|
||||
1 nutc=0
|
||||
2 nsps=0
|
||||
if(ntrperiod.eq.1) then
|
||||
if(ntrperiod0.eq.1) then
|
||||
nsps=6912
|
||||
nzhsym=181
|
||||
else if(ntrperiod.eq.2) then
|
||||
shared_data%params%nzhsym=181
|
||||
else if(ntrperiod0.eq.2) then
|
||||
nsps=15360
|
||||
nzhsym=178
|
||||
else if(ntrperiod.eq.5) then
|
||||
shared_data%params%nzhsym=178
|
||||
else if(ntrperiod0.eq.5) then
|
||||
nsps=40960
|
||||
nzhsym=172
|
||||
else if(ntrperiod.eq.10) then
|
||||
shared_data%params%nzhsym=172
|
||||
else if(ntrperiod0.eq.10) then
|
||||
nsps=82944
|
||||
nzhsym=171
|
||||
else if(ntrperiod.eq.30) then
|
||||
shared_data%params%nzhsym=171
|
||||
else if(ntrperiod0.eq.30) then
|
||||
nsps=252000
|
||||
nzhsym=167
|
||||
shared_data%params%nzhsym=167
|
||||
endif
|
||||
if(nsps.eq.0) stop 'Error: bad TRperiod'
|
||||
|
||||
@@ -212,7 +232,7 @@ program jt9
|
||||
do iblk=1,npts/kstep
|
||||
k=iblk*kstep
|
||||
call timer('read_wav',0)
|
||||
read(10,end=3) id2(k-kstep+1:k)
|
||||
read(10,end=3) shared_data%id2(k-kstep+1:k)
|
||||
go to 4
|
||||
3 call timer('read_wav',1)
|
||||
print*,'EOF on input file ',infile
|
||||
@@ -225,7 +245,7 @@ program jt9
|
||||
ingain=0
|
||||
call timer('symspec ',0)
|
||||
nminw=1
|
||||
call symspec(k,ntrperiod,nsps,ingain,nminw,pxdb,s,df3, &
|
||||
call symspec(shared_data,k,ntrperiod,nsps,ingain,nminw,pxdb,s,df3, &
|
||||
ihsym,npts8)
|
||||
call timer('symspec ',1)
|
||||
endif
|
||||
@@ -234,8 +254,46 @@ program jt9
|
||||
endif
|
||||
enddo
|
||||
close(10)
|
||||
call fillcom(nutc0,ndepth,nrxfreq,mode,tx9,flow,fsplit,fhigh)
|
||||
call decoder(ss,id2,nfsample)
|
||||
shared_data%params%nutc=nutc
|
||||
shared_data%params%ndiskdat=1
|
||||
shared_data%params%ntr=60
|
||||
shared_data%params%nfqso=nrxfreq
|
||||
shared_data%params%newdat=1
|
||||
shared_data%params%npts8=74736
|
||||
shared_data%params%nfa=flow
|
||||
shared_data%params%nfsplit=fsplit
|
||||
shared_data%params%nfb=fhigh
|
||||
shared_data%params%ntol=20
|
||||
shared_data%params%kin=64800
|
||||
shared_data%params%nzhsym=181
|
||||
shared_data%params%ndepth=ndepth
|
||||
shared_data%params%dttol=3.
|
||||
shared_data%params%minsync=-1 !### TEST ONLY
|
||||
shared_data%params%naggressive=1
|
||||
shared_data%params%n2pass=1
|
||||
shared_data%params%nranera=8 ! ntrials=10000
|
||||
shared_data%params%nrobust=0
|
||||
shared_data%params%nexp_decode=nexp_decode
|
||||
shared_data%params%mycall=mycall
|
||||
shared_data%params%mygrid=mygrid
|
||||
shared_data%params%hiscall=hiscall
|
||||
shared_data%params%hisgrid=hisgrid
|
||||
if (shared_data%params%mycall == '') shared_data%params%mycall='K1ABC'
|
||||
if (shared_data%params%hiscall == '') shared_data%params%hiscall='W9XYZ'
|
||||
if (shared_data%params%hisgrid == '') shared_data%params%hiscall='EN37'
|
||||
if (tx9) then
|
||||
shared_data%params%ntxmode=9
|
||||
else
|
||||
shared_data%params%ntxmode=65
|
||||
end if
|
||||
if (mode.eq.0) then
|
||||
shared_data%params%nmode=65+9
|
||||
else
|
||||
shared_data%params%nmode=mode
|
||||
end if
|
||||
shared_data%params%datetime="2013-Apr-16 15:13" !### Temp
|
||||
if(mode.eq.9 .and. fsplit.ne.2700) shared_data%params%nfa=fsplit
|
||||
call decoder(shared_data%ss,shared_data%id2,shared_data%params,nfsample)
|
||||
enddo
|
||||
|
||||
call timer('jt9 ',1)
|
||||
|
||||
+14
-8
@@ -1,21 +1,25 @@
|
||||
subroutine jt9a()
|
||||
|
||||
use, intrinsic :: iso_c_binding, only: c_f_pointer
|
||||
use prog_args
|
||||
|
||||
include 'jt9com.f90'
|
||||
|
||||
! These routines connect the shared memory region to the decoder.
|
||||
interface
|
||||
function address_jt9()
|
||||
integer*1, pointer :: address_jt9
|
||||
use, intrinsic :: iso_c_binding, only: c_ptr
|
||||
type(c_ptr) :: address_jt9
|
||||
end function address_jt9
|
||||
end interface
|
||||
|
||||
integer*1 attach_jt9
|
||||
! integer*1 lock_jt9,unlock_jt9
|
||||
integer size_jt9
|
||||
integer*1, pointer :: p_jt9
|
||||
character*80 cwd
|
||||
! Multiple instances:
|
||||
character*80 mykey
|
||||
type(dec_data), pointer :: shared_data
|
||||
type(params_block) :: local_params
|
||||
logical fileExists
|
||||
common/tracer/limtrace,lu
|
||||
|
||||
@@ -56,17 +60,19 @@ subroutine jt9a()
|
||||
print*,"Must start 'jt9 -s <thekey>' from within WSJT-X."
|
||||
go to 999
|
||||
endif
|
||||
p_jt9=>address_jt9()
|
||||
call timer('jt9b ',0)
|
||||
call jt9b(p_jt9,nbytes)
|
||||
call timer('jt9b ',1)
|
||||
call c_f_pointer(address_jt9(),shared_data)
|
||||
local_params=shared_data%params !save a copy because wsjtx carries on accessing
|
||||
call flush(6)
|
||||
call timer('decoder ',0)
|
||||
call decoder(shared_data%ss,shared_data%id2,local_params,12000)
|
||||
call timer('decoder ',1)
|
||||
|
||||
100 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists)
|
||||
if(fileExists) go to 10
|
||||
call sleep_msec(100)
|
||||
go to 100
|
||||
|
||||
999 call timer('jt9b ',101)
|
||||
999 call timer('decoder ',101)
|
||||
|
||||
return
|
||||
end subroutine jt9a
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
subroutine jt9b(jt9com,nbytes)
|
||||
|
||||
include 'constants.f90'
|
||||
integer*1 jt9com(0:nbytes-1)
|
||||
kss=0
|
||||
ksavg=kss + 4*184*NSMAX
|
||||
kid2=ksavg + 4*NSMAX
|
||||
knutc=kid2 + 2*NTMAX*12000
|
||||
call jt9c(jt9com(kss),jt9com(ksavg),jt9com(kid2),jt9com(knutc))
|
||||
|
||||
return
|
||||
end subroutine jt9b
|
||||
@@ -1,27 +0,0 @@
|
||||
subroutine jt9c(ss,savg,id2,nparams0)
|
||||
|
||||
include 'constants.f90'
|
||||
real*4 ss(184*NSMAX),savg(NSMAX)
|
||||
integer*2 id2(NTMAX*12000)
|
||||
|
||||
integer nparams0(61),nparams(61)
|
||||
character datetime*20,mycall*12,mygrid*6,hiscall*12,hisgrid*6
|
||||
common/npar/nutc,ndiskdat,ntrperiod,nfqso,newdat,npts8,nfa,nfsplit,nfb, &
|
||||
ntol,kin,nzhsym,nsave,nagain,ndepth,ntxmode,nmode,minw,nclearave, &
|
||||
minsync,emedelay,dttol,nlist,listutc(10),n2pass,nranera, &
|
||||
naggressive,nrobust,nexp_decode,nspare(9),datetime,mycall,mygrid, &
|
||||
hiscall,hisgrid
|
||||
|
||||
common/patience/npatience,nthreads
|
||||
equivalence (nparams,nutc)
|
||||
|
||||
nutc=id2(1)+int(savg(1)) !Silence compiler warning
|
||||
nparams=nparams0 !Copy parameters into common/npar/
|
||||
! if(ndiskdat.ne.0) npatience=2
|
||||
|
||||
call flush(6)
|
||||
nfsample=12000
|
||||
call decoder(ss,id2,nfsample)
|
||||
|
||||
return
|
||||
end subroutine jt9c
|
||||
@@ -0,0 +1,50 @@
|
||||
use, intrinsic :: iso_c_binding, only: c_int, c_short, c_float, c_char
|
||||
|
||||
include 'constants.f90'
|
||||
|
||||
!
|
||||
! these structures must be kept in sync with ../commons.h
|
||||
!
|
||||
type, bind(C) :: params_block
|
||||
integer(c_int) :: nutc
|
||||
integer(c_int) :: ndiskdat
|
||||
integer(c_int) :: ntr
|
||||
integer(c_int) :: nfqso
|
||||
integer(c_int) :: newdat
|
||||
integer(c_int) :: npts8
|
||||
integer(c_int) :: nfa
|
||||
integer(c_int) :: nfsplit
|
||||
integer(c_int) :: nfb
|
||||
integer(c_int) :: ntol
|
||||
integer(c_int) :: kin
|
||||
integer(c_int) :: nzhsym
|
||||
integer(c_int) :: nsubmode
|
||||
integer(c_int) :: nagain
|
||||
integer(c_int) :: ndepth
|
||||
integer(c_int) :: ntxmode
|
||||
integer(c_int) :: nmode
|
||||
integer(c_int) :: minw
|
||||
integer(c_int) :: nclearave
|
||||
integer(c_int) :: minsync
|
||||
real(c_float) :: emedelay
|
||||
real(c_float) :: dttol
|
||||
integer(c_int) :: nlist
|
||||
integer(c_int) :: listutc(10)
|
||||
integer(c_int) :: n2pass
|
||||
integer(c_int) :: nranera
|
||||
integer(c_int) :: naggressive
|
||||
integer(c_int) :: nrobust
|
||||
integer(c_int) :: nexp_decode
|
||||
character(kind=c_char, len=20) :: datetime
|
||||
character(kind=c_char, len=12) :: mycall
|
||||
character(kind=c_char, len=6) :: mygrid
|
||||
character(kind=c_char, len=12) :: hiscall
|
||||
character(kind=c_char, len=6) :: hisgrid
|
||||
end type params_block
|
||||
|
||||
type, bind(C) :: dec_data
|
||||
real(c_float) :: ss(184,NSMAX)
|
||||
real(c_float) :: savg(NSMAX)
|
||||
integer(c_short) :: id2(NMAX)
|
||||
type(params_block) :: params
|
||||
end type dec_data
|
||||
+10
-16
@@ -1,4 +1,4 @@
|
||||
subroutine symspec(k,ntrperiod,nsps,ingain,nminw,pxdb,s,df3,ihsym,npts8)
|
||||
subroutine symspec(shared_data,k,ntrperiod,nsps,ingain,nminw,pxdb,s,df3,ihsym,npts8)
|
||||
|
||||
! Input:
|
||||
! k pointer to the most recent new data
|
||||
@@ -17,23 +17,17 @@ subroutine symspec(k,ntrperiod,nsps,ingain,nminw,pxdb,s,df3,ihsym,npts8)
|
||||
! ss() JT9 symbol spectra at half-symbol steps
|
||||
! savg() average spectra for waterfall display
|
||||
|
||||
include 'constants.f90'
|
||||
include 'jt9com.f90'
|
||||
|
||||
type(dec_data) :: shared_data
|
||||
real*4 w3(MAXFFT3)
|
||||
real*4 s(NSMAX)
|
||||
real*4 ssum(NSMAX)
|
||||
real*4 xc(0:MAXFFT3-1)
|
||||
real*4 tmp(NSMAX)
|
||||
complex cx(0:MAXFFT3/2)
|
||||
integer*2 id2
|
||||
integer nch(7)
|
||||
|
||||
character datetime*20,mycall*12,mygrid*6,hiscall*12,hisgrid*6
|
||||
common/jt9com/ss(184,NSMAX),savg(NSMAX),id2(NMAX),nutc,ndiskdat, &
|
||||
ntr,mousefqso,newdat,npts8a,nfa,nfsplit,nfb,ntol,kin,nzhsym, &
|
||||
nsubmode,nagain,ndepth,ntxmode,nmode,minw,nclearave,minsync, &
|
||||
emedelay,dttol,nlist,listutc(10),datetime,mycall,mygrid, &
|
||||
hiscall,hisgrid
|
||||
|
||||
common/jt9w/syellow(NSMAX)
|
||||
data rms/999.0/,k0/99999999/,nfft3z/0/
|
||||
data nch/1,2,4,9,18,36,72/
|
||||
@@ -64,12 +58,12 @@ subroutine symspec(k,ntrperiod,nsps,ingain,nminw,pxdb,s,df3,ihsym,npts8)
|
||||
ja=0
|
||||
ssum=0.
|
||||
ihsym=0
|
||||
if(ndiskdat.eq.0) id2(k+1:)=0 !Needed to prevent "ghosts". Not sure why.
|
||||
if(shared_data%params%ndiskdat.eq.0) shared_data%id2(k+1:)=0 !Needed to prevent "ghosts". Not sure why.
|
||||
endif
|
||||
gain=10.0**(0.1*ingain)
|
||||
sq=0.
|
||||
do i=k0+1,k
|
||||
x1=id2(i)
|
||||
x1=shared_data%id2(i)
|
||||
sq=sq + x1*x1
|
||||
enddo
|
||||
sq=sq * gain
|
||||
@@ -85,7 +79,7 @@ subroutine symspec(k,ntrperiod,nsps,ingain,nminw,pxdb,s,df3,ihsym,npts8)
|
||||
do i=0,nfft3-1 !Copy data into cx
|
||||
j=ja+i-(nfft3-1)
|
||||
xc(i)=0.
|
||||
if(j.ge.1 .and.j.le.NMAX) xc(i)=fac0*id2(j)
|
||||
if(j.ge.1 .and.j.le.NMAX) xc(i)=fac0*shared_data%id2(j)
|
||||
enddo
|
||||
ihsym=ihsym+1
|
||||
|
||||
@@ -99,18 +93,18 @@ subroutine symspec(k,ntrperiod,nsps,ingain,nminw,pxdb,s,df3,ihsym,npts8)
|
||||
j=i-1
|
||||
if(j.lt.0) j=j+nfft3
|
||||
sx=fac*(real(cx(j))**2 + aimag(cx(j))**2)
|
||||
if(ihsym.le.184) ss(ihsym,i)=sx
|
||||
if(ihsym.le.184) shared_data%ss(ihsym,i)=sx
|
||||
ssum(i)=ssum(i) + sx
|
||||
s(i)=1000.0*gain*sx
|
||||
enddo
|
||||
|
||||
savg=ssum/ihsym
|
||||
shared_data%savg=ssum/ihsym
|
||||
|
||||
if(mod(ihsym,10).eq.0) then
|
||||
mode4=nch(nminw+1)
|
||||
nsmo=min(10*mode4,150)
|
||||
nsmo=4*nsmo
|
||||
call flat1(savg,iz,nsmo,syellow)
|
||||
call flat1(shared_data%savg,iz,nsmo,syellow)
|
||||
if(mode4.ge.2) call smo(syellow,iz,tmp,mode4)
|
||||
if(mode4.ge.2) call smo(syellow,iz,tmp,mode4)
|
||||
syellow(1:250)=0.
|
||||
|
||||
Reference in New Issue
Block a user