diff --git a/README.md b/README.md index 4c05238..4264780 100644 --- a/README.md +++ b/README.md @@ -50,20 +50,20 @@ By default, each node is allocated: By default, this script searches for prime numbers from `1-10,000` and `10,001-20,000` - You can adjust the range searched per node by providing an integer argument, e.g.: + You can adjust the range searched per node by providing an integer argument, e.g.: /vagrant/primes.sh 20000 The script will then drop you into a `watch -n0.1 squeue` view so you can see - each job computing on `nodes[3-4]`. You may `CTRL+c` out of this view, and - the jobs will continue in the background. The home directory for the `submit` - user is in the shared `/vagrant` directory, so the results from each node are - shared back to the login node. + the job computing on `nodes[3-4]`. You may `CTRL+c` out of this view, and + the job will continue in the background. The home directory for the `submit` + user is in the shared `/vagrant` directory, so the results from each node are + shared back to the login node. 4. View the resulting prime numbers found, check `ls` for exact filenames - less slurm-1.out - less slurm-2.out + less slurm-1_0.out + less slurm-2_1.out ### Configuration Tool diff --git a/primes.sh b/primes.sh index 588b639..41d7a1f 100755 --- a/primes.sh +++ b/primes.sh @@ -24,7 +24,7 @@ RANGE=${1:-10000} function find_primes() { local START="$1" local END="$2" - echo "INFO: Job $SLURM_JOB_ID looking for prime numbers from $START to $END" + echo "INFO: Job ${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID} looking for prime numbers from $START to $END" for ((i=START;i<=END;i++)); do if [ "$(factor "$i")" == "$i: $i" ]; then echo "$i" @@ -32,10 +32,13 @@ function find_primes() { done } -if [ -z "$SLURM_JOB_ID" ]; then - sbatch -N1 --wrap="$0 1 $RANGE" - sbatch -N1 --wrap="$0 $((RANGE + 1)) $((RANGE * 2))" +if [ -z "$SLURM_ARRAY_JOB_ID" ]; then + sbatch -N1 -a0-1 "$0" "$RANGE" watch -n0.1 squeue else - find_primes "$1" "$2" + if [ "$SLURM_ARRAY_TASK_ID" -eq 0 ]; then + find_primes 1 "$RANGE" + else + find_primes $((RANGE + 1)) $((RANGE * 2)) + fi fi