function ozone2_ode23s ( )

%*****************************************************************************80
%
%% ozone2_ode23s uses ode23s() to solve ozone2_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 April 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ozone2_ode23s():\n' );
  fprintf ( 1, '  Solve ozone2_ode() using ode23s().\n' );

  [ k2, k3, sigma2, t0, y0, tstop ] = ozone2_parameters ( );

  f = @ ozone2_deriv;
  tspan = [ t0, tstop ];
%
%  We need to use the "options" argument to loosen the error tolerance.
%
  options = odeset ( 'RelTol', 1.0E-03, 'AbsTol', 1.0E-02 );

  [ t, y ] = ode23s ( f, tspan, y0, options );

  n = size ( t, 1 );
  dt = tstop / ( n - 1 );
  fprintf ( 1, '  number of time steps = %d\n', n );
  fprintf ( 1, '  average timestep =     %g seconds\n', dt );

  figure ( 1 );
  clf ( );
  plot ( t, y(:,1), 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  y1  --->' );
  title ( 'ozone2_ode(): ode23s y1' );
  filename = 'ozone2_ode23s_y1.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  figure ( 2 );
  clf ( );
  plot ( t, y(:,2), 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  y2  --->' );
  title ( 'ozone2_ode(): ode23s y2' );
  filename = 'ozone2_ode23s_y2.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  figure ( 3 );
  clf ( );
  plot ( t, y(:,3), 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  y3  --->' );
  title ( 'ozone2_ode(): ode23s y3' );
  filename = 'ozone2_ode23s_y3.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  figure ( 4 );
  clf ( );
  plot ( t, y(:,4), 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  y4  --->' );
  title ( 'ozone2_ode(): ode23s y4' );
  filename = 'ozone2_ode23s_y4.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  h = ozone2_conserved ( y );

  figure ( 5 );
  clf ( );
  hold ( 'on' );
    plot ( t, h, 'r-', 'linewidth', 3 );
    plot ( tspan, [h(1),h(1)], 'b--', 'linewidth', 3 );
    plot ( tspan, [0.0,0.0], 'k--', 'linewidth', 3 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  h  --->' );
  title ( 'ozone2_ode(): ode23s conservation' );
  filename = 'ozone2_ode23s_conservation.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

