[Swift-commit] r7430 - in branches/release-0.95/examples/tutorial: . bin part01 part02 part03 part04 part05 part06

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Fri Dec 13 15:36:00 CST 2013


Author: davidk
Date: 2013-12-13 15:35:59 -0600 (Fri, 13 Dec 2013)
New Revision: 7430

Added:
   branches/release-0.95/examples/tutorial/bin/
   branches/release-0.95/examples/tutorial/bin/cleanup
   branches/release-0.95/examples/tutorial/bin/simulate
   branches/release-0.95/examples/tutorial/bin/stats
   branches/release-0.95/examples/tutorial/part01/
   branches/release-0.95/examples/tutorial/part01/p1.swift
   branches/release-0.95/examples/tutorial/part01/swift.properties
   branches/release-0.95/examples/tutorial/part02/
   branches/release-0.95/examples/tutorial/part02/p2.swift
   branches/release-0.95/examples/tutorial/part02/swift.properties
   branches/release-0.95/examples/tutorial/part03/
   branches/release-0.95/examples/tutorial/part03/p3.swift
   branches/release-0.95/examples/tutorial/part03/swift.properties
   branches/release-0.95/examples/tutorial/part04/
   branches/release-0.95/examples/tutorial/part04/p4.swift
   branches/release-0.95/examples/tutorial/part04/swift.properties
   branches/release-0.95/examples/tutorial/part05/
   branches/release-0.95/examples/tutorial/part05/p5.swift
   branches/release-0.95/examples/tutorial/part05/swift.properties
   branches/release-0.95/examples/tutorial/part06/
   branches/release-0.95/examples/tutorial/part06/p6.swift
   branches/release-0.95/examples/tutorial/part06/swift.properties
   branches/release-0.95/examples/tutorial/setup.sh
Removed:
   branches/release-0.95/examples/tutorial/MyFirstMapper.java
   branches/release-0.95/examples/tutorial/ParameterSweep/
   branches/release-0.95/examples/tutorial/arrays.swift
   branches/release-0.95/examples/tutorial/capitalise.swift
   branches/release-0.95/examples/tutorial/capitalise_anonymous.swift
   branches/release-0.95/examples/tutorial/default.swift
   branches/release-0.95/examples/tutorial/fixed_array_mapper.1.txt
   branches/release-0.95/examples/tutorial/fixed_array_mapper.2.txt
   branches/release-0.95/examples/tutorial/fixed_array_mapper.3.txt
   branches/release-0.95/examples/tutorial/fixed_array_mapper.swift
   branches/release-0.95/examples/tutorial/foreach.1.txt
   branches/release-0.95/examples/tutorial/foreach.2.txt
   branches/release-0.95/examples/tutorial/foreach.3.txt
   branches/release-0.95/examples/tutorial/foreach.swift
   branches/release-0.95/examples/tutorial/hello.swift
   branches/release-0.95/examples/tutorial/if.swift
   branches/release-0.95/examples/tutorial/manyparam.swift
   branches/release-0.95/examples/tutorial/my_first_mapper.swift
   branches/release-0.95/examples/tutorial/one.txt
   branches/release-0.95/examples/tutorial/parameter.swift
   branches/release-0.95/examples/tutorial/regexp_mapper.swift
   branches/release-0.95/examples/tutorial/regexp_mapper.words.txt
   branches/release-0.95/examples/tutorial/restart.swift
   branches/release-0.95/examples/tutorial/sequential_iteration.swift
   branches/release-0.95/examples/tutorial/three.txt
   branches/release-0.95/examples/tutorial/two.txt
   branches/release-0.95/examples/tutorial/types.swift
   branches/release-0.95/examples/tutorial/wcl
   branches/release-0.95/examples/tutorial/words.txt
Log:
Updated tutorial scripts
Local site


Deleted: branches/release-0.95/examples/tutorial/MyFirstMapper.java
===================================================================
--- branches/release-0.95/examples/tutorial/MyFirstMapper.java	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/MyFirstMapper.java	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,50 +0,0 @@
-/*
- * Copyright 2012 University of Chicago
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package tutorial;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.griphyn.vdl.mapping.AbsFile;
-import org.griphyn.vdl.mapping.AbstractMapper;
-import org.griphyn.vdl.mapping.Path;
-import org.griphyn.vdl.mapping.PhysicalFormat;
-
-public class MyFirstMapper extends AbstractMapper {
-
-  AbsFile myfile = new AbsFile("myfile.txt");
-
-  public boolean isStatic() {
-    return false;
-  }
-
-  public Collection existing() {
-    if (myfile.exists())
-      return Arrays.asList(new Path[] {Path.EMPTY_PATH});
-    else
-      return Collections.EMPTY_LIST;
-  }
-
-  public PhysicalFormat map(Path p) {
-    if(p.equals(Path.EMPTY_PATH))
-      return myfile;
-    else
-      return null;
-  }
-}

Deleted: branches/release-0.95/examples/tutorial/arrays.swift
===================================================================
--- branches/release-0.95/examples/tutorial/arrays.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/arrays.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,12 +0,0 @@
-type messagefile; 
-
-app (messagefile t) greeting (string s[]) {   
-     echo s[0] s[1] s[2] stdout=@filename(t);
-}
-
-messagefile outfile <"arrays.txt">;
-
-string words[] = ["how","are","you"];
-
-outfile = greeting(words);
-

Added: branches/release-0.95/examples/tutorial/bin/cleanup
===================================================================
--- branches/release-0.95/examples/tutorial/bin/cleanup	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/bin/cleanup	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,2 @@
+rm -rf *.rlog *.kml *.swiftx *.out output outdir logs hi.* _concurrent .swift/tmp run0*
+


Property changes on: branches/release-0.95/examples/tutorial/bin/cleanup
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/release-0.95/examples/tutorial/bin/simulate
===================================================================
--- branches/release-0.95/examples/tutorial/bin/simulate	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/bin/simulate	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,137 @@
+#! /bin/bash
+# 
+# Simulate is a 
+
+printparams()
+{
+  printf "\nSimulation parameters:\n\n"
+  echo bias=$bias
+  echo biasfile=$biasfile
+  echo initseed=$initseed
+  echo log=$log
+  echo paramfile=$paramfile
+  echo range=$range
+  echo scale=$scale
+  echo seedfile=$seedfile
+  echo timesteps=$timesteps
+  echo output width=$width
+}
+
+log() {
+  printf "\nCalled as: $0: $cmdargs\n\n"
+  printf "Start time: "; /bin/date
+  printf "Running as user: "; /usr/bin/id
+  printf "Running on node: "; /bin/hostname
+  printf "Node IP address: "; /bin/hostname -I
+  printparams
+  printf "\nEnvironment:\n\n"
+  printenv | sort
+}
+
+addsims() {
+  while read f1 ; do
+    read -u 3 f2 
+    if [ _$f1 = _ ]; then f1=$lastf1; fi
+    if [ _$f2 = _ ]; then f2=$lastf2; fi
+    printf "%${width}d\n" $(($f1+$f2)) 
+    lastf1=$f1
+    lastf2=$f2
+  done <$1 3<$2
+}
+
+# set defaults
+
+bias=0
+biasfile=none
+initseed=none
+log=yes
+paramfile=none
+range=100
+scale=1
+seedfile=none
+timesteps=0
+nvalues=1
+width=8
+cmdargs="$*"
+
+usage()
+{
+  echo $( basename $0 ): usage:
+  cat <<END
+    -b|--bias       offset bias: add this integer to all results
+    -B|--biasfile   file of integer biases to add to results
+    -l|--log        generate a log in stderr if not null
+    -n|--nvalues    print this many values per simulation            
+    -r|--range      range (limit) of generated results
+    -s|--seed       use this integer [0..32767] as a seed
+    -S|--seedfile   use this file (containing integer seeds [0..32767]) one per line
+    -t|--timesteps  number of simulated "timesteps" in seconds (determines runtime)
+    -x|--scale      scale the results by this integer
+    -h|-?|?|--help  print this help
+END
+}
+
+# FIXME: NOT YET IMPLEMENTED:
+#    -p|--paramfile  take these parameters (in form param=value) from this file 
+#    -p|--paramfile) paramfile=$2 ;;
+
+while [ $# -gt 0 ]; do
+  case $1 in
+    -b|--bias)      bias=$2      ;;
+    -B|--biasfile)  biasfile=$2  ;;
+    -l|--log)       log=$2       ;;
+    -n|--nvalues)   nvalues=$2   ;;       
+    -s|--seed)      initseed=$2  ;;
+    -S|--seedfile)  seedfile=$2  ;;
+    -t|--timesteps) timesteps=$2 ;;
+    -r|--range)     range=$2     ;;   
+    -w|--width)     width=$2     ;;
+    -x|--scale)     scale=$2     ;;
+    -h|-?|--help|*) usage; exit  ;;
+  esac
+  shift 2
+done
+    
+# process initial seed
+
+if [ $initseed != none ]; then
+  RANDOM=$initseed
+fi
+
+# process file of seeds
+
+if [ $seedfile != none ]; then
+  seed=0
+  while read $seedfile s; do
+    seed=$(($seed+$s))
+  done <$seedfile
+  RANDOM=$seed
+fi
+
+# run for some number of "timesteps"
+
+sleep $timesteps
+
+# emit N (nvalues) "simulation results" scaled and biased by argument values
+
+simout=$(mktemp simout.XXXX)
+for ((i=0;i<nvalues;i++)); do
+  # value=$(( (($RANDOM)*(2**16))+$RANDOM ))
+  value=$(( (($RANDOM)*(2**48)) + (($RANDOM)*(2**32)) + (($RANDOM)*(2**16)) + $RANDOM ))
+  printf "%${width}d\n" $(( ($value%range)*scale+bias))
+done  >$simout
+
+# process file of biases
+
+if [ $biasfile != none ]; then
+  addsims $simout $biasfile
+else
+  cat $simout
+fi
+rm $simout
+
+# log environmental data
+
+if [ $log != off ]; then
+  log 1>&2
+fi


Property changes on: branches/release-0.95/examples/tutorial/bin/simulate
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/release-0.95/examples/tutorial/bin/stats
===================================================================
--- branches/release-0.95/examples/tutorial/bin/stats	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/bin/stats	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+log() {
+  printf "\nCalled as: $0: $cmdargs\n\n"
+  printf "Start time: "; /bin/date
+  printf "Running as user: "; /usr/bin/id
+  printf "Running on node: "; /bin/hostname
+  printf "Node IP address: "; /bin/hostname -I
+  printf "\nEnvironment:\n\n"
+  printenv | sort
+}
+
+awk '
+
+{ sum += $1}
+
+END { printf("%d\n",sum/NR) }
+' $*
+log 1>&2


Property changes on: branches/release-0.95/examples/tutorial/bin/stats
___________________________________________________________________
Added: svn:executable
   + *

Deleted: branches/release-0.95/examples/tutorial/capitalise.swift
===================================================================
--- branches/release-0.95/examples/tutorial/capitalise.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/capitalise.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,14 +0,0 @@
-type messagefile;
-
-app (messagefile t) greeting (string s) {   
-    echo s stdout=@filename(t);
-}
-
-app (messagefile o) capitalise(messagefile i) {   
-    tr "[a-z]" "[A-Z]" stdin=@filename(i) stdout=@filename(o);
-}
-
-messagefile hellofile <"capitalise.1.txt">;
-messagefile final <"capitalise.2.txt">;
-hellofile = greeting("hello from Swift");
-final = capitalise(hellofile);

Deleted: branches/release-0.95/examples/tutorial/capitalise_anonymous.swift
===================================================================
--- branches/release-0.95/examples/tutorial/capitalise_anonymous.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/capitalise_anonymous.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,14 +0,0 @@
-type messagefile;
-
-app (messagefile t) greeting (string s) {   
-    echo s stdout=@filename(t);
-}
-
-app (messagefile o) capitalise(messagefile i) {   
-    tr "[a-z]" "[A-Z]" stdin=@filename(i) stdout=@filename(o);
-}
-
-messagefile hellofile;
-messagefile final <"capitalise_anonymous.txt">;
-hellofile = greeting("hello from Swift");
-final = capitalise(hellofile);

Deleted: branches/release-0.95/examples/tutorial/default.swift
===================================================================
--- branches/release-0.95/examples/tutorial/default.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/default.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,15 +0,0 @@
-type file;
-
-// s has a default value
-app (file t) echo (string s="hello world") { 
-        echo s stdout=@filename(t);		
-}
-
-file hw1<"default.1.txt">;
-file hw2<"default.2.txt">;
-
-// procedure call using the default value
-hw1 = echo();		
-
-// using a different value
-hw2 = echo(s="hello again"); 

Deleted: branches/release-0.95/examples/tutorial/fixed_array_mapper.1.txt
===================================================================
--- branches/release-0.95/examples/tutorial/fixed_array_mapper.1.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/fixed_array_mapper.1.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-one

Deleted: branches/release-0.95/examples/tutorial/fixed_array_mapper.2.txt
===================================================================
--- branches/release-0.95/examples/tutorial/fixed_array_mapper.2.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/fixed_array_mapper.2.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-two words

Deleted: branches/release-0.95/examples/tutorial/fixed_array_mapper.3.txt
===================================================================
--- branches/release-0.95/examples/tutorial/fixed_array_mapper.3.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/fixed_array_mapper.3.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-three words now

Deleted: branches/release-0.95/examples/tutorial/fixed_array_mapper.swift
===================================================================
--- branches/release-0.95/examples/tutorial/fixed_array_mapper.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/fixed_array_mapper.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,16 +0,0 @@
-type messagefile; 
-type countfile; 
-
-app (countfile t) countwords (messagefile f) {   
-   wc "-w" @filename(f) stdout=@filename(t);
-}
-
-string inputNames = "fixed_array_mapper.1.txt fixed_array_mapper.2.txt fixed_array_mapper.3.txt";
-string outputNames = "fixed_array_mapper.1.count fixed_array_mapper.2.count fixed_array_mapper.3.count";
-
-messagefile inputfiles[] <fixed_array_mapper;files=inputNames>;
-countfile outputfiles[] <fixed_array_mapper;files=outputNames>;
-
-outputfiles[0] = countwords(inputfiles[0]);
-outputfiles[1] = countwords(inputfiles[1]);
-outputfiles[2] = countwords(inputfiles[2]);

Deleted: branches/release-0.95/examples/tutorial/foreach.1.txt
===================================================================
--- branches/release-0.95/examples/tutorial/foreach.1.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/foreach.1.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-one

Deleted: branches/release-0.95/examples/tutorial/foreach.2.txt
===================================================================
--- branches/release-0.95/examples/tutorial/foreach.2.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/foreach.2.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-two words

Deleted: branches/release-0.95/examples/tutorial/foreach.3.txt
===================================================================
--- branches/release-0.95/examples/tutorial/foreach.3.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/foreach.3.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-three words now

Deleted: branches/release-0.95/examples/tutorial/foreach.swift
===================================================================
--- branches/release-0.95/examples/tutorial/foreach.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/foreach.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,18 +0,0 @@
-type messagefile; 
-type countfile; 
-
-app (countfile t) countwords (messagefile f) {   
-     wc "-w" @filename(f) stdout=@filename(t);
-}
-
-string inputNames = "foreach.1.txt foreach.2.txt foreach.3.txt";
-
-messagefile inputfiles[] <fixed_array_mapper;files=inputNames>;
-
-foreach f in inputfiles {
-  countfile c<regexp_mapper;
-	    source=@f,
-            match="(.*)txt",
-            transform="\\1count">;
-  c = countwords(f);
-}

Deleted: branches/release-0.95/examples/tutorial/hello.swift
===================================================================
--- branches/release-0.95/examples/tutorial/hello.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/hello.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,10 +0,0 @@
-type messagefile;
-
-app (messagefile t) greeting() { 
-    echo "Hello, world!" stdout=@filename(t);
-}
-
-messagefile outfile <"hello.txt">;
-
-outfile = greeting();
-

Deleted: branches/release-0.95/examples/tutorial/if.swift
===================================================================
--- branches/release-0.95/examples/tutorial/if.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/if.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,16 +0,0 @@
-type messagefile;
-
-app (messagefile t) greeting (string s) {
-   echo s stdout=@filename(t);
-}
-
-messagefile outfile <"if.txt">;
-
-boolean morning = true;
-
-if(morning) {
-  outfile = greeting("good morning");
-} else {
-  outfile = greeting("good afternoon");
-}
-

Deleted: branches/release-0.95/examples/tutorial/manyparam.swift
===================================================================
--- branches/release-0.95/examples/tutorial/manyparam.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/manyparam.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,13 +0,0 @@
-type messagefile;
-
-app (messagefile t) greeting (string s) {   
-    echo s stdout=@filename(t);
-}
-
-messagefile english <"manyparam.english.txt">;
-messagefile french <"manyparam.french.txt">;
-messagefile japanese <"manyparam.japanese.txt">;
-
-english = greeting("hello");
-french = greeting("bonjour");
-japanese = greeting("konnichiwa");

Deleted: branches/release-0.95/examples/tutorial/my_first_mapper.swift
===================================================================
--- branches/release-0.95/examples/tutorial/my_first_mapper.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/my_first_mapper.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,9 +0,0 @@
-type messagefile;
-
-app (messagefile t) greeting() {
-        echo "hello" stdout=@filename(t);
-}
-
-messagefile outfile <my_first_mapper>;
-
-outfile = greeting();

Deleted: branches/release-0.95/examples/tutorial/one.txt
===================================================================
--- branches/release-0.95/examples/tutorial/one.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/one.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-one

Deleted: branches/release-0.95/examples/tutorial/parameter.swift
===================================================================
--- branches/release-0.95/examples/tutorial/parameter.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/parameter.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,8 +0,0 @@
-type messagefile;
-
-app (messagefile t) greeting (string s) {   
-    echo s stdout=@filename(t);
-}
-
-messagefile outfile <"parameter.hello.txt">;
-outfile = greeting("hello world");

Added: branches/release-0.95/examples/tutorial/part01/p1.swift
===================================================================
--- branches/release-0.95/examples/tutorial/part01/p1.swift	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part01/p1.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,9 @@
+type file;
+
+app (file o) simulation ()
+{
+  simulate stdout=filename(o);
+}
+
+file f <"sim.out">;
+f = simulation();

Added: branches/release-0.95/examples/tutorial/part01/swift.properties
===================================================================
--- branches/release-0.95/examples/tutorial/part01/swift.properties	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part01/swift.properties	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1 @@
+site=local

Added: branches/release-0.95/examples/tutorial/part02/p2.swift
===================================================================
--- branches/release-0.95/examples/tutorial/part02/p2.swift	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part02/p2.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,11 @@
+type file;
+
+app (file o) simulation ()
+{
+  simulate stdout=filename(o);
+}
+
+foreach i in [0:9] {
+  file f <single_file_mapper; file=strcat("output/sim_",i,".out")>;
+  f = simulation();
+}

Added: branches/release-0.95/examples/tutorial/part02/swift.properties
===================================================================
--- branches/release-0.95/examples/tutorial/part02/swift.properties	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part02/swift.properties	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1 @@
+site=local

Added: branches/release-0.95/examples/tutorial/part03/p3.swift
===================================================================
--- branches/release-0.95/examples/tutorial/part03/p3.swift	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part03/p3.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,27 @@
+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);

Added: branches/release-0.95/examples/tutorial/part03/swift.properties
===================================================================
--- branches/release-0.95/examples/tutorial/part03/swift.properties	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part03/swift.properties	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1 @@
+site=local

Added: branches/release-0.95/examples/tutorial/part04/p4.swift
===================================================================
--- branches/release-0.95/examples/tutorial/part04/p4.swift	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part04/p4.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,29 @@
+type file;
+
+app (file out, file log) simulation (int sim_steps, int sim_range, int sim_values)
+{
+  simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@out stderr=@log;
+}
+
+app (file out, file log) analyze (file s[])
+{
+  stats filenames(s) stdout=@out stderr=@log;
+}
+
+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")>;
+  file simlog <single_file_mapper; file=strcat("output/sim_",i,".log")>;
+  (simout,simlog) = simulation(steps,range,values);
+  sims[i] = simout;
+}
+
+file stats_out<"output/average.out">;
+file stats_log<"output/average.log">;
+(stats_out, stats_log) = analyze(sims);

Added: branches/release-0.95/examples/tutorial/part04/swift.properties
===================================================================
--- branches/release-0.95/examples/tutorial/part04/swift.properties	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part04/swift.properties	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1 @@
+site=local

Added: branches/release-0.95/examples/tutorial/part05/p5.swift
===================================================================
--- branches/release-0.95/examples/tutorial/part05/p5.swift	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part05/p5.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,29 @@
+type file;
+
+app (file out, file log) simulation (int sim_steps, int sim_range, int sim_values)
+{
+  simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@out stderr=@log;
+}
+
+app (file out, file log) analyze (file s[])
+{
+  stats filenames(s) stdout=@out stderr=@log;
+}
+
+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")>;
+  file simlog <single_file_mapper; file=strcat("output/sim_",i,".log")>;
+  (simout,simlog) = simulation(steps,range,values);
+  sims[i] = simout;
+}
+
+file stats_out<"output/average.out">;
+file stats_log<"output/average.log">;
+(stats_out, stats_log) = analyze(sims);

Added: branches/release-0.95/examples/tutorial/part05/swift.properties
===================================================================
--- branches/release-0.95/examples/tutorial/part05/swift.properties	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part05/swift.properties	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1 @@
+site=local

Added: branches/release-0.95/examples/tutorial/part06/p6.swift
===================================================================
--- branches/release-0.95/examples/tutorial/part06/p6.swift	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part06/p6.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,53 @@
+type file;
+
+# app() functions for application programs to be called:
+
+app (file out) genseed (int nseeds)
+{
+  simulate "-r" 2000000 "-n" nseeds stdout=@out;
+}
+
+app (file out) genbias (int bias_range, int nvalues)
+{
+  simulate "-r" bias_range "-n" nvalues stdout=@out;
+}
+
+app (file out, file log) simulation (int timesteps, int sim_range, file bias_file, 
+                                     int scale, int sim_count, file seed_file)
+{
+  simulate "-t" timesteps "-r" sim_range "-B" @bias_file "-x" scale
+           "-n" sim_count "-S" @seed_file stdout=@out stderr=@log;
+}
+
+app (file out, file log) analyze (file s[])
+{
+  stats filenames(s) stdout=@out stderr=@log;
+}
+
+# Command line arguments
+
+int   nsim = toInt(arg("nsim",   "10"));  # number of simulation programs to run
+int  steps = toInt(arg("steps",  "1"));   # number of timesteps (seconds) per simulation
+int  range = toInt(arg("range",  "100")); # range of the generated random numbers
+int values = toInt(arg("values", "10"));  # number of values generated per simulation
+
+# Main script and data
+file seedfile <"output/seed.dat">;        # Dynamically generated bias for simulation ensemble
+
+tracef("\n*** Script parameters: nsim=%i range=%i num values=%i\n\n", nsim, range, values);
+seedfile = genseed(1);
+
+file sims[];                      # Array of files to hold each simulation output
+
+foreach i in [0:nsim-1] {
+  file biasfile <single_file_mapper; file=strcat("output/bias_",i,".dat")>;
+  file simout   <single_file_mapper; file=strcat("output/sim_",i,".out")>;
+  file simlog   <single_file_mapper; file=strcat("output/sim_",i,".log")>;
+  biasfile = genbias(1000, 20);
+  (simout,simlog) = simulation(steps, range, biasfile, 1000000, values, seedfile);
+  sims[i] = simout;
+}
+
+file stats_out<"output/average.out">;
+file stats_log<"output/average.log">;
+(stats_out,stats_log) = analyze(sims);

Added: branches/release-0.95/examples/tutorial/part06/swift.properties
===================================================================
--- branches/release-0.95/examples/tutorial/part06/swift.properties	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/part06/swift.properties	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1 @@
+site=local

Deleted: branches/release-0.95/examples/tutorial/regexp_mapper.swift
===================================================================
--- branches/release-0.95/examples/tutorial/regexp_mapper.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/regexp_mapper.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,16 +0,0 @@
-type messagefile; 
-type countfile; 
-
-app (countfile t) countwords (messagefile f) {   
-	wc "-w" @filename(f) stdout=@filename(t);
-}
-
-messagefile inputfile <"regexp_mapper.words.txt">;
-
-countfile c <regexp_mapper;
-	    source=@inputfile,
-            match="(.*)txt",
-            transform="\\1count">;
-
-c = countwords(inputfile);
-

Deleted: branches/release-0.95/examples/tutorial/regexp_mapper.words.txt
===================================================================
--- branches/release-0.95/examples/tutorial/regexp_mapper.words.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/regexp_mapper.words.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-Testing is so much fun!

Deleted: branches/release-0.95/examples/tutorial/restart.swift
===================================================================
--- branches/release-0.95/examples/tutorial/restart.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/restart.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,24 +0,0 @@
-type file;  
-  
-app (file f) touch() {  
-    touch @f;  
-}  
-  
-app (file f) processL(file inp) {  
-    echo "processL" stdout=@f;  
-}  
-  
-app (file f) processR(file inp) {  
-    broken "process" stdout=@f;  
-}  
-  
-app (file f) join(file left, file right) {  
-    echo "join" @left @right stdout=@f;  
-}  
-  
-file f = touch();  
-  
-file g = processL(f);  
-file h = processR(f);  
-  
-file i = join(g,h);  

Deleted: branches/release-0.95/examples/tutorial/sequential_iteration.swift
===================================================================
--- branches/release-0.95/examples/tutorial/sequential_iteration.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/sequential_iteration.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,12 +0,0 @@
-
-string alphabet[];
-alphabet[0] = "a";
-alphabet[1] = "b";
-alphabet[2] = "c";
-alphabet[3] = "d";
-alphabet[4] = "e";
-
-iterate i  
-{
-   tracef("Letter %i is: %s\n", i, alphabet[i]);
-}  until(i == 5);

Added: branches/release-0.95/examples/tutorial/setup.sh
===================================================================
--- branches/release-0.95/examples/tutorial/setup.sh	                        (rev 0)
+++ branches/release-0.95/examples/tutorial/setup.sh	2013-12-13 21:35:59 UTC (rev 7430)
@@ -0,0 +1,8 @@
+#
+# Program to set up tutorial PATH
+# Run as: source setup.sh
+#
+
+# Add tutorial apps to $PATH
+TUTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+export PATH=$TUTDIR/bin:$PATH

Deleted: branches/release-0.95/examples/tutorial/three.txt
===================================================================
--- branches/release-0.95/examples/tutorial/three.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/three.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-three words now

Deleted: branches/release-0.95/examples/tutorial/two.txt
===================================================================
--- branches/release-0.95/examples/tutorial/two.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/two.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-two words

Deleted: branches/release-0.95/examples/tutorial/types.swift
===================================================================
--- branches/release-0.95/examples/tutorial/types.swift	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/types.swift	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,20 +0,0 @@
-type messagefile;
-
-type details {
-    string name;
-    int pies;
-}
-
-app (messagefile t) greeting (details d) {   
-    echo "Hello. Your name is" d.name "and you have eaten" d.pies "pies." stdout=@filename(t);
-}
-
-details person;
-
-person.name = "John";
-person.pies = 3;
-
-messagefile outfile <"types.pies.txt">;
-
-outfile = greeting(person);
-

Deleted: branches/release-0.95/examples/tutorial/wcl
===================================================================
--- branches/release-0.95/examples/tutorial/wcl	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/wcl	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1,3 +0,0 @@
-#!/bin/bash
-echo -n $(wc -c < $1) > $2
-

Deleted: branches/release-0.95/examples/tutorial/words.txt
===================================================================
--- branches/release-0.95/examples/tutorial/words.txt	2013-12-13 21:33:45 UTC (rev 7429)
+++ branches/release-0.95/examples/tutorial/words.txt	2013-12-13 21:35:59 UTC (rev 7430)
@@ -1 +0,0 @@
-Hello world, this is a test




More information about the Swift-commit mailing list