[Swift-commit] r5685 - in trunk/examples/tutorial: . ParameterSweep

wilde at ci.uchicago.edu wilde at ci.uchicago.edu
Sun Feb 26 12:20:37 CST 2012


Author: wilde
Date: 2012-02-26 12:20:37 -0600 (Sun, 26 Feb 2012)
New Revision: 5685

Added:
   trunk/examples/tutorial/ParameterSweep/README
   trunk/examples/tutorial/ParameterSweep/gensweep.sh
   trunk/examples/tutorial/ParameterSweep/simulate.sh
   trunk/examples/tutorial/ParameterSweep/sweep.sh
   trunk/examples/tutorial/ParameterSweep/sweep.swift
Removed:
   trunk/examples/tutorial/gensweep.sh
   trunk/examples/tutorial/simulate.sh
   trunk/examples/tutorial/sweep.sh
   trunk/examples/tutorial/sweep.swift
Log:
Move initial files for ParameterSweep tutorial example to right place; add README.

Added: trunk/examples/tutorial/ParameterSweep/README
===================================================================
--- trunk/examples/tutorial/ParameterSweep/README	                        (rev 0)
+++ trunk/examples/tutorial/ParameterSweep/README	2012-02-26 18:20:37 UTC (rev 5685)
@@ -0,0 +1,18 @@
+
+This directory contains an example of running a "parameter sweep" or
+"ensemble" of N simulations or "members".
+
+To run:
+
+  # make sure Swift 0.93 or trunk is in your $PATH
+
+  svn co https://svn.ci.uchicago.edu/svn/vdl2/trunk/tutorial/ParameterSweep
+  cd ParameterSweep
+
+  ./sweep.sh    # Runs default sweep of 5 members with 3 common data/parameter files
+
+  ./sweep.sh -nMembers=20 -nCommon=2 # 20  members with 2 common data/parameter files
+
+  # Each run is executed in a new unique runNNN directory: run001, run002, ...
+
+  # tc, sites file (local.xml), and Swift properties files (cf) are generated by sweep.sh

Copied: trunk/examples/tutorial/ParameterSweep/gensweep.sh (from rev 5684, trunk/examples/tutorial/gensweep.sh)
===================================================================
--- trunk/examples/tutorial/ParameterSweep/gensweep.sh	                        (rev 0)
+++ trunk/examples/tutorial/ParameterSweep/gensweep.sh	2012-02-26 18:20:37 UTC (rev 5685)
@@ -0,0 +1,36 @@
+#! /bin/sh
+
+#
+# gensweep.sh - Generate per-member and common parameter files
+#               for a parameter sweep (an ensemble of simulations).
+#               Generates 2-column files of the form: "paramter value" 
+
+# echo gensweep.sh: $0 $* >/dev/tty # For debugging on localhost
+
+# Determine the filename patterns from the supplied zero'th file names
+
+nMembers=$1
+mBase=$(basename $2 .0)
+mDir=$(dirname  $2)
+mName=$mDir/$mBase
+
+nCommon=$3
+cBase=$(basename $4 .0)
+cDir=$(dirname  $4)
+cName=$cDir/$cBase
+
+# Generate an input file for each simulation in the ensemble
+
+for (( m=0; m<nMembers; m++ )); do
+  echo n    $m       >$mName.$m
+  echo rate $RANDOM >>$mName.$m
+  echo dx   $RANDOM >>$mName.$m
+done
+
+# Generate the input files common to all simulations in the ensemble
+
+for (( c=0; c<nCommon; c++ )); do
+  echo c     $c       >$cName.$c
+  echo alpha $RANDOM >>$cName.$c
+  echo beta  $RANDOM >>$cName.$c
+done

Copied: trunk/examples/tutorial/ParameterSweep/simulate.sh (from rev 5684, trunk/examples/tutorial/simulate.sh)
===================================================================
--- trunk/examples/tutorial/ParameterSweep/simulate.sh	                        (rev 0)
+++ trunk/examples/tutorial/ParameterSweep/simulate.sh	2012-02-26 18:20:37 UTC (rev 5685)
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+#
+# simulate.sh - a tiny script to model a "simulation application"
+#               Reads N files of 2-column lines of the form "parameter value"
+#               Computes a random function of (some of) the inputs
+
+awk ' # Prints a single text line result with a random function of (some of) the input parameters
+
+{ param[$1] = $2 } # read in the parameter values (for this member plus common files)
+
+END {
+  srand(param["n"] * param["rate"]) / param["beta"]; # the "simulation" :)
+  printf ("Simulation number: %d alpha: %f beta: %f: result: %f\n", param["n"],
+           param["alpha"], param["beta"], rand());
+}
+
+' $*  # member-file common-files...

Copied: trunk/examples/tutorial/ParameterSweep/sweep.sh (from rev 5684, trunk/examples/tutorial/sweep.sh)
===================================================================
--- trunk/examples/tutorial/ParameterSweep/sweep.sh	                        (rev 0)
+++ trunk/examples/tutorial/ParameterSweep/sweep.sh	2012-02-26 18:20:37 UTC (rev 5685)
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+# Create new runNNN directory
+
+rundir=$( echo run??? | sed -e 's/^.*run//' | awk '{ printf("run%03d\n", $1+1)}' )
+mkdir $rundir
+
+cat >$rundir/cf <<END
+
+wrapperlog.always.transfer=true
+sitedir.keep=true
+execution.retries=0
+lazy.errors=false
+
+END
+
+cat >$rundir/local.xml <<END
+
+<config>
+  <pool handle="local">
+    <execution provider="local" />
+    <profile namespace="karajan" key="jobThrottle">.23</profile>
+    <profile namespace="karajan" key="initialScore">10000</profile>
+    <filesystem provider="local"/>
+    <workdirectory>$PWD/swiftwork</workdirectory>
+  </pool>
+</config>
+
+END
+
+cat >$rundir/tc <<END
+
+local gensweep $PWD/gensweep.sh
+local simulate $PWD/simulate.sh
+
+END
+
+cp sweep.swift $rundir
+
+cd $rundir
+echo Running in directory $rundir
+swift -config cf -tc.file tc -sites.file local.xml sweep.swift $* 2>&1 | tee swift.out

Copied: trunk/examples/tutorial/ParameterSweep/sweep.swift (from rev 5684, trunk/examples/tutorial/sweep.swift)
===================================================================
--- trunk/examples/tutorial/ParameterSweep/sweep.swift	                        (rev 0)
+++ trunk/examples/tutorial/ParameterSweep/sweep.swift	2012-02-26 18:20:37 UTC (rev 5685)
@@ -0,0 +1,62 @@
+type file;
+
+# Application to generate the parameter and data files
+
+app (file m[], file c[]) genSweep (int nm, int nc)  
+{
+  gensweep nm @filename(m[0]) nc @filename(c[0]);
+}
+
+# Application to perform a "simulation"
+
+app (file o) simulation (file f, file common[])
+{
+  simulate stdout=@filename(o) @filename(f) @filenames(common);
+}
+
+# Set the size of the parameter sweep
+
+int nMembers = @toInt(@arg("nMembers","5"));   // number of members in the simulation
+int nCommon  = @toInt(@arg("nCommon","3"));    // number of common files to each sim
+tracef("Running parameter sweep ensemble of %i members with %i common files\n", nMembers, nCommon);
+
+# Generate the file names to use
+
+string mName[];
+string oName[];
+string cName[];
+
+foreach i in [0:nMembers-1] {
+  mName[i] = @sprintf("member.%i",i);
+  oName[i] = @sprintf("result.%i",i);
+}
+
+foreach i in [0:nCommon-1] {
+  cName[i] = @sprintf("common.%i",i);
+}
+
+# Set the file names to use
+
+file mFile[] <array_mapper; files=mName>;
+file cFile[] <array_mapper; files=cName>;
+file oFile[] <array_mapper; files=oName>;
+
+# Generate the files for the ensemble run
+
+(mFile, cFile) = genSweep(nMembers, nCommon);
+
+# Perform the ensemble of parallel simulations
+
+foreach f, i in mFile {
+  oFile[i] = simulation(f, cFile);
+}
+
+
+
+/* For debugging:
+
+trace("mFiles", at filenames(mFile));
+trace("oFiles", at filenames(oFile));
+trace("cFiles", at filenames(cFile));
+
+*/
\ No newline at end of file

Deleted: trunk/examples/tutorial/gensweep.sh
===================================================================
--- trunk/examples/tutorial/gensweep.sh	2012-02-26 18:10:34 UTC (rev 5684)
+++ trunk/examples/tutorial/gensweep.sh	2012-02-26 18:20:37 UTC (rev 5685)
@@ -1,36 +0,0 @@
-#! /bin/sh
-
-#
-# gensweep.sh - Generate per-member and common parameter files
-#               for a parameter sweep (an ensemble of simulations).
-#               Generates 2-column files of the form: "paramter value" 
-
-# echo gensweep.sh: $0 $* >/dev/tty # For debugging on localhost
-
-# Determine the filename patterns from the supplied zero'th file names
-
-nMembers=$1
-mBase=$(basename $2 .0)
-mDir=$(dirname  $2)
-mName=$mDir/$mBase
-
-nCommon=$3
-cBase=$(basename $4 .0)
-cDir=$(dirname  $4)
-cName=$cDir/$cBase
-
-# Generate an input file for each simulation in the ensemble
-
-for (( m=0; m<nMembers; m++ )); do
-  echo n    $m       >$mName.$m
-  echo rate $RANDOM >>$mName.$m
-  echo dx   $RANDOM >>$mName.$m
-done
-
-# Generate the input files common to all simulations in the ensemble
-
-for (( c=0; c<nCommon; c++ )); do
-  echo c     $c       >$cName.$c
-  echo alpha $RANDOM >>$cName.$c
-  echo beta  $RANDOM >>$cName.$c
-done

Deleted: trunk/examples/tutorial/simulate.sh
===================================================================
--- trunk/examples/tutorial/simulate.sh	2012-02-26 18:10:34 UTC (rev 5684)
+++ trunk/examples/tutorial/simulate.sh	2012-02-26 18:20:37 UTC (rev 5685)
@@ -1,18 +0,0 @@
-#! /bin/sh
-
-#
-# simulate.sh - a tiny script to model a "simulation application"
-#               Reads N files of 2-column lines of the form "parameter value"
-#               Computes a random function of (some of) the inputs
-
-awk ' # Prints a single text line result with a random function of (some of) the input parameters
-
-{ param[$1] = $2 } # read in the parameter values (for this member plus common files)
-
-END {
-  srand(param["n"] * param["rate"]) / param["beta"]; # the "simulation" :)
-  printf ("Simulation number: %d alpha: %f beta: %f: result: %f\n", param["n"],
-           param["alpha"], param["beta"], rand());
-}
-
-' $*  # member-file common-files...

Deleted: trunk/examples/tutorial/sweep.sh
===================================================================
--- trunk/examples/tutorial/sweep.sh	2012-02-26 18:10:34 UTC (rev 5684)
+++ trunk/examples/tutorial/sweep.sh	2012-02-26 18:20:37 UTC (rev 5685)
@@ -1,42 +0,0 @@
-#! /bin/sh
-
-# Create new runNNN directory
-
-rundir=$( echo run??? | sed -e 's/^.*run//' | awk '{ printf("run%03d\n", $1+1)}' )
-mkdir $rundir
-
-cat >$rundir/cf <<END
-
-wrapperlog.always.transfer=true
-sitedir.keep=true
-execution.retries=0
-lazy.errors=false
-
-END
-
-cat >$rundir/local.xml <<END
-
-<config>
-  <pool handle="local">
-    <execution provider="local" />
-    <profile namespace="karajan" key="jobThrottle">.23</profile>
-    <profile namespace="karajan" key="initialScore">10000</profile>
-    <filesystem provider="local"/>
-    <workdirectory>$PWD/swiftwork</workdirectory>
-  </pool>
-</config>
-
-END
-
-cat >$rundir/tc <<END
-
-local gensweep $PWD/gensweep.sh
-local simulate $PWD/simulate.sh
-
-END
-
-cp sweep.swift $rundir
-
-cd $rundir
-echo Running in directory $rundir
-swift -config cf -tc.file tc -sites.file local.xml sweep.swift $* 2>&1 | tee swift.out

Deleted: trunk/examples/tutorial/sweep.swift
===================================================================
--- trunk/examples/tutorial/sweep.swift	2012-02-26 18:10:34 UTC (rev 5684)
+++ trunk/examples/tutorial/sweep.swift	2012-02-26 18:20:37 UTC (rev 5685)
@@ -1,62 +0,0 @@
-type file;
-
-# Application to generate the parameter and data files
-
-app (file m[], file c[]) genSweep (int nm, int nc)  
-{
-  gensweep nm @filename(m[0]) nc @filename(c[0]);
-}
-
-# Application to perform a "simulation"
-
-app (file o) simulation (file f, file common[])
-{
-  simulate stdout=@filename(o) @filename(f) @filenames(common);
-}
-
-# Set the size of the parameter sweep
-
-int nMembers = @toInt(@arg("nMembers","5"));   // number of members in the simulation
-int nCommon  = @toInt(@arg("nCommon","3"));    // number of common files to each sim
-tracef("Running parameter sweep ensemble of %i members with %i common files\n", nMembers, nCommon);
-
-# Generate the file names to use
-
-string mName[];
-string oName[];
-string cName[];
-
-foreach i in [0:nMembers-1] {
-  mName[i] = @sprintf("member.%i",i);
-  oName[i] = @sprintf("result.%i",i);
-}
-
-foreach i in [0:nCommon-1] {
-  cName[i] = @sprintf("common.%i",i);
-}
-
-# Set the file names to use
-
-file mFile[] <array_mapper; files=mName>;
-file cFile[] <array_mapper; files=cName>;
-file oFile[] <array_mapper; files=oName>;
-
-# Generate the files for the ensemble run
-
-(mFile, cFile) = genSweep(nMembers, nCommon);
-
-# Perform the ensemble of parallel simulations
-
-foreach f, i in mFile {
-  oFile[i] = simulation(f, cFile);
-}
-
-
-
-/* For debugging:
-
-trace("mFiles", at filenames(mFile));
-trace("oFiles", at filenames(oFile));
-trace("cFiles", at filenames(cFile));
-
-*/
\ No newline at end of file




More information about the Swift-commit mailing list