%N grgray %F $MIR/src/grgray.f
%D Gray-scale map of a 2D data array
%B
      SUBROUTINE GRGRAY (A, IDIM, JDIM, I1, I2, J1, J2,
     1                   FG, BG, PA, MININD, MAXIND, MODE)
      INTEGER IDIM, JDIM, I1, I2, J1, J2, MININD, MAXIND, MODE
      REAL    A(IDIM,JDIM)
      REAL    FG, BG
      REAL    PA(6)

 This is a device-dependent support routine for PGGRAY.

 Draw gray-scale map of an array in current window. Array
 values between FG and BG are shaded in gray levels determined
 by linear interpolation. FG may be either less than or greater
 than BG.  Array values outside the range FG to BG are
 shaded black or white as appropriate.

 GRGRAY uses GRIMG0 on devices with enough color indices available.
 Note that it changes the color table to gray-scale.
 Otherwise in does a random dither with GRIMG3.

 Arguments:
  A      (input)  : the array to be plotted.
  IDIM   (input)  : the first dimension of array A.
  JDIM   (input)  : the second dimension of array A.
  I1, I2 (input)  : the inclusive range of the first index
                    (I) to be plotted.
  J1, J2 (input)  : the inclusive range of the second
                    index (J) to be plotted.
  FG     (input)  : the array value which is to appear in
                    foreground color.
  BG     (input)  : the array value which is to appear in
                    background color.
  PA     (input)  : transformation matrix between array grid and
                    device coordinates (see GRCONT).
  MODE   (input)  : transfer function.
