| 
									
										
										
										
											2020-10-25 13:58:18 -04:00
										 |  |  | program test_q65
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-29 13:17:09 -04:00
										 |  |  |   character*84 cmd1,cmd2,line
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   character*22 msg
 | 
					
						
							|  |  |  |   character*8 arg
 | 
					
						
							| 
									
										
										
										
											2020-10-03 08:25:17 -04:00
										 |  |  |   character*1 csubmode
 | 
					
						
							| 
									
										
										
										
											2021-01-01 15:28:41 -05:00
										 |  |  |   integer naptype(0:5)
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   logical decok
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   nargs=iargc()
 | 
					
						
							| 
									
										
										
										
											2021-01-03 11:19:39 -05:00
										 |  |  |   if(nargs.ne.12) then
 | 
					
						
							|  |  |  |      print*,'Usage:   test_q65        "msg"       A-D depth freq  DT fDop  f1 Stp TRp Q nfiles SNR'
 | 
					
						
							|  |  |  |      print*,'Example: test_q65 "K1ABC W9XYZ EN37"  A    3   1500 0.0  5.0 0.0  1   60 3  100   -20'
 | 
					
						
							| 
									
										
										
										
											2020-11-17 15:09:03 -05:00
										 |  |  |      print*,'Use SNR = 0 to loop over all relevant SNRs'
 | 
					
						
							|  |  |  |      print*,'Use MyCall=K1ABC, HisCall=W9XYZ, HisGrid="EN37" for AP decodes'
 | 
					
						
							| 
									
										
										
										
											2020-11-17 15:31:33 -05:00
										 |  |  |      print*,'Option Q sets QSOprogress (0-5) for AP decoding.'
 | 
					
						
							|  |  |  |      print*,'Add 16 to requested depth to enable message averaging.'
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |      go to 999
 | 
					
						
							|  |  |  |   endif
 | 
					
						
							|  |  |  |   call getarg(1,msg)
 | 
					
						
							| 
									
										
										
										
											2020-10-03 08:25:17 -04:00
										 |  |  |   call getarg(2,csubmode)
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   call getarg(3,arg)
 | 
					
						
							| 
									
										
										
										
											2020-10-03 08:25:17 -04:00
										 |  |  |   read(arg,*) ndepth
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   call getarg(4,arg)
 | 
					
						
							| 
									
										
										
										
											2020-10-03 08:25:17 -04:00
										 |  |  |   read(arg,*) nf0
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   call getarg(5,arg)
 | 
					
						
							| 
									
										
										
										
											2020-10-03 08:25:17 -04:00
										 |  |  |   read(arg,*) dt
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   call getarg(6,arg)
 | 
					
						
							| 
									
										
										
										
											2020-10-03 08:25:17 -04:00
										 |  |  |   read(arg,*) fDop
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   call getarg(7,arg)
 | 
					
						
							| 
									
										
										
										
											2021-01-03 11:19:39 -05:00
										 |  |  |   read(arg,*) f1
 | 
					
						
							| 
									
										
										
										
											2020-09-26 16:49:06 -04:00
										 |  |  |   call getarg(8,arg)
 | 
					
						
							| 
									
										
										
										
											2021-01-03 11:19:39 -05:00
										 |  |  |   read(arg,*) nstp
 | 
					
						
							| 
									
										
										
										
											2020-10-03 08:25:17 -04:00
										 |  |  |   call getarg(9,arg)
 | 
					
						
							| 
									
										
										
										
											2021-01-03 11:19:39 -05:00
										 |  |  |   read(arg,*) ntrperiod
 | 
					
						
							| 
									
										
										
										
											2020-11-17 15:09:03 -05:00
										 |  |  |   call getarg(10,arg)
 | 
					
						
							| 
									
										
										
										
											2021-01-03 11:19:39 -05:00
										 |  |  |   read(arg,*) nQSOprogress
 | 
					
						
							|  |  |  |   call getarg(11,arg)
 | 
					
						
							|  |  |  |   read(arg,*) nfiles
 | 
					
						
							|  |  |  |   call getarg(12,arg)
 | 
					
						
							| 
									
										
										
										
											2020-11-19 13:45:16 -05:00
										 |  |  |   read(arg,*) snr
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-26 16:49:06 -04:00
										 |  |  |   if(ntrperiod.eq.15) then
 | 
					
						
							|  |  |  |      nsps=1800
 | 
					
						
							| 
									
										
										
										
											2020-12-05 13:46:07 -05:00
										 |  |  |      i50=-23
 | 
					
						
							| 
									
										
										
										
											2020-09-26 16:49:06 -04:00
										 |  |  |   else if(ntrperiod.eq.30) then
 | 
					
						
							|  |  |  |      nsps=3600
 | 
					
						
							| 
									
										
										
										
											2020-12-05 13:46:07 -05:00
										 |  |  |      i50=-26
 | 
					
						
							| 
									
										
										
										
											2020-09-26 16:49:06 -04:00
										 |  |  |   else if(ntrperiod.eq.60) then
 | 
					
						
							| 
									
										
										
										
											2020-10-25 14:10:38 -04:00
										 |  |  |      nsps=7200
 | 
					
						
							| 
									
										
										
										
											2020-12-05 13:46:07 -05:00
										 |  |  |      i50=-29
 | 
					
						
							| 
									
										
										
										
											2020-09-26 16:49:06 -04:00
										 |  |  |   else if(ntrperiod.eq.120) then
 | 
					
						
							|  |  |  |      nsps=16000
 | 
					
						
							|  |  |  |      i50=-31
 | 
					
						
							|  |  |  |   else if(ntrperiod.eq.300) then
 | 
					
						
							|  |  |  |      nsps=41472
 | 
					
						
							|  |  |  |      i50=-35
 | 
					
						
							|  |  |  |   else
 | 
					
						
							|  |  |  |      stop 'Invalid TR period'
 | 
					
						
							|  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2020-12-05 13:46:07 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-06 08:12:16 -05:00
										 |  |  |   i50=i50 + 8.0*log(1.0+fDop)/log(240.0)
 | 
					
						
							| 
									
										
										
										
											2020-11-19 15:25:28 -05:00
										 |  |  |   ia=i50 + 7
 | 
					
						
							| 
									
										
										
										
											2020-11-19 13:50:59 -05:00
										 |  |  |   ib=i50 - 10
 | 
					
						
							| 
									
										
										
										
											2020-11-19 13:45:16 -05:00
										 |  |  |   if(snr.ne.0.0) then
 | 
					
						
							|  |  |  |      ia=99
 | 
					
						
							|  |  |  |      ib=99
 | 
					
						
							| 
									
										
										
										
											2020-09-26 16:49:06 -04:00
										 |  |  |   endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   baud=12000.0/nsps
 | 
					
						
							|  |  |  |   tsym=1.0/baud
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | !                1         2         3         4         5         6         7
 | 
					
						
							| 
									
										
										
										
											2021-05-29 13:17:09 -04:00
										 |  |  | !       1234567890123456789012345678901234567890123456789012345678901234567890123456'
 | 
					
						
							|  |  |  |   cmd1='q65sim   "K1ABC W9XYZ EN37      " A 1500  5.0  0.0   0.0  1  60  100   -10.0 > junk0'
 | 
					
						
							| 
									
										
										
										
											2021-06-08 11:12:42 -04:00
										 |  |  |   cmd2='jt9 -3 -p  15 -L 300 -H 3000 -d   3 -b A -Q 3 -f 1500 -X 32 *.wav > junk'
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   write(cmd1(10:33),'(a)') '"'//msg//'"'
 | 
					
						
							| 
									
										
										
										
											2020-10-03 08:25:17 -04:00
										 |  |  |   cmd1(35:35)=csubmode
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   write(cmd1(37:40),'(i4)') nf0
 | 
					
						
							| 
									
										
										
										
											2020-12-05 13:46:07 -05:00
										 |  |  |   write(cmd1(41:45),'(f5.0)') fDop
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   write(cmd1(46:50),'(f5.2)') dt
 | 
					
						
							| 
									
										
										
										
											2021-05-29 13:17:09 -04:00
										 |  |  |   write(cmd1(51:56),'(i6)') nint(f1)
 | 
					
						
							|  |  |  |   write(cmd1(57:59),'(i3)') nstp
 | 
					
						
							|  |  |  |   write(cmd1(60:63),'(i4)') ntrperiod
 | 
					
						
							|  |  |  |   write(cmd1(64:68),'(i5)') nfiles
 | 
					
						
							| 
									
										
										
										
											2020-10-25 13:58:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-26 16:49:06 -04:00
										 |  |  |   write(cmd2(11:13),'(i3)') ntrperiod
 | 
					
						
							| 
									
										
										
										
											2021-01-31 09:06:20 -05:00
										 |  |  |   write(cmd2(33:35),'(i3)') ndepth
 | 
					
						
							|  |  |  |   write(cmd2(45:45),'(i1)') nQSOprogress
 | 
					
						
							|  |  |  |   write(cmd2(50:53),'(i4)') nf0
 | 
					
						
							|  |  |  |   cmd2(40:40)=csubmode
 | 
					
						
							| 
									
										
										
										
											2021-01-03 11:19:39 -05:00
										 |  |  |   
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   call system('rm -f *.wav')
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-04 09:07:03 -05:00
										 |  |  |   write(*,1008) ntrperiod,csubmode,ndepth,fDop,f1,nstp
 | 
					
						
							| 
									
										
										
										
											2021-05-29 13:17:09 -04:00
										 |  |  | 1008 format('Mode:',i4,a1,'  Depth:',i3,'  fDop:',f6.1,'  Drift:',f8.1,  &
 | 
					
						
							| 
									
										
										
										
											2021-01-04 09:07:03 -05:00
										 |  |  |           '  Steps:',i3)
 | 
					
						
							| 
									
										
										
										
											2021-01-01 15:28:41 -05:00
										 |  |  |   write(*,1010) (j,j=0,5)
 | 
					
						
							|  |  |  |   write(12,1010) (j,j=0,5)
 | 
					
						
							| 
									
										
										
										
											2021-01-04 09:07:03 -05:00
										 |  |  | 1010 format(' SNR Sync Avg Dec  Bad',6i4,'  tdec   avg  rms'/64('-'))
 | 
					
						
							| 
									
										
										
										
											2020-09-26 16:49:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-06 10:29:03 -04:00
										 |  |  |   dterr=tsym/4.0
 | 
					
						
							|  |  |  |   nferr=max(1,nint(0.5*baud),nint(fdop/3.0))
 | 
					
						
							| 
									
										
										
										
											2020-12-05 11:09:15 -05:00
										 |  |  |   ndec1z=nfiles
 | 
					
						
							| 
									
										
										
										
											2021-02-19 09:44:03 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |   do nsnr=ia,ib,-1
 | 
					
						
							| 
									
										
										
										
											2020-11-19 13:45:16 -05:00
										 |  |  |      snr1=nsnr
 | 
					
						
							|  |  |  |      if(ia.eq.99) snr1=snr
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |      nsync=0
 | 
					
						
							| 
									
										
										
										
											2020-10-25 13:58:18 -04:00
										 |  |  |      ndec1=0
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |      nfalse=0
 | 
					
						
							| 
									
										
										
										
											2020-11-11 15:20:35 -05:00
										 |  |  |      naptype=0
 | 
					
						
							| 
									
										
										
										
											2020-10-25 13:58:18 -04:00
										 |  |  |      ndecn=0
 | 
					
						
							| 
									
										
										
										
											2021-05-29 13:17:09 -04:00
										 |  |  |      write(cmd1(72:76),'(f5.1)') snr1
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |      call system(cmd1)
 | 
					
						
							|  |  |  |      call sec0(0,tdec)
 | 
					
						
							|  |  |  |      call system(cmd2)
 | 
					
						
							|  |  |  |      call sec0(1,tdec)
 | 
					
						
							|  |  |  |      open(10,file='junk',status='unknown')
 | 
					
						
							|  |  |  |      n=0
 | 
					
						
							| 
									
										
										
										
											2020-12-15 09:31:29 -05:00
										 |  |  |      snrsum=0.
 | 
					
						
							|  |  |  |      snrsq=0.
 | 
					
						
							|  |  |  |      nsum=0
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |      do iline=1,9999
 | 
					
						
							| 
									
										
										
										
											2020-09-26 16:49:06 -04:00
										 |  |  |         read(10,'(a71)',end=10) line
 | 
					
						
							| 
									
										
										
										
											2020-10-06 10:29:03 -04:00
										 |  |  |         if(index(line,'<Decode').eq.1) cycle
 | 
					
						
							| 
									
										
										
										
											2020-12-15 09:31:29 -05:00
										 |  |  |         read(line,*) itime,xsnr,xdt,nf
 | 
					
						
							| 
									
										
										
										
											2020-11-03 17:17:21 -05:00
										 |  |  |         decok=index(line,trim(msg)).gt.0
 | 
					
						
							| 
									
										
										
										
											2020-12-15 09:31:29 -05:00
										 |  |  |         if(decok) then
 | 
					
						
							|  |  |  |            snrsum=snrsum + xsnr
 | 
					
						
							|  |  |  |            snrsq=snrsq + xsnr*xsnr
 | 
					
						
							|  |  |  |            nsum=nsum+1
 | 
					
						
							|  |  |  |         endif
 | 
					
						
							| 
									
										
										
										
											2020-10-06 10:29:03 -04:00
										 |  |  |         if((abs(xdt-dt).le.dterr .and. abs(nf-nf0).le.nferr) .or. decok) then
 | 
					
						
							|  |  |  |            nsync=nsync+1
 | 
					
						
							|  |  |  |         endif
 | 
					
						
							| 
									
										
										
										
											2020-12-01 11:24:21 -05:00
										 |  |  |         idec=-1
 | 
					
						
							| 
									
										
										
										
											2020-10-25 13:58:18 -04:00
										 |  |  |         iavg=0
 | 
					
						
							|  |  |  |         i0=23
 | 
					
						
							|  |  |  |         if(ntrperiod.le.30) i0=25
 | 
					
						
							| 
									
										
										
										
											2020-12-31 15:52:06 -05:00
										 |  |  |         if(line(i0:i0).ne.' ') then
 | 
					
						
							|  |  |  |            i1=index(line,'q')
 | 
					
						
							|  |  |  |            idec=-1
 | 
					
						
							| 
									
										
										
										
											2021-01-31 09:06:20 -05:00
										 |  |  |            read(line(i1+1:i1+1),*) idec
 | 
					
						
							|  |  |  |            if(line(i1+2:i1+2).eq.'*') then
 | 
					
						
							|  |  |  |               iavg=10
 | 
					
						
							|  |  |  |            else
 | 
					
						
							|  |  |  |               read(line(i1+2:i1+2),*,end=100) iavg
 | 
					
						
							|  |  |  |            endif
 | 
					
						
							| 
									
										
										
										
											2020-12-23 09:47:11 -05:00
										 |  |  |         endif
 | 
					
						
							| 
									
										
										
										
											2021-01-31 09:06:20 -05:00
										 |  |  | 100     if(idec.lt.0) cycle
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |         if(decok) then
 | 
					
						
							| 
									
										
										
										
											2020-10-25 13:58:18 -04:00
										 |  |  |            ndecn=ndecn + 1
 | 
					
						
							|  |  |  |            if(iavg.le.1) ndec1=ndec1 + 1
 | 
					
						
							| 
									
										
										
										
											2020-12-01 11:24:21 -05:00
										 |  |  |            naptype(idec)=naptype(idec) + 1
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  |         else
 | 
					
						
							|  |  |  |            nfalse=nfalse + 1
 | 
					
						
							|  |  |  |            print*,'False: ',line
 | 
					
						
							|  |  |  |         endif
 | 
					
						
							|  |  |  |      enddo
 | 
					
						
							|  |  |  | 10   close(10)
 | 
					
						
							| 
									
										
										
										
											2020-12-15 09:31:29 -05:00
										 |  |  |      snr_avg=0.
 | 
					
						
							|  |  |  |      snr_rms=0.
 | 
					
						
							|  |  |  |      if(nsum.ge.1) then
 | 
					
						
							|  |  |  |         snr_avg=snrsum/nsum
 | 
					
						
							|  |  |  |         snr_rms=sqrt(snrsq/nsum - snr_avg**2)
 | 
					
						
							|  |  |  |      endif
 | 
					
						
							| 
									
										
										
										
											2021-01-04 09:07:03 -05:00
										 |  |  |      write(*,1100) snr1,nsync,ndecn,ndec1,nfalse,naptype,tdec/nfiles,  &
 | 
					
						
							|  |  |  |           snr_avg,snr_rms
 | 
					
						
							|  |  |  |      write(12,1100) snr1,nsync,ndecn,ndec1,nfalse,naptype,tdec/nfiles, &
 | 
					
						
							|  |  |  |           snr_avg,snr_rms
 | 
					
						
							|  |  |  | 1100 format(f5.1,4i4,i5,5i4,f6.2,f6.1,f5.1)
 | 
					
						
							| 
									
										
										
										
											2020-12-05 11:09:15 -05:00
										 |  |  |      if(ndec1.lt.nfiles/2 .and. ndec1z.ge.nfiles/2) then
 | 
					
						
							|  |  |  |         snr_thresh=snr1 + float(nfiles/2 - ndec1)/(ndec1z-ndec1)
 | 
					
						
							| 
									
										
										
										
											2020-11-19 15:25:28 -05:00
										 |  |  |         open(13,file='snr_thresh.out',status='unknown',position='append')
 | 
					
						
							|  |  |  |         write(13,1200) ntrperiod,csubmode,ndepth,nQSOprogress,nfiles,   &
 | 
					
						
							| 
									
										
										
										
											2021-01-04 09:07:03 -05:00
										 |  |  |              fdop,f1,nstp,nfalse,snr_thresh,trim(msg)
 | 
					
						
							|  |  |  | 1200    format(i3,a1,2i3,i5,2f7.1,2i3,f7.1,2x,a)
 | 
					
						
							| 
									
										
										
										
											2020-11-19 15:25:28 -05:00
										 |  |  |         close(13)
 | 
					
						
							| 
									
										
										
										
											2020-10-06 10:29:03 -04:00
										 |  |  |      endif
 | 
					
						
							| 
									
										
										
										
											2020-08-08 09:14:12 -04:00
										 |  |  |      flush(6)
 | 
					
						
							|  |  |  |      flush(12)
 | 
					
						
							| 
									
										
										
										
											2020-10-25 13:58:18 -04:00
										 |  |  |      if(ndec1.eq.0 .and. ndecn.eq.0) exit           !Bail out if no decodes at this SNR
 | 
					
						
							| 
									
										
										
										
											2020-12-05 11:09:15 -05:00
										 |  |  |      ndec1z=ndec1
 | 
					
						
							| 
									
										
										
										
											2020-10-06 10:29:03 -04:00
										 |  |  |   enddo  ! nsnr
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-25 13:58:18 -04:00
										 |  |  | 999 end program test_q65
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-25 13:58:18 -04:00
										 |  |  | include 'sec0.f90'
 | 
					
						
							| 
									
										
										
										
											2020-08-06 14:23:39 -04:00
										 |  |  | 
 |