#!/bin/sh

## template of JDL
jdl=`condor_config_val libexec`/mpi_jdl

## where I am
pwd=`pwd`

## default
np=1


doneParsing=false
while [ $doneParsing == "false" ];
do
    doneParsing=true

    if [ "$1" == "-np" ]; then 
        shift
        np="$1"
        shift
        doneParsing="false"
    fi
done


executable=$1
shift

if [ ! -e ${executable} ]; then
   echo 'Executable ${executable} does not exist!!!'
   exit 1
fi


if [ -e ${pwd}/${executable} ]; then
    executable=${pwd}/${executable}
fi


condor_submit ${jdl} \
    -append "arguments = ${executable} $@" \
    -append "machine_count = ${np}"

exit $?

