	real a(99), s(99)
	character*110 f0,f1
	nk=iargc()
	if(nk.lt.1)then
	  write(*,*)' av batchfile'
	  stop
	endif
	call getarg(1,f0)
	open(2,file=f0,status='old')
21	read(2,*,end=29),f0
	open(1,file=f0,status='old')
	i=0
11	read(1,'(a)',end=99)f1
	i=i+1
	k=lnblnk(f1)
	if(k.lt.94.or.index(f1(88:),'X').ne.0)then
	  i=i-1
	  goto 11
	endif
	read(f1(92:),*)a(i),s(i)
1	format(2f8.3)
	goto 11
99	n=i
	close(1)
	call avs(a,s,n,av,as)
        if(as.lt.0.001)as=0.001
	write(*,'(a,i2,a,2f9.3)')'---',n,'---'//f0(1:12),av,as
	goto 21
29	close(2)
	end

	subroutine avs(a,s,n,x,z)
	real a(1),s(1),w(99)
	do 10 i=1,n
10	w(i)=(1./s(i))**2
c10	w(i)=1.

	x=0
	y=0
	do 20 i=1,n	
	y=y+w(i)
20	x=x+a(i)*w(i)
	x=x/y

	z=0	
	do 30 i=1,n
30	z=z+(a(i)-x)**2*w(i)
	z=sqrt(z/y/(n-1))
	if(n.eq.1)z=s(1)

	end
