	character*133 dis,err
	character*20 f1
	character*1 col(16)
	integer mag(16),a(16)
	logical logi
	if(iargc().lt.1)then
          write(*,*)
	  write(*,*)' putmag file'
	  stop
	endif
	inquire(file='av.dat',exist=logi)
	if(.not.logi)stop 'av.dat not found'

	open(1,file='av.dat',status='old')
	n16=0
101	read(1,'(a)',end=102)dis
	if(dis(1:2).ne.'--')goto 101
	k=index(dis,'.')+1
	read(dis(k+1:),*)x
	n16=n16+1
	mag(n16)=x*1000+0.1
	col(n16)=dis(k:k)
	goto 101	
102	close(1)

	call getarg(1,f1)
	open(1,file=f1,status='old')
	read(1,'(a)')dis
	write(*,'(a)')dis(1:lnblnk(dis))
	kk=133-(16-n16)*6
10	read(1,'(a)',end=99)dis
	read(1,'(a)')err
	do 20 i=1,n16
20	read(dis(i*6+32:),'(i6)')a(i)
	do 30 i=1,n16
30	if(a(i).ne.0)a(i)=a(i)+mag(i)

	do 40 i=1,n16
	if(a(i).ne.0)then
	  write(dis(i*6+32:),'(i6)')a(i)
        else
	  write(dis(i*6+32:),'(a)')'      '
	endif
40	continue
	if(dis(13:13).eq.'-')then
	  dis(13:13)=' '
	  dis(14:14)='-'
	endif
	  
	write(*,'(a)')dis(1:kk)
	write(*,'(a)')err(1:kk)
	goto 10
99	close(1)

	end	
