Tags: programming
A PBS script I wrote to allow me to spawn across multiple nodes, much like mpirun does, except without the MPI.
#!/bin/sh
#PBS -l nodes=3:ppn=1
NODES=`sort $PBS_NODEFILE`
echo $NODES
function spawn() {
NODE=$1
COUNT=$2
echo Spawning $COUNT on $NODE
rsh $NODE -n "~/mark.sh" &
#rsh $NODE -n "cd $PWD ; ./run.sh --agent --threads $COUNT" &
}
LAST=
COUNT=0
for N in $NODES ; do
if [ "$N" = "$LAST" ] ; then
COUNT=$[COUNT+1]
else
if [ 0 -ne $COUNT ] ; then
spawn $LAST $COUNT
fi
COUNT=1
LAST=$N
fi
done
if [ 0 -ne $COUNT ] ; then
spawn $LAST $COUNT
fi
# Wait for children to exit
wait