      SUBROUTINE TIMES(QTIME,NQ,NORUN,SAMTIM,LIM,HELJD,NQOLD,NRNOLD)     
C     
C     ROUTINE TO FILL THE TIME ARRAY FOR THE CORRESPONDING DATA Q 
C     
      DIMENSION SAMTIM(NORUN),LIM(2,NORUN)     
      DOUBLE PRECISION QTIME(NQ),HELJD(NORUN),TTT,OLDTIM
C     
C     IQ POINTS TO THE CURRENT POSITION IN THE TIME ARRAY   
C     
   25 FORMAT(12X,'DISCONTINUITY AT CHANNEL ',I5,' WHICH IS ',   
     *       F13.2,' SECONDS AFTER THE PREVIOUS CHANNEL')  
      PRINT 50,NORUN,(J,SAMTIM(J),(LIM(K,J),K=1,2),HELJD(J),
     *         J=NRNOLD+1,NORUN)  
   50 FORMAT(/12X,'AUTOMATIC TIME CALCULATION FOR THE ',I3,' RUNS'/    
     *       (14X,'RUN ',I3,'  SAMPLING TIME ',0PF5.1,', FROM ',I7,    
     *        ' TO ',I7,'  HJD OF ',4PD20.7))   
      PRINT 75    
   75 FORMAT(1X)  
      IRUN=NRNOLD+1
      IQ=LIM(1,IRUN)
      QTIME(IQ)=0.5*SAMTIM(IRUN)+(HELJD(IRUN)-HELJD(1))*86400.0D0
      OLDTIM=QTIME(IQ)   
  100 IQ=IQ+1     
      IF(IQ.GT.NQ)GO TO 180   
      IF(IRUN.EQ.NORUN)GO TO 120    
      IF(IQ-LIM(1,IRUN+1))120,140,160     
  120 OLDTIM=OLDTIM+SAMTIM(IRUN)    
      QTIME(IQ)=OLDTIM  
      GO TO 100   
  140 TTT=86400.D0*(HELJD(IRUN+1)-HELJD(IRUN))+SAMTIM(IRUN+1)/2.0 
     *    -SAMTIM(IRUN)/2.0-(LIM(2,IRUN)-LIM(1,IRUN))*SAMTIM(IRUN)
      OLDTIM=OLDTIM+TTT 
      QTIME(IQ)=OLDTIM  
      PRINT 25,IQ,TTT   
      IRUN=IRUN+1 
      IF(IRUN.LE.NORUN)GO TO 100    
      PRINT 150,IQ,IRUN,NORUN 
  150 FORMAT(12X,'ERROR...ERROR...'/14X,'CHANNEL NO =  ',I7/14X,
     *       'RUN POINTER = ',I3/14X,'NUMBER OF RUNS = ',I3)    
      STOP 'TIMES'
  160 PRINT 165,IQ,LIM(1,IRUN+1)    
  165 FORMAT(12X,'ERROR...ERROR...'/14X,'CHANNEL NO =  ',I7/14X,
     *       'CHANNEL OF NEXT RUN = ',I7)
      STOP 'TIMES'
  180 PRINT *,' '    
      DO 200 J=1,NORUN  
        IP1=LIM(1,J)    
        IP2=LIM(2,J)    
        PRINT 190,J,IP1,QTIME(IP1),IP2,QTIME(IP2)     
  190   FORMAT(12X,'RUN ',I3,'  CHANNEL ',I7,' HAS TIME ',F15.5,
     *         '  CHANNEL ',I7,' HAS TIME ',F15.5)  
  200 CONTINUE    
      RETURN
      END   
