diff options
| author | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
| commit | ffc62c792c9a5196cb4ce7a353287dfe20db6524 (patch) | |
| tree | 1269efa852935b183daae4bb33a58d1b4d2ffb53 /lib/jt9.f90 | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
New upstream version 3.3.0~beta1+dfsgupstream/3.3.0_beta1+dfsg
Diffstat (limited to 'lib/jt9.f90')
| -rw-r--r-- | lib/jt9.f90 | 96 |
1 files changed, 57 insertions, 39 deletions
diff --git a/lib/jt9.f90 b/lib/jt9.f90 index be09716b..1e59bd8e 100644 --- a/lib/jt9.f90 +++ b/lib/jt9.f90 @@ -12,11 +12,10 @@ program jt9 use readwav use jt9_input_validation, only: parse_integer, parse_real, parse_wav_filename_nutc use, intrinsic :: iso_fortran_env, only: error_unit - use ft8_mod1, only : dd8 - use jt65_mod6, only : dd use streaming_emit, only: streaming_emit_set_enabled, streaming_emit_error use jt9_params_init, only: init_default_params, init_streaming_extra_fields, & apply_per_mode_policy, cli_args_t + use decode_completion_module, only: decode_completion_result, write_decode_completion include 'jt9com.f90' @@ -32,6 +31,8 @@ program jt9 real*4 s(NSMAX) real*8 TRperiod integer npct_unused + integer(c_int) :: engine_attempt_no, engine_valid_samples + integer(c_int64_t) :: engine_input_id character c character(len=500) optarg, infile @@ -45,11 +46,12 @@ program jt9 bLowSidelobes = .false., nexp_decode_set = .false., & have_ntol = .false.,multift8 = .false.,hidedupes = .false., & lft8lowth = .true.,lft8subpass = .true.,lwidedxcsearch = .true., & - stream_mode = .false. - type (option) :: long_options(43) = [ & + stream_mode = .false., use_mtd_fft_plans = .false., wav_utc_has_seconds + type (option) :: long_options(44) = [ & option ('help', .false., 'h', 'Display this help message', ''), & option ('version', .false., 'v', 'Display version and build revision', ''),& - option ('shmem',.true.,'s','Use shared memory for sample data','KEY'), & + option ('shmem',.true.,'s','Use native shared memory for sample data','NAME'), & + option ('ipc-lock', .true., '1', 'Shared-memory worker lifetime lock', 'PATH'), & option ('stream', .false., '0', & 'Read framed PCM samples from stdin', & ''), & @@ -135,7 +137,7 @@ program jt9 TRperiod=60.d0 do - call getopt('hvs:e:a:b:r:m:p:d:f:F:w:t:9876543WYqkTMUSZL:S:H:c:G:x:g:X:Q:C:R:N:E:D:', & + call getopt('hvs:e:a:b:r:m:p:d:f:F:w:t:9876543WYqkTMUSZL:S:H:c:G:x:g:X:Q:C:R:N:E:D:1:', & long_options,c,optarg,arglen,stat,offset,remain,.true.) if (stat .ne. 0) then exit @@ -148,6 +150,8 @@ program jt9 case ('s') read_files = .false. shm_key = optarg(:arglen) + case ('1') + ipc_lock_path = optarg(:arglen) case ('0') read_files = .false. stream_mode = .true. @@ -256,7 +260,7 @@ program jt9 print *, ' Reads data from *.wav files.' print *, '' print *, ' jt9 -s <key> [-w patience] [-m threads] [-e path] [-a path] [-t path] [-r path]' - print *, ' Gets data from shared memory region with key==<key>' + print *, ' Gets data from the native shared memory name supplied with -s' print *, '' print *, ' cat <pcm-stream> | jt9 --stream' print *, ' Reads framed PCM samples from stdin.' @@ -389,11 +393,14 @@ program jt9 ' Hz WAV sample rate for the selected mode' stop 2 end if - call parse_wav_filename_nutc(infile, nutc) + call parse_wav_filename_nutc(infile, nutc, wav_utc_has_seconds) + if((mode.eq.66.or.mode.eq.240.or.mode.eq.241.or.mode.eq.242).and..not.wav_utc_has_seconds) & + nutc=100*nutc nsps=6912 npts=TRperiod*12000.d0 kstep=nsps/2 k=0 + engine_valid_samples=0 nhsym=0 nhsym0=-999 if(iarg .eq. offset + 1) then @@ -405,7 +412,8 @@ program jt9 if(mode.eq.5) npts=21*3456 if(mode.eq.66) npts=TRperiod*12000 nblocks=npts/kstep - if(mode.eq.4) nblocks=(npts+kstep-1)/kstep + if(mode.eq.4.or.mode.eq.9.or.mode.eq.240.or.mode.eq.241.or.mode.eq.242) & + nblocks=(npts+kstep-1)/kstep do iblk=1,nblocks k0=(iblk-1)*kstep k=min(iblk*kstep,npts) @@ -421,12 +429,13 @@ program jt9 stop 2 end if if (samples_read == 0) then - print*,'EOF on input file ',trim(infile) + if(mode.ne.9.or.engine_valid_samples.eq.0) print*,'EOF on input file ',trim(infile) exit end if + engine_valid_samples=k0+samples_read nhsym=(k-2048)/kstep if(nhsym.ge.1 .and. nhsym.ne.nhsym0) then - if(mode.eq.9 .or. mode.eq.74) then + if(mode.eq.74) then ! Compute rough symbol spectra for the JT9 decoder ingain=0 call timer('symspec ',0) @@ -436,15 +445,17 @@ program jt9 call timer('symspec ',1) endif nhsym0=nhsym - if(nhsym.ge.181 .and. mode.ne.240 .and. mode.ne.241 .and. & + if(nhsym.ge.181 .and. mode.ne.9 .and. mode.ne.240 .and. mode.ne.241 .and. & mode.ne.242 .and. mode.ne.66) exit endif if (samples_read < k-k0) then - print*,'EOF on input file ',trim(infile) + if(mode.ne.9) print*,'EOF on input file ',trim(infile) exit end if enddo close(unit=wav%lun) + engine_input_id=int(iarg-offset,c_int64_t) + engine_attempt_no=0 ! WAV-path-only mode adjustment (mode=164 with submode<100 bumps by 100). ! Hoisted before init_default_params so the bumped value is threaded @@ -467,6 +478,7 @@ program jt9 call init_default_params(shared_data%params, mode, TRperiod, args) ! WAV-path post-init overrides. + shared_data%params%ntr = int(TRperiod) shared_data%params%nutc = nutc ! parsed from filename shared_data%params%ndiskdat = .true. ! reading from disk shared_data%params%nzhsym = nhsym ! per-period (matches former jt9.f90:486) @@ -518,19 +530,16 @@ program jt9 shared_data%params%nzhsym=nearly id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456) id2a(nearly*3456+1:)=0 - call multimode_decoder(shared_data%ss,id2a, & - shared_data%params,nfsample) + call run_engine_wav(id2a,nearly*3456) nearly=47 shared_data%params%nzhsym=nearly id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456) id2a(nearly*3456+1:)=0 - call multimode_decoder(shared_data%ss,id2a, & - shared_data%params,nfsample) + call run_engine_wav(id2a,nearly*3456) id2a(nearly*3456+1:50*3456)=shared_data%id2(nearly*3456+1:50*3456) id2a(50*3456+1:)=0 shared_data%params%nzhsym=50 - call multimode_decoder(shared_data%ss,id2a, & - shared_data%params,nfsample) + call run_engine_wav(id2a,50*3456) cycle else if(mode.eq.8 .and. shared_data%params%lmultift8) then if(shared_data%params%ndecoderstart.lt.2) then @@ -539,38 +548,24 @@ program jt9 shared_data%params%nzhsym=nearly id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456) id2a(nearly*3456+1:)=0 - call multimode_decoder(shared_data%ss,id2a, & - shared_data%params,nfsample) + call run_engine_wav(id2a,nearly*3456) if(shared_data%params%ndecoderstart.lt.2) then nearly=46 shared_data%params%lmultift8=.false. shared_data%params%nzhsym=nearly id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456) id2a(nearly*3456+1:)=0 - call multimode_decoder(shared_data%ss,id2a, & - shared_data%params,nfsample) + call run_engine_wav(id2a,nearly*3456) endif if(shared_data%params%ndecoderstart.eq.0) nearly=49 if(shared_data%params%ndecoderstart.eq.1) nearly=50 shared_data%params%lmultift8=.true. shared_data%params%nzhsym=nearly - id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456) - id2a(nearly*3456+1:)=0 - dd(1:nearly*3456)=shared_data%id2(1:nearly*3456) - dd(nearly*3456+1:)=0 - dd8(1:nearly*3456)=shared_data%id2(1:nearly*3456) - dd8(nearly*3456+1:)=0 else if(shared_data%params%ndecoderstart.eq.2) nearly=48 if(shared_data%params%ndecoderstart.eq.3) nearly=49 if(shared_data%params%ndecoderstart.eq.4) nearly=50 shared_data%params%nzhsym=nearly - id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456) - id2a(nearly*3456+1:)=0 - dd(1:nearly*3456)=shared_data%id2(1:nearly*3456) - dd(nearly*3456+1:)=0 - dd8(1:nearly*3456)=shared_data%id2(1:nearly*3456) - dd8(nearly*3456+1:)=0 endif ! MSK144 @@ -579,8 +574,15 @@ program jt9 endif ! Normal decoding pass - call multimode_decoder(shared_data%ss,shared_data%id2, & - shared_data%params,nfsample) + if(mode.eq.8.or.mode.eq.9.or.mode.eq.65.or.mode.eq.66.or. & + mode.eq.240.or.mode.eq.241.or.mode.eq.242) then + call run_engine_wav(shared_data%id2,engine_valid_samples) + else if(mode.eq.5) then + call run_engine_wav(shared_data%id2,72576) + else + call multimode_decoder(shared_data%ss,shared_data%id2, & + shared_data%params,nfsample) + endif enddo call timer('jt9 ',1) @@ -593,12 +595,14 @@ program jt9 ! Save FFTW wisdom and free memory if(len(trim(wisfile)).gt.0) iret=fftwf_export_wisdom_to_filename(wisfile) - if(mode.eq.8 .and. shared_data%params%lmultift8) then + if(allocated(shared_data)) then + use_mtd_fft_plans=mode.eq.8 .and. shared_data%params%lmultift8 + endif + if(use_mtd_fft_plans) then call four2avar(a,-1,1,1,1) call filbigvar(-1.,0,0.,0,0.,0.,0) !used for FFT plans for FT8 multithread detector else call four2a(a,-1,1,1,1) - call filbig(a,-1,1,0.0,0,0,0,0,0) !used for all other FFT plans endif call fftwf_cleanup_threads() call fftwf_cleanup() @@ -606,6 +610,20 @@ program jt9 contains + subroutine run_engine_wav(samples, pass_samples) + integer*2, intent(inout) :: samples(*) + integer, intent(in) :: pass_samples + type(decode_completion_result) :: completion + + engine_attempt_no=engine_attempt_no+1 + call run_decoder_engine(samples,shared_data%params, & + nfsample,completion,0,engine_input_id,engine_input_id, & + engine_attempt_no,min(engine_valid_samples,pass_samples)) + if(.not.completion%available) return + if(.not.lquiet) call write_decode_completion(completion) + call flush(6) + end subroutine run_engine_wav + subroutine require_integer(option, text, value) character(len=*), intent(in) :: option, text integer, intent(out) :: value |
