%N chnselcg %F $MIR/src/subs/cgsubs.for
%D Make list of CHAN and REGION selected channel groups
%P nebk
%: plotting
%B
      subroutine chnselcg (blc, trc, kbin, maxbox, boxes, ngrps,
     *                     grpbeg, ngrp)

      integer maxbox, boxes(maxbox), grpbeg(*), ngrp(*), ngrps, kbin(2),
     *  blc(3), trc(3)
  ---------------------------------------------------------------------
  Find the channels designated by the CHAN and REGION specifiations
  via the RUNS arrays.    Note that currently, none of the
  CG programs call BOXMASK so that all planes offered by the
  REGION keyword are selected by CHANSELCG as being good.
  Blanked pixels are dealt with by READIMCG

  Input
    blc,trc    Cube surrounding region of interest
    kbin       Channel increment and average to step through image.
               If kbin(1) and kbin(2) = 0 then output groups begin
               every time the selected channels are non-contiguous
               and the end channel of each group is made equal to
               the number of contiguous channels in that group
    maxbox     Maximum number of boxes
    boxes      Boxes following BOXINPUT,BOXSET,BOXINFO (optional) and
               BOXMASK
  Output
    ngrps      Number of groups of channels
    grpbeg     Array of start channels for each group of selected
               channels.  Each group will be averaged together to
               make one sub-plot
    ngrp       Number of channels in each group
