function ozone_midpoint ( n )

%*****************************************************************************80
%
%% ozone_midpoint() uses midpoint() to solve ozone_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 April 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ozone_midpoint():\n' );
  fprintf ( 1, '  Use midpoint() to solve ozone_ode().\n' );

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

  f = @ ozone_deriv;
  tspan = [ t0, tstop ];

  [ t, y ] = midpoint ( f, tspan, y0, n );

  dt = ( tstop - t0 ) / n;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of time steps = %d\n', n );
  fprintf ( 1, '  Timestep size =        %g seconds\n', dt );

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

  return
end


