	program GetLHFECVs
c get non-zero HFE command verifications
c **26-Jun-17**rev. 3-Sep-18**
	character filen*29,sta*2,day*3,tf*1,df*1,cr*1,time*21
	integer*2 in(3200)
	integer sf(4)
	logical goodt
	parameter (cr='0d'x)
	data time(1:15)/'1975-***T**:**:'/
&	,filen/'a**_hfe_1975_l1_arcsav_cv.tab'/
	equivalence (filen(2:3),sta)
c
	write(*,"('station: '$)")
	read(*,'(a2)') sta
	open(7,file='../hfel1aPDSs/'//filen)
	write(7,"(a36,a1)") 'year-dayThr:mn:sc.ms  f stat cmd m f',cr
	write(*,"('days: '$)")
	read(*,*) id1,id2
	do id=id1,id2
	 write(day,'(i3)') id
	 if (day(1:1).eq.' ') day(1:1)='0'
	 open(1,file='../../cleanup/asr'//sta//'/asr.'//sta//'.'//day
&	 ,access='direct',form='unformatted',recl=6400,status='old',err=29)
	 write(*,*) day
	 nr=1
10	 read(1,rec=nr,end=19) in
	 do k=1,45
	  if (in(k).eq.0) go to 17
c get ALSEP word 46(station 15) or 7(station 17)
	  if (sta.eq.'15') then
	   kv=and(in(k*48+177),'3f3c'x)
	  else
	   kv=and(in(k*16+2334),'3f3c'x)
	   end if
	  if (kv.ne.0) then
	   kc=or(and(rshift(kv,5),'78'x),and(rshift(kv,3),7))
	   ka=and(rshift(kv,2),1)
	   if((kc.ge.93.and.kc.le.102).or.kc.eq.106) then
c get time & frame count
	    i0=k*4+4
	    i2=in(i0+2)
	    i3=in(i0+3)
	    i4=in(i0+4)
	    it=or(or(or(or(or(and(lshift(i2,18),'7c000000'x),
&	    and(lshift(i2,20),'3f00000'x)),and(lshift(i3,6),'fc000'x)),
&	    and(lshift(i3,8),'3f00'x)),and(rshift(i4,6),'fc'x)),
&	    and(rshift(i4,4),3))
	    kd=it/5400000
	    it=mod(it,5400000)
	    kh=it/225000
	    it=mod(it,225000)
	    km=it/3750
	    sec=(mod(it,3750)*16+and(in(i0+4),15))/1000.
	    write(time(6:8),'(i3)') kd
	    if (time(6:6).eq.' ') time(6:6)='0'
	    if (time(7:7).eq.' ') time(7:7)='0'
	    write(time(10:11),'(i2)') kh
	    write(time(13:14),'(i2)') km
	    write(time(16:21),'(f6.3)') sec
	    do i=10,16,3
	     if (time(i:i).eq.' ') time(i:i)='0'
	     end do
	    goodt=iabs(kd-id).le.1
	    tf='-'
	    if (and(i2,'2000'x).ne.0) tf='*'
	    isf=in(i0+1)
	    do i=4,1,-1
	     sf(i)=and(isf,7)
	     isf=rshift(isf,4)
	     end do
	    df='-'
	    k0=k*48+140
	    if (in(k0+1).ne.'3864'x.or.in(k0+2).ne.'432c'x) df='*'	    
c output
	    if (goodt) then
	     write(7,'(a21,1xa1,1x4i1,o4,o2,1x2a1)') 
&	     time,tf,sf,kc,ka,df,cr
	     end if
	    end if
	   end if
17	  end do
	 nr=nr+1
	 go to 10
19	 close(1)
29	 end do
	close(7)
	stop
	end

