	subroutine read
	
	include 'raslab.cmm'

	character*125 string
	character*1 ch(125)
	character*4 sys
	equivalence(string,ch)
	equivalence(ch(31),sys)
	dimension value(9),offset(4)
	character*80 fname2
	
c
c	Offsets:
        offset(1)=0
        offset(2)=0
        offset(3)=0
        offset(4)=0


	write(6,*)' which lab system shall I read?'
	read(5,980)sysname
980	format(a4)


	write(6,*)' which Daily???.res file (yyyymmdd)?'
	read(5,1030)fname
	write(6,1030)fname
1030	format(a)
	write(fname2,1031)fname
	write(6,1031)fname
1031	format(a)


	print *,'infile ',fname,fname2
	open(1,file=fname,readonly)
	write(6,*)' file opened!'
	ncyc=1
33	read(1,1000,end=99) string
1000	format(a125)
	if(sys.eq.sysname) then
	  read(string,1002)nhour,nminu,nsec
 	  tim=nhour+float(nminu)/60.+float(nsec)/3600.
C	  tim=nhour+float(nminu)/100.+float(nsec)/10000.
	  time(ncyc)=tim
1002      format(21x,i2.2,1x,i2.2,1x,i2.2)
	  read(1,1000,end=99)string
	  if(ch(1).eq.'u'.and.ch(2).eq.'d') then
	    read(string,1001)value
	    dat(1,ncyc)=value(1)-offset(1)
	    dat(2,ncyc)=value(2)-offset(2)
	    dat(3,ncyc)=value(3)-offset(3)
	    dat(4,ncyc)=1000.*value(6)-offset(4)
1001	    format(9x,3e14.3,2e12.3,2e14.3,2e11.3)
c	    if(value(1).eq.0.) goto 33
c	    if(value(2).eq.0.) goto 33
c	    if(value(3).eq.0.) goto 33
c	    if(value(6).eq.0.) goto 33
c	    if(value(3).lt.0.9) goto 33
c	    if(value(3).gt.1.1) goto 33
	  else
	    goto 33
	  endif
	else
	  goto 33
	endif
	
	ncyc=ncyc+1

	do kskip=1,6
	  read(1,1000,end=99)string
	enddo

	goto 33

99	close(1)

	mcyc=ncyc-1
	write(6,1050)mcyc
1050	format(' mcyc:',2i5)

	end
