function ranlib_test_bot ( )

%*****************************************************************************80
%
%% RANLIB_TEST_BOT is a test program for the bottom level routines
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    19 September 2014
%
%  Author:
%
%    John Burkardt
%
  genlst = [ 1, 5, 10, 20, 32 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, 'RANLIB_TEST_BOT\n' );
  fprintf ( 1, '  Test the lower level random number generators.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Five of the 32 generators will be tested.\n' );
  fprintf ( 1, '  We generate 100000 numbers, reset the block\n' );
  fprintf ( 1, '  and do it again.  No disagreements should occur.\n' );
  fprintf ( 1, '\n' );
%
%  Initialize the generators.
%
  initialize ( );
%
%  Set up all generators.
%
  seed1 = 12345;
  seed2 = 54321;
  set_initial_seed ( seed1, seed2 );
%
%  For a selected set of generators
%
  nbad = 0;
  answer = zeros ( 10000, 1 );

  for ixgen = 1 : 5

    igen = genlst(ixgen);
    cgn_set ( igen );
    fprintf ( 1, '  Testing generator %d\n', igen );
%
%  Use 10 blocks, and generate 1000 numbers per block
%
    init_generator ( 0 );

    for iblock = 1 : 10
      for ians = 1 : 1000
        ix = ians + ( iblock - 1 ) * 1000;
        answer(ix) = i4_uni ( );
      end
      init_generator ( 2 );
    end
%
%  Do it again and compare answers
%  Use 10 blocks, and generate 1000 numbers.
%
    init_generator ( 0 );

    for iblock = 1 : 10
      for ians = 1 : 1000
        ix = ians + ( iblock - 1 ) * 1000;
        itmp = i4_uni ( );

        if ( itmp ~= answer(ix) )

          fprintf ( 1, '\n' );
          fprintf ( 1, 'RANLIB_TEST_BOT - Warning\n!' );
          fprintf ( 1, '  Data disagreement:\n' );
          fprintf ( 1, '  Block = %d\n', iblock );
          fprintf ( 1, '  N within block = %d\n', ians );
          fprintf ( 1, '  Index in ANSWER = %d\n', ix );
          fprintf ( 1, '  First value =  %d\n', answer(ix) );
          fprintf ( 1, '  Second value = %d\n', itmp );

          nbad = nbad + 1;

          if ( 10 < nbad )
            fprintf ( 1, '\n' );
            fprintf ( 1, 'RANLIB_TEST_BOT - Warning!\n' );
            fprintf ( 1, '  More than 10 mismatches.\n' );
            fprintf ( 1, '  Tests terminated early.\n' );
            return
          end

        end

      end

      init_generator ( 2 );

    end

  end

  return
end
