[Swift-commit] r6420 - in SwiftTutorials/UofC_2013-04-09: bin part04 part05
wilde at ci.uchicago.edu
wilde at ci.uchicago.edu
Tue Apr 9 09:46:48 CDT 2013
Author: wilde
Date: 2013-04-09 09:46:48 -0500 (Tue, 09 Apr 2013)
New Revision: 6420
Added:
SwiftTutorials/UofC_2013-04-09/bin/highest.sh
SwiftTutorials/UofC_2013-04-09/bin/lowest.sh
Modified:
SwiftTutorials/UofC_2013-04-09/bin/cleanup
SwiftTutorials/UofC_2013-04-09/bin/random2.sh
SwiftTutorials/UofC_2013-04-09/bin/random3.sh
SwiftTutorials/UofC_2013-04-09/bin/random4.sh
SwiftTutorials/UofC_2013-04-09/part04/README
SwiftTutorials/UofC_2013-04-09/part05/README
SwiftTutorials/UofC_2013-04-09/part05/p5.swift
Log:
Added new parts for arg passing and cluster execution.
Modified: SwiftTutorials/UofC_2013-04-09/bin/cleanup
===================================================================
--- SwiftTutorials/UofC_2013-04-09/bin/cleanup 2013-04-09 06:58:54 UTC (rev 6419)
+++ SwiftTutorials/UofC_2013-04-09/bin/cleanup 2013-04-09 14:46:48 UTC (rev 6420)
@@ -2,14 +2,14 @@
echo Removing:
echo
-ls -ltd *log *.d swiftwork _concurrent output *.kml *.swiftx swift.log applist config sites.xml pathlist 2>/dev/null
+ls -ltd *log *.d swiftwork _concurrent output *.kml *.swiftx swift.log 2>/dev/null
echo
echo Enter y to proceed:
read ok
if [ _$ok = _y -o _$ok = _Y -o _$ok = _yes ]; then
echo
set -x
- rm -rf *log *.d swiftwork _concurrent output *.kml *.swiftx swift.log applist config sites.xml pathlist
+ rm -rf *log *.d swiftwork _concurrent output *.kml *.swiftx swift.log
else
echo
echo No files removed.
Added: SwiftTutorials/UofC_2013-04-09/bin/highest.sh
===================================================================
--- SwiftTutorials/UofC_2013-04-09/bin/highest.sh (rev 0)
+++ SwiftTutorials/UofC_2013-04-09/bin/highest.sh 2013-04-09 14:46:48 UTC (rev 6420)
@@ -0,0 +1,2 @@
+#! /bin/sh
+sort -nr | head -$1
Property changes on: SwiftTutorials/UofC_2013-04-09/bin/highest.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/UofC_2013-04-09/bin/lowest.sh
===================================================================
--- SwiftTutorials/UofC_2013-04-09/bin/lowest.sh (rev 0)
+++ SwiftTutorials/UofC_2013-04-09/bin/lowest.sh 2013-04-09 14:46:48 UTC (rev 6420)
@@ -0,0 +1,2 @@
+#! /bin/sh
+sort -n | head -$1
Property changes on: SwiftTutorials/UofC_2013-04-09/bin/lowest.sh
___________________________________________________________________
Added: svn:executable
+ *
Modified: SwiftTutorials/UofC_2013-04-09/bin/random2.sh
===================================================================
--- SwiftTutorials/UofC_2013-04-09/bin/random2.sh 2013-04-09 06:58:54 UTC (rev 6419)
+++ SwiftTutorials/UofC_2013-04-09/bin/random2.sh 2013-04-09 14:46:48 UTC (rev 6420)
@@ -1,5 +1,7 @@
#! /bin/sh
-range=$1
+runtime=${1:-0}
-echo $(($RANDOM%range))
+sleep $runtime
+
+echo $(($RANDOM))
Modified: SwiftTutorials/UofC_2013-04-09/bin/random3.sh
===================================================================
--- SwiftTutorials/UofC_2013-04-09/bin/random3.sh 2013-04-09 06:58:54 UTC (rev 6419)
+++ SwiftTutorials/UofC_2013-04-09/bin/random3.sh 2013-04-09 14:46:48 UTC (rev 6420)
@@ -1,9 +1,10 @@
#! /bin/sh
-range=$1
-n=$2
+runtime=${1:-0}
+range=$2
-for ((i=0;i<n;i++)); do
- echo $(($RANDOM%range))
-done
+sleep $runtime
+echo $(($RANDOM%range))
+
+
Modified: SwiftTutorials/UofC_2013-04-09/bin/random4.sh
===================================================================
--- SwiftTutorials/UofC_2013-04-09/bin/random4.sh 2013-04-09 06:58:54 UTC (rev 6419)
+++ SwiftTutorials/UofC_2013-04-09/bin/random4.sh 2013-04-09 14:46:48 UTC (rev 6420)
@@ -1,8 +1,8 @@
#! /bin/sh
-range=$1
-n=$2
-runtime=$3
+runtime=${1:-0}
+range=$2
+n=$3
sleep $runtime
Modified: SwiftTutorials/UofC_2013-04-09/part04/README
===================================================================
--- SwiftTutorials/UofC_2013-04-09/part04/README 2013-04-09 06:58:54 UTC (rev 6419)
+++ SwiftTutorials/UofC_2013-04-09/part04/README 2013-04-09 14:46:48 UTC (rev 6420)
@@ -4,9 +4,9 @@
Study the program:
-- @strcat() is a Swift builtin function (the @name() form is used for many bu not all builtins)
+- @strcat() is a Swift builtin function (the @name() form is used for many but not all builtins)
-- @strcat() coerces numeric args to strings
+- Note that @strcat() coerces numeric args to strings
- <"filename"> was a shorthand for <single_file_mapper;...> but the latter is more flexible.
@@ -23,22 +23,20 @@
Try:
-- changing the output names
+- Adjust the script to take the number of simulations to do from the command line
-- @arg("argname") returns arguments after the .swift script on the swift command line:
+ @arg("argname") returns arguments after the .swift script on the swift command line:
swift -tc.file tc p4.swift -myarg1=value1 ...
+ @arg("argname","default") returns "default" if the argname is not given on the command line
+
@toInt() converts strings to integers:
@toInt(@arg("myArg1"))
- Adjust the script to take the number of simulations to do from the command line
- trace(expr1,...) traces expressions on stdout.
Try inserting a few traces. But remember: Swift is *very* concurrent!
-
-
-
Modified: SwiftTutorials/UofC_2013-04-09/part05/README
===================================================================
--- SwiftTutorials/UofC_2013-04-09/part05/README 2013-04-09 06:58:54 UTC (rev 6419)
+++ SwiftTutorials/UofC_2013-04-09/part05/README 2013-04-09 14:46:48 UTC (rev 6420)
@@ -12,7 +12,7 @@
Run the program:
-$ swift -tc.file tc p4.swift
+$ swift -tc.file tc p5.swift
Look at the output:
Modified: SwiftTutorials/UofC_2013-04-09/part05/p5.swift
===================================================================
--- SwiftTutorials/UofC_2013-04-09/part05/p5.swift 2013-04-09 06:58:54 UTC (rev 6419)
+++ SwiftTutorials/UofC_2013-04-09/part05/p5.swift 2013-04-09 14:46:48 UTC (rev 6420)
@@ -12,7 +12,9 @@
file sims[];
-foreach i in [0:9] {
+int nsim = @toInt(@arg("nsim","10"));
+
+foreach i in [0:nsim-1] {
file simout <single_file_mapper; file=@strcat("output/sim_",i,".out")>;
simout = mysim();
sims[i] = simout;
More information about the Swift-commit
mailing list