function st_data_write ( output_filename, nrow, ncol, nnzero, row, col, a )

%*****************************************************************************80
%
%% st_data_write() writes the data of an ST file.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 November 2008
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string OUTPUT_FILENAME, the name of the ST file.
%
%    integer NROW, the assumed number of rows in the matrix.
%
%    integer NCOL, the assumed number of columns in the matrix.
%
%    integer NNZERO, the assumed number of nonzeros in the matrix.
%
%    integer ROW(NNZERO), COL(NNZERO), the 0-based row and column
%    index of a nonzero matrix entry.
%
%    real A(NNZERO), the value of a nonzero matrix entry.
%
  output_unit = fopen ( output_filename, 'wt' );

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

  for k = 1 : nnzero

    fprintf ( output_unit, '  %8d  %8d  %16.8f\n', row(k), col(k), a(k) );

  end

  fclose ( output_unit );

  return
end
