	parameter (n=5000)
        real d(n,8),xm(n),dm(n)
        character*40 f1,f2,f3,aa
	character*1  ch
	character*3  ch3
	character*12 ac,dc
	character*78 dis
	byte bell
	real a(2048*2048)
	real b(2048*2048)
	logical logi

	if(iargc().lt.3)then
	write(*,*)
	write(*,*)'       ******** DISplay star**********2000.7* '
	write(*,*)
	write(*,*)
	write(*,*)'       Usage: no3 no1_out frame1 frame2'
	write(*,*)
	write(*,*)
	stop
	endif
	call getarg(1,f1)
	inquire(file=f1,exist=logi)
	if(.not.logi)then
	  write(*,*)f1,'file not found !'
	  stop
	endif
	call getarg(2,f2)
	k=index(f2,'.')
	if(k.eq.0)f2=f2(1:lnblnk(f2))//'.fit'
	inquire(file=f2,exist=logi)
	if(.not.logi)then
	  write(*,*)f2,'file not found !'
	  stop
	endif
	call getarg(3,f3)
	k=index(f3,'.')
	if(k.eq.0)f3=f3(1:lnblnk(f3))//'.fit'
	inquire(file=f3,exist=logi)
	if(.not.logi)then
	  write(*,*)f3,'file not found !'
	  stop
	endif
	call readfits(f2,a,n1,n2)
	write(*,*)'readin ...',f2
	call readfits(f3,b,n3,n4)
	write(*,*)'readin ...',f3
	
	bell=7

        open(1,file=f1,status='old')
	m=0
	x=0.
10	m=m+1
	read(1,8,end=11)i1,i2,x,j1,j2,y,(d(m,i),i=3,8)
8	format(2(1x,i2,1x,i2,1x,f5.2),2f7.2,4f7.1)
	d(m,1)=i1+i2/60.+x/3600.
	d(m,2)=j1+j2/60.+y/3600.
        xm(m)=(d(m,4)+d(m,3))/2.
        dm(m)=d(m,4)-d(m,3)
	x=x+d(m,2)
        goto 10
11	m=m-1
        write(aa(1:),*)' epoch=2000. total number:',m
	close(1)

	call pgbegin(0,'/xw',1,1)
c	call pgslw(2)
	call pgsch(0.8)
	call pgenv(11.5,20.5,-2.5,2.0,0,0)
	call pglabel(' ','delta mag',aa)
	do 20 i=1,m
20	call pgpoint(1,xm(i),dm(i),21)

	num=0
	kk=0
110     call pgcurse(x,y,ch)
        ii=ichar(ch)

c right button****************
        if(ii.eq.132)then
          call pgend
	  stop
        endif


c left button****************
        if(ii.eq.128)then
	  r=1e10
	  do 30 i=1,m
	  rr=(xm(i)-x)**2+(dm(i)-y)**2
          if(rr.lt.r)then
            k=i
            r=rr
          endif
30	  continue
	  if(r.gt.0.01)then
	    write(*,'(a)')bell
	    goto 110
	  endif
c	  write(*,*)(d(k,i),i=1,8)
          num=num+1
	  call pgsci(9)
	  if(kk.eq.k)then
	    num=num-1
	    call pgsci(0)
 	    call pgpoint(1,xm(k),dm(k),21)
	  endif
          write(ch3(1:),'(i3)')num
	  call pgsch(0.6)
          call pgtext(xm(k)-0.02,dm(k)+0.03,ch3)
	  call pgsch(0.8)
          call toms(d(k,1),ac,1)
          call toms(d(k,2),dc,0)
	  write(*,12)num,ac,dc,(d(k,i),i=3,8)
12	  format(i3,') ',a,1x,a,2f7.2,4f7.1)
          call pgsci(0)
          call pgtext(11.5,-2.9,dis)
          write(dis(1:),12)num,ac,dc,(d(k,i),i=3,8)
          call pgsci(9)
          call pgtext(11.5,-2.9,dis)

	  call disp(a,n1,n2,d(k,5),d(k,6),90,500,1)
	  call disp(b,n3,n4,d(k,7),d(k,8),200,500,0)
	  if(kk.eq.k)then
	    k=0
	    num=num-1
	  endif
	  kk=k
	  goto 110
	endif

c display data
        if(ch.eq.'d')then
	  r=1e10
	  do 130 i=1,m
	  rr=(xm(i)-x)**2+(dm(i)-y)**2
          if(rr.lt.r)then
            k=i
            r=rr
          endif
130	  continue
	  if(r.gt.0.01)then
	    write(*,'(a)')bell
	    goto 110
	  endif

	  call disd(a,n1,n2,d(k,5),d(k,6))
	  call disd(b,n3,n4,d(k,7),d(k,8))

	  goto 110
	endif



	goto 110



	end


cccccccccc
	subroutine disd(a,n1,n2,zx,zy)
	real a(n1,n2)
	integer map(15,15)
	integer*2 ma(15,15)
	i1=nint(zx)
	i2=nint(zy)
        do 203 j1=i1-7,i1+7
        do 203 j2=i2-7,i2+7
	x=a(j1,j2)
	if(x.gt.99999.)x=99999.
	if(x.lt.-9999.)x=-9999.
        map(j1-i1+8,j2-i2+8)=x		
203	continue
	write(*,*)
	do 204 j=1,15
204	write(*,'(15i5)')(map(i,j),i=1,15)
	do 205 i=1,15
	do 205 j=1,15
	k=map(i,j)
	if(k.gt.32767)k=32767
205	ma(i,j)=k
	call whitexblack(ma,15,15,white,sigma)
	xx=0
        do 206 j1=-5,+5
        do 206 j2=-5,+5
	k=j1*j1+j2*j2
	if(k.gt.25)goto 206
	x=a(j1+i1,j2+i2)-white
	if(x.gt.0)xx=xx+x
206	continue
	write(*,*)'radius=5  adu=',xx,' mag=',25.-2.5*alog10(xx)
	end
cccccccccccccccccccccc

	subroutine disp(a,n1,n2,zx,zy,ix,iy,jp)
	real a(n1,n2),uy(101*101),ux(101*101)
	integer*2 map(101,101),ma(101*101)
	ip=0
	i1=nint(zx)
	i2=nint(zy)
	j=0
        do 203 j1=i1-50,i1+50
        do 203 j2=i2-50,i2+50
	if(j1.lt.1 .or. j1.gt.n1 .or. j2.lt.1 .or. j2.gt.n2)then
	  map(j1-i1+51,j2-i2+51)=32767
	else 
          white=a(j1,j2)*.25
	  j=j+1
          uy(j)=white
          ux(j)=sqrt((j1-zx)**2+(j2-zy)**2)
          k=white
          if(k.gt.32767)k=32767
          if(k.lt.-32767)k=-32767
          map(j1-i1+51,j2-i2+51)=k
	  ip=ip+1
	  ma(ip)=k
	endif
203	continue
	call whitexblack(ma,1,ip,white,sigma)
	black=white+20.*sigma
	do 204 i=1,101
	map(i,1)=0
	map(i,101)=0
	map(1,i)=0
	map(101,i)=0
204	continue

        call ximage2(map,101,ix,iy,white,black)

	do 205 i=1,101
	do 205 j=1,101
205	map(i,j)=11
	x=0.
	do 206 i=1,101*101
	i1=ux(i)*16.+1
	if(i1.gt.101)goto 206
	if(uy(i).gt.x)x=uy(i)
206	continue

	if(jp.eq.1)scale=101./x

	do 207 i=1,101*101
	i1=ux(i)*16.+1
	if(i1.gt.101)goto 207
	i2=uy(i)*scale
	if(i2.gt.101)i2=101
	if(i2.lt.1)i2=1
	map(i1,102-i2)=1		
207	continue		
        call ximage3(map,101,ix+240,iy)


	end

        subroutine ximage2(map,n,ix,iy,black,white)
        integer*2 map(n,n)
        character dummy
        real rbuf(101*101+2)
        n16=86
        d=n16/(black-white)
        rbuf(1)=ix
        rbuf(2)=iy
        i6=2
        do 30 j=1,n
        do 30 i=1,n
        k=nint(d*(map(i,j)-white))
        if(k.lt.1)k=1
        if(k.gt.n16)k=n16
        i6=i6+1
30      rbuf(i6)=k+15
        i6=n+2
        call xwdriv(27,rbuf,i6,dummy)
        call pgebuf
        end

        subroutine ximage3(map,n,ix,iy)
        integer*2 map(n,n)
        character dummy
        real rbuf(101*101+2)
        rbuf(1)=ix
        rbuf(2)=iy
	m=2
        do 30 j=1,n
        do 30 i=1,n
	m=m+1
30      rbuf(m)=map(i,j)
        m=n+2
        call xwdriv(27,rbuf,m,dummy)
        call pgebuf
        end
