annotate bin/runme.sh @ 181:55169996c3bf

add support for multiple calls to srun with a counter
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Fri, 21 Jul 2023 11:38:20 +0100
parents e1bc9d8d688c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
167
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
1 #!/usr/bin/bash
181
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
2 # Invoke this as e.g. sbatch --ntasks=10 -c 20 runme.sh [-m first last] [args for work/bin/_runme.sh]
167
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
3 # It will run on the login node
181
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
4 # -m i j will launch _runme.sh multiple times with a -a in {first..last}
167
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
5
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
6 #SBATCH --time=01:00:00
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
7 #SBATCH --partition=standard
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
8 #SBATCH --qos=standard
178
e1bc9d8d688c ec184 now, run w. unbuffered output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 174
diff changeset
9 #SBATCH --account=ec184-hst
167
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
10 #SBATCH --job-name runme
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
11
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
12 export W=/work/dc007/dc007
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
13
181
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
14 if [ "$1" = "-m" ]
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
15 then
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
16 ss={$2..$3}
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
17 shift; shift; shift;
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
18 echo $(date) Launching $SLURM_JOB_NUM_NODES nodes in $(pwd) for runme -a $ss "$@" from $(hostname) to do $SLURM_NTASKS tasks, $SLURM_CPUS_PER_TASK cpus each 1>&2
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
19 for i in $(eval echo $ss)
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
20 do
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
21 srun --unbuffered -c $SLURM_CPUS_PER_TASK $W/shared/bin/sing $W/hst/bin/_runme.sh -a $i "$@"
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
22 echo $(date) Finished $i
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
23 done
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
24 else
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
25 echo $(date) Launching $SLURM_JOB_NUM_NODES nodes in $(pwd) for runme "$@" from $(hostname) to do $SLURM_NTASKS tasks, $SLURM_CPUS_PER_TASK cpus each 1>&2
167
3213a8bb2ed1 new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
26
181
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
27 srun --unbuffered -c $SLURM_CPUS_PER_TASK $W/shared/bin/sing $W/hst/bin/_runme.sh "$@"
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
28 echo $(date) Finished
55169996c3bf add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 178
diff changeset
29 fi