        program update_coordinates
c
c       Checks against wds.summ and updates precise coordinates and 
c       component magnitudes. 
c       Run "wc orb6.master orb6.master.new" to check files are of same size
c       or "diff orb6.master orb6.master.new" for a more thorough check,
c       then "mv orb6.master.new orb6.master"
c       
        character*18 rad(200000),rad1
        character*10 wds(200000),wds1
        character*7 dd(200000),dd1
        character*5 comp(200000),v1(200000),v2(200000),comp1,v11,v22,c1
        character*1 vflag(200000),vflag1,vflag2,c108,c109,c110,c111
        character*278 line,etc1,etc2
c
        open(10,file='/home/wih/WDS/wds.summ',status='UNKNOWN')
        open(11,file='orb6.master',status='UNKNOWN')
        open(12,file='orb6.master.new',status='UNKNOWN')
c
        n=0
  100   read(10,901,end=110) wds1,dd1,comp1,v11,v22,c108,c109,c110,c111,
     $     rad1
  901   format(a10,a7,a5,t59,a5,1x,a5,t108,4a1,1x,a18)
        n=n+1
        wds(n)=wds1
        dd(n)=dd1
        comp(n)=comp1
        rad(n)=rad1
        v1(n)=v11
        v2(n)=v22
        vflag(n)=' '
        if ((c108 .eq. 'R') .or. (c109 .eq. 'R') .or. 
     $      (c110 .eq. 'R') .or. (c111 .eq. 'R')) vflag(n)='r'
        if ((c108 .eq. 'B') .or. (c109 .eq. 'B') .or. 
     $      (c110 .eq. 'B') .or. (c111 .eq. 'B')) vflag(n)='b'
        if ((c108 .eq. 'K') .or. (c109 .eq. 'K') .or. 
     $      (c110 .eq. 'K') .or. (c111 .eq. 'K')) vflag(n)='k'
        if (n .le. 100) write(6,991) wds(n),dd(n),comp(n),v1(n),v2(n),
     $     vflag(n),rad(n)
  991   format(a10,1x,a7,1x,a5,1x,a5,1x,a5,1x,a1,1x,a18)
        go to 100
c
  110   nwds=n
c
c       read and write orb6 header lines
c
        do 200 n=1,4
        read(11,902) line
  902   format(a278)
        write(12,902) line
  200   continue
c
c       read a line. If blank, write out and read another
c
  300   read(11,902,end=999) line
        read(line,903) c1
  903   format(a5)
        if (c1 .eq. '     ') write(12,902) line
        if (c1 .eq. '     ') go to 300
        read(line,904) rad1,wds1,dd1,comp1,etc1,v11,vflag1,v22,vflag2,
     $     etc2
  904   format(a18,1x,a10,1x,a7,a5,a24,a5,a1,1x,a5,a1,a199)
c
c       check for match against wds summary lines. If matches wds, dd, 
c       and comp, update coordinates and magnitues
c
        do 400 n=1,nwds
        if (wds1  .ne.  wds(n)) go to 400
        if (dd1   .ne.   dd(n)) go to 400
        if (comp1 .ne. comp(n)) go to 400
        rad1=rad(n)
        v11=v1(n)
        v22=v2(n)
        vflag1=vflag(n)
        if (v22 .ne. '  .  ') vflag2=vflag(n)
        go to 500
  400   continue
c
  500   write(12,904) rad1,wds1,dd1,comp1,etc1,v11,vflag1,v22,vflag2,
     $     etc2
        go to 300
c
  999   stop
        end


