| 305 | == Running Manny Serial Jobs == |
| 306 | |
| 307 | 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: |
| 308 | |
| 309 | {{{ |
| 310 | #!/bin/bash |
| 311 | #SBATCH -J array_example |
| 312 | #SBATCH --array=0-4 |
| 313 | #SBATCH -N 1 |
| 314 | #SBATCH -n 20 |
| 315 | #SBATCH --time=01:00:00 |
| 316 | |
| 317 | srun ./runscript.sh |
| 318 | }}} |
| 319 | |
| 320 | The contents of the script "runscript.sh" would be: |
| 321 | |
| 322 | {{{ |
| 323 | #!/bin/bash |
| 324 | |
| 325 | RUNNUMBER=$((SLURM_ARRAY_TASK_ID*SLURM_NTASKS + SLURM_PROCID + 1)) |
| 326 | ./scripts/run$RUNNUMBER.sh |
| 327 | }}} |
| 328 | |
| 329 | Make sure your scripts have executable permissions. Then, submitting with: |
| 330 | |
| 331 | {{{ |
| 332 | sbatch run100scripts.srun |
| 333 | }}} |
| 334 | |
| 335 | will run the 100 scripts as a 5 job array, with 20 tasks each. |
| 336 | |
| 337 | |