      CHARACTER HD1*6,HD2*1,HD3*5, SIGNAL*6
      INTEGER RAH,RAM,DECD,DECM,DECS,HD,TESTHR
      DATA SIGNAL/'HR    '/
      OPEN(UNIT=1,FILE='hd.cat',STATUS='OLD')
      OPEN(UNIT=2,FILE='bsc4.dat',STATUS='OLD')
      OPEN(UNIT=3,FILE='hd_hr.cat')
      IHD=0
      IHR=0
 1    READ(2,2000,END=2) HD,RAH,RAM,RAS,DECD,DECM,DECS,PMA,PMD,TESTHR
 2000 FORMAT (I6,2I3,F5.1,I4,2I3,2F7.3,I5)
      IHR=IHR+1
 2    IHD=IHD+1
      READ(1,1000,END=10) HD1,HD2,HD3
 1000 FORMAT (A6,1X,A1,1X,A5)
      IF (IHD.LT.HD) THEN
         WRITE(3,3000) HD1,HD2,HD3
 3000    FORMAT(A6,A1,A5)
         GOTO 2
      ENDIF 
      IF (IHD.EQ.HD) THEN
         WRITE(3,3001) SIGNAL,TESTHR
 3001    FORMAT(A6,I6)
         WRITE(*,5000) IHR,TESTHR,HD1,RAH,RAM,RAS
 5000    FORMAT(2I5,1X,A6,2I3,F5.1)
         GOTO 1
      ELSE
         GOTO 2
      ENDIF
 10   CLOSE(3)
      CLOSE(2)
      CLOSE(1)
      STOP
      END

