function [ id, type, rep, field, symm, nrow, ncol, nnz, indx, jndx, value ] ...
  = mm_file_read ( input_unit )

%*****************************************************************************80
%
%% mm_file_read() reads data from a Matrix Market file.
%
%  Discussion:
%
%    The data may be either sparse coordinate format, or dense array format.
%
%    The unit input_unit must be open, and the file will be rewound on return.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    02 May 2004
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer INPUT_UNIT, the input unit identifier.
%
%  Output:
%
%    character ID, the Matrix Market identifier.
%    This value must be '%%MatrixMarket'.
%
%    character TYPE, the Matrix Market type.
%    This value must be 'matrix'.
%
%    character REP, the Matrix Market 'representation'
%    indicator.  Possible values include:
%    'coordinate'   (for sparse data)
%    'array'        (for dense data)
%    'elemental'    (to be added)
%
%    character FIELD, the Matrix Market 'field'.
%    Possible values include:
%    'real'
%    'double'
%    'complex'
%    'integer'
%    'pattern'
%
%    character SYMM, the Matrix Market symmetry.
%    Possible values include:
%    'symmetric'
%    'hermitian'
%    'skew-symmetric'
%    'general'
%
%    integer NROW, the number of rows in the matrix.
%
%    integer NCOL, the number of columns in the matrix.
%
%    integer NNZ, the number of nonzero entries required to store
%    the matrix, if REP = 'coordinate'.
%
%    integer INDX(NNZ), the row indices for coordinate format.
%    Not used if REP is 'array'.
%
%    integer JNDX(NNZ), the column indices for coordinate format.
%    Not used if REP is 'array'.
%
%    complex VALUE(NNZ), the matrix values.
%

%
%  Read and check the header line.
%
  [ id, type, rep, field, symm ] = mm_header_read ( input_unit );

  ok = mm_header_check ( id, type, rep, field, symm );
  
  if ( ~ ok ) 
    fprintf ( 1, '\n' );
    fprintf ( 1, 'MM_FILE_READ - Fatal error!\n' );
    fprintf ( 1, '  The header information was not acceptable.\n' );
    error ( 'MM_FILE_READ - Fatal error!' );
  end
%
%  Read through the comment lines:
%
  while ( true )

    comment = mm_comment_read ( input_unit );

    if ( comment(1) ~= '%' )
      break;
    end

  end
%
%  The line we just read is not a comment.  It is presumably the SIZE line.
%
  [ nrow, ncol, nnz ] = mm_size_read_string ( comment, rep, symm );
%
%  Read the data values.
%
  [ value, indx, jndx ] = mm_values_read ( input_unit, rep, field, nnz );

  return
end
