[Swift-commit] r7151 - SwiftApps/tryswift/scripts
davidk at ci.uchicago.edu
davidk at ci.uchicago.edu
Fri Oct 11 13:41:26 CDT 2013
Author: davidk
Date: 2013-10-11 13:41:25 -0500 (Fri, 11 Oct 2013)
New Revision: 7151
Added:
SwiftApps/tryswift/scripts/004-analysis.html
SwiftApps/tryswift/scripts/004-analysis.swift
SwiftApps/tryswift/scripts/004-analysis.txt
Removed:
SwiftApps/tryswift/scripts/p3.html
SwiftApps/tryswift/scripts/p3.swift
SwiftApps/tryswift/scripts/p3.txt
SwiftApps/tryswift/scripts/part03.png
SwiftApps/tryswift/scripts/part3.txt
Log:
Script for multiple apps (post-processing example)
Added: SwiftApps/tryswift/scripts/004-analysis.html
===================================================================
--- SwiftApps/tryswift/scripts/004-analysis.html (rev 0)
+++ SwiftApps/tryswift/scripts/004-analysis.html 2013-10-11 18:41:25 UTC (rev 7151)
@@ -0,0 +1,69 @@
+<html>
+
+<head>
+<link href="formatting.css" rel="stylesheet" media="screen">
+</head>
+
+<body>
+<h2>Multiple apps</h2>
+
+<p>After all the parallel simulations in an ensemble run have completed,
+it is typically necessary to gather and analyze their results with some
+kind of post-processing analysis program or script. This script shows
+an example of this.</p>
+
+<p>The first change in this script is to the simulate script:</p>
+
+<pre>
+app (file o) simulate (int time)
+{
+ simulate "-t" time stdout=filename(o);
+}
+</pre>
+
+<p>Simulate now takes an argument, time. The command "simulate -t 10" will sleep
+for 10 seconds before printing a value. This is an example of how to pass command
+line arguments to an app in Swift.</p>
+
+<p>We introduce a new app call called stats:</p>
+
+<pre>
+app (file o) stats (file s[])
+{
+ stats filenames(s) stdout=filename(o);
+}
+</pre>
+
+<p>The stats app function takes an array of files as input (file s[]). The stats app takes a list of
+files, reads the numbers contained inside, and prints the average value. The filenames() function simply
+prints a list of all filenames contained within a file array.</p>
+
+<p>Within the foreach loop:
+<pre>
+ simout = simulate(time);
+ sims[i] = simout;
+</pre>
+
+<p>We now add each simout file to the sims array before finally passing all the files to stats</p>
+<pre>
+foreach i in [1:nsims] {
+ string fname = strcat("output/sim_",i,".out");
+ file simout <single_file_mapper; file=fname>;
+ simout = simulate(time);
+ sims[i] = simout;
+}
+
+file average<"output/average.out">;
+average = stats(sims);
+</pre>
+
+Execute the script and view output/average.out to verify it succeeded.
+
+<h3>Exercises</h3>
+<ul>
+<li>Simulate takes another command line option, -r. The -r option sets the range of random numbers it generates. Call simulate with the added options -r 1000.</li>
+<li>Modify the simulate app so that it takes a second int representing range (hint: multiple inputs are separated by commas).</li>
+</ul>
+
+</body>
+</html>
Added: SwiftApps/tryswift/scripts/004-analysis.swift
===================================================================
--- SwiftApps/tryswift/scripts/004-analysis.swift (rev 0)
+++ SwiftApps/tryswift/scripts/004-analysis.swift 2013-10-11 18:41:25 UTC (rev 7151)
@@ -0,0 +1,25 @@
+type file;
+
+app (file o) simulate (int time)
+{
+ simulate "-t" time stdout=filename(o);
+}
+
+app (file o) stats (file s[])
+{
+ stats filenames(s) stdout=filename(o);
+}
+
+file sims[];
+int time = 5;
+int nsims = 10;
+
+foreach i in [1:nsims] {
+ string fname = strcat("output/sim_",i,".out");
+ file simout <single_file_mapper; file=fname>;
+ simout = simulate(time);
+ sims[i] = simout;
+}
+
+file average<"output/average.out">;
+average = stats(sims);
Added: SwiftApps/tryswift/scripts/004-analysis.txt
===================================================================
--- SwiftApps/tryswift/scripts/004-analysis.txt (rev 0)
+++ SwiftApps/tryswift/scripts/004-analysis.txt 2013-10-11 18:41:25 UTC (rev 7151)
@@ -0,0 +1 @@
+Multiple apps
Deleted: SwiftApps/tryswift/scripts/p3.html
===================================================================
--- SwiftApps/tryswift/scripts/p3.html 2013-10-11 17:30:56 UTC (rev 7150)
+++ SwiftApps/tryswift/scripts/p3.html 2013-10-11 18:41:25 UTC (rev 7151)
@@ -1,740 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-<head>
-<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
-<meta name="generator" content="AsciiDoc 8.6.4" />
-<title>Part 3: Analyzing results of a parallel ensemble</title>
-<style type="text/css">
-/* Sans-serif font. */
-h1, h2, h3, h4, h5, h6,
-div.title, caption.title,
-thead, p.table.header,
-div#toctitle,
-span#author, span#revnumber, span#revdate, span#revremark,
-div#footer {
- font-family: Arial,Helvetica,sans-serif;
-}
-
-/* Serif font. */
-div.sectionbody {
- font-family: Georgia,"Times New Roman",Times,serif;
-}
-
-/* Monospace font. */
-tt {
- font-size: inherit;
-}
-
-body {
- margin: 1em 5% 1em 5%;
-}
-
-a {
- color: blue;
- text-decoration: underline;
-}
-a:visited {
- color: fuchsia;
-}
-
-em {
- font-style: italic;
- color: navy;
-}
-
-strong {
- font-weight: bold;
- color: #083194;
-}
-
-tt {
- font-size: inherit;
- color: navy;
-}
-
-h1, h2, h3, h4, h5, h6 {
- color: #527bbd;
- margin-top: 1.2em;
- margin-bottom: 0.5em;
- line-height: 1.3;
-}
-
-h1, h2, h3 {
- border-bottom: 2px solid silver;
-}
-h2 {
- padding-top: 0.5em;
-}
-h3 {
- float: left;
-}
-h3 + * {
- clear: left;
-}
-
-div.sectionbody {
- margin-left: 0;
-}
-
-hr {
- border: 1px solid silver;
-}
-
-p {
- margin-top: 0.5em;
- margin-bottom: 0.5em;
-}
-
-ul, ol, li > p {
- margin-top: 0;
-}
-ul > li { color: #aaa; }
-ul > li > * { color: black; }
-
-pre {
- padding: 0;
- margin: 0;
-}
-
-span#author {
- color: #527bbd;
- font-weight: bold;
- font-size: 1.1em;
-}
-span#email {
-}
-span#revnumber, span#revdate, span#revremark {
-}
-
-div#footer {
- font-size: small;
- border-top: 2px solid silver;
- padding-top: 0.5em;
- margin-top: 4.0em;
-}
-div#footer-text {
- float: left;
- padding-bottom: 0.5em;
-}
-div#footer-badges {
- float: right;
- padding-bottom: 0.5em;
-}
-
-div#preamble {
- margin-top: 1.5em;
- margin-bottom: 1.5em;
-}
-div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
-div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
-div.admonitionblock {
- margin-top: 1.0em;
- margin-bottom: 1.5em;
-}
-div.admonitionblock {
- margin-top: 2.0em;
- margin-bottom: 2.0em;
- margin-right: 10%;
- color: #606060;
-}
-
-div.content { /* Block element content. */
- padding: 0;
-}
-
-/* Block element titles. */
-div.title, caption.title {
- color: #527bbd;
- font-weight: bold;
- text-align: left;
- margin-top: 1.0em;
- margin-bottom: 0.5em;
-}
-div.title + * {
- margin-top: 0;
-}
-
-td div.title:first-child {
- margin-top: 0.0em;
-}
-div.content div.title:first-child {
- margin-top: 0.0em;
-}
-div.content + div.title {
- margin-top: 0.0em;
-}
-
-div.sidebarblock > div.content {
- background: #ffffee;
- border: 1px solid #dddddd;
- border-left: 4px solid #f0f0f0;
- padding: 0.5em;
-}
-
-div.listingblock > div.content {
- border: 1px solid #dddddd;
- border-left: 5px solid #f0f0f0;
- background: #f8f8f8;
- padding: 0.5em;
-}
-
-div.quoteblock, div.verseblock {
- padding-left: 1.0em;
- margin-left: 1.0em;
- margin-right: 10%;
- border-left: 5px solid #f0f0f0;
- color: #777777;
-}
-
-div.quoteblock > div.attribution {
- padding-top: 0.5em;
- text-align: right;
-}
-
-div.verseblock > pre.content {
- font-family: inherit;
- font-size: inherit;
-}
-div.verseblock > div.attribution {
- padding-top: 0.75em;
- text-align: left;
-}
-/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
-div.verseblock + div.attribution {
- text-align: left;
-}
-
-div.admonitionblock .icon {
- vertical-align: top;
- font-size: 1.1em;
- font-weight: bold;
- text-decoration: underline;
- color: #527bbd;
- padding-right: 0.5em;
-}
-div.admonitionblock td.content {
- padding-left: 0.5em;
- border-left: 3px solid #dddddd;
-}
-
-div.exampleblock > div.content {
- border-left: 3px solid #dddddd;
- padding-left: 0.5em;
-}
-
-div.imageblock div.content { padding-left: 0; }
-span.image img { border-style: none; }
-a.image:visited { color: white; }
-
-dl {
- margin-top: 0.8em;
- margin-bottom: 0.8em;
-}
-dt {
- margin-top: 0.5em;
- margin-bottom: 0;
- font-style: normal;
- color: navy;
-}
-dd > *:first-child {
- margin-top: 0.1em;
-}
-
-ul, ol {
- list-style-position: outside;
-}
-ol.arabic {
- list-style-type: decimal;
-}
-ol.loweralpha {
- list-style-type: lower-alpha;
-}
-ol.upperalpha {
- list-style-type: upper-alpha;
-}
-ol.lowerroman {
- list-style-type: lower-roman;
-}
-ol.upperroman {
- list-style-type: upper-roman;
-}
-
-div.compact ul, div.compact ol,
-div.compact p, div.compact p,
-div.compact div, div.compact div {
- margin-top: 0.1em;
- margin-bottom: 0.1em;
-}
-
-div.tableblock > table {
- border: 3px solid #527bbd;
-}
-thead, p.table.header {
- font-weight: bold;
- color: #527bbd;
-}
-tfoot {
- font-weight: bold;
-}
-td > div.verse {
- white-space: pre;
-}
-p.table {
- margin-top: 0;
-}
-/* Because the table frame attribute is overriden by CSS in most browsers. */
-div.tableblock > table[frame="void"] {
- border-style: none;
-}
-div.tableblock > table[frame="hsides"] {
- border-left-style: none;
- border-right-style: none;
-}
-div.tableblock > table[frame="vsides"] {
- border-top-style: none;
- border-bottom-style: none;
-}
-
-
-div.hdlist {
- margin-top: 0.8em;
- margin-bottom: 0.8em;
-}
-div.hdlist tr {
- padding-bottom: 15px;
-}
-dt.hdlist1.strong, td.hdlist1.strong {
- font-weight: bold;
-}
-td.hdlist1 {
- vertical-align: top;
- font-style: normal;
- padding-right: 0.8em;
- color: navy;
-}
-td.hdlist2 {
- vertical-align: top;
-}
-div.hdlist.compact tr {
- margin: 0;
- padding-bottom: 0;
-}
-
-.comment {
- background: yellow;
-}
-
-.footnote, .footnoteref {
- font-size: 0.8em;
-}
-
-span.footnote, span.footnoteref {
- vertical-align: super;
-}
-
-#footnotes {
- margin: 20px 0 20px 0;
- padding: 7px 0 0 0;
-}
-
-#footnotes div.footnote {
- margin: 0 0 5px 0;
-}
-
-#footnotes hr {
- border: none;
- border-top: 1px solid silver;
- height: 1px;
- text-align: left;
- margin-left: 0;
- width: 20%;
- min-width: 100px;
-}
-
-div.colist td {
- padding-right: 0.5em;
- padding-bottom: 0.3em;
- vertical-align: top;
-}
-div.colist td img {
- margin-top: 0.3em;
-}
-
- at media print {
- div#footer-badges { display: none; }
-}
-
-div#toc {
- margin-bottom: 2.5em;
-}
-
-div#toctitle {
- color: #527bbd;
- font-size: 1.1em;
- font-weight: bold;
- margin-top: 1.0em;
- margin-bottom: 0.1em;
-}
-
-div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
- margin-top: 0;
- margin-bottom: 0;
-}
-div.toclevel2 {
- margin-left: 2em;
- font-size: 0.9em;
-}
-div.toclevel3 {
- margin-left: 4em;
- font-size: 0.9em;
-}
-div.toclevel4 {
- margin-left: 6em;
- font-size: 0.9em;
-}
-
-span.aqua { color: aqua; }
-span.black { color: black; }
-span.blue { color: blue; }
-span.fuchsia { color: fuchsia; }
-span.gray { color: gray; }
-span.green { color: green; }
-span.lime { color: lime; }
-span.maroon { color: maroon; }
-span.navy { color: navy; }
-span.olive { color: olive; }
-span.purple { color: purple; }
-span.red { color: red; }
-span.silver { color: silver; }
-span.teal { color: teal; }
-span.white { color: white; }
-span.yellow { color: yellow; }
-
-span.aqua-background { background: aqua; }
-span.black-background { background: black; }
-span.blue-background { background: blue; }
-span.fuchsia-background { background: fuchsia; }
-span.gray-background { background: gray; }
-span.green-background { background: green; }
-span.lime-background { background: lime; }
-span.maroon-background { background: maroon; }
-span.navy-background { background: navy; }
-span.olive-background { background: olive; }
-span.purple-background { background: purple; }
-span.red-background { background: red; }
-span.silver-background { background: silver; }
-span.teal-background { background: teal; }
-span.white-background { background: white; }
-span.yellow-background { background: yellow; }
-
-span.big { font-size: 2em; }
-span.small { font-size: 0.6em; }
-a:link { color:navy; }
-a:visited { color:navy; }
-
-.monospaced, code, pre {
- font-family: "Courier New", Courier, monospace;
- font-size: medium; /* inherit; */
- color: black;
- padding: 0;
- margin: 0;
-}
-
-/*
- background: #f8f8f8;
- border: 1px solid #dddddd;
- border-left: 5px solid #f0f0f0;
- margin-right: 10%;
-*/
-
-div.listingblock > div.content {
- padding: 0.5em;
- background: none;
- border: none;
- border-left: none;
- margin-right: none;
-}
-
-</style>
-<script type="text/javascript">
-/*<![CDATA[*/
-window.onload = function(){asciidoc.footnotes();}
-var asciidoc = { // Namespace.
-
-/////////////////////////////////////////////////////////////////////
-// Table Of Contents generator
-/////////////////////////////////////////////////////////////////////
-
-/* Author: Mihai Bazon, September 2002
- * http://students.infoiasi.ro/~mishoo
- *
- * Table Of Content generator
- * Version: 0.4
- *
- * Feel free to use this script under the terms of the GNU General Public
- * License, as long as you do not remove or alter this notice.
- */
-
- /* modified by Troy D. Hanson, September 2006. License: GPL */
- /* modified by Stuart Rackham, 2006, 2009. License: GPL */
-
-// toclevels = 1..4.
-toc: function (toclevels) {
-
- function getText(el) {
- var text = "";
- for (var i = el.firstChild; i != null; i = i.nextSibling) {
- if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
- text += i.data;
- else if (i.firstChild != null)
- text += getText(i);
- }
- return text;
- }
-
- function TocEntry(el, text, toclevel) {
- this.element = el;
- this.text = text;
- this.toclevel = toclevel;
- }
-
- function tocEntries(el, toclevels) {
- var result = new Array;
- var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
- // Function that scans the DOM tree for header elements (the DOM2
- // nodeIterator API would be a better technique but not supported by all
- // browsers).
- var iterate = function (el) {
- for (var i = el.firstChild; i != null; i = i.nextSibling) {
- if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
- var mo = re.exec(i.tagName);
- if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
- result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
- }
- iterate(i);
- }
- }
- }
- iterate(el);
- return result;
- }
-
- var toc = document.getElementById("toc");
- var entries = tocEntries(document.getElementById("content"), toclevels);
- for (var i = 0; i < entries.length; ++i) {
- var entry = entries[i];
- if (entry.element.id == "")
- entry.element.id = "_toc_" + i;
- var a = document.createElement("a");
- a.href = "#" + entry.element.id;
- a.appendChild(document.createTextNode(entry.text));
- var div = document.createElement("div");
- div.appendChild(a);
- div.className = "toclevel" + entry.toclevel;
- toc.appendChild(div);
- }
- if (entries.length == 0)
- toc.parentNode.removeChild(toc);
-},
-
-
-/////////////////////////////////////////////////////////////////////
-// Footnotes generator
-/////////////////////////////////////////////////////////////////////
-
-/* Based on footnote generation code from:
- * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
- */
-
-footnotes: function () {
- var cont = document.getElementById("content");
- var noteholder = document.getElementById("footnotes");
- var spans = cont.getElementsByTagName("span");
- var refs = {};
- var n = 0;
- for (i=0; i<spans.length; i++) {
- if (spans[i].className == "footnote") {
- n++;
- // Use [\s\S] in place of . so multi-line matches work.
- // Because JavaScript has no s (dotall) regex flag.
- note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
- noteholder.innerHTML +=
- "<div class='footnote' id='_footnote_" + n + "'>" +
- "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
- n + "</a>. " + note + "</div>";
- spans[i].innerHTML =
- "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
- "' title='View footnote' class='footnote'>" + n + "</a>]";
- var id =spans[i].getAttribute("id");
- if (id != null) refs["#"+id] = n;
- }
- }
- if (n == 0)
- noteholder.parentNode.removeChild(noteholder);
- else {
- // Process footnoterefs.
- for (i=0; i<spans.length; i++) {
- if (spans[i].className == "footnoteref") {
- var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
- href = href.match(/#.*/)[0]; // Because IE return full URL.
- n = refs[href];
- spans[i].innerHTML =
- "[<a href='#_footnote_" + n +
- "' title='View footnote' class='footnote'>" + n + "</a>]";
- }
- }
- }
-}
-
-}
-/*]]>*/
-</script>
-</head>
-<body class="article" style="max-width:800px">
-<div id="header">
-<h1>Part 3: Analyzing results of a parallel ensemble</h1>
-</div>
-<div id="content">
-<div id="preamble">
-<div class="sectionbody">
-<div class="paragraph"><p>After all the parallel simulations in an ensemble run have completed,
-its typically necessary to gather and analyze their results with some
-kind of post-processing analysis program or script. p3.swift
-introduces such a postprocessing step. In this case, the files created
-by all of the parallel runs of <tt>simulation.sh</tt> will be averaged by by
-the trivial "analysis application" <tt>stats.sh</tt>:</p></div>
-<div class="imageblock" style="text-align:center;">
-<div class="content">
-<img src="part03.png" alt="part03.png" />
-</div>
-</div>
-<div class="listingblock">
-<div class="title">p3.swift</div>
-<div class="content">
-<pre><tt>type file;
-
-app (file o) simulation (int sim_steps, int sim_range, int sim_values)
-{
- simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@filename(o);
-}
-
-app (file o) analyze (file s[])
-{
- stats @filenames(s) stdout=@filename(o);
-}
-
-int nsim = @toInt(@arg("nsim","10"));
-int steps = @toInt(@arg("steps","1"));
-int range = @toInt(@arg("range","100"));
-int values = @toInt(@arg("values","5"));
-
-file sims[];
-
-foreach i in [0:nsim-1] {
- file simout <single_file_mapper; file=@strcat("output/sim_",i,".out")>;
- simout = simulation(steps,range,values);
- sims[i] = simout;
-}
-
-file stats<"output/average.out">;
-stats = analyze(sims);</tt></pre>
-</div></div>
-<div class="paragraph"><p>To run:</p></div>
-<div class="listingblock">
-<div class="content">
-<pre><tt>$ cd part03
-$ swift p3.swift</tt></pre>
-</div></div>
-<div class="paragraph"><p>Note that in <tt>p3.swift</tt> we expose more of the capabilities of the
-<tt>simulate.sh</tt> application to the <tt>simulation()</tt> app function:</p></div>
-<div class="listingblock">
-<div class="content">
-<pre><tt>app (file o) simulation (int sim_steps, int sim_range, int sim_values)
-{
- simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@filename(o);
-}</tt></pre>
-</div></div>
-<div class="paragraph"><p><tt>p3.swift</tt> also shows how to fetch application-specific values from
-the <tt>swift</tt> command line in a Swift script using <tt>@arg()</tt> which
-accepts a keyword-style argument and its default value:</p></div>
-<div class="listingblock">
-<div class="content">
-<pre><tt>int nsim = @toInt(@arg("nsim","10"));
-int steps = @toInt(@arg("steps","1"));
-int range = @toInt(@arg("range","100"));
-int values = @toInt(@arg("values","5"));</tt></pre>
-</div></div>
-<div class="paragraph"><p>Now we can specify that more runs should be performed and that each should run for more timesteps, and produce more that one value each, within a specified range, using command line arguments placed after the Swift script name in the form <tt>-parameterName=value</tt>:</p></div>
-<div class="listingblock">
-<div class="content">
-<pre><tt>$ swift p3.swift -nsim=3 -steps=10 -values=4 -range=1000000
-
-Swift 0.94.1 RC2 swift-r6895 cog-r3765
-
-RunID: 20130827-1439-s3vvo809
-Progress: time: Tue, 27 Aug 2013 14:39:42 -0500
-Progress: time: Tue, 27 Aug 2013 14:39:53 -0500 Active:2 Stage out:1
-Final status: Tue, 27 Aug 2013 14:39:53 -0500 Finished successfully:4
-
-$ ls output/
-average.out sim_0.out sim_1.out sim_2.out
-$ more output/*
-::::::::::::::
-output/average.out
-::::::::::::::
-651368
-::::::::::::::
-output/sim_0.out
-::::::::::::::
- 735700
- 886206
- 997391
- 982970
-::::::::::::::
-output/sim_1.out
-::::::::::::::
- 260071
- 264195
- 869198
- 933537
-::::::::::::::
-output/sim_2.out
-::::::::::::::
- 201806
- 213540
- 527576
- 944233</tt></pre>
-</div></div>
-<div class="paragraph"><p>Now try running (<tt>-nsim=</tt>) 100 simulations of (<tt>-steps=</tt>) 1 second each:</p></div>
-<div class="listingblock">
-<div class="content">
-<pre><tt>$ swift p3.swift -nsim=100 -steps=1
-Swift 0.94.1 RC2 swift-r6895 cog-r3765
-
-RunID: 20130827-1444-rq809ts6
-Progress: time: Tue, 27 Aug 2013 14:44:55 -0500
-Progress: time: Tue, 27 Aug 2013 14:44:56 -0500 Selecting site:79 Active:20 Stage out:1
-Progress: time: Tue, 27 Aug 2013 14:44:58 -0500 Selecting site:58 Active:20 Stage out:1 Finished successfully:21
-Progress: time: Tue, 27 Aug 2013 14:44:59 -0500 Selecting site:37 Active:20 Stage out:1 Finished successfully:42
-Progress: time: Tue, 27 Aug 2013 14:45:00 -0500 Selecting site:16 Active:20 Stage out:1 Finished successfully:63
-Progress: time: Tue, 27 Aug 2013 14:45:02 -0500 Active:15 Stage out:1 Finished successfully:84
-Progress: time: Tue, 27 Aug 2013 14:45:03 -0500 Finished successfully:101
-Final status: Tue, 27 Aug 2013 14:45:03 -0500 Finished successfully:101</tt></pre>
-</div></div>
-<div class="paragraph"><p>We can see from Swift’s "progress" status that the tutorial’s default
-<tt>sites.xml</tt> parameters for local execution allow Swift to run up to 20
-application invocations concurrently on the login node. We’ll look at
-this in more detail in the next sections where we execute applications
-on the site’s compute nodes.</p></div>
-</div>
-</div>
-</div>
-<div id="footnotes"><hr /></div>
-<div id="footer">
-<div id="footer-text">
-Last updated 2013-09-11 13:13:02 CDT
-</div>
-</div>
-</body>
-</html>
Deleted: SwiftApps/tryswift/scripts/p3.swift
===================================================================
--- SwiftApps/tryswift/scripts/p3.swift 2013-10-11 17:30:56 UTC (rev 7150)
+++ SwiftApps/tryswift/scripts/p3.swift 2013-10-11 18:41:25 UTC (rev 7151)
@@ -1,27 +0,0 @@
-type file;
-
-app (file o) simulation (int sim_steps, int sim_range, int sim_values)
-{
- simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=filename(o);
-}
-
-app (file o) analyze (file s[])
-{
- stats filenames(s) stdout=filename(o);
-}
-
-int nsim = toInt(arg("nsim","10"));
-int steps = toInt(arg("steps","1"));
-int range = toInt(arg("range","100"));
-int values = toInt(arg("values","5"));
-
-file sims[];
-
-foreach i in [0:nsim-1] {
- file simout <single_file_mapper; file=strcat("output/sim_",i,".out")>;
- simout = simulation(steps,range,values);
- sims[i] = simout;
-}
-
-file stats<"output/average.out">;
-stats = analyze(sims);
Deleted: SwiftApps/tryswift/scripts/p3.txt
===================================================================
--- SwiftApps/tryswift/scripts/p3.txt 2013-10-11 17:30:56 UTC (rev 7150)
+++ SwiftApps/tryswift/scripts/p3.txt 2013-10-11 18:41:25 UTC (rev 7151)
@@ -1 +0,0 @@
-p3
Deleted: SwiftApps/tryswift/scripts/part03.png
===================================================================
(Binary files differ)
Deleted: SwiftApps/tryswift/scripts/part3.txt
===================================================================
--- SwiftApps/tryswift/scripts/part3.txt 2013-10-11 17:30:56 UTC (rev 7150)
+++ SwiftApps/tryswift/scripts/part3.txt 2013-10-11 18:41:25 UTC (rev 7151)
@@ -1,108 +0,0 @@
-Part 3: Analyzing results of a parallel ensemble
-================================================
-
-After all the parallel simulations in an ensemble run have completed,
-its typically necessary to gather and analyze their results with some
-kind of post-processing analysis program or script. p3.swift
-introduces such a postprocessing step. In this case, the files created
-by all of the parallel runs of `simulation.sh` will be averaged by by
-the trivial "analysis application" `stats.sh`:
-
-image::part03.png[align="center"]
-
-.p3.swift
-----
-sys::[cat ../part03/p3.swift]
-----
-
-To run:
-----
-$ cd part03
-$ swift p3.swift
-----
-
-Note that in `p3.swift` we expose more of the capabilities of the
-`simulate.sh` application to the `simulation()` app function:
-
------
-app (file o) simulation (int sim_steps, int sim_range, int sim_values)
-{
- simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@filename(o);
-}
------
-
-`p3.swift` also shows how to fetch application-specific values from
-the `swift` command line in a Swift script using `@arg()` which
-accepts a keyword-style argument and its default value:
-
------
-int nsim = @toInt(@arg("nsim","10"));
-int steps = @toInt(@arg("steps","1"));
-int range = @toInt(@arg("range","100"));
-int values = @toInt(@arg("values","5"));
------
-
-Now we can specify that more runs should be performed and that each should run for more timesteps, and produce more that one value each, within a specified range, using command line arguments placed after the Swift script name in the form `-parameterName=value`:
-
------
-$ swift p3.swift -nsim=3 -steps=10 -values=4 -range=1000000
-
-Swift 0.94.1 RC2 swift-r6895 cog-r3765
-
-RunID: 20130827-1439-s3vvo809
-Progress: time: Tue, 27 Aug 2013 14:39:42 -0500
-Progress: time: Tue, 27 Aug 2013 14:39:53 -0500 Active:2 Stage out:1
-Final status: Tue, 27 Aug 2013 14:39:53 -0500 Finished successfully:4
-
-$ ls output/
-average.out sim_0.out sim_1.out sim_2.out
-$ more output/*
-::::::::::::::
-output/average.out
-::::::::::::::
-651368
-::::::::::::::
-output/sim_0.out
-::::::::::::::
- 735700
- 886206
- 997391
- 982970
-::::::::::::::
-output/sim_1.out
-::::::::::::::
- 260071
- 264195
- 869198
- 933537
-::::::::::::::
-output/sim_2.out
-::::::::::::::
- 201806
- 213540
- 527576
- 944233
------
-
-Now try running (`-nsim=`) 100 simulations of (`-steps=`) 1 second each:
-
------
-$ swift p3.swift -nsim=100 -steps=1
-Swift 0.94.1 RC2 swift-r6895 cog-r3765
-
-RunID: 20130827-1444-rq809ts6
-Progress: time: Tue, 27 Aug 2013 14:44:55 -0500
-Progress: time: Tue, 27 Aug 2013 14:44:56 -0500 Selecting site:79 Active:20 Stage out:1
-Progress: time: Tue, 27 Aug 2013 14:44:58 -0500 Selecting site:58 Active:20 Stage out:1 Finished successfully:21
-Progress: time: Tue, 27 Aug 2013 14:44:59 -0500 Selecting site:37 Active:20 Stage out:1 Finished successfully:42
-Progress: time: Tue, 27 Aug 2013 14:45:00 -0500 Selecting site:16 Active:20 Stage out:1 Finished successfully:63
-Progress: time: Tue, 27 Aug 2013 14:45:02 -0500 Active:15 Stage out:1 Finished successfully:84
-Progress: time: Tue, 27 Aug 2013 14:45:03 -0500 Finished successfully:101
-Final status: Tue, 27 Aug 2013 14:45:03 -0500 Finished successfully:101
------
-
-We can see from Swift's "progress" status that the tutorial's default
-`sites.xml` parameters for local execution allow Swift to run up to 20
-application invocations concurrently on the login node. We'll look at
-this in more detail in the next sections where we execute applications
-on the site's compute nodes.
More information about the Swift-commit
mailing list