#!/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 submits a batch job to the Queuing System"	
	echo "program_name is the name of your compiled executable or script,"
	echo "you should not provide an mpirun or charmrun"
	echo "Options"
	echo "-stdout <filename>: The Std. Output file of the job, default /dev/null"
	echo "-stderr <filename>: The Std. Error file of the job, default /dev/null"
	echo "-stdin <filename>: The Std. Input file of the jo, default /dev/null"
	echo "-type [mpi/charm/mcharm/uni]: The type of 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 +n2 +ppn2 ./hello -stdout out -time 1:0:0
	runs hello on 2 nodes and 4 processors for 1 hour as a batch job"
else
   $CLIENT $HOST $PORT job -pwd $DIR -stdout null -stdin null -stderr null $*
fi
	
