diff --git a/triton/examples/array/pi_array_hardcoded_alt.sh b/triton/examples/array/pi_array_hardcoded_alt.sh new file mode 100644 index 000000000..377890422 --- /dev/null +++ b/triton/examples/array/pi_array_hardcoded_alt.sh @@ -0,0 +1,11 @@ +#!/bin/bash +#SBATCH --time=01:00:00 +#SBATCH --mem=500M +#SBATCH --job-name=pi-array-hardcoded +#SBATCH --output=pi-array-hardcoded_%a.out +#SBATCH --array=0-4 + +SEEDS=(123 38 22 60 432) +SEED=${SEEDS[SLURM_ARRAY_TASK_ID]} + +srun python slurm/pi.py 2500000 --seed=$SEED > pi_$SEED.json diff --git a/triton/tut/array.rst b/triton/tut/array.rst index 1a1d97e5a..e847f504b 100644 --- a/triton/tut/array.rst +++ b/triton/tut/array.rst @@ -203,6 +203,17 @@ of successes):: $ cat pi_22.json {"successes": 1963163, "pi_estimate": 3.1410608, "iterations": 2500000} +An alternative to using ``case`` statement would be using ``bash`` arrays, like in the following example +:download:`pi_array_hardcoded_alt.sh ` +. + +.. literalinclude:: /triton/examples/array/pi_array_hardcoded_alt.sh + :language: slurm + +``bash`` arrays and variables only support non-negative integers or strings, so if your parameters are e.g. real numbers, they can be put in the array as strings:: + FREQUENCIES=("2.8" "2.9" "3.0" "3.1") + FREQUENCY=${FREQUENCIES[SLURM_ARRAY_TASK_ID]} + Reading parameters from one file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~