function crs_write ( prefix, row, col, val )

%*****************************************************************************80
%
%% crs_write() writes a sparse matrix in CRS format to 3 files.
%
%  Discussion:
%
%    Three files will be created:
%    * prefix_row.txt contains N+1 row start values;
%    * prefix_col.txt contains NZ column indices;
%    * prefix_val.txt contains NZ matrix entries
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 June 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string PREFIX, a common prefix for the filenames.
%
%    integer ROW(N+1): the nonzero offdiagonal elements 
%    of row I of A are contained in A(ROW(I)) through A(ROW(I+1)-1).
%
%    integer COL(NZ): the column indices of the nonzero elements of A.
%
%    real VAL(NZ): the nonzero elements of A.
%
  filename = strcat ( prefix, '_row.txt' );
  save ( filename, 'row', '-ASCII' );
  fprintf ( 1, '  Saved data as "%s"\n', filename );

  filename = strcat ( prefix, '_col.txt' );
  save ( filename, 'col', '-ASCII' );
  fprintf ( 1, '  Saved data as "%s"\n', filename );

  filename = strcat ( prefix, '_val.txt' );
  save ( filename, 'val', '-ASCII' );
  fprintf ( 1, '  Saved data as "%s"\n', filename );

  return
end
