#!/bin/ksh # $Id: mpirun.sx,v 1.4 2008/07/23 04:51:56 theurich Exp $ ################################################################################ # This script abides to the ESMF script rules for executing the bundled test # and example applications. # # 1) -np N prog # runs N copies of executable "prog" in parallel. The script must hide all # of the system specific details, such as going through a queueing system # and/or calling a system specific mpirun script with modified arguments. # # 2) The output of the script must be written to a file named "prog".stdout and # it must contain the combination of stdout and stderr output of the # execution. # # 3) The script must block, i.e. _not_ return, until the output described in #2 # has become accessible. # # To access this script set environment variable ESMF_MPIRUN= in # your shell before executing any of the ESMF run targets or targets that # call run targets indirectly, such as the all_tests. ################################################################################ if [ "$1" != "-np" ] then echo "Usage: mpirun -np # prog" exit 1 fi export num_procs=$2 shift 2 export prog=$* echo "In mpirun.sx" export working_dir=`pwd` # Extract batch run script cat > $ESMF_DIR/scripts/esmf_script << THE_END_OF_BATCH_SCRIPT #PBS -S /bin/sh #PBS $ESMF_MPIBATCHOPTIONS #PBS -o $prog.stdout #PBS -e $prog.error #PBS -Z cd $working_dir rm -f $prog.stdout $prog.error mpirun -np $num_procs $prog THE_END_OF_BATCH_SCRIPT chmod a+x $ESMF_DIR/scripts/esmf_script echo " qsub $ESMF_DIR/scripts/esmf_script" proc_id=`qsub $ESMF_DIR/scripts/esmf_script ` echo $proc_id # wait for job to complete. qwait -f $proc_id # Clean up rm -f $ESMF_DIR/scripts/esmf_script