%N cnvlr %F $MIR/src/subs/cnvl.for
%D Convolve the beam with a subimage (in "runs" format).
%P rjs
%: convolution, fft
%B
      subroutine CnvlR(handle,in,nx,ny,runs,nRuns,out,flags)

      ptrdiff handle
      integer nx,ny,nruns,runs(3,nruns)
      character flags*(*)
      real in(*),out(*)

  This convolves, or correlates, an image by a beam pattern.  The input
  image is in an array in "runs" format. The beam pattern is passed in
  as a handle as previously returned by either the CnvlIniA or CnvlIniF
  routines.

  The output image can either be in runs format (see flag='c' below),
  or the same size as the previously input beam. In the latter case,
  the output image is centered in the middle of the output array.  In
  particular, if the beam is of size n1 x n2, and the input image is of
  size nx x ny, then the output image will be of size n1 x n2, and
  pixel (i,j) in the input will correspond to pixel (x0+i,y0+j) in the
  output, where
       x0 = n1/2 - nx/2
       y0 = n2/2 - ny/2

  Input:
    handle     Handle of the beam, previously returned by CnvlIniA or
               CnvlIniF.
    in         Input pixels to convolve.
    nx,ny      Image size.
    runs       Runs of the image.
    nRuns      The number of runs.
    flags      Extra processing options:
                'c'    The output is the same size as the input. The
                       default is the output image is the size of the
                       beam.
                'x'    Correlate with the beam. The default is to
                       convolve with the beam.
  Output:
    out        The convolved image. This can be either in runs format,
               or an array the size of the beam (depending on the 'x'
               flag).
