Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
create an usage function to smpirun, check if at least one parameter is passed
authorLucas Schnorr <Lucas.Schnorr@imag.fr>
Thu, 28 Apr 2011 08:16:19 +0000 (10:16 +0200)
committerLucas Schnorr <Lucas.Schnorr@imag.fr>
Thu, 28 Apr 2011 08:16:44 +0000 (10:16 +0200)
src/smpi/smpirun.in

index 51fc175..07c97f7 100755 (executable)
@@ -18,6 +18,24 @@ POWER="${DEFAULT_POWER}"
 
 SIMOPTS="--cfg=maxmin/precision:1e-9 --cfg=network/model:SMPI --cfg=TCP_gamma:4194304"
 
+
+#usage to print the way this script should be called
+function usage () {
+    echo "usage:"
+    echo "$0 [-quiet] [-keep-temps] [-trace <tracefile>] [-np <numprocs>] -platform <xmldesc> -hostfile <hostfile> [-map] program [program-options]"
+    echo "or (deprecated usage):"
+    echo "$0 [-quiet] [-keep-temps] [-np <numprocs>] [-bandwidth <bytes/sec>] [-latency <secs>] program [program-options]"
+    echo
+}
+
+#check if we have at least one parameter
+if [ $# -eq 0 ]
+then
+    usage
+    exit
+fi
+
+
 while true; do
   case "$1" in
    "-np" | "-n")
@@ -75,11 +93,7 @@ while true; do
    ;;
 
    "-help" | "--help" | "-h")
-      echo "usage:"
-      echo "$0 [-quiet] [-keep-temps] [-trace <tracefile>] [-np <numprocs>] -platform <xmldesc> -hostfile <hostfile> [-map] program [program-options]"
-      echo "or (deprecated usage):"
-      echo "$0 [-quiet] [-keep-temps] [-np <numprocs>] [-bandwidth <bytes/sec>] [-latency <secs>] program [program-options]"
-      echo
+      usage
       exit
    ;;