function mesh2d_write ( p, t, label )

%*****************************************************************************80
%
%% mesh2d_write() writes mesh2d() node and triangulation data to files.
%
%  Discussion:
%
%    The output files will have the names
%      LABEL_nodes.txt
%      LABEL_elements.txt
%    where LABEL is the common filename prefix specified by the user.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 December 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real p(np,2): the point coordinates.
%
%    integer t(nt,3): the indices of points forming triangles.
%
%    character label: the common filename prefix to use.
%
  np = size ( p, 1 );
  nt = size ( t, 1 );

  fprintf ( 1, '  %d nodes and %d triangles created\n', np, nt );

  node_filename = [ label, '_nodes.txt' ];
  r8mat_write ( node_filename, np, 2, p );
  fprintf ( 1, '  Nodes stored as "%s"\n', node_filename );

  element_filename = [ label, '_elements.txt' ];
  i4mat_write ( element_filename, nt, 3, t );
  fprintf ( 1, '  Elements stored as "%s"\n', element_filename );

  return
end

