Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions triton/examples/array/pi_array_hardcoded_alt.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions triton/tut/array.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 </triton/examples/array/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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down