%N matchcg %F $MIR/src/subs/cgsubs.for
%D Match fields with allowed types and die if no good
%: plotting
%B
      subroutine matchcg (n, field, string, struct, ntype, types)

      integer ntype, n
      character*(*) types(ntype), string, field, struct
  ---------------------------------------------------------------------
  Look for string in list of allowed ones.  If not found die with
  fatal error.  Expand string for minimum match.  Extra variables
  can be used to provide error messages.  These messages expect
  that the string is one field from several fields making up
  one structure, and that there are several structures being
  examined.  For example, an overlay file for CGDISP expects
  many rows, each describing one overlay.  Each row contains
  several fields, each of which may take on different values.

  Inputs:
    ntype      The number of possible values that STRING can have
    type       An array of possible values for STRING

    n          Number of the thing that we are matching (used
               in  error messages if non zero)
    field      A string describing what field STRING is (used
               in error messages if non blank).
    struct     A string describing the generic name of the structure
               from which STRING is one field (used in error messages
               if non blank).
               Examples are "overlay", "slice"
  Input/output:
    string     The string that we are trying to match.  It is
               expanded from minimum  match on output

  An example of an error message would be:

   STRING is ambiguous for STRUCT # N field FIELD.  Choose from: ...

  Thus, if STRING was "rel", STRUCT was "overlay", N was 14 and FIELD
  was "xotype" then the message would read

   "rel" is ambiguous for overlay # 14 field "xotype". Choose from: ...

  Got it ??
