      program moving
      interface operator ( .runningaverage. )
          function series ( rough, run ) result ( smooth )
            real,    dimension ( : ), intent(in) :: rough
            integer,                  intent(in) :: run
            real,    dimension ( size(rough) )   :: smooth
            end function series
      end interface
      real, dimension ( 15 ) :: raw
      call random_number ( raw )
      raw = raw * 10.0
      print *, " "
      print 100, "Raw   ", raw
100   format ( ' ', a, 15f4.1 )
      print *, " "
      do i = 0, 8, 1
         print 100, "Smooth", raw .runningaverage. i
      end do
      print *, " "
      end program moving

      function series ( rough, run ) result ( smooth )
      real,    dimension ( : ), intent(in) :: rough
      integer,                  intent(in) :: run
      real,    dimension ( size(rough) )   :: smooth
      n = size ( rough )
      m = run + 1 + run
      if ( n .lt. m ) then
           smooth = sum ( rough ) / n
      else
           smooth = sum ( rough ) / n
           j = lbound(rough,DIM=1) + run
           k = ubound(rough,DIM=1) - run
           do i = j, k, 1
              smooth(i) = sum ( rough(i-run:i+run) ) / m
           end do
      end if
      end function series
