      SUBROUTINE QEDIN(Q,TQ,NQ,NORUN,SAMTIM,LIM,HELJD,TITLE)     
C     
C     ROUTINE TO READ IN QED FORMATTED DATA     
C     
      DIMENSION Q(1),SAMTIM(1),LIM(2,1)   
      DOUBLE PRECISION TQ(1),HELJD(1),TIME
      CHARACTER FNAME*25,FORMAT*80,TITLE*80  
      FORMAT='(F10.3,I10)'
      IHEAD=0
      ISEC=0
    1 READ 4,FNAME
    4 FORMAT(A)   
      IF(FNAME.EQ.'BEGIN'.OR.
     *   FNAME.EQ.'begin')THEN
        NORUN=0
        LIM(1,1)=0
        NQ=0
        TITLE=' '
        GO TO 1
      END IF
    5 IF(FNAME.EQ.'END'.OR.
     *   FNAME.EQ.'end')THEN  
        RETURN    
      END IF
      OPEN(11,FILE=FNAME,STATUS='OLD')     
      AMX=-1.0E35
      AMN=1.0E35
      NORUN=NORUN+1     
      NQ=NQ+1     
      LIM(1,NORUN)=NQ   
      READ(11,6)SAMTIM(NORUN),HELJD(NORUN)
    6 FORMAT(/11X,F7.3/7X,F15.7/)
      HELJD(NORUN)=HELJD(NORUN)-2440000.0D0
      IF(TITLE.EQ.' ')THEN
        TITLE=FNAME(:LNBLNK(FNAME))
      ELSE
        TITLE=TITLE(:LNBLNK(TITLE)) // ' - ' // FNAME(:LNBLNK(FNAME))
      END IF
      IPT=0 

   10 READ(11,FORMAT,END=50)TQ(NQ),INTQ
      Q(NQ)=INTQ
      TQ(NQ)=TQ(NQ)+(HELJD(NORUN)-HELJD(1))*86400.0D0
     *       -62.0d0   !  to convert back from Ephemeris Time
      IPT=IPT+1   
      IF(AMX.LT.Q(NQ))AMX=Q(NQ)
      IF(AMN.GT.Q(NQ))AMN=Q(NQ)
      NQ=NQ+1     
      GO TO 10    
C     
   50 NQ=NQ-1     
      LIM(2,NORUN)=NQ   
      PRINT 100,IPT,FNAME,HELJD(NORUN),SAMTIM(NORUN),AMN,AMX
  100 FORMAT(12X,I5,' POINTS READ FROM FILE ',A12,' FROM HJD ',  
     *       F11.5,'  SAMPLING TIME ',F7.2,'  MIN ',1PE12.5,'  MAX ',
     *       E12.5)
      REWIND 11   
      CLOSE(11)   
      GO TO 1     
      END   
