[Swift-commit] r7817 - SwiftApps/swift-galaxy/swift
ketan at ci.uchicago.edu
ketan at ci.uchicago.edu
Mon May 5 20:43:46 CDT 2014
Author: ketan
Date: 2014-05-05 20:43:46 -0500 (Mon, 05 May 2014)
New Revision: 7817
Modified:
SwiftApps/swift-galaxy/swift/swiftforeach.sh
Log:
code clean
Modified: SwiftApps/swift-galaxy/swift/swiftforeach.sh
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeach.sh 2014-05-06 01:18:00 UTC (rev 7816)
+++ SwiftApps/swift-galaxy/swift/swiftforeach.sh 2014-05-06 01:43:46 UTC (rev 7817)
@@ -47,31 +47,35 @@
stringargs=$1
shift
+#workout the file args
+fileargs=()
+while [ $# -gt 0 ] ; do
+ fileargs+=("\"$1\"")
+ shift
+done
+
+#workout the stringargs
+if [ "${stringargs}" ] ; then
+ stringarrayexpr='string stringargs[]=['$(echo $stringargs | sed -e 's/ *$//g' -e 's/[^ ][^ ]*/"&"/g' -e 's/ /,/g')'];';
+else
+ stringarrayexpr='string stringargs[];'
+fi
+
+#workout standard input file
+if [ "${stdin}" ] ; then
+ stdinfilexpr='file stdinfile<'\"${stdin}\"'>;'
+else
+ stdinfilexpr='file stdinfile<'\"/dev/null\"'>;'
+fi
+
touch None # Create a "None" file in case user does not specify any stdin file
+#### End common setup ####
+
+
if [ "$k_or_t" = "swiftK" ]
-then # invoke /K
-
- #workout the array only if user adds args else make it blank
- if [ "${stringargs}" ] ; then
- stringarrayexpr='string stringargs[]=['$(echo $stringargs | sed -e 's/ *$//g' -e 's/[^ ][^ ]*/"&"/g' -e 's/ /,/g')'];';
- else
- stringarrayexpr='string stringargs[];'
- fi
+then #### invoke K
- #workout standard input file
- if [ "${stdin}" ] ; then
- stdinfilexpr='file stdinfile<'\"${stdin}\"'>;'
- else
- stdinfilexpr='file stdinfile<'\"/dev/null\"'>;'
- fi
-
- fileargs=()
- while [ $# -gt 0 ] ; do
- fileargs+=("\"$1\"")
- shift
- done
-
#workout the array only if user adds args else make it blank
if [ ${#fileargs[@]} -gt 0 ] ; then
tmp=$(printf -- '%s,' "${fileargs[@]}")
@@ -80,6 +84,8 @@
filearrayexpr='file fileargs[];'
fi
+ if [ "$range_or_list" == "list" ]
+ then ## list
cat << EOF > $wdir/script.swift
/*
@@ -108,7 +114,37 @@
(out,err) = anapp(exec, i, stringargs, fileargs, stdinfile);
}
EOF
-
+
+else ## range
+
+cat << EOF > $wdir/script.swift
+
+/*
+*
+* Swift source script is generated automatically via the Swift-Galaxy
+* integration tool. Be careful before making any changes to it directly as
+* it might be tied with other configuration and paramter values.
+*
+*/
+
+type file;
+
+app (file _out, file _err) anapp(file _exec, int _i, string _stringargs[], file _fileargs[], file _stdin){
+ $interpreter @_exec _i _stringargs @_fileargs stdin=@_stdin stdout=@_out stderr=@_err;
+}
+
+$stringarrayexpr
+$filearrayexpr
+$stdinfilexpr
+
+file exec<"$executable">;
+foreach i in [$rstart:$rend:$stepsize]{
+ file out <single_file_mapper; file=@strcat("$outloc", "/", i, ".out")>;
+ file err <single_file_mapper; file=@strcat("$outloc", "/", i, ".err")>;
+ (out,err) = anapp(exec, i, stringargs, fileargs, stdinfile);
+}
+EOF
+
swift=$(which swift)
BASEDIR=$(dirname $0)
@@ -134,28 +170,10 @@
$swift -sites.file $wdir/sites.xml -tc.file $wdir/tc -config $wdir/cf $wdir/script.swift "${swiftargs}" 2>$logfile
EXITCODE=$?
-else # Invoke T
+else
+#### Invoke T
- #workout the array only if user adds args else make it blank
- if [ "${stringargs}" ] ; then
- stringarrayexpr='string stringargs[]=['$(echo $stringargs | sed -e 's/ *$//g' -e 's/[^ ][^ ]*/"&"/g' -e 's/ /,/g')'];';
- else
- stringarrayexpr='string stringargs[];'
- fi
- #workout standard input file
- if [ "${stdin}" ] ; then
- stdinfilexpr='file stdinfile<'\"${stdin}\"'>;'
- else
- stdinfilexpr='file stdinfile<'\"/dev/null\"'>;'
- fi
-
- fileargs=()
- while [ $# -gt 0 ] ; do
- fileargs+=("\"$1\"")
- shift
- done
-
#workout the array only if user adds args else make it blank
if [ ${#fileargs[@]} -gt 0 ] ; then
tmp=$(printf -- '%s,' "${fileargs[@]}")
@@ -197,7 +215,7 @@
stc=$(which stc)
turbine=$(which turbine)
- $stc -j `which java` $wdir/script.swift "${swiftargs}" 2>$logfile
+ $stc -j $(\which java) $wdir/script.swift "${swiftargs}" 2>$logfile
$turbine -n 3 $wdir/script.tcl
More information about the Swift-commit
mailing list