#!/bin/sh

if [ $# -lt 2 ]; then
   echo usage: $0 "node-count program [args ...]"
   exit 1
fi

n=$1
code=$2
shift
shift

rm -fr cout-*
rm -fr cerr-*

cat > make-dump <<EOF
#!/bin/sh -f
ulimit -c unlimited
out=cout-\`hostname\`
err=cerr-\`hostname\`
rm -f \$out
exec >\$out 2>\$err $code \$*
EOF
chmod +x make-dump

/usr/local/mpich-gm-1.2.5/bin/mpirun \
    -np $n \
    -machinefile /home/edwards/test.conf \
    ./make-dump $*
