	program getclockrate
c get clock rate from ARCSAV files
c **25-Sep-17**
	character ,st*2,day*3,amin*6,amax*7
	integer in(1600),int(2,45),ind(24,45),crb(8)
	equivalence (in(5),int(1,1)),(in(95),ind(1,1))
c
	write(*,"('station: '$)")
	read(*,'(a2)') st
	open(7,file='../clockrates/clockrate.'//st)
	write(7,'(a64,4xa2)')
&	 'day   min     < 26563 26564 26565 26566 26567 26568 <        max'
&	,'sr'
	do id=92,182
	 write(day,'(i3)') id
	 if (day(1:1).eq.' ') day(1:1)='0'
	 open(1,file='../../cleanup/asr'//st//'/asr.'//st//'.'//day
&	 ,access='direct',form='unformatted',recl=6400,status='old',err=29)
	 write(*,*) day
	 do i=1,8
	  crb(i)=0
	  end do
	 minc=27000
	 maxc=26000
	 ns=0
	 nr=1
10	 read(1,rec=nr,end=19) in
c check if frame count range is 45
c	write('(4z9)') int(1,1),int(2,1),ind(1,1),ind(2,1)
	 ifc=or(and(rshift(ind(2,1),21),'78'x),and(rshift(ind(2,1),19),7))
	 lfc=or(and(rshift(ind(2,45),21),'78'x),and(rshift(ind(2,45),19),7))
	 if (mod(lfc+90-ifc,90).eq.44) then
c get time increment
	  it=or(or(and(rshift(int(2,1),4),'3f000'x)
&	  ,and(rshift(int(2,1),2),'fc0'x)),and(int(2,1),'3f'x))
	  lt=or(or(and(rshift(int(2,45),4),'3f000'x)
&	  ,and(rshift(int(2,45),2),'fc0'x)),and(int(2,45),'3f'x))
	  mt=and(lt-it,'3ffff'x)
	  if (mt.lt.26563) then
	   minc=min(minc,mt)
	   crb(1)=crb(1)+1
	  else if (mt.gt.26568) then
	   maxc=max(maxc,mt)
	   crb(8)=crb(8)+1
	  else
	   ii=mt-26561
	   crb(ii)=crb(ii)+1
	   end if
	 else
	  write(*,*) nr,ifc,lfc
	  end if
	 nr=nr+1
	 go to 10
c output a summary for the day
19	 ns=0
	 nc=0
	 do i=2,7
	  ns=ns+crb(i)
	  nc=nc+crb(i)*(i-2)
	  end do
	 flm=(nc/real(ns)+26563.)/44.
	 amin='      '
	 amax='       '
	 if (minc.lt.26563) write(amin,'(i6)') minc
	 if (maxc.gt.26568) write(amax,'(i7)') maxc
	 write(7,'(a3,a6,8i6,a7,f8.3)') day,amin,(crb(i),i=1,8),amax,flm
29	 end do
	stop
	end
