module steering { # Bob Clapp's steering filter
  use helix
  integer, private :: n   # helix period
  real,    private :: dc  # triangle half-width, filter d.c.
contains
  subroutine steer_init( amp, n1) {
    real,    intent( in) :: amp
    integer, intent( in) :: n1
    dc = amp; n = n1 
  }
  subroutine steering2( slope, aa) {
    type( filter)     :: aa
    real, intent( in) :: slope
    integer           :: h, nh, ip
    real              :: p0
    nh = size( aa%lag);  p0 =( nh+1.)/2.
    ip = n - p0 + slope
    do h = 1, nh {		
       aa%lag(h) = ip + h
       aa%flt(h) = p0 - 1. - abs (ip + h - n - slope)
   }
   where (aa%flt < 0.) aa%flt = 0.
   aa%flt = -dc*aa%flt/sum(aa%flt)
  }
}
