	program vusd2ala
c vusd to ascii conversion
c **05-Oct-11** automatic
	character vn*4,mode(3)*1,temp*3
	integer data(101),llt(4)
	integer*2 hdr(9),sbn(2)
	byte nhdata(3,308),edata(6,154)
	equivalence (hdr(1),data(1)),(sbn(1),data(24))
&	,(nhdata(1,1),data(25)),(edata(1,1),data(25))
	data mode/'N','H','E'/
c
	write(*,"('start at tape: '$)")
	read(*,*) nts
	do nt=nts,10
	 do nf=1,57
	  write(vn,'(2i2)') nt,nf
	  do i=1,3,2
	   if (vn(i:i).eq.' ') vn(i:i)='0'
	   end do
	  open(1,file='../../nz2/viking/vusds/vusd.'//vn,access='direct'
&	  ,form='unformatted',recl=404,status='old',err=29)
	  open(2,file='../vusas/vusa.'//vn)
	  write(*,*) vn
	  nr=1
10	  read(1,rec=nr,end=19) data
	  k9=hdr(9)
	  k9=and(k9,'ff'x)
	  if (k9.gt.153) then
	   write(*,'(a1,i5,z5)') '*',nr,hdr(9)
	   go to 18
	   end if
	  md=and(data(21),3)+1
	  n=sbn(2)/3/(md/3+1)
	  write(temp,'(z3)') hdr(6)
	  read(temp,'(i3)') kd
	  write(temp,'(z2)') k9
	  read(temp,'(i2)') ky
	  kd=kd+(ky-76)*366
	  call vtime(data(20),kd,llt)
	  sec=llt(4)/100.
	  write(2,'(a1,i6,z3,z4,z7,1xa1,i3/a1,i9,i4,2i3,f6.2)') 
&	  'H',nr,hdr(9),hdr(6),data(21),mode(md),n,
&	  'G',data(20),(llt(i),i=1,3),sec
	  if (md.lt.3) then
c normal or high-data-rate mode
	   do j=1,n
	    write(2,'(3i5)') (nhdata(i,j),i=1,3)
	    end do
	  else
c event mode
	   do j=1,n
	    write(2,'(3(i5,i3))') (edata(i,j),i=1,6)
	    end do
	   end if
18	  nr=nr+1
	  go to 10
19	  close(1)
	  close(2)
29	  end do
	 end do
	stop
	end

