	parameter (m=49999)
	character*133 a
	character*23 f1,f2
	character*1 c1(m),cc
	real ra(m),de(m)
	k=iargc()
	if(k.lt.1)then
	  write(*,*)
	  write(*,*)' Usage: putmark file'
          write(*,*)'   assume: oldfile is *.mag'
          write(*,*)'           newfile is *.mag0'
	  write(*,*)
	  stop
	endif
	call getarg(1,f1)

	k=index(f1,'.')-1
	if(k.le.0)k=lnblnk(f1)
	f2=f1(1:k)//'.mag'
	kk=k

	open(1,file=f2,status='old')
	read(1,'(a)')a
        do 9 i=23,32
9       if(a(i:i).eq.':'.or.a(i:i).eq.'.')a(i:i)=','
        read(a(23:),*)i,j,k
        z=i+j/60.+k/3600.
        cosy=cos(z*3.141592654/180.)

	n=0
10	n=n+1
	read(1,'(a)',end=11)a
	call ihd(a,ra(n),de(n))
	c1(n)=a(1:1)
	read(1,'(a)')a
	goto 10
11	close(1)
	n=n-1

	f2=f1(1:kk)//'.mag0'
	open(1,file=f2,status='old')
	read(1,'(a)')a
	write(*,'(a)')a
20	read(1,'(a)',end=99)a
	if(a(1:1).ne.' ')goto 31
	call ihd(a,x1,x2)
	r=8.
	do 30 j=1,n
        z=(ra(j)-x1)
        if(z.gt. 999999.)z=z-1296000.
        if(z.lt.-999999.)z=z+1296000.
        z=z*cosy
        z=z*z+(de(j)-x2)**2
        if(z.lt.r)then
          r=z
          cc=c1(j)
        endif
30	continue
	a(1:1)=' '
	if(r.lt.4.)a(1:1)=cc
31	write(*,'(a)')a
	read(1,'(a)')a
	write(*,'(a)')a
	goto 20
99	close(1)
	end

        subroutine ihd(a,x,y)
        character*60 a
        read(a(1:),'(2(1x,i2,1x,i2,1x,f5.2))')i1,j1,z1,i2,j2,z2
        x=(i1*3600+j1*60+z1)*15
        y= i2*3600+j2*60+z2
        k=index(a(2:18),'-')
        if(k.gt.0)y=-y
        end
