-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintmachinefile
More file actions
executable file
·33 lines (31 loc) · 975 Bytes
/
printmachinefile
File metadata and controls
executable file
·33 lines (31 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function printmachinefile(){
nodelist=$(echo $SLURM_JOB_NODELIST | sed 's/node//' )
# echo "#nodelist=$nodelist"
nodelist=$(echo $nodelist | cut -d "[" -f2 | cut -d "]" -f1)
# echo "#nodelist=$nodelist"
ntpn=$((SLURM_NTASKS / SLURM_JOB_NUM_NODES))
IFS=','
read -ra ADDR <<< "$nodelist" # str is read into an array as tokens separated by IFS
for elem in "${ADDR[@]}"; do # access each element of array
# echo "#elem=$elem"
if echo $elem | grep -q "-"
then
first=$(echo $elem | cut -d "-" -f1 | sed 's/^0*//')
last=$(echo $elem | cut -d "-" -f2 | sed 's/^0*//')
# echo "#first=$first last=$last"
for (( nodeidx=first; nodeidx<=last; nodeidx++ ))
do
for (( j = 0; j < $ntpn; j++ ));
do
#echo "node0$nodeidx"
printf "node%02d\n" $nodeidx
done
done
else
for (( j = 0; j < $ntpn; j++ ));
do
printf "node%02d\n" $elem
done
fi
done
}