#!/bin/sh # # wrapper for the xplor script - used for MPI jobs # [ -z "$MPIRUN_CMD" ] && MPIRUN_CMD=mpirun XPLOR=/opt/exp_soft/enmr/CIRMMP/xplor-nih/2.21/64/bin/xplor sgi_mpi=0 $MPIRUN_CMD -v -np 1 /bin/echo 2>&1 | head -1 | grep -q "SGI MPI" && sgi_mpi=1 while [ -n "$1" ]; do opt=$1 shift case "$opt" in -np) MPI_NP=$1 shift ;; -o) [ $sgi_mpi -eq 0 ] && args="$args $opt $1" outFile=$1 shift ;; -machinefile) MPI_ARGS="$MPI_ARGS $opt $1" [ -z "$MPI_NP" ] && MPI_NP=`grep -v ^# $1|wc -l` shift ;; *) args="$args $opt" esac done MPI_NP=${MPI_NP:-1} MPI_ARGS="-np $MPI_NP $MPI_ARGS" #remove any old output files # if [ "$outFile" != "" ]; then count=0 while [ $count -lt $MPI_NP ]; do rm -f $outFile.$count count=`expr $count + 1` done fi #on SGIs, prefix a string to node's output for separation # if [ $sgi_mpi -eq 1 ]; then MPI_ARGS="-p 'MPI:%g ' $MPI_ARGS" # here's an awk filter to separate the output into separate files - # one for each MPI node. # if [ "$outFile" != "" ]; then outFilter="awk -F'[: ]' '/^MPI/ {num=\$2;" outFilter="$outFilter "'line=substr($0,length($2)+6);' outFilter="$outFilter "'print line >>outfile "." num; }' outFilter="$outFilter "'$1 !~ /^MPI/ {print >> outfile "." 0; }' outFilter="$outFilter "'{fflush(""); }'"'" outFilter="$outFilter "' outfile=$outFile' fi fi if [ -z "$outFilter" ]; then eval "exec $MPIRUN_CMD $MPI_ARGS $XPLOR $args" else eval "exec $MPIRUN_CMD $MPI_ARGS $XPLOR $args 2>&1 | $outFilter" fi