| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  | subroutine jt9a()
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |   use, intrinsic :: iso_c_binding, only: c_f_pointer, c_null_char, c_bool
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  |   use prog_args
 | 
					
						
							| 
									
										
										
										
											2015-12-27 15:40:57 +00:00
										 |  |  |   use timer_module, only: timer
 | 
					
						
							|  |  |  |   use timer_impl, only: init_timer !, limtrace
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |   use shmem
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 20:29:55 +00:00
										 |  |  |   include 'jt9com.f90'
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 11:16:54 -05:00
										 |  |  |   integer*2 id2a(180000)
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  | ! Multiple instances:
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |   type(dec_data), pointer, volatile :: shared_data !also makes target volatile
 | 
					
						
							| 
									
										
										
										
											2015-12-17 20:29:55 +00:00
										 |  |  |   type(params_block) :: local_params
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |   logical(c_bool) :: ok
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-27 15:40:57 +00:00
										 |  |  |   call init_timer (trim(data_dir)//'/timer.out')
 | 
					
						
							| 
									
										
										
										
											2015-04-22 17:48:03 +00:00
										 |  |  | !  open(23,file=trim(data_dir)//'/CALL3.TXT',status='unknown')
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | !  limtrace=-1                            !Disable all calls to timer()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Multiple instances: set the shared memory key before attaching
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |   call shmem_setkey(trim(shm_key)//c_null_char)
 | 
					
						
							|  |  |  |   ok=shmem_attach()
 | 
					
						
							|  |  |  |   if(.not.ok) call abort
 | 
					
						
							| 
									
										
										
										
											2020-03-14 17:06:54 -04:00
										 |  |  |   msdelay=30
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |   call c_f_pointer(shmem_address(),shared_data)
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  | ! Terminate if ipc(2) is 999
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:35:08 -04:00
										 |  |  | 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
 | 
					
						
							| 
									
										
										
										
											2020-03-16 11:08:09 -04:00
										 |  |  | ! Wait here until GUI has set ipc(2) to 1
 | 
					
						
							|  |  |  |   if(shared_data%ipc(2).ne.1) then
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |      ok=shmem_unlock()
 | 
					
						
							|  |  |  |      if(.not.ok) call abort
 | 
					
						
							| 
									
										
										
										
											2020-03-14 17:06:54 -04:00
										 |  |  |      call sleep_msec(msdelay)
 | 
					
						
							|  |  |  |      go to 10
 | 
					
						
							|  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2020-03-15 14:25:56 -04:00
										 |  |  |   shared_data%ipc(2)=0
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |   nbytes=shmem_size()
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  |   if(nbytes.le.0) then
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |      ok=shmem_unlock()
 | 
					
						
							|  |  |  |      ok=shmem_detach()
 | 
					
						
							|  |  |  |      print*,'jt9a: Shared memory does not exist.'
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  |      print*,"Must start 'jt9 -s <thekey>' from within WSJT-X."
 | 
					
						
							|  |  |  |      go to 999
 | 
					
						
							|  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2020-03-12 14:31:02 -04:00
										 |  |  |   local_params=shared_data%params !save a copy because wsjtx carries on accessing  
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |   ok=shmem_unlock()
 | 
					
						
							|  |  |  |   if(.not.ok) call abort
 | 
					
						
							| 
									
										
										
										
											2015-12-17 20:29:55 +00:00
										 |  |  |   call flush(6)
 | 
					
						
							|  |  |  |   call timer('decoder ',0)
 | 
					
						
							| 
									
										
										
										
											2020-02-14 11:16:54 -05:00
										 |  |  |   if(local_params%nmode.eq.8 .and. local_params%ndiskdat) then
 | 
					
						
							| 
									
										
										
										
											2020-03-05 15:37:31 -05:00
										 |  |  | ! Early decoding pass, FT8 only, when wsjtx reads from disk
 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:03:39 -05:00
										 |  |  |      nearly=41
 | 
					
						
							| 
									
										
										
										
											2020-02-14 11:16:54 -05:00
										 |  |  |      local_params%nzhsym=nearly
 | 
					
						
							|  |  |  |      id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456)
 | 
					
						
							|  |  |  |      id2a(nearly*3456+1:)=0
 | 
					
						
							| 
									
										
										
										
											2020-03-19 15:53:44 -04:00
										 |  |  |      call multimode_decoder(shared_data%ss,id2a,local_params,12000)
 | 
					
						
							| 
									
										
										
										
											2020-03-05 15:37:31 -05:00
										 |  |  |      nearly=47
 | 
					
						
							|  |  |  |      local_params%nzhsym=nearly
 | 
					
						
							|  |  |  |      id2a(1:nearly*3456)=shared_data%id2(1:nearly*3456)
 | 
					
						
							|  |  |  |      id2a(nearly*3456+1:)=0
 | 
					
						
							| 
									
										
										
										
											2020-03-19 15:53:44 -04:00
										 |  |  |      call multimode_decoder(shared_data%ss,id2a,local_params,12000)
 | 
					
						
							| 
									
										
										
										
											2020-02-14 11:16:54 -05:00
										 |  |  |      local_params%nzhsym=50
 | 
					
						
							|  |  |  |   endif
 | 
					
						
							|  |  |  | ! Normal decoding pass
 | 
					
						
							| 
									
										
										
										
											2020-03-19 15:53:44 -04:00
										 |  |  |   call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000)
 | 
					
						
							| 
									
										
										
										
											2015-12-17 20:29:55 +00:00
										 |  |  |   call timer('decoder ',1)
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  | ! Wait here until GUI routine decodeDone() has set ipc(3) to 1
 | 
					
						
							|  |  |  | 100 ok=shmem_lock()
 | 
					
						
							|  |  |  |   if(.not.ok) call abort
 | 
					
						
							| 
									
										
										
										
											2020-03-16 11:08:09 -04:00
										 |  |  |   if(shared_data%ipc(3).ne.1) then
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |      ok=shmem_unlock()
 | 
					
						
							|  |  |  |      if(.not.ok) call abort
 | 
					
						
							| 
									
										
										
										
											2020-03-14 17:06:54 -04:00
										 |  |  |      call sleep_msec(msdelay)
 | 
					
						
							|  |  |  |      go to 100
 | 
					
						
							|  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2020-03-15 14:25:56 -04:00
										 |  |  |   shared_data%ipc(3)=0
 | 
					
						
							| 
									
										
										
										
											2020-03-16 10:27:22 -04:00
										 |  |  |   ok=shmem_unlock()
 | 
					
						
							|  |  |  |   if(.not.ok) call abort
 | 
					
						
							| 
									
										
										
										
											2020-03-14 17:06:54 -04:00
										 |  |  |   go to 10
 | 
					
						
							|  |  |  |   
 | 
					
						
							| 
									
										
										
										
											2015-12-17 20:29:55 +00:00
										 |  |  | 999 call timer('decoder ',101)
 | 
					
						
							| 
									
										
										
										
											2014-12-03 00:06:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return
 | 
					
						
							|  |  |  | end subroutine jt9a
 |