	character*70 f1,f2
        character*1  cc
        logical logi
	real a(200)
	open(1,file='../con1',status='old')
10	read(1,'(a)',end=100)f1
        cc=' '
	read(f1(21:),*)con1,e1,con2,e2
        if(lnblnk(f1).gt.54)cc=f1(54:54)
	f1=f1(1:16)//'.con'
	inquire(file=f1,exist=logi)
	if(.not.logi)goto 10
        open(2,file=f1,status='old')
20	read(2,'(a)')f2
	if(f2(5:5).ne.'%')goto 20
        read(f2(26:),*)ipix
        read(2,'(36x,f12.3)')adjust
	m=1
30	read(2,'(a)')f2
	if(f2(5:5).eq.'e')goto 40
	read(f2(32:),*)a1,a2
	a(m)=a1-a2
	m=m+1
	goto 30
40      m=m-1
	call d3s(a,m,av3,rms3)
	read(f2(12:),*)av
	read(2,'(a)')f2
	read(f2(15:),*)n,rms
	write(*,1)f1(1:16),con1,e1,con2,e2,cc,av,n,rms,con1+av,
     *     ipix,adjust,m,con1+av3,rms3 
1	format(a,2(f7.3,f6.3),a,'|',f8.3,i4,f6.3,' |',f8.3,
     *     i5,f7.3,i5,f8.3,f6.3)
	close(2)
	goto 10
100	close(1)
	end	

	subroutine d3s(a,m,av,s)
	real a(m)
5	x=0
	n=0
	do 10 i=1,m
	if(a(i).ne.-1)then
	  x=x+a(i)
	  n=n+1
	endif
10	continue
	av=x/n
	x=0
	do 20 i=1,m
	if(a(i).ne.-1)then
	  x=x+(a(i)-av)**2
	endif
20	continue
	s=sqrt(x/n)
c	write(*,*)n,av,s
	s3=s*3
	ip=0
	do 30 i=1,m
	if(a(i).ne.-1.and.abs(a(i)-av).gt.s3)then
	  ip=1
	  a(i)=-1
	endif
30	continue
	if(ip.eq.1)goto 5
	m=n
	end
