[Swift-commit] r6577 - SwiftTutorials/CMTS_2013-06-17/basic_swift/part08

yadunandb at ci.uchicago.edu yadunandb at ci.uchicago.edu
Mon Jun 17 14:35:26 CDT 2013


Author: yadunandb
Date: 2013-06-17 14:35:25 -0500 (Mon, 17 Jun 2013)
New Revision: 6577

Added:
   SwiftTutorials/CMTS_2013-06-17/basic_swift/part08/p9.swift
Modified:
   SwiftTutorials/CMTS_2013-06-17/basic_swift/part08/README
Log:
Commiting part09



Modified: SwiftTutorials/CMTS_2013-06-17/basic_swift/part08/README
===================================================================
--- SwiftTutorials/CMTS_2013-06-17/basic_swift/part08/README	2013-06-17 19:21:41 UTC (rev 6576)
+++ SwiftTutorials/CMTS_2013-06-17/basic_swift/part08/README	2013-06-17 19:35:25 UTC (rev 6577)
@@ -1,14 +1,12 @@
 
-TOPIC: Example pipeline 
+TOPIC: Example pipeline with readData
 
-This example shows combining two app calls in a pipeline. There are two apps
-defined in this script: mysim4, and mysim4_filename. 
+This example shows combining two app calls in a pipeline. The mysim4 app from the
+previous example part08 is called twice here.
 
-mysim4 takes integer to determine the number of random numbers to generate.
-mysim4_filename reads a file to determine the number of random numbers to generate
+mysim4 takes an integer to determine the number of random numbers to generate.
+The random number generated by mysim4 is read from its output file and redirected 
+as an argument to itself to generate a random number of random numbers.
 
-In this example, we use mysim4 to generate a random number. The output of mysim4
-get passed as input to mysim4_filename.
-
 To run
 $ swift p8.swift -steps=10 -range=100 -count=6 -nsim=1

Added: SwiftTutorials/CMTS_2013-06-17/basic_swift/part08/p9.swift
===================================================================
--- SwiftTutorials/CMTS_2013-06-17/basic_swift/part08/p9.swift	                        (rev 0)
+++ SwiftTutorials/CMTS_2013-06-17/basic_swift/part08/p9.swift	2013-06-17 19:35:25 UTC (rev 6577)
@@ -0,0 +1,32 @@
+type file;
+
+app (file o) mysim4 (int timesteps, int range_value, int count_value)
+{
+  random4 timesteps range_value count_value stdout=@filename(o);
+}
+
+app (file o) analyze (file s[])
+{
+  average @filenames(s) stdout=@filename(o);
+}
+
+file sims[];
+int  nsim  = @toInt(@arg("nsim",  "10"));
+int  steps = @toInt(@arg("steps", "1"));
+int  range = @toInt(@arg("range", "100"));
+int  count = @toInt(@arg("count", "10"));
+
+foreach i in [0:nsim-1] {
+
+  file simout <single_file_mapper; file=@strcat("output/sim_",i,".out")>;
+  simout   = mysim4(steps, range, 1);
+  int rand = readData(simout);
+
+  file simout2 <single_file_mapper; file=@strcat("output/sim_", i, ".tmp.out")>;
+  simout2  = mysim4(steps, range, rand);
+
+  sims[i] = simout2;
+}
+
+file stats<"output/average.out">;
+stats = analyze(sims);




More information about the Swift-commit mailing list