#! /bin/sh
#
# Special args for the ch_p4 device
setrshcmd="no"
case $arg in 
    --INIT)
	p4pgfile=
        p4ssport=
        p4wd=""
        use_execer=0
	leavePGFile=0
	;;
    -e)
      	use_execer=1
        device_knows_arg=1
	;;
    -pg)
      	use_execer=0
        device_knows_arg=1
      	;;
    -leave_pg|-keep_pg)
      	leavePGFile=1
        device_knows_arg=1
	;;
    -p4pg)
      	if [ $np -gt  1 ] ; then
	    echo "-p4pg and -np are mutually exclusive; -np $np being ignored."
            np=1
	fi
	p4pgfile="$1"
	shift
      	leavePGFile=1
        device_knows_arg=1
	;;
    -p4wd)
	p4workdir="$1"
	shift
        device_knows_arg=1
	;;
    -p4ssport)
      	p4ssport="$1"
	shift
        if [ $p4ssport = "0" -a "$MPI_P4SSPORT" != "" ] ; then
	    p4ssport=$MPI_P4SSPORT
      	fi
        device_knows_arg=1
	;;
    -rsh)
        rshcmd="$1"
	setrshcmd="yes"
	shift
	;;
    -usage | --usage)
cat <<EOF
    Special Options for ch_p4 device:

    -e      Use execer to start the program on workstation
            clusters
    -pg     Use a procgroup file to start the p4 programs, not execer
            (default)
    -leave_pg
            Don't delete the P4 procgroup file after running
    -p4pg filename
            Use the given p4 procgroup file instead of creating one.
            Overrides -np and -nolocal, selects -leave_pg.
    -p4wd pathname
            Use pathname as the working directory for the program 
    -p4ssport num
            Use the p4 secure server with port number num to start the
            programs.  If num is 0, use the value of the 
            environment variable MPI_P4SSPORT.  Using the server can
            speed up process startup.  If MPI_USEP4SSPORT as well as
            MPI_P4SSPORT are set, then that has the effect of giving
            mpirun the -p4ssport 0 parameters.

    -leave_pg
            Don't delete the P4 procgroup file after running
    -rsh cmd
            Use the named command as the command to start remote processes
EOF
esac
