2021-01-07 10:05:53 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								subroutine get_fst4_bitmetrics(cd,nss,bitmetrics,s4,nsync_qual,badsync)
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-24 10:17:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   use timer_module, only: timer
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-23 12:48:50 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   include 'fst4_params.f90'
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   complex cd(0:NN*nss-1)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   complex cs(0:3,NN)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   complex csymb(nss)
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   complex, allocatable, save :: ci(:,:)   ! ideal waveforms, 20 samples per symbol, 4 tones
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 13:07:07 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   complex c1(4,8),c2(16,4),c4(256,2)
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-29 12:31:16 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   integer isyncword1(0:7),isyncword2(0:7)
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   integer graymap(0:3)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   integer ip(1)
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-20 09:48:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   integer hbits(2*NN)
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   logical one(0:65535,0:15)    ! 65536 8-symbol sequences, 16 bits
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   logical first
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   logical badsync
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   real bitmetrics(2*NN,4)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   real s2(0:65535)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   real s4(0:3,NN)
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-29 12:31:16 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   data isyncword1/0,1,3,2,1,0,2,3/
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   data isyncword2/2,3,1,0,3,2,0,1/
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   data graymap/0,1,3,2/
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-19 10:16:04 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   data first/.true./,nss0/-1/
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-07 10:05:53 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   save first,one,nss0
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   if(nss.ne.nss0 .and. allocated(ci)) deallocate(ci)
							 | 
						
					
						
							
								
									
										
										
										
											2021-01-07 10:05:53 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-19 10:16:04 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   if(first .or. nss.ne.nss0) then
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      allocate(ci(nss,0:3))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      one=.false.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      do i=0,65535
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         do j=0,15
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if(iand(i,2**j).ne.0) one(i,j)=.true.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      twopi=8.0*atan(1.0)
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 13:07:07 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      dphi=twopi/nss
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      do itone=0,3
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         dp=(itone-1.5)*dphi
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         phi=0.0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         do j=1,nss
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            ci(j,itone)=cmplx(cos(phi),sin(phi))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            phi=mod(phi+dp,twopi)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      first=.false.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   do k=1,NN
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      i1=(k-1)*NSS
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      csymb=cd(i1:i1+NSS-1)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      do itone=0,3
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         cs(itone,k)=sum(csymb*conjg(ci(:,itone)))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      enddo
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-04 09:15:44 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      s4(0:3,k)=abs(cs(0:3,k))**2
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Sync quality check
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   is1=0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   is2=0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   is3=0
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-28 15:22:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   is4=0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   is5=0
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   badsync=.false.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   ibmax=0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   do k=1,8
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ip=maxloc(s4(:,k))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-29 12:31:16 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      if(isyncword1(k-1).eq.(ip(1)-1)) is1=is1+1
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-27 08:53:11 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      ip=maxloc(s4(:,k+38))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-29 12:31:16 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      if(isyncword2(k-1).eq.(ip(1)-1)) is2=is2+1
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-27 08:53:11 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      ip=maxloc(s4(:,k+76))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-29 12:31:16 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      if(isyncword1(k-1).eq.(ip(1)-1)) is3=is3+1
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-27 08:53:11 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      ip=maxloc(s4(:,k+114))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-29 12:31:16 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      if(isyncword2(k-1).eq.(ip(1)-1)) is4=is4+1
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-27 08:53:11 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      ip=maxloc(s4(:,k+152))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-29 12:31:16 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      if(isyncword1(k-1).eq.(ip(1)-1)) is5=is5+1
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   enddo
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-27 08:53:11 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   nsync=is1+is2+is3+is4+is5   !Number of correct hard sync symbols, 0-40
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   badsync=.false.
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-28 15:22:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   if(nsync .lt. 16) then
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-20 15:41:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      badsync=.true.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   endif
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-24 10:17:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   call timer('seqcorrs',0)
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   bitmetrics=0.0
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Process the frame in 8-symbol chunks. Use 1-symbol correlations to calculate
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! 2-symbol correlations. Then use 2-symbol correlations to calculate 4-symbol
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! correlations. Finally, use 4-symbol correlations to calculate 8-symbol corrs.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! This eliminates redundant calculations.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   do k=1,NN,8
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      do m=1,8  ! do 4 1-symbol correlations for each of 8 symbs
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         s2=0
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         do n=1,4
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            c1(n,m)=cs(graymap(n-1),k+m-1) 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            s2(n-1)=abs(c1(n,m))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         ipt=(k-1)*2+2*(m-1)+1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         do ib=0,1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            bm=maxval(s2(0:3),one(0:3,1-ib)) - &
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								               maxval(s2(0:3),.not.one(0:3,1-ib))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if(ipt+ib.gt.2*NN) cycle
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            bitmetrics(ipt+ib,1)=bm
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      do m=1,4  ! do 16 2-symbol correlations for each of 4 2-symbol groups
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         s2=0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         do i=1,4
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            do j=1,4
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								               is=(i-1)*4+j
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								               c2(is,m)=c1(i,2*m-1)-c1(j,2*m)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								               s2(is-1)=abs(c2(is,m))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         enddo
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         ipt=(k-1)*2+4*(m-1)+1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         do ib=0,3
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            bm=maxval(s2(0:15),one(0:15,3-ib)) - &
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								               maxval(s2(0:15),.not.one(0:15,3-ib))
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if(ipt+ib.gt.2*NN) cycle
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            bitmetrics(ipt+ib,2)=bm
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      enddo
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      do m=1,2 ! do 256 4-symbol corrs for each of 2 4-symbol groups
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         s2=0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         do i=1,16
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            do j=1,16
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								               is=(i-1)*16+j
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								               c4(is,m)=c2(i,2*m-1)+c2(j,2*m)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								               s2(is-1)=abs(c4(is,m))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         enddo 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         ipt=(k-1)*2+8*(m-1)+1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         do ib=0,7
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            bm=maxval(s2(0:255),one(0:255,7-ib)) - &
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								               maxval(s2(0:255),.not.one(0:255,7-ib))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if(ipt+ib.gt.2*NN) cycle
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            bitmetrics(ipt+ib,3)=bm
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      s2=0 ! do 65536 8-symbol correlations for the entire group
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      do i=1,256
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         do j=1,256
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            is=(i-1)*256+j
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 13:03:33 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            s2(is-1)=abs(c4(i,1)+c4(j,2))
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ipt=(k-1)*2+1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      do ib=0,15
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         bm=maxval(s2(0:65535),one(0:65535,15-ib)) - &
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            maxval(s2(0:65535),.not.one(0:65535,15-ib))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         if(ipt+ib.gt.2*NN) cycle
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         bitmetrics(ipt+ib,4)=bm
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      enddo
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   enddo
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-14 12:42:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-24 10:17:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   call timer('seqcorrs',1)
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-20 09:48:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   hbits=0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   where(bitmetrics(:,1).ge.0) hbits=1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   ns1=count(hbits(  1: 16).eq.(/0,0,0,1,1,0,1,1,0,1,0,0,1,1,1,0/))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   ns2=count(hbits( 77: 92).eq.(/1,1,1,0,0,1,0,0,1,0,1,1,0,0,0,1/))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   ns3=count(hbits(153:168).eq.(/0,0,0,1,1,0,1,1,0,1,0,0,1,1,1,0/))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   ns4=count(hbits(229:244).eq.(/1,1,1,0,0,1,0,0,1,0,1,1,0,0,0,1/))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   ns5=count(hbits(305:320).eq.(/0,0,0,1,1,0,1,1,0,1,0,0,1,1,1,0/))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   nsync_qual=ns1+ns2+ns3+ns4+ns5
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   if(nsync_qual.lt. 46) then
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      badsync=.true.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   endif
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   call normalizebmet(bitmetrics(:,1),2*NN)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   call normalizebmet(bitmetrics(:,2),2*NN)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   call normalizebmet(bitmetrics(:,3),2*NN)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   call normalizebmet(bitmetrics(:,4),2*NN)
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-20 09:48:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   scalefac=2.83
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   bitmetrics=scalefac*bitmetrics
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-16 12:28:56 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   return
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-23 12:48:50 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								end subroutine get_fst4_bitmetrics
							 |