function triangulation_refine_local_test ( )

%*****************************************************************************80
%
%% triangulation_refine_local_test() tests triangulation_refine_local().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 April 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../triangulation_refine_local' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'triangulation_refine_local_test()\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test triangulation_refine_local().\n' );

  prefix = 'ell3';

  [ node_num, element_num, node_xy, element_node, element_neighbor ] = ...
    grid_read ( prefix );

  r8mat_print ( node_num, 2, node_xy, '  Node coordinates' );
  i4mat_print ( element_num, 3, element_node, '  Element node array:' );
  i4mat_print ( element_num, 3, element_neighbor, ...
    '  Element neighbor array' );

  element = 11;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Refine element %d\n', element );

  [ node_num2, element_num2, node_xy2, element_node2, ...
    element_neighbor2 ] = triangulation_refine_local ( node_num, ...
    element_num, node_xy, element_node, element_neighbor, element );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Refined number of nodes =          %d\n', node_num2 );
  fprintf ( 1, '  Refined number of elements =       %d\n', element_num2 );

  r8mat_print ( node_num2, 2, node_xy2, '  Refined node coordinates' );
  i4mat_print ( element_num2, 3, element_node2, '  Refined element node array:' );
  i4mat_print ( element_num2, 3, element_neighbor2, ...
    '  Refined element neighbor array' );
%
%  Write out the refined data.
%
  node_refined_filename = strcat ( prefix, '_refined_nodes.txt' );
  element_refined_filename = strcat ( prefix, '_refined_elements.txt' );
  element_neighbor_refined_filename = strcat ( prefix, '_refined_element_neighbors.txt' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Refined node file is "%s".\n', node_refined_filename );
  fprintf ( 1, '  Refined element file is "%s".\n', element_refined_filename );
  fprintf ( 1, '  Refined element neighbor file is "%s".\n', ...
    element_neighbor_refined_filename );

  r8mat_write ( node_refined_filename, node_num2, 2, node_xy2 );
  i4mat_write ( element_refined_filename, element_num2, 3, element_node2 );
  i4mat_write ( element_neighbor_refined_filename, element_num2, 3, element_neighbor2 );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'triangulation_refine_local_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../triangulation_refine_local' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

