      SUBROUTINE HRAVG(T1,T2,FILL,BTIME,DTIME,T,DATA,NPTS,
     &                 TOUT,DOUT,PARR,NOUT)
C
C PRODUCE AVERAGES OF PERIOD DTIME FROM INPUTTED HOUR AVERAGE DATA.
C ROUTINE DOES NOT REMOVE TIME POINTS WITH NULL AVERAGES.
C
      INTEGER*4 PARR(1)
      REAL*4 DATA(1),DOUT(1)
      REAL*8 T(1),TIME,TIME1,TIME2,TOUT(1),T1,T2,TEND
C
C T1 START TIME
C T2 END TIME
C FILL  FILL DATA VALUE
C BTIME RESOLUTION OF INPUT DATA (HOURS)
C DTIME AVERAGING INTERVAL (HOURS)
C T     INPUT TIME ARRAY
C DATA  INPUT DATA ARRAY
C NPTS  NUMBER OF POINTS IN INPUT DATA
C TOUT  OUTPUT TIME ARRAY
C DOUT  OUTPUT ARRAY OF DTIME AVERAGES
C PARR  OUTPUT ARRAY - # OF AVGS/PT
C NOUT NUMBER OF POINTS IN OUTPUT DATA
C
      SUM = 0.0
      NUM = 0
      TEND = T2 + DBLE(BTIME/(100.0*24.0*DAYS(T2)))
C
      TIME1 = T1 - DBLE(BTIME/(100.0*24.0*DAYS(T1)))
      TIME2 = TIME1 + DBLE(DTIME/(24.0*DAYS(TIME1)))
      IARR = 0
      INDEX = 0
  10  CONTINUE
       IARR = IARR + 1
       IF (IARR.GT.NPTS) GOTO 20
       TIME = T(IARR)
       VAL = DATA(IARR)
C
C GET DATA FROM PROPER TIME INTERVAL
C
  15   CONTINUE
       IF (TIME.LT.TIME1) GOTO 10
       IF (TIME.GE.TIME2) GOTO 20
       IF (TIME.GT.TEND) GOTO 20
C
C ACCUMULATE DATA NOT INCLUDING FILL POINTS
C
       IF (VAL.NE.FILL) THEN
        SUM = SUM + VAL
        NUM = NUM + 1
       END IF
C
      GOTO 10
   20 CONTINUE
C
C AVERAGE DATA AND INCREMENT TIME INTERVAL
C
       AVG = FILL
       IF (NUM.NE.0) THEN
        AVG = SUM/FLOAT(NUM)
       END IF
       INDEX = INDEX + 1
       TOUT(INDEX) = TIME1 + DBLE(BTIME/(100.0*24.0*DAYS(TIME1)))
       DOUT(INDEX) = AVG
       PARR(INDEX) = NUM
       TIME1 = TIME2
       TIME2 = TIME1 + DBLE(DTIME/(24.0*DAYS(TIME1)))
       SUM = 0.0
       NUM = 0
      IF (IARR.LE.NPTS.AND.TIME.LE.TEND) GOTO 15
C
C RETURN FROM AVERAGING OVER DESIRED TIME INTERVAL
C
 100  CONTINUE
      WRITE(6,800) TOUT(1),TOUT(INDEX),INDEX
      CLOSE(10)
      NOUT = INDEX
C
      RETURN
 800  FORMAT(' START ',F12.8,'   STOP ',F12.8,'   POINTS ',I5)
      END
