diff options
| author | Christoph Berg <myon@debian.org> | 2020-05-11 22:17:58 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2020-05-11 22:17:58 +0200 |
| commit | 32a41b1abe1a4aab0892c9c2051be6ba5b379f1e (patch) | |
| tree | c6e107c1ee4d70610e43a7912e57c720334a08c7 /lib/jt9a.f90 | |
| parent | 08299e8b2bf50ba90daf570f57def529dd29d6e7 (diff) | |
New upstream version 2.2.0~rc1+repackupstream/2.2.0_rc1+repack
Diffstat (limited to 'lib/jt9a.f90')
| -rw-r--r-- | lib/jt9a.f90 | 99 |
1 files changed, 59 insertions, 40 deletions
diff --git a/lib/jt9a.f90 b/lib/jt9a.f90 index 9729e080..b0df912c 100644 --- a/lib/jt9a.f90 +++ b/lib/jt9a.f90 @@ -1,30 +1,17 @@ subroutine jt9a() - use, intrinsic :: iso_c_binding, only: c_f_pointer + use, intrinsic :: iso_c_binding, only: c_f_pointer, c_null_char, c_bool use prog_args use timer_module, only: timer use timer_impl, only: init_timer !, limtrace + use shmem include 'jt9com.f90' -! These routines connect the shared memory region to the decoder. - interface - function 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*2 id2a(180000) ! Multiple instances: - character*80 mykey - type(dec_data), pointer :: shared_data + type(dec_data), pointer, volatile :: shared_data !also makes target volatile type(params_block) :: local_params - logical fileExists - -! Multiple instances: - i0 = len(trim(shm_key)) + logical(c_bool) :: ok call init_timer (trim(data_dir)//'/timer.out') ! open(23,file=trim(data_dir)//'/CALL3.TXT',status='unknown') @@ -32,43 +19,75 @@ subroutine jt9a() ! limtrace=-1 !Disable all calls to timer() ! Multiple instances: set the shared memory key before attaching - mykey=trim(repeat(shm_key,1)) - i0 = len(mykey) - i0=setkey_jt9(trim(mykey)) - i1=attach_jt9() - msdelay=10 + call shmem_setkey(trim(shm_key)//c_null_char) + ok=shmem_attach() + if(.not.ok) call abort + msdelay=30 + call c_f_pointer(shmem_address(),shared_data) -10 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists) - if(fileExists) then +! Terminate if ipc(2) is 999 +10 ok=shmem_lock() + if(.not.ok) call abort + if(shared_data%ipc(2).eq.999.0) then + ok=shmem_unlock() + ok=shmem_detach() + go to 999 + endif +! Wait here until GUI has set ipc(2) to 1 + if(shared_data%ipc(2).ne.1) then + ok=shmem_unlock() + if(.not.ok) call abort call sleep_msec(msdelay) go to 10 endif + shared_data%ipc(2)=0 - inquire(file=trim(temp_dir)//'/.quit',exist=fileExists) - if(fileExists) then - i1=detach_jt9() - go to 999 - endif - if(i1.eq.999999) stop !Silence compiler warning - - nbytes=size_jt9() + nbytes=shmem_size() if(nbytes.le.0) then - print*,'jt9a: Shared memory mem_jt9 does not exist.' + ok=shmem_unlock() + ok=shmem_detach() + print*,'jt9a: Shared memory does not exist.' print*,"Must start 'jt9 -s <thekey>' from within WSJT-X." go to 999 endif - call c_f_pointer(address_jt9(),shared_data) - local_params=shared_data%params !save a copy because wsjtx carries on accessing + local_params=shared_data%params !save a copy because wsjtx carries on accessing + ok=shmem_unlock() + if(.not.ok) call abort call flush(6) call timer('decoder ',0) + if(local_params%nmode.eq.8 .and. local_params%ndiskdat) then +! Early decoding pass, FT8 only, when wsjtx reads from disk + nearly=41 + local_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,local_params,12000) + nearly=47 + local_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,local_params,12000) + local_params%nzhsym=50 + endif +! Normal decoding pass call multimode_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(msdelay) - go to 100 +! Wait here until GUI routine decodeDone() has set ipc(3) to 1 +100 ok=shmem_lock() + if(.not.ok) call abort + if(shared_data%ipc(3).ne.1) then + ok=shmem_unlock() + if(.not.ok) call abort + call sleep_msec(msdelay) + go to 100 + endif + shared_data%ipc(3)=0 + ok=shmem_unlock() + if(.not.ok) call abort + go to 10 + 999 call timer('decoder ',101) return |
