#!/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
#
dbgfile=$p4workdir/PId$$
#
echo "handle SIGUSR1" >> $dbgfile
echo "br MPI_Init" >> $dbgfile
echo "set args $cmdLineArgs -p4pg $p4pgfile -p4wd $p4workdir" >> $dbgfile
echo "run" >> $dbgfile
gdb -x $dbgfile $prognamemain
/bin/rm -f $dbgfile
