| | 108 | === Running serial jobs === |
| | 109 | |
| | 110 | If you are running a large number of serial jobs, it is recommended to submit them as a job array to make the best use of your allocated resources. For example, suppose you are running 100 serial jobs using scripts located in a "scripts" folder, each of which does a serial calculation: scripts/run1.sh, scripts/run2.sh, ..., scripts/run100.sh. You would create an sbatch script named "run100scripts.srun" with contents: |
| | 111 | |
| | 112 | {{{ |
| | 113 | #!/bin/bash |
| | 114 | #SBATCH -J array_example |
| | 115 | #SBATCH --array=0-4 |
| | 116 | #SBATCH -N 1 |
| | 117 | #SBATCH -n 20 |
| | 118 | #SBATCH --time=01:00:00 |
| | 119 | |
| | 120 | srun ./runscript.sh |
| | 121 | }}} |
| | 122 | |
| | 123 | The contents of the script "runscript.sh" would be: |
| | 124 | |
| | 125 | {{{ |
| | 126 | #!/bin/bash |
| | 127 | |
| | 128 | RUNNUMBER=$((SLURM_ARRAY_TASK_ID*SLURM_NTASKS + SLURM_PROCID + 1)) |
| | 129 | ./scripts/run$RUNNUMBER.sh |
| | 130 | }}} |
| | 131 | |
| | 132 | Make sure your scripts have executable permissions. Then, submitting with: |
| | 133 | |
| | 134 | {{{ |
| | 135 | sbatch run100scripts.srun |
| | 136 | }}} |
| | 137 | |
| | 138 | will run the 100 scripts as a 5 job array, with 20 tasks each. |
| | 139 | |