mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-01 16:13:57 -04:00
95926577ae
Groundwork for calling the decoders directly from C/C++ threads. To access the timer module timer_module must now be used. Instrumented code need only use the module function 'timer' which is now a procedure pointer that is guaranteed to be associated (unless null() is assigned to it, which should not be done). The default behaviour of 'timer' is to do nothing. If a Fortran program wishes to profile code it should now use the timer_impl module which contains a default timer implementation. The main program should call 'init_timer([filename])' before using 'timer' or calling routines that are instrumented. If 'init_timer([filename])'. If it is called then an optional file name may be provided with 'timer.out' being used as a default. The procedure 'fini_timer()' may be called to close the file. The default timer implementation is thread safe if used with OpenMP multi-threaded code so long as the OpenMP thread team is given the copyin(/timer_private/) attribute for correct operation. The common block /timer_private/ should be included for OpenMP use by including the file 'timer_common.inc'. The module 'lib/timer_C_wrapper.f90' provides a Fortran wrapper along with 'init' and 'fini' subroutines which allow a C/C++ application to call timer instrumented Fortran code and for it to receive callbacks of 'timer()' subroutine invocations. No C/C++ timer implementation is provided at this stage. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6320 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
130 lines
3.7 KiB
Fortran
130 lines
3.7 KiB
Fortran
program jt65
|
|
|
|
! Test the JT65 decoder for WSJT-X
|
|
|
|
use options
|
|
use timer_module, only: timer
|
|
use timer_impl, only: init_timer
|
|
|
|
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*12 mycall,hiscall
|
|
character*6 hisgrid
|
|
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','') ]
|
|
|
|
ntol=10
|
|
nfqso=1270
|
|
nagain=0
|
|
nsubmode=0
|
|
ntrials=10000
|
|
nlow=200
|
|
nhigh=4000
|
|
n2pass=2
|
|
nrobust=0
|
|
nexp_decoded=0
|
|
naggressive=1
|
|
|
|
do
|
|
call getopt('f:hn:rc:x:g:X: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 ('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
|
|
|
|
call init_timer()
|
|
call timer('jt65 ',0)
|
|
|
|
ndecoded=0
|
|
do ifile=noffset+1,noffset+nremain
|
|
newdat=1
|
|
nfa=nlow
|
|
nfb=nhigh
|
|
minsync=0
|
|
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
|