#!/bin/bash

CLIENT=/home/arch/skumar2/charm/net-linux/pgms/scheduler/client

if [ "x$SCHEDULER_PATH" != "x" ]
    then CLIENT=$SCHEDULER_PATH/client;
fi

HOST=localhost
PORT=1999
DIR=$(/bin/pwd)

if [ "x$1" = "x" ]  || [ "$1" = "-help" ] || [ "$1" = "-h" ];
	then echo "fsub <program_name> [<options>] [<arguments>]"
	echo "fsub-mpi submits a batch  MPI job to the Queuing System"	
	echo "program_name is the name of your compiled executable or script,"
	echo "you should not provide an mpirun"
	echo "Options"
	echo "-stdout <filename>: The Std. Output file of the job"
	echo "-stderr <filename>: The Std. Error file of the job"
	echo "-stdin <filename>: The Std. Input file of the job"
	echo "-time <hh:mm:ss> : time requested for the job";	
	echo "-pwd <directory name>: Process Working Directory, default is current directory"
	
	echo ""
	echo "+n<value> : Number of nodes requested for the job" 
	echo "+ppn<value> : Number of processors per node to use"
	echo "+p<value> : Alternative to +n<> and +ppn<>. 
	Number of processors requested for the job, assumes 
	that all processors on a node will be used" 

	echo ""
	echo "If a processor range needs to be provided for the job"
	echo "-minnode <value> : minimum number of nodes used by the job"
	echo "-maxnode <value> : maximum number of nodes used by the job"
	echo "-minpe <value> : minimum number of processors used by the job"
	echo "-maxpe <value> : maximum number of processors used by the job"
	echo "#Processors allocated to the job varies between these bounds"
	echo ""
	echo "For example:
	fsub-mpi +n2 +ppn2 ./hello_mpi -stdout out -time 1:0:0
	runs hello_mpi on 2 nodes and 4 processors for 1 hour as a batch job"
else
   $CLIENT $HOST $PORT job -type mpi -pwd $DIR -stdout null -stdin null -stderr null $*
fi
	
