function [ k1, k2, t0, y0, tstop ] = reaction_twoway_parameters ( k1_user, ...
  k2_user, t0_user, y0_user, tstop_user )

%*****************************************************************************80
%
%% reaction_twoway_parameters() returns parameters for reaction_twoway_ode().
%
%  Discussion:
%
%    If input values are specified, this resets the default parameters.
%    Otherwise, the output will be the current defaults.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 April 2021
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Willem Hundsdorfer, Jan Verwer,
%    Numerical solution of time-dependent advection-diffusion-reaction equations,
%    Springer, 2003
%    ISBN: 978-3-662-09017-6
%
%  Input:
%
%    real K1_USER, K2_USER: the reaction rates.
%    The value of K2 is suggested to be 10, 100, or 1000.
%
%    real T0_USER: the initial time.
%
%    real Y0_USER[2]: the initial conditions.
%
%    real TSTOP_USER: the final time.
%
%  Output:
%
%    real K1, K2: the reaction rates.
%    The value of K2 is suggested to be 10, 100, or 1000.
%
%    real T0: the initial time.
%
%    real Y0[2]: the initial conditions.
%
%    real TSTOP: the final time.
%
  persistent k1_default;
  persistent k2_default;
  persistent t0_default;
  persistent y0_default;
  persistent tstop_default;
%
%  Initialize defaults.
%
  if ( isempty ( k1_default ) )
    k1_default = 1.0;
  end

  if ( isempty ( k2_default ) )
    k2_default = 10.0;
  end

  if ( isempty ( t0_default ) )
    t0_default = 0.0;
  end

  if ( isempty ( y0_default ) )
    y0_default = [ 0.1, 0.9 ];
  end

  if ( isempty ( tstop_default ) )
    tstop_default = 1.0;
  end
%
%  Update defaults if input was supplied.
%
  if ( 1 <= nargin )
    k1_default = k1_user;
  end

  if ( 2 <= nargin )
    k2_default = k2_user;
  end

  if ( 3 <= nargin )
    t0_default = t0_user;
  end

  if ( 4 <= nargin )
    y0_default = y0_user;
  end

  if ( 5 <= nargin )
    tstop_default = tstop_user;
  end
%
%  Return values.
%
  k1 = k1_default;
  k2 = k2_default;
  t0 = t0_default;
  y0 = y0_default;
  tstop = tstop_default;
  
  return
end

