	subroutine readd(fname,day,data,edata,ndata,cmnt,iret)
	parameter (nlim=1600)
	real*4    day(nlim),data(nlim,19),edata(nlim,19)
	integer   nchk(nlim)
	character cmnt*20,fname*25
	character dummy*80
	logical exflag
*------- clear data ------------
 2001	do 2000 i21=1,nlim
 2101	  do 2100 i22=1,19
	    data(i21,i22)=0.0
	    edata(i21,i22)=0.0
 2100	  continue
 2000	continue
	iret=0
*------- inquire file ----------
	inquire(file=fname,exist=exflag)
	if(exflag)then
*------- open file -------------
	open(7,file=fname,status='old')
*------- read comment ----------
	read(7,'(a20)') cmnt
	ndata=0
 1000	continue
*------- read data -------------
	read(7,'(a80)',end=999) dummy
	read(dummy,'(i4)') no
	if(no.eq.0) goto 1000
	read(dummy,'(4x,i4,4f8.4,2f8.3)') ich,d,e1,e2,ed,da,el
	if(ich.eq.108) then
	  mch=17
	elseif(ich.eq.916) then
	  mch=18
	elseif(ich.eq.116) then
	  mch=19
	else
	  mch=int(float(ich)/101)
	endif
	if(ndata.le.0) goto 1200
*------- search previous day ---
 1101	do 1100 i11=1,ndata
	  if(day(i11).eq.da)then
	    data(i11,mch)=d
	    edata(i11,mch)=ed
	    goto 1000
	  endif
 1100	continue
*------- new data --------------
 1200	continue
	ndata=ndata+1
	data(ndata,mch)=d
	edata(ndata,mch)=ed
	day(ndata)=da

*	day(ndata)=da+46795.5
*	    ---- to julian day

*------- check ndata -----------
	if(ndata.ge.nlim) then
	  write(*,'(1h,'' Too many data '')')
	  goto 999
	endif
*------- next data -------------
	goto 1000
  999 	continue
	close(7)
*------- for all channel -------
	if(ndata.le.0) goto 990
 1301   do 1300 i13=1,ndata
	  if(data(i13,19).eq.0.0) then
	    if(data(i13,17).ne.0.0.and.data(i13,18).ne.0.0) then
	      data(i13,19)=data(i13,17)+data(i13,18)
	      edata(i13,19)=sqrt(edata(i13,17)**2
     &	                              +edata(i13,18)**2)
	    else
	      data(i13,19)=0.0
	      edata(i13,19)=0.0
	    endif
	  endif
 1300	continue
*------- Check consistency -----
 1501	do 1500 i15=1,ndata
	  csum1=0.0
	  esum1=0.0
	  csum2=0.0
	  esum2=0.0
	  rsum1=0.0
	  ersm1=0.0
	  rsum2=0.0
	  ersm2=0.0
	  nchk(i15)=1
	  if(edata(i15,17).gt.0.0) then
 1511	    do 1510 i151=1,8
	      csum1=csum1+data(i15,i151)
	      esum1=sqrt(esum1**2+edata(i15,i151)**2)
 1510	    continue
	    if(data(i15,17).eq.0.0) then
	      rsum1=csum1+1.0
	      esum1=0.0
	    else
	      rsum1=csum1/data(i15,17)
	      ersm1=sqrt((csum1*edata(i15,17))**2
     &             +(esum1*data(i15,17))**2)/(data(i15,17)**2)
	    endif
	    if(data(i15,17).lt.0.0) rsum1=abs(rsum1)
	    if(rsum1+ersm1.lt.0.45.or.rsum1-ersm1.gt.1.20)
     &        nchk(i15)=0
*	    if(rsum1.lt.0.1.or.rsum1.gt.10.0) nchk(i15)=0
	  endif
	  if(edata(i15,18).gt.0.0) then
 1521       do 1520 i152=9,16
              csum2=csum2+data(i15,i152)
              esum2=sqrt(esum2**2+edata(i15,i152)**2)
 1520       continue
	    if(data(i15,18).eq.0.0) then
	      rsum2=csum2+1.0
	      esum2=0.0
	    else
              rsum2=csum2/data(i15,18)
              ersm2=sqrt((csum2*edata(i15,18))**2
     &             +(esum2*data(i15,18))**2)/(data(i15,18)**2)
	    endif
	    if(data(i15,18).lt.0.0) rsum2=abs(rsum2)
            if(rsum2+ersm2.lt.0.45.or.rsum2-ersm2.gt.1.20)
     &         nchk(i15)=0
*	    if(rsum2.lt.0.1.or.rsum2.gt.10.0) nchk(i15)=0
	  endif
 1500	continue
*------- Sort data -------------
	mdata=0
 1531	do 1530 i153=1,ndata
	  if(nchk(i153).eq.0) goto 1530
	  mdata=mdata+1
	  day(mdata)=day(i153)
 1541	  do 1540 i154=1,19
	    data(mdata,i154) =data(i153,i154)
	    edata(mdata,i154)=edata(i153,i154)
 1540	  continue
 1530	continue
	ndata=mdata
*------- return ----------------
	else
	  write(*,*) 'File cannot be found! Input once again!'
	  write(*,*)
	  iret=9
	endif
  990 	continue
	return
	end
