function ozone2_ode_test ( )

%*****************************************************************************80
%
%% ozone2_ode_test tests ozone2_ode().
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    26 January 2021
%
%  Author:
%
%    John Burkardt
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ozone2_ode_test:\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test ozone2_ode().\n' );
%
%  Get the parameters.  We need the value of t0.
%
  [ k2, k3, sigma2, t0, y0 ] = ozone2_parameters ( );
%
%  Time interval is t0 = sunrise (4am) day 1 to tstop = sunset (8pm) day 6,
%  measured in seconds.
%
  tstop = 504000.0;
  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 );
%
%  Ask ode23s to solve the system.
%
  f = @ ozone2_deriv;

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

  nt = length ( t );
  dt = tstop / ( nt - 1 );
  fprintf ( 1, '  ode15s: number of time steps = %d\n', nt );
  fprintf ( 1, '          average timestep =     %g seconds\n', dt );
%
%  Plot y1, y2, y3, y4 and the conserved quantity.
%
  figure ( 1 );
  clf ( );
  plot ( t, y(:,1), 'b-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  y1  --->' );
  title ( 'ozone2 ode y1' );
  filename = 'ozone2_ode_y1.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

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

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

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

  figure ( 5 );
  clf ( );
  h = ozone2_conserved ( y );
  plot ( t, h, 'b-', tspan, [0.0,0.0], 'k--', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  h  --->' );
  title ( 'ozone2 ode conservation' );
  legend ( 'ode15s', 'zero' );
  filename = 'ozone2_ode_conservation.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ozone_ode_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  return
end
