      SUBROUTINE QUIST(TQ,Q,NOQ,NORUN,SAMTIM,LIM)     
C     THIS SUBROUTINE AVERAGES CONSECUTIVE CHANNELS IN ARRAY
C     Q TO INCREASE THE SAMPLING INTERVAL AND DECREASE THE  
C     NYQUIST FREQUENCY.  THIS IS USEFUL TO INVESTIGATE THE 
C     LOW FREQUENCY STRUCTURE IN THE POWER SPECTRUM.  
C     ***** INPUT DATA *****  
C     1.) NAV, THE REQUIRED SAMPLING TIME (FREE FORMAT)     
C     
      DIMENSION Q(NOQ),SAMTIM(NORUN),LIM(2,NORUN)   
      DOUBLE PRECISION TQ(NOQ),TV
      READ *, AV
  200 DELREQ=AV 
      PRINT 201,DELREQ  
  201 FORMAT(12X,'REQUIRED SAMPLING TIME IS ',F8.2)   
      DO 400 KJ=1,NORUN 
        IP1=LIM(1,KJ)   
        IP2=LIM(2,KJ)   
        IF(KJ.EQ.1)INDEX=0    
        IF(KJ.GT.1)INDEX=LIM(2,KJ-1)
        NAV=NINT(DELREQ/SAMTIM(KJ)) 
        IF(NAV.LT.1)THEN
          PRINT *,'Incorrect averaging: NAV= ',nav
          PRINT *,'Sampling time of run ',kj,'  is ',samtim(kj)
          STOP
        END IF
        DO 300 I=IP1,IP2,NAV  
          INDEX=INDEX+1 
          NAVI=NAV+I-1  
          IF(NAVI.LE.IP2)GO TO 225  
          NAV=NAV-(NAVI-IP2)  
          NAVI=IP2
  225     V=0.0   
          TV=0.0  
          DO 250 J=I,NAVI     
            V=V+Q(J)    
            TV=TV+TQ(J) 
  250     CONTINUE
          Q(INDEX)=V/NAV
          TQ(INDEX)=TV/NAV    
  300   CONTINUE  
        SAMTIM(KJ)=IFIX(DELREQ/SAMTIM(KJ)) * SAMTIM(KJ)     
  350   IF(KJ.GT.1)LIM(1,KJ)=LIM(2,KJ-1)+1
        IF(INDEX.NE.0)LIM(2,KJ)=INDEX     
  400 CONTINUE    
      NOQ=LIM(2,NORUN)  
      PRINT 410,NORUN,(LIM(1,J),LIM(2,J),SAMTIM(J),J=1,NORUN)     
  410 FORMAT(12X,'INDEX POINTERS FOR THE ',I3,' RUNS :'/    
     *       (14X,'FIRST POINT IS ',I5,'   LAST POINT IS ',I5,    
     *      '    SAMPLING TIME IS ',F6.1))
      PRINT 450,NOQ     
  450 FORMAT(12X,'NQ IS NOW ',I7)   
      RETURN
      END   
