###########################################################
# Perl script based on Karsten Bonath's Batch-Script for
# using LLRnet 0.9b7 with newer LLR-versions, version 0.74
# Copyright 2010 Max Dettweiler and Gary Barnes
###########################################################

*** NOTE:  To skip the history and get started, go to the next paragraph labeled like this:  ***

This Perl script replaces LLRnet's built-in primality testing code, which is based on LLR 3.5.0, with code that calls a stand-alone LLR binary, allowing the use of the latest version of LLR. Karsten Bonath made small changes to LLRnet by removing the test code and tweaking some output to make it more specifically useful for this application.

The script is a Linux version of Karsten's Windows/DOS batch file and is largely identical in terms of functionality.  It does the job of tying together the modified LLRnet, which is used for server communications, and LLR that is used for the actual test. It also adds a few features not found in the original LLRnet such as the ability to have multiple clients write to a centralized prime log and to optionally beep when a prime is found.

Karsten made small patches to some Windows LLR 3.8.0 binary values in order to remove a small amount of output that would normally display for each test.  In an automated setup such as this, the displays create additional screen output that is not needed. However, there is nothing to keep either this script or Karsten's batch file from working just as well with the original version of LLR.  The changes that Karsten made to Windows LLR are as follows:

-------------
Patched "cllr.exe":
4560CC: 00 -> V1 = ... ; Computing U0...done.
456344: 00 -> Starting Lucas Lehmer Riesel prime test of...
-------------

This client uses the original Linux LLR 3.8.0.  Although it would not be necessary to run the Linux client, in order to create a binary of the modified Windows LLR executable, similar changes would need to be made to the Linux LLR executable.

*** Start here to skip the history and get started ***

Below are the user modifiable settings.  It is designed to be run as is but several configuration options can be changed as specified in the initial part of the do.pl script:

$llrPath = './llr';       <-- Set paths to the LLR and LLRnet binaries here.  In Linux
$llrnetPath = './llrnet'; <-- the current-directory paths need to be prefixed with ./

$beepOnPrime = "false"; <-- Set this to "true" to have the computer beep when it
                        <-- finds a prime. This will not work on all systems.

$individualPrimeLog = "false"; <-- Set this to "true" to write all primes to a file primes.txt in
                               <-- the client's own directory.  Set it to "false" to write all primes
                               <-- in the parent directory, which would be useful for multiple cores.

$iniOptions = "OutputIterations=10000\n"; <-- Specify options for llr.ini here. Each line
                                          <-- needs to be separated by a newline character
                                          <-- (\n) and there should also be one at the end.

$errorTimeout = 60; <-- The number of seconds that the client will wait after five
                    <-- consecutive attempts at server communication before retrying.

In llr-clientconfig.txt, enter the server, port to connect to, username, and the number of k/n pairs to retrieve in a batch. Use of the -once option is no longer recommended.  It is not needed with the cancellation of pairs option as shown below.

To run the client, open a terminal window to the client directory and run the command "./do.pl".  This assumes that the file has -x privileges.  "perl do.pl" will work regardless of privileges. The client will fetch the number of k/n pairs specified in llr-clientconfig.txt as WUCacheSize, run them, return the results to the server, and repeat until the program is exited by hitting Ctrl-C or the server runs out of pairs.  To restart where it left off, run it in the same manner.

To cancel all unprocessed pairs, run "./do.pl -c".  This only needs to be executed one time.  This is IMPORTANT and has a two-fold purpose.  Since the client now processes all pairs in the batch before returning any results to the server, this function will now return all processed results as well as all remaining unprocessed pairs to the server.  In order to get credit for processed results that have not been returned to the server, this function must be utilized.  The other alternative is to set the WuCache to 1 but doing so is less efficient because of the additional server communication time needed after processing each pair.

Please send questions or comments to gbarnes017@gmail.com or max@noprimeleftbehind.net.

Versions:
0.70 - Original public release after alpha testing.

0.71 - Correct problem with results not being returned to the server whenever there is an internet outage or server problem at or before the time that the batch is finished.  Changes were made to both the main process and the job cancellation process.

0.74 - Raised version number to match the Windows script. No changes were made to this script itself.
