[Swift-commit] r6467 - demo/cray/swift-2.0/part08

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Wed Apr 17 14:45:29 CDT 2013


Author: wozniak
Date: 2013-04-17 14:45:29 -0500 (Wed, 17 Apr 2013)
New Revision: 6467

Modified:
   demo/cray/swift-2.0/part08/p8.swift
Log:
Convert to Swift/T


Modified: demo/cray/swift-2.0/part08/p8.swift
===================================================================
--- demo/cray/swift-2.0/part08/p8.swift	2013-04-17 19:38:05 UTC (rev 6466)
+++ demo/cray/swift-2.0/part08/p8.swift	2013-04-17 19:45:29 UTC (rev 6467)
@@ -1,29 +1,38 @@
-type file;
 
-app (file o) mysim5 (int timesteps, int range, file bias, int count)
+#include <builtins.swift>
+#include <assert.swift>
+#include <files.swift>
+#include <string.swift>
+#include <sys.swift>
+
+app (file o) mysim5 (int timesteps, int rnge, file bias, int count)
 {
-  random5 timesteps range @filename(bias) count stdout=@filename(o);
+  "random5.sh" timesteps rnge bias count @stdout=o;
 }
 
 app (file o) analyze (file s[])
 {
-  average @filenames(s) stdout=@filename(o);
+  "avg.sh" s @stdout=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"));
+main
+{
+  file sims[];
+  int  nsim  = toint(argv("nsim",  "10"));
 
-file bias<"data/bias.dat">;
+  int  steps = toint(argv("steps", "1"));
+  int  rnge = toint(argv("range", "100"));
+  int  count = toint(argv("count", "10"));
 
-foreach i in [0:nsim-1] {
-  file simout <single_file_mapper; file=@strcat("data/sim_",i,".out")>;
-  simout = mysim5(steps,range,bias,count);
-  sims[i] = simout;
+  file bias = input_file("data/bias.dat");
+
+  foreach i in [0:nsim-1] {
+    file simout <sprintf("data/sim_%i.out",i)>;
+    simout = mysim5(steps,rnge,bias,count);
+    sims[i] = simout;
+  }
+
+  file stats<"output/average.out">;
+  stats = analyze(sims);
 }
-
-file stats<"output/average.out">;
-stats = analyze(sims);




More information about the Swift-commit mailing list