function [ ist, jst, ast ] = i4st_data_read ( filename, m, n, nst )

%*****************************************************************************80
%
%% I4ST_DATA_READ reads the data of an I4ST file.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    27 September 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, string FILENAME, the name of the file.
%
%    Input, integer M, the number of rows.
%
%    Input, integer N, the number of columns.
%
%    Input, integer NST, the number of nonzeros.
%
%    Output, integer IST(NST), JST(NST), the row and column indices.
%
%    Output, integer AST(NST), the nonzero values.
%
  input = fopen ( filename );

  if ( input < 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'I4ST_DATA_READ - Error!\n' );
    fprintf ( 1, '  Could not open the input file.\n' );
    error ( 'I4ST_DATA_READ - Error!' );
    return
  end

  string = '  %d  %d  %d';

  for k = 1 : nst

    line = fgets ( input );

    if ( line == -1 )
      fprintf ( 1, '\n' );
      fprintf ( 1, 'I4ST_DATA_READ - Error!\n' );
      fprintf ( 1, '  Premature end of input data.\n' );
      error ( 'I4ST_DATA_READ - Error!' );
      break
    end

    [ x, count ] = sscanf ( line, string );

    ist(k) = x(1);
    jst(k) = x(2);
    ast(k) = x(3);

  end

  fclose ( input );

  return
end
