Skip to content

Instantly share code, notes, and snippets.

@ehermes
Created April 29, 2015 16:09
Show Gist options
  • Select an option

  • Save ehermes/108cfcfeac8dcd05e28e to your computer and use it in GitHub Desktop.

Select an option

Save ehermes/108cfcfeac8dcd05e28e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
NIMAGES=8
#NNODES=8
WD=`pwd`
while [ $# -gt 0 ]
do
case "$1" in
(-nimages) NIMAGES="$2"; shift;;
# (-nnodes) NNODES="$2"; shift;;
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
(*) break;;
esac
shift
done
JOBID=$1
OUTPUT=$(squeue -j $JOBID -o %R -h)
if [ "${OUTPUT:0:4}" != "aci-" ]
then
echo $OUTPUT 1>&2
exit 1
fi
NODES=${OUTPUT:4}
if [ "${NODES:0:1}" == "[" ]
then
LEN=`expr length $NODES`
NODES=${NODES:1:$(($LEN - 2))}
IFS=','
read -ra NODES <<< "$NODES"
i=0
NODELIST=()
for NODE in "${NODES[@]}"
do
SUBLEN=`expr length $NODE`
if [ "$SUBLEN" -eq "7" ]
then
for SUBNODE in `seq -s ',' ${NODE:0:3} ${NODE:4:3}`
do
NODELIST+=($SUBNODE)
i=$(($i+1))
done
elif [ "$SUBLEN" -eq 3 ]
then
NODELIST+=($NODE)
i=$(($i+1))
else
echo "Error parsing output!" 1>&2
echo $OUTPUT 1>&2
exit 1
fi
done
else
NNODES=1
NODELIST=($NODES)
fi
for NODE in ${NODELIST[@]}
do
echo $NODE
done
echo $i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment