#! /bin/sh

cmdLineArgs=""
p4pgfile=""
p4workdir=""
prognamemain=""

while [ 1 -le $# ] ; do
  arg=$1
  shift
  case $arg in
     -cmdlineargs)
        cmdLineArgs="$1"
        shift
	;;
     -p4pg)
        p4pgfile="$1"
	shift
	;;
     -p4wd)
        p4workdir="$1"
	shift
	;;
     -progname)
        prognamemain="$1"
	shift
	;;
  esac   
done
#
if [ -n "$LADEBUG_HOME" ] ; then
    ldbdir=$LADEBUG_HOME
    ladebug=$ldbdir/ladebug
    if [ -f $ldbdir/ladebug.cat ] && [ -r $ldbdir/ladebug.cat ] ; then
      if [ -n "$NLSPATH" ];  then
	 nlsmore=$NLSPATH
      else
	 nlsmore=""
      fi
      NLSPATH=$ldbdir/$nlsmore
    fi
else
    ladebug="ladebug"
fi
#
#
# Need to `eval echo $cmdLineArgs` to undo evil quoting done in mpirun.args
#
$ladebug -parallel $prognamemain `eval echo $cmdLineArgs` -p4pg $p4pgfile -p4wd $p4workdir -mpichtv
