function subcompnz_next_test ( )

%*****************************************************************************80
%
%% subcompnz_next_test() tests subcompnz_next().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 June 2015
%
%  Author:
%
%    John Burkardt
%
  n = 6;
  k = 3;
  a = [];
  more = 0;
  h = 0;
  t = 0;
  n2 = 0;
  more2 = 0;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'subcompnz_next_test():\n' );
  fprintf ( 1, '  subcompnz_next() generates subcompositions\n' );
  fprintf ( 1, '  using nonzero parts.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Seek all subcompositions of N = %d\n', n );
  fprintf ( 1, '  using K = %d nonzero parts.\n', k );
  fprintf ( 1, '\n' );
  fprintf ( 1, '     #   Sum\n' );
  fprintf ( 1, '\n' );

  rank = 0;

  while ( true )

    [ a, more, h, t, n2, more2 ] = subcompnz_next ( n, k, a, more, ...
      h, t, n2, more2 );

    rank = rank + 1;
    fprintf ( 1, '  %4d  %4d  ', rank, sum ( a(1:k) ) );
    for i = 1 : k
      fprintf ( 1, '%4d', a(i) );
    end
    fprintf ( 1, '\n' );

    if ( ~more )
      break
    end

  end

  return
end
