function ozone_lsode ( )

%*****************************************************************************80
%
%% ozone_lsode() uses lsode() to solve the ozone ODE.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 May 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ozone_lsode():\n' );
  fprintf ( 1, '  Use lsode() to solve the ozone ODE.\n' );

  [ k2, k3, t0, y0, tstop ] = ozone_parameters ( );
%
%  Have to use a special version of the derivative with arguments reordered.
%
  f = @ ozone_deriv_lsode;
  tspan = [ t0, tstop ];
  t = linspace ( t0, tstop, 101 );
%
%  Have to call the ODE solver with arguments in different order and meaning.
%
  y = lsode ( f, y0, t );

  figure ( 1 );
  clf ( );
  plot ( t, y(:,1), 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  y  --->' );
  title ( 'ozone lsode(), y1' );
  filename = 'ozone_lsode_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 ( 'ozone lsode() y2' );
  filename = 'ozone_lsode_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 ( 'ozone lsode() y3' );
  filename = 'ozone_lsode_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 ( 'ozone lsode() y4' );
  filename = 'ozone_lsode_y4.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  h = ozone_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 ( 'ozone lsode conservation' );
  filename = 'ozone_lsode_conservation.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ozone_lsode:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end

