#!/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$$
#
# START EDITING HERE
#echo "ignore USR1" >> $dbgfile
#echo "debug $prognamemain" >> $dbgfile
#echo "stop in MPI_Init" >> $dbgfile
#echo  "run  -p4pg $p4pgfile -p4wd $p4workdir $prognamemain $cmdLineArgs" >> $dbgfile
#
#dbx -s$dbgfile $prognamemain
# END EDITING HERE
#/bin/rm -f $dbgfile
cat <<EOF
Modify the mpirun_dbg.dbx file to make use of the proper dbx commands to
run a program.  

The command syntax of dbx on various platforms has been changing in 
incompatible ways; you will need to find out how to accomplish the following
steps:

Tell dbx to ignore SIG_USR1
Specify the name of the program to debug
Tell dbx to stop in MPI_Init
Run a program with specific options (see the example below)

For some versions of dbx, the following commands can be used.
First, place the commands into a temporary file (all of the shell variables
are set in the mpirun_dbg.dbx script):
echo "ignore USR1" >> \$dbgfile
echo "debug $prognamemain" >> \$dbgfile
echo "stop in MPI_Init" >> \$dbgfile
echo  "run  -p4pg \$p4pgfile -p4wd \$p4workdir \$prognamemain \$cmdLineArgs" >> \$dbgfile
 
Then tell dbx to run the program, reading this file first:

dbx -s \$dbgfile \$prognamemain

If your dbx supports -sr filename instead of -s filename, use that instead. 
Note that in some versions of dbx, -s filename causes and .dbxinit or .dbxrc
file to be ignored; other version read the -s specified filename in addition
to .dbxinit or .dbxrc .  
EOF

