	character*133 dis,err
	character*30 f1,f2
	character color,col(16)
	logical logi
	integer  eds(14500),av(16),jj(16)
	k=iargc()
	if(k.lt.2)then
	  write(*,*)' usage puteds getcat.cat T*i_15.mag'
	  write(*,*)
	  write(*,*)'     use: eds.datt'
	  stop
	endif
        call getarg(1,f1)
        call getarg(2,f2)
        inquire(file=f1,exist=logi)
        if(.not.logi)stop 'file not found !'
	open(1,file=f1,status='old')
	open(2,file=f2,status='unknown')
        inquire(file='eds.dat',exist=logi)
        if(.not.logi)stop 'eds.dat not found !'
	open(3,file='eds.dat',status='old')
	do 20 i=1,14500
20	eds(i)=0
	i=0
21	read(3,*,end=22)k
	eds(k)=1
	i=i+1
	goto 21
22	close(3)
	write(*,*)'readin eds=',i
c get color & m filters
	read(1,'(a)',end=100)dis
	ik=(lnblnk(dis)-36)/6
	write(*,*)' colors =',ik
	do 401 i=1,16
401	av(i)=0
	do 41 i=1,ik
41	read(dis(36+i*6:),*)col(i)
	  write(*,*)(col(i),i=1,ik)

c-------
	write(2,'(a)')dis(1:lnblnk(dis))
10	read(1,'(a)',end=100)dis

	if(dis(3:3).eq.'c')goto 10
	read(1,'(a)')err
	do 91 i=1,ik
91	read(dis(i*6+32:),'(i6)')jj(i)
	k=0	
	do 92 i=1,ik
	if(jj(i).ne.0)then
	  k=k+1
c	  jj(i)=jj(i)+av(i)
	  write(dis(i*6+32:),'(i6)')jj(i)
	else
	  write(dis(i*6+32:),'(a)')'      '
	endif
92	continue
	read(err(25:),*)j
	if(eds(j).ne.0)dis(1:1)='e'
	if(k.ge.3)write(2,'(a)')dis(1:lnblnk(dis))
	if(k.ge.3)write(2,'(a)')err(1:lnblnk(err))
	goto 10
100	close(1)
	close(2)
	end
