view bin/runme.sh @ 196:436c976ed27f

try to get -m working properly
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Tue, 22 Apr 2025 14:32:50 +0100
parents 55169996c3bf
children 78d9e09e151e
line wrap: on
line source

#!/usr/bin/bash
# Invoke this as e.g. sbatch --ntasks=10 -c 20 runme.sh [-m first last] [args for work/bin/_runme.sh]
# It will run on the login node
#  -m i j will launch _runme.sh multiple times with a -a in {first..last}

#SBATCH --time=01:00:00
#SBATCH --partition=standard
#SBATCH --qos=standard
#SBATCH --account=ec276-hst
#SBATCH --job-name runme

export W=/work/dc007/dc007

if [ "$1" = "-m" ]
then
 ss={$2..$3}
 shift; shift; shift;
 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
 for i in $(eval echo $ss)
 do
  echo $(date) Launching $i
  srun --unbuffered -c $SLURM_CPUS_PER_TASK $W/shared/bin/sing $W/hst/bin/_runme.sh -a $i "$@" &
  echo $(date) Launched $i
 done
 wait
 echo $(date) Finished
else
 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

 srun --unbuffered -c $SLURM_CPUS_PER_TASK $W/shared/bin/sing $W/hst/bin/_runme.sh "$@"
 echo $(date) Finished
fi