diff options
| author | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
| commit | 37f727ac0746fd85504aa46c1f023c09b3eff33a (patch) | |
| tree | c8a7ce04545040a8f161ba279528730bd9a3e6ab /lib/jt9.f90 | |
| parent | d63dd8d081a6fcd0715cd13f26df59fb831769d2 (diff) | |
New upstream version 1.8.0+repackupstream/1.8.0+repack
Diffstat (limited to 'lib/jt9.f90')
| -rw-r--r-- | lib/jt9.f90 | 299 |
1 files changed, 193 insertions, 106 deletions
diff --git a/lib/jt9.f90 b/lib/jt9.f90 index 5a0b77c6..10461209 100644 --- a/lib/jt9.f90 +++ b/lib/jt9.f90 @@ -7,172 +7,206 @@ program jt9 use prog_args use, intrinsic :: iso_c_binding use FFTW3 + use timer_module, only: timer + use timer_impl, only: init_timer, fini_timer + use readwav + + include 'jt9com.f90' - include 'constants.f90' integer(C_INT) iret - integer*4 ihdr(11) + type(wav_header) wav real*4 s(NSMAX) - integer*2 id2 character c character(len=500) optarg, infile character wisfile*80 - integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700,fhigh=4007,nrxfreq=1500,ntrperiod=1,ndepth=1 - logical :: shmem = .false., read_files = .false., have_args = .false., tx9 = .false., display_help = .false. - type (option) :: long_options(16) = [ & - 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=1', '<minutes>'), & - option ('executable-path', .true., 'e', 'Location of subordinate executables (KVASD) default="."', '<path>'), & - option ('data-path', .true., 'a', 'Location of writeable data files, detfault="."', '<path>'), & - option ('temp-path', .true., 't', 'Temporary files path, default="."', '<path>'), & - option ('lowest', .true., 'L', 'Lowest frequency decoded (JT65), default=200Hz', '<hertz>'), & - option ('highest', .true., 'H', 'Highest frequency decoded, default=4007Hz', '<hertz>'), & - option ('split', .true., 'S', 'Lowest JT9 frequency decoded, default=2700Hz', '<hertz>'), & - option ('rx-frequency', .true., 'f', 'Receive frequency offset, default=1500', '<hertz>'), & - option ('patience', .true., 'w', 'FFTW3 planing patience (0-4), default=1', '<patience>'), & - option ('fft-threads', .true., 'm', 'Number of threads to process large FFTs, default=1', '<number>'), & - option ('jt65', .false., '6', 'JT65 mode', ''), & - option ('jt9', .false., '9', 'JT9 mode', ''), & - option ('depth', .true., 'd', 'JT9 decoding depth (1-3), default=1', '<number>'), & - option ('tx-jt9', .false., 'T', 'Tx mode is JT9, default=JT65', '') ] - common/jt9com/ss(184,NSMAX),savg(NSMAX),id2(NMAX),nutc,ndiskdat,ntr, & - mousefqso,newdat,nfa,nfsplit,nfb,ntol,kin,nzhsym,nsynced,ndecoded - common/tracer/limtrace,lu +!### ndepth was defined as 60001. Why??? + integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, & + fhigh=4000,nrxfreq=1500,ntrperiod=1,ndepth=1,nexp_decode=0 + logical :: read_files = .true., tx9 = .false., display_help = .false. + type (option) :: long_options(25) = [ & + 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', & + 'MINUTES'), & + option ('executable-path', .true., 'e', & + 'Location of subordinate executables (KVASD) default PATH="."', & + 'PATH'), & + option ('data-path', .true., 'a', & + 'Location of writeable data files, default PATH="."', 'PATH'), & + option ('temp-path', .true., 't', & + 'Temporary files path, default PATH="."', 'PATH'), & + option ('lowest', .true., 'L', & + 'Lowest frequency decoded (JT65), default HERTZ=200', 'HERTZ'), & + option ('highest', .true., 'H', & + 'Highest frequency decoded, default HERTZ=4007', 'HERTZ'), & + option ('split', .true., 'S', & + 'Lowest JT9 frequency decoded, default HERTZ=2700', 'HERTZ'), & + option ('rx-frequency', .true., 'f', & + 'Receive frequency offset, default HERTZ=1500', 'HERTZ'), & + option ('patience', .true., 'w', & + 'FFTW3 planing patience (0-4), default PATIENCE=1', 'PATIENCE'), & + option ('fft-threads', .true., 'm', & + 'Number of threads to process large FFTs, default THREADS=1', & + 'THREADS'), & + option ('jt65', .false., '6', 'JT65 mode', ''), & + option ('jt9', .false., '9', 'JT9 mode', ''), & + option ('ft8', .false., '8', 'FT8 mode', ''), & + option ('jt4', .false., '4', 'JT4 mode', ''), & + option ('qra64', .false., 'q', 'QRA64 mode', ''), & + option ('sub-mode', .true., 'b', 'Sub mode, default SUBMODE=A', 'A'), & + option ('depth', .true., 'd', & + 'JT9 decoding depth (1-3), default DEPTH=1', 'DEPTH'), & + 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/patience/npatience,nthreads - common/decstats/num65,numbm,numkv,num9,numfano,infile + common/decstats/ntry65a,ntry65b,n65a,n65b,num9,numfano data npatience/1/,nthreads/1/ + nsubmode = 0 + do - call getopt('hs:e:a:r:m:p:d:f:w:t:96TL:S:H:',long_options,c,optarg,arglen,stat, & - offset,remain) + call getopt('hs:e:a:b:r:m:p:d:f:w:t:9864qTL:S:H:c:G:x:g:X:', & + long_options,c,optarg,arglen,stat,offset,remain,.true.) if (stat .ne. 0) then exit end if - have_args = .true. select case (c) case ('h') display_help = .true. - case ('s') - shmem = .true. + read_files = .false. shm_key = optarg(:arglen) - case ('e') exe_dir = optarg(:arglen) - case ('a') data_dir = optarg(:arglen) - + case ('b') + nsubmode = ichar (optarg(:1)) - ichar ('A') case ('t') temp_dir = optarg(:arglen) - case ('m') read (optarg(:arglen), *) nthreads - case ('p') - read_files = .true. read (optarg(:arglen), *) ntrperiod - case ('d') - read_files = .true. read (optarg(:arglen), *) ndepth - case ('f') - read_files = .true. read (optarg(:arglen), *) nrxfreq - case ('L') - read_files = .true. read (optarg(:arglen), *) flow - case ('S') - read_files = .true. read (optarg(:arglen), *) fsplit - case ('H') - read_files = .true. read (optarg(:arglen), *) fhigh - + case ('q') + mode = 164 + case ('4') + mode = 4 case ('6') - read_files = .true. if (mode.lt.65) mode = mode + 65 - case ('9') - read_files = .true. if (mode.lt.9.or.mode.eq.65) mode = mode + 9 - + case ('8') + mode = 8 case ('T') - read_files = .true. tx9 = .true. - case ('w') read (optarg(:arglen), *) npatience - + case ('c') + read (optarg(:arglen), *) mycall + case ('G') + read (optarg(:arglen), *) mygrid + case ('x') + read (optarg(:arglen), *) hiscall + case ('g') + read (optarg(:arglen), *) hisgrid + case ('X') + read (optarg(:arglen), *) nexp_decode end select end do - if (display_help .or. .not. have_args .or. (stat .lt. 0 .or. (shmem .and. remain .gt. 0) & - .or. (read_files .and. remain .eq. 0) .or. & - (shmem .and. read_files))) then - print*,'Usage: jt9 -p <per> OPTIONS file1 [file2 ...]' - print*,' Reads data from *.wav files.' - print*,'' - print*,' jt9 -s <key> [-w n] [-m n] [-e path] [-a path] [-t path]' - print*,' Gets data from shared memory region with key==<key>' + if (display_help .or. stat .lt. 0 & + .or. (.not. read_files .and. remain .gt. 0) & + .or. (read_files .and. remain .lt. 1)) then + + print *, 'Usage: jt9 [OPTIONS] file1 [file2 ...]' + print *, ' Reads data from *.wav files.' + print *, '' + print *, ' jt9 -s <key> [-w patience] [-m threads] [-e path] [-a path] [-t path]' + print *, ' Gets data from shared memory region with key==<key>' + print *, '' + print *, 'OPTIONS:' + print *, '' do i = 1, size (long_options) - print*,'' call long_options(i) % print (6) end do go to 999 endif + + iret=fftwf_init_threads() !Initialize FFTW threading + +! Default to 1 thread, but use nthreads for the big ones + call fftwf_plan_with_nthreads(1) - iret=fftwf_init_threads() !Initialize FFTW threading - call fftwf_plan_with_nthreads(1) !Default to 1 thread but use nthreads for the big ones ! Import FFTW wisdom, if available wisfile=trim(data_dir)//'/jt9_wisdom.dat'// C_NULL_CHAR iret=fftwf_import_wisdom_from_filename(wisfile) - num65=0 - numbm=0 - numkv=0 + ntry65a=0 + ntry65b=0 + n65a=0 + n65b=0 num9=0 numfano=0 - if (shmem) then - call jt9a() + if (.not. read_files) then + call jt9a() !We're running under control of WSJT-X go to 999 endif - limtrace=0 - lu=12 + allocate(shared_data) nflatten=0 do iarg = offset + 1, offset + remain call get_command_argument (iarg, optarg, arglen) infile = optarg(:arglen) - open(10,file=infile,access='stream',status='old',err=998) - read(10) ihdr - nutc0=ihdr(1) !Silence compiler warning + call wav%read (infile) + nfsample=wav%audio_format%sample_rate i1=index(infile,'.wav') - read(infile(i1-4:i1-1),*,err=1) nutc0 + if(i1.lt.1) i1=index(infile,'.WAV') + if(infile(i1-5:i1-5).eq.'_') then + read(infile(i1-4:i1-1),*,err=1) nutc + else + read(infile(i1-6:i1-1),*,err=1) nutc + endif go to 2 -1 nutc0=0 +1 nutc=0 2 nsps=0 if(ntrperiod.eq.1) then nsps=6912 - nzhsym=173 + shared_data%params%nzhsym=181 else if(ntrperiod.eq.2) then nsps=15360 - nzhsym=178 + shared_data%params%nzhsym=178 else if(ntrperiod.eq.5) then nsps=40960 - nzhsym=172 + shared_data%params%nzhsym=172 else if(ntrperiod.eq.10) then nsps=82944 - nzhsym=171 + shared_data%params%nzhsym=171 else if(ntrperiod.eq.30) then nsps=252000 - nzhsym=167 + shared_data%params%nzhsym=167 endif if(nsps.eq.0) stop 'Error: bad TRperiod' @@ -181,47 +215,101 @@ program jt9 nhsym0=-999 npts=(60*ntrperiod-6)*12000 if(iarg .eq. offset + 1) then - open(12,file=trim(data_dir)//'/timer.out',status='unknown') + call init_timer (trim(data_dir)//'/timer.out') call timer('jt9 ',0) endif - id2=0 !??? Why is this necessary ??? + shared_data%id2=0 !??? Why is this necessary ??? do iblk=1,npts/kstep k=iblk*kstep + if(mode.eq.8 .and. k.gt.179712) exit call timer('read_wav',0) - read(10,end=10) id2(k-kstep+1:k) - call timer('read_wav',1) - + read(unit=wav%lun,end=3) shared_data%id2(k-kstep+1:k) + go to 4 +3 call timer('read_wav',1) + print*,'EOF on input file ',infile + exit +4 call timer('read_wav',1) nhsym=(k-2048)/kstep if(nhsym.ge.1 .and. nhsym.ne.nhsym0) then -! Emit signal readyForFFT - ingain=0 - call timer('symspec ',0) - call symspec(k,ntrperiod,nsps,ingain,nflatten,pxdb,s,df3,ihsym,npts8) - call timer('symspec ',1) + if(mode.eq.9 .or. mode.eq.74) then +! Compute rough symbol spectra for the JT9 decoder + ingain=0 + call timer('symspec ',0) + nminw=1 + call symspec(shared_data,k,ntrperiod,nsps,ingain,nminw,pxdb, & + s,df3,ihsym,npts8,pxdbmax) + call timer('symspec ',1) + endif nhsym0=nhsym - if(ihsym.ge.173) go to 10 + if(nhsym.ge.181) exit endif enddo - -10 close(10) - call fillcom(nutc0,ndepth,nrxfreq,mode,tx9,flow,fsplit,fhigh) - call decoder(ss,id2) + close(unit=wav%lun) + shared_data%params%nutc=nutc + shared_data%params%ndiskdat=.true. + shared_data%params%ntr=60 + shared_data%params%nfqso=nrxfreq + shared_data%params%newdat=.true. + 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%lapon=.true. + shared_data%params%napwid=75 + shared_data%params%dttol=3. + +! shared_data%params%minsync=0 !### TEST ONLY +! shared_data%params%nfqso=1500 !### TEST ONLY +! mycall="G3WDG " !### TEST ONLY +! hiscall="VK7MO " !### TEST ONLY +! hisgrid="QE37 " !### TEST ONLY + if(mode.eq.164 .and. nsubmode.lt.100) nsubmode=nsubmode+100 + + shared_data%params%naggressive=0 + shared_data%params%n2pass=2 +! shared_data%params%nranera=8 !### ntrials=10000 + shared_data%params%nranera=6 !### ntrials=3000 + shared_data%params%nrobust=.false. + 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%nsubmode=nsubmode + shared_data%params%datetime="2013-Apr-16 15:13" !### Temp + if(mode.eq.9 .and. fsplit.ne.2700) shared_data%params%nfa=fsplit + call multimode_decoder(shared_data%ss,shared_data%id2,shared_data%params,nfsample) enddo call timer('jt9 ',1) call timer('jt9 ',101) - go to 999 - -998 print*,'Cannot open file:' - print*,infile 999 continue ! Output decoder statistics - write(12,1100) numbm,numkv,numbm+numkv,num65,numfano,num9 -1100 format(58('-')/' BM KV JT65 Tries JT9 Tries'/ & - 58('-')/6i8) + call fini_timer () +! open (unit=12, file=trim(data_dir)//'/timer.out', status='unknown', position='append') +! write(12,1100) n65a,ntry65a,n65b,ntry65b,numfano,num9 +!1100 format(58('-')/' JT65_1 Tries_1 JT65_2 Tries_2 JT9 Tries'/ & +! 58('-')/6i8) ! Save wisdom and free memory iret=fftwf_export_wisdom_to_filename(wisfile) @@ -229,5 +317,4 @@ program jt9 call filbig(a,-1,1,0.0,0,0,0,0,0) !used for FFT plans call fftwf_cleanup_threads() call fftwf_cleanup() - end program jt9 |
