[Swift-commit] r8164 - in SwiftTutorials/ATPESC_2014-08-14: . swift-k swift-k/app swift-k/bin swift-k/doc swift-k/doc/figs swift-k/doc/images swift-k/doc/images/icons swift-k/part01 swift-k/part01m swift-k/part02 swift-k/part02m swift-k/part03 swift-k/part03m swift-k/part04 swift-k/part05 swift-k/part06 swift-k/part06m swift-k/part07 swift-k/part08 swift-k/src swift-k/src/c-ray swift-k/src/md swift-k/src/shdemo
wilde at ci.uchicago.edu
wilde at ci.uchicago.edu
Wed Aug 13 18:08:09 CDT 2014
Author: wilde
Date: 2014-08-13 18:14:19 -0500 (Wed, 13 Aug 2014)
New Revision: 8164
Added:
SwiftTutorials/ATPESC_2014-08-14/swift-k/
SwiftTutorials/ATPESC_2014-08-14/swift-k/README
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/genmovie
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/gettrj.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdmaxk
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats
SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz
SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/
SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup
SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts
SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/TODO
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/activeplot.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/asciidoc.css
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/cumulativeplot.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.dia
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/caution.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/example.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/home.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/important.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/next.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/note.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/prev.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/tip.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/up.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/warning.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part01.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part02.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part03.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part04.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part05.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part06.png
SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/p1.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/p1.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/p2.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/p2.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/p3.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/p3.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/p4.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/p5.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/p6.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/p6m.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/
SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/md.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.swift
SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.midway.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/Makefile
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/README
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/c-ray.c
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/scene.cr
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/sphfract.cr
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/Makefile
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/main.c
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.c
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.h
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.i
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.tcl
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh
SwiftTutorials/ATPESC_2014-08-14/swift-k/tukey.properties
SwiftTutorials/ATPESC_2014-08-14/swift-k/tutorial.pptx
Log:
Copy swift-k tutorial structure from xsede.2014.0425 where the md (particle) demo was developed, for ATPESC 2014.
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/README
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/README (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/README 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1 @@
+link doc/README
\ No newline at end of file
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/README
___________________________________________________________________
Added: svn:special
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/genmovie
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/genmovie (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/genmovie 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,6 @@
+#! /bin/sh
+
+movie=$1
+shift
+
+convert -delay 20 $* $movie
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/gettrj.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/gettrj.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/gettrj.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,3 @@
+# awk "\$1 == ${1:-1} { print \$0 }"
+
+awk "\$1 == ${1:-1} { for (i=2; i<NF; i++) printf \$i \" \"; print $NF}"
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/gettrj.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdmaxk
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdmaxk (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdmaxk 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,38 @@
+#! /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
+}
+
+nfiles=$1
+shift
+
+gawk '
+
+BEGIN { maxKe = 0.0; LASTFILE=""; FILENUM=0; print("sim energy");}
+
+{
+ if ( $1 == "Step" ) next;
+ if ( (LASTFILE != "") && (FILENAME != LASTFILE)) {
+ printf("%s %f\n", FILENUM++, maxKe )
+ maxKe = 0.0;
+ }
+ Ke = $3 + 0.0;
+ if ( Ke > maxKe ) maxKe = Ke;
+ LASTFILE=FILENAME
+}
+
+#END { printf("max Ke for %s is %f\n", LASTFILE, maxKe ) }
+ END { printf("%s %f\n", FILENUM, maxKe ) }
+
+
+
+' $* | sort -n -k2 | tail -$nfiles # | awk '{print $1}'
+
+# log 1>&2
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdmaxk
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,23 @@
+#! /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 '
+
+{
+ sum2 += $2
+ sum3 += $3
+ sum4 += $4
+}
+
+END { printf("%f %f %f\n", sum2/NR, sum3/NR, sum4/NR) }
+' $*
+log 1>&2
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,37 @@
+#! /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
+}
+
+nfiles=$1
+shift
+
+gawk '
+
+BEGIN { totKe = 0.0; LASTFILE=""; FILENUM=0}
+
+{
+ if ( $1 == "Step" ) next;
+ if ( (LASTFILE != "") && (FILENAME != LASTFILE)) {
+ printf("%s %f\n", FILENUM++, totKe )
+ totKe = 0.0;
+ }
+ totKe += $3 + 0.0;
+ LASTFILE=FILENAME
+}
+
+#END { printf("tot Ke for %s is %f\n", LASTFILE, totKe ) }
+ END { printf("%s %f\n", FILENUM, totKe ) }
+
+
+
+' $* | sort -n -k2 | tail -$nfiles # | awk '{print $1}'
+
+# log 1>&2
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+mdout=$1
+vzout=$2
+shift 2
+
+md "$@" >& md.out # Run the MD command
+
+cat <<EOF >c-ray-cmds
+# walls
+s 0 -1000 2 99 0.2 0.2 0.2 0.0 0.0
+
+# lights
+l -50 100 -50
+
+# camera
+# position FOV target
+c 0 6 -17 45 0 -1 0
+EOF
+
+for t in md??.trj; do
+ cat $t c-ray-cmds | c-ray >$t.ppm
+ convert $t.ppm $t.png
+done
+
+convert -delay 20 md??.trj.png t.gif
+
+mv md.dat $mdout
+mv t.gif $vzout
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+mdtrj=$1
+vzout=$2
+frame=$3
+
+APPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+cat <<END >c-ray-trailer
+# walls
+s 0 -1000 2 99 0.2 0.2 0.2 0.0 0.0
+
+# lights
+l -50 100 -50
+
+# camera
+# position FOV target
+c 0 6 -17 45 0 -1 0
+END
+
+(
+ awk "\$1 == $frame {for (i=2; i<NF; i++) printf \$i \" \"; print \$NF}" <$mdtrj | sed -e 's/^[0-9]\+ //'
+
+ cat c-ray-trailer
+) | $APPDIR/c-ray >t.ppm
+
+convert t.ppm $vzout
+
+
+
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,135 @@
+#! /bin/bash
+
+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: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats 2014-08-13 23:14:19 UTC (rev 8164)
@@ -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("%f\n",sum/NR) }
+' $*
+log 1>&2
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,34 @@
+#! /bin/sh
+
+mdtrj=$1
+vzout=$2
+
+wd=`mktemp -d viz.XXXXXX`
+
+ln $1 $wd
+
+cd $wd
+
+tar zxf *.tgz
+
+cat <<EOF >c-ray-cmds
+# walls
+s 0 -1000 2 99 0.2 0.2 0.2 0.0 0.0
+
+# lights
+l -50 100 -50
+
+# camera
+# position FOV target
+c 0 6 -17 45 0 -1 0
+EOF
+
+for t in md??.trj; do
+ cat $t c-ray-cmds | c-ray >$t.ppm
+ convert $t.ppm $t.png
+done
+
+convert -delay 20 md??.trj.png ../$(basename $1 .tgz).gif
+
+# mv md.dat $mdout
+# mv t.gif $vzout
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,2 @@
+rm -rf *.rlog *.kml *.swiftx *.out output outdir logs hi.* _concurrent .swift/tmp run0*
+
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1 @@
+for h in $(cat hosts.txt); do ssh $h hostname -f; done
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,15 @@
+#! /bin/sh
+
+BIN=$(cd $(dirname $0); pwd)
+BASE=$(cd $BIN/..; pwd)
+LOC=$(cd $BASE/..; pwd)
+
+echo executing $0 from BIN=$BIN
+echo making tutorial package of BASE=$BASE
+echo placing tutorial package in LOC=$LOC
+
+(
+ cd $LOC
+ tar zcf swift-cray-tutorial.tgz --exclude-vcs swift-cray-tutorial
+ scp swift-cray-tutorial.tgz p01532 at raven.cray.com:
+)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+#usage: ./plotswiftlogs.ketan <swift-logfile.log>
+
+SWIFTLOGFILE=$1
+
+#TMPDIR=`mktemp -d plotlog.XXX`
+
+grep -i ProgressTicker $SWIFTLOGFILE > swiftoutfile.out
+
+SWIFTOUTFILE=swiftoutfile.out
+
+#extract start time
+TMPDATE=`grep -i progress $SWIFTOUTFILE 2>/dev/null | head -n 1 | cut -f1-2 -d ' '`
+START_TIME=`date +%s -d "$TMPDATE"`
+
+#extract end time
+TMPDATE=`grep -i progress $SWIFTOUTFILE 2>/dev/null | tail -n 1 | cut -f1-2 -d ' '`
+END_TIME=`date +%s -d "$TMPDATE"`
+
+#duration
+DIFFTIME=$((END_TIME - START_TIME))
+
+#extract active runs in a file
+(grep -o -i "Active:[0-9]*" $SWIFTOUTFILE 2>/dev/null | awk -F: '{print $2}' >active.txt)
+
+#extract successful completions in a file
+(grep -o -i "Successfully:[0-9]*" $SWIFTOUTFILE 2>/dev/null | awk -F: '{print $2}' > cumulative.txt)
+
+#prepare tics
+activelines=`wc -l active.txt | awk '{print $1}'`
+cumulines=`wc -l cumulative.txt | awk '{print $1}'`
+
+if [ $activelines -ne 0 ]
+then
+ activelinespertic=`echo "scale=5 ; $DIFFTIME / $activelines" | bc`
+fi
+
+seq 0 $activelinespertic $DIFFTIME > activetics.txt
+
+if [ $cumulines -ne 0 ]
+then
+ cumulinespertic=`echo "scale=5 ; $DIFFTIME / $cumulines" | bc`
+fi
+
+seq 0 $cumulinespertic $DIFFTIME > cumultics.txt
+
+#final plot data
+paste activetics.txt active.txt > plot_active.txt
+paste cumultics.txt cumulative.txt > plot_cumulative.txt
+
+cat << EOF1 > plotit.gp
+set terminal png enhanced
+set nokey
+set output "cumulativeplot.png"
+set xlabel "Time in sec"
+set ylabel "number of completed apps"
+set title "Cumulative Apps Completed"
+plot "plot_cumulative.txt" using 1:2 with lines
+set output "activeplot.png"
+set xlabel "Time in sec"
+set ylabel "number of active apps"
+set title "Active Apps"
+plot "plot_active.txt" using 1:2 with line
+EOF1
+
+gnuplot plotit.gp 2>/dev/null
+rm swiftoutfile.out plotit.gp active.txt cumulative.txt activetics.txt plot_active.txt plot_cumulative.txt cumultics.txt
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,717 @@
+Swift Tutorial for RCC Midway Cluster
+=====================================
+
+////
+
+This is the asciidoc input file.
+Its content is viewable as a plain-text README file.
+
+////
+
+This tutorial is viewable at:
+http://swiftlang.org/tutorials/midway/tutorial.html
+
+////
+
+Tutorial Outline:
+
+Introductory example, running apps locally on login node:
+
+ p1 - Run an application under Swift
+ p2 - Parallel loops with foreach
+ p3 - Merging/reducing the results of a parallel foreach loop
+
+Compute-node exercises, running apps via qsub and aprun:
+
+ p4 - Running apps on RCC Midway cluster
+ p5 - Running on multiple pools of compute nodes
+ p6 - Running a more complex workflow pattern
+
+////
+
+Introduction: Why Parallel Scripting?
+------------------------------------
+
+Swift is a simple scripting language for executing many instances of
+ordinary application programs on distributed parallel resources.
+Swift scripts run many copies of ordinary programs concurrently, using
+statements like this:
+-----
+foreach protein in proteinList {
+ runBLAST(protein);
+}
+-----
+Swift acts like a structured "shell" language. It runs programs
+concurrently as soon as their inputs are available, reducing the need
+for complex parallel programming. Swift expresses your workflow in a
+portable fashion: The same script runs on multicore computers,
+clusters, clouds, grids, and supercomputers.
+
+In this tutorial, you'll be able to first try a few Swift examples
+(parts 1-3) on a Midway login host, to get a sense of the
+language. Then in parts 4-6 you'll run similar workflows on Midway
+compute nodes, and see how more complex workflows can be expressed
+with Swift scripts.
+
+Swift tutorial setup
+--------------------
+If you are using a temporary/guest account to access Midway, follow
+the instructions at http://docs.rcc.uchicago.edu/tutorials/intro-to-rcc-workshop.html
+for more information on using a yubikey to log in.
+
+Once you are logged into the Midway login host, run the following commands
+to set up your environment.
+
+-----
+$ cd $HOME
+$ wget http://swiftlang.org/tutorials/midway/swift-midway-tutorial.tar.gz
+$ tar xvfz swift-midway-tutorial.tar.gz
+$ cd swift-midway-tutorial
+$ source setup.sh
+-----
+
+Verify your environment
+~~~~~~~~~~~~~~~~~~~~~~~
+
+To verify that Swift loaded, do:
+
+-----
+$ swift -version # verify that you have Swift 0.95 RC1
+-----
+
+NOTE: If you re-login or open new ssh sessions, you must re-run `source setup.sh` in each ssh shell/window.
+
+To check out the tutorial scripts from SVN
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If you later want to get the most recent version of this tutorial from
+the Swift Subversion repository, do:
+
+-----
+$ svn co https://svn.ci.uchicago.edu/svn/vdl2/SwiftTutorials/swift-midway-tutorial
+-----
+
+This will create a directory called "swift-midway-tutorial" which contains all of the
+files used in this tutorial.
+
+
+Simple "science applications" for the workflow tutorial
+-------------------------------------------------------
+
+This tutorial is based on two intentionally trivial example programs,
+`simulation` and `stats`, (implemented as bash shell scripts)
+that serve as easy-to-understand proxies for real science
+applications. These "programs" behave as follows.
+
+simulate.sh
+~~~~~~~~~~~
+
+The simulation script serves as a trivial proxy for any more
+complex scientific simulation application. It generates and prints a
+set of one or more random integers in the range [0-2^62) as controlled
+by its command line arguments, which are:
+
+-----
+$ simulate -help
+simulate: usage:
+ -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
+-----
+
+All of these arguments are optional, with default values indicated above as `[n]`.
+
+////
+.simulation arguments
+[width="80%",cols="^2,10",options="header"]
+
+|=======================
+|Argument|Short|Description
+|1 |runtime: sets run time of simulation in seconds
+|2 |range: limits generated values to the range [0,range-1]
+|3 |biasfile: add the integer contained in this file to each value generated
+|4 |scale: multiplies each generated value by this integer
+|5 |count: number of values to generate in the simulation
+|=======================
+////
+
+With no arguments, simulate prints 1 number in the range of
+1-100. Otherwise it generates n numbers of the form (R*scale)+bias
+where R is a random integer. By default it logs information about its
+execution environment to stderr. Here's some examples of its usage:
+
+-----
+$ simulate 2>log
+ 51
+$ head -5 log
+
+Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate:
+Start time: Mon Dec 2 13:47:41 CST 2013
+Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop)
+
+$ simulate -n 4 -r 1000000 2>log
+ 239454
+ 386702
+ 13849
+ 873526
+
+$ simulate -n 3 -r 1000000 -x 100 2>log
+ 6643700
+62182300
+ 5230600
+
+$ simulate -n 2 -r 1000 -x 1000 2>log
+ 565000
+ 636000
+
+$ time simulate -n 2 -r 1000 -x 1000 -t 3 2>log
+ 336000
+ 320000
+real 0m3.012s
+user 0m0.005s
+sys 0m0.006s
+-----
+
+stats
+~~~~~
+
+The stats script serves as a trivial model of an "analysis"
+program. It reads N files each containing M integers and simply prints
+the average of all those numbers to stdout. Similarly to simulate
+it logs environmental information to the stderr.
+
+-----
+$ ls f*
+f1 f2 f3 f4
+
+$ cat f*
+25
+60
+40
+75
+
+$ stats f* 2>log
+50
+-----
+
+
+Basic of the Swift language with local execution
+------------------------------------------------
+
+A Summary of Swift in a nutshell
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+* Swift scripts are text files ending in `.swift` The `swift` command
+runs on any host, and executes these scripts. `swift` is a Java
+application, which you can install almost anywhere. On Linux, just
+unpack the distribution `tar` file and add its `bin/` directory to
+your `PATH`.
+
+* Swift scripts run ordinary applications, just like shell scripts
+do. Swift makes it easy to run these applications on parallel and
+remote computers (from laptops to supercomputers). If you can `ssh` to
+the system, Swift can likely run applications there.
+
+* The details of where to run applications and how to get files back
+and forth are described in configuration files separate from your
+program. Swift speaks ssh, PBS, Condor, SLURM, LSF, SGE, Cobalt, and
+Globus to run applications, and scp, http, ftp, and GridFTP to move
+data.
+
+* The Swift language has 5 main data types: `boolean`, `int`,
+`string`, `float`, and `file`. Collections of these are dynamic,
+sparse arrays of arbitrary dimension and structures of scalars and/or
+arrays defined by the `type` declaration.
+
+* Swift file variables are "mapped" to external files. Swift sends
+files to and from remote systems for you automatically.
+
+* Swift variables are "single assignment": once you set them you can't
+change them (in a given block of code). This makes Swift a natural,
+"parallel data flow" language. This programming model keeps your
+workflow scripts simple and easy to write and understand.
+
+* Swift lets you define functions to "wrap" application programs, and
+to cleanly structure more complex scripts. Swift `app` functions take
+files and parameters as inputs and return files as outputs.
+
+* A compact set of built-in functions for string and file
+manipulation, type conversions, high level IO, etc. is provided.
+Swift's equivalent of `printf()` is `tracef()`, with limited and
+slightly different format codes.
+
+* Swift's `foreach {}` statement is the main parallel workhorse of the
+language, and executes all iterations of the loop concurrently. The
+actual number of parallel tasks executed is based on available
+resources and settable "throttles".
+
+* In fact, Swift conceptually executes *all* the statements,
+expressions and function calls in your program in parallel, based on
+data flow. These are similarly throttled based on available resources
+and settings.
+
+* Swift also has `if` and `switch` statements for conditional
+execution. These are seldom needed in simple workflows but they enable
+very dynamic workflow patterns to be specified.
+
+We'll see many of these points in action in the examples below. Lets
+get started!
+
+Part 1: Run a single application under Swift
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The first swift script, p1.swift, runs simulate to generate a
+single random number. It writes the number to a file.
+
+image::part01.png["p1 workflow",align="center"]
+
+.p1.swift
+-----
+sys::[cat ../part01/p1.swift]
+-----
+
+
+To run this script, run the following command:
+-----
+$ cd part01
+$ swift p1.swift
+Swift 0.94.1 RC2 swift-r6895 cog-r3765
+
+RunID: 20130827-1413-oa6fdib2
+Progress: time: Tue, 27 Aug 2013 14:13:33 -0500
+Final status: Tue, 27 Aug 2013 14:13:33 -0500 Finished successfully:1
+$ cat sim.out
+ 84
+$ swift p1.swift
+$ cat sim.out
+ 36
+-----
+
+To cleanup the directory and remove all outputs (including the log
+files and directories that Swift generates), run the cleanup script
+which is located in the tutorial PATH:
+
+-----
+$ cleanup
+------
+
+NOTE: You'll also find a Swift configuration file in each `partNN`
+directory of this tutorial. This file specifies the environment-specific
+details of how to run. These files will be explained in more
+detail in parts 4-6, and can be ignored for now.
+
+Part 2: Running an ensemble of many apps in parallel with a "foreach" loop
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The `p2.swift` script introduces the `foreach` parallel iteration
+construct to run many concurrent simulations.
+
+image::part02.png[align="center"]
+
+.p2.swift
+-----
+sys::[cat ../part02/p2.swift]
+-----
+
+The script also shows an
+example of naming the output files of an ensemble run. In this case, the output files will be named
+`output/sim_N.out`.
+
+To run the script and view the output:
+-----
+$ cd ../part02
+$ swift p2.swift
+$ ls output
+sim_0.out sim_1.out sim_2.out sim_3.out sim_4.out sim_5.out sim_6.out sim_7.out sim_8.out sim_9.out
+$ more output/*
+::::::::::::::
+output/sim_0.out
+::::::::::::::
+ 44
+::::::::::::::
+output/sim_1.out
+::::::::::::::
+ 55
+...
+::::::::::::::
+output/sim_9.out
+::::::::::::::
+ 82
+-----
+
+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` will be averaged by by
+the trivial "analysis application" `stats`:
+
+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` 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
+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.
+
+
+Running applications on Midway compute nodes with Swift
+-------------------------------------------------------
+
+Part 4: Running a parallel ensemble on Midway compute nodes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+`p4.swift` will run our mock "simulation" applications on Midway
+compute nodes. The script is similar to as `p3.swift`, but specifies
+that each simulation app invocation should additionally return the
+log file which the application writes to `stderr`.
+
+Now when you run `swift p4.swift` you'll see that two types output
+files will placed in the `output/` directory: `sim_N.out` and
+`sim_N.log`. The log files provide data on the runtime environment of
+each app invocation. For example:
+
+-----
+$ cat output/sim_0.log
+Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate: --timesteps 1 --range 100 --nvalues 5
+
+Start time: Mon Dec 2 12:17:06 CST 2013
+Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop)
+Running on node: midway002
+Node IP address: 10.50.181.2 172.25.181.2
+
+Simulation parameters:
+
+bias=0
+biasfile=none
+initseed=none
+log=yes
+paramfile=none
+range=100
+scale=1
+seedfile=none
+timesteps=1
+output width=8
+
+Environment:
+
+ANTLR_ROOT=/software/antlr-2.7-el6-x86_64
+ANT_HOME=/software/ant-1.8.4-all
+ANT_HOME_modshare=/software/ant-1.8.4-all:3
+...
+-----
+
+Swift's `swift.properties` configuration file allows many parameters to
+specify how jobs should be run on a given cluster.
+
+Consider for example that Midway has several Slurm partitions. The sandyb
+partition has 16 cores, and the westmere partition has 12 cores. Depending
+on the application and which partitions are busy, you may want to modify
+where you run.
+
+Here is an example of the swift.properties in the part04 directory:
+
+-----
+site=westmere
+site.westmere.slurm.reservation=workshop
+site.westmere.slurm.exclusive=false
+-----
+
+The first line, site=westmere, allows you to define which partition to run on. Swift includes
+templates for each partition that provides some reasonable default values. Other valid partitions
+are amd, bigmem, gpu, local, and sandyb.
+
+The second and third line override some of the default values, by specifying a reservation that will
+be used for this session, and enabling node sharing.
+
+Try changing the queue to run on the sandyb queue. The new swift.properties should look like this:
+-----
+site=sandyb
+site.sandyb.slurm.reservation=workshop
+site.sandyb.slurm.exclusive=false
+----
+
+Performing larger Swift runs
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+To test with larger runs, there are two changes that are required. The first is a
+change to the command line arguments. The example below will run 1000 simulations
+with each simulation taking 5 seconds.
+
+-----
+$ swift p6.swift -steps=5 -nsim=1000
+-----
+
+Plotting run activity
+~~~~~~~~~~~~~~~~~~~~~
+
+The tutorial `bin` directory in your `PATH` provides a script
+`plot.sh` to plot the progress of a Swift script. It generates two
+image files: `activeplot.png`, which shows the number of active jobs
+over time, and `cumulativeplot.png`, which shows the total number of
+app calls completed as the Swift script progresses.
+
+After each Swift run, a new run directory is created called runNNN.
+Each run directory will have a log file with a similar name called
+runNNN.log. Once you have identified the log file name, run the
+command `plot.sh` <logfile>` to generate the plots for that
+specific run. For example:
+
+-----
+$ ls
+output p3.swift run000 swift.properties
+
+$ cd run000/
+
+$ ls
+apps cf p3-20131202-2004-0kh4ha6e.d run000.log sites.xml
+
+$ plot.sh run000.log
+-----
+
+This yields plots like:
+
+image::activeplot.png[width=700,align=center]
+image::cumulativeplot.png[width=700,align=center]
+
+Part 5: Controlling the compute-node pools where applications run
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This section is under development.
+
+Part 6: Specifying more complex workflow patterns
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+p6.swift expands the workflow pattern of p4.swift to add additional
+stages to the workflow. Here, we generate a dynamic seed value that
+will be used by all of the simulations, and for each simulation, we
+run an pre-processing application to generate a unique "bias
+file". This pattern is shown below, followed by the Swift script.
+
+image::part06.png[align="center"]
+
+.p6.swift
+----
+sys::[cat ../part06/p6.swift]
+----
+
+Note that the workflow is based on data flow dependencies: each simulation depends on the seed value, calculated in this statement:
+-----
+seedfile = genseed(1);
+-----
+and on the bias file, computed and then consumed in these two dependent statements:
+-----
+ biasfile = genbias(1000, 20);
+ (simout,simlog) = simulation(steps, range, biasfile, 1000000, values, seedfile);
+-----
+
+To run:
+----
+$ cd ../part06
+$ swift p6.swift
+----
+
+The default parameters result in the following execution log:
+
+-----
+$ swift p6.swift
+Swift 0.94.1 RC2 swift-r6895 cog-r3765
+
+RunID: 20130827-1917-jvs4gqm5
+Progress: time: Tue, 27 Aug 2013 19:17:56 -0500
+
+*** Script parameters: nsim=10 range=100 num values=10
+
+Progress: time: Tue, 27 Aug 2013 19:17:57 -0500 Stage in:1 Submitted:10
+Generated seed=382537
+Progress: time: Tue, 27 Aug 2013 19:17:59 -0500 Active:9 Stage out:1 Finished successfully:11
+Final status: Tue, 27 Aug 2013 19:18:00 -0500 Finished successfully:22
+-----
+which produces the following output:
+-----
+$ ls -lrt output
+total 264
+-rw-r--r-- 1 p01532 61532 9 Aug 27 19:17 seed.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_9.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_8.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_7.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_6.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_5.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_4.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_3.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_2.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_1.dat
+-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_0.dat
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_9.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_9.log
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_8.log
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_7.out
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_6.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_6.log
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_5.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_5.log
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_4.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_4.log
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_1.log
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_8.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:18 sim_7.log
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_3.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:18 sim_3.log
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_2.out
+-rw-r--r-- 1 p01532 61532 14898 Aug 27 19:18 sim_2.log
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_1.out
+-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_0.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:18 sim_0.log
+-rw-r--r-- 1 p01532 61532 9 Aug 27 19:18 average.out
+-rw-r--r-- 1 p01532 61532 14675 Aug 27 19:18 average.log
+-----
+
+Each sim_N.out file is the sum of its bias file plus newly "simulated" random output scaled by 1,000,000:
+
+-----
+$ cat output/bias_0.dat
+ 302
+ 489
+ 81
+ 582
+ 664
+ 290
+ 839
+ 258
+ 506
+ 310
+ 293
+ 508
+ 88
+ 261
+ 453
+ 187
+ 26
+ 198
+ 402
+ 555
+
+$ cat output/sim_0.out
+64000302
+38000489
+32000081
+12000582
+46000664
+36000290
+35000839
+22000258
+49000506
+75000310
+-----
+
+We produce 20 values in each bias file. Simulations of less than that
+number of values ignore the unneeded number, while simualtions of more
+than 20 will use the last bias number for all remoaining values past
+20. As an exercise, adjust the code to produce the same number of
+bias values as is needed for each simulation. As a further exercise,
+modify the script to generate a unique seed value for each simulation,
+which is a common practice in ensemble computations.
+
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/TODO
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/TODO (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/TODO 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,137 @@
+PLAN
+
+basics
+cloud
+uc3
+multisystems
+(modis)
+
+get hosts.txt for cloud dynamically
+
+Show variety of UC3 activity and what ran where
+
+get hostname and app_resources into provider staging (hostname into all _swiftwrap)
+
+Show gridftp and go connect to process the modis dataset
+
+Show SwiftR for R users, SwiftPy for Enthought PY?
+
+fetching apps vs sending apps vs parrot/cvmfs/oasis etc ????
+
+Demo script-aps, bin apps, building apps, caching apps. etc.
+
+Do a Swift BLAST workflow -- with viz !!! (spice it up with help from Dina)
+
+OSG page from Mats: "Is your job HTC-ready"
+
+Use new Trunk config in tutorial?
+
+
+Add viz and status display; add node probing to tutorial.
+
+Debug failure with pinfiles
+
+
+What "exercises to suggest?"
+
+- run stats app locally
+- installed vs transferred apps
+- transferred programs vs transferred scripts
+- summarize things about the env from the .log files, ala stats.
+
+Y-style dag: 2 sims and average
+
+Show how to find temp files at runtime...
+
+Show how to find hung processes at runtime... (or get other trace data...)
+
+make your owb versions of the programs; verify that you can substitute them
+
+Add a layer to isolate shell version v installed version
+
+Show how to handle a paramfile
+
+Test if OSGCOnnect works and account string (PorjectName) works OK for both!
+
+SHow how to handle long lists of files (eg writeData and other swift.properties)
+
+Expand arith to arb prec using bc
+
+
+ISSUES
+
+error in pin files? debug and turn back on
+PATH issues for various providers
+
+bin dir?
+
+setup.csh and .csh testing
+
+IMPROVEMENTS
+
+1. Cleanup.sh mentioned in the tutorial
+[fixed]
+
+2. cd ../part02
+[fixed]
+
+3. support for zsh, csh
+[pending]
+
+4. What results are created and where did the outputs go ?
+and pointers to what the log files mean
+[pending]
+
+5. Part4,
+- cd ../part04 is missing. Cleanup the README
+[fixed]
+
+6. Part5
+- cd ../part05 is missing. Cleanup
+[fixed]
+
+7. Part7
+-Change from running on Tukey analysis cluster compute nodes
+[fixed]
+
+8. Part6
+command line args for nsim and steps, tell user the different behavior
+that can be expected with different arg options
+[pending]
+
+9. Draw workflow for the modis demos
+[pending]
+
+10. Link to more technical swift-lang references
+[pending]
+
+11. Links to detailed language constructs, when explaining
+apps, link to the section on apps in the userguide.
+[pending]
+
+
+
+---
+
+From Yadu:
+
+I've committed all the changes that I made on Friday and you can get them
+from -> https://svn.ci.uchicago.edu/svn/vdl2/SwiftTutorials/CIC_2013-08-09
+
+I'm trying to make this tutorial easily work on several sites so that, we
+do not have to tweak things for every single tutorial. Once this is done,
+I can also add it to the test-battery as well. I think this has value
+considering that we spend atleast 1-2 days for every demo.
+
+Now, the major pending item is the Modis demo, specifically the issue of
+bringing data to any site and scripts. Slight tweaks to allow for sending
+the scripts as args to apps would also be needed.
+
+So the major changes are:
+1. Source the setup.sh script with the target site name
+eg. source setups.sh <cloud|uc3|midway|beagle>
+2. No separate cloud folder
+3. [pending] fix modis data and scripts
+4. [pending] support for zsh and other shells?
+
+---
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/activeplot.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/activeplot.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/asciidoc.css
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/asciidoc.css (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/asciidoc.css 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,26 @@
+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;
+}
+
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,3 @@
+#!/bin/bash -e
+
+asciidoc -a icons -a toc -a toplevels=2 -a stylesheet=$PWD/asciidoc.css -a max-width=800px -o tutorial.html README
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/cumulativeplot.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/cumulativeplot.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.dia
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.dia
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/caution.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/caution.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/example.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/example.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/home.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/home.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/important.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/important.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/next.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/next.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/note.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/note.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/prev.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/prev.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/tip.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/tip.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/up.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/up.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/warning.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/warning.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part01.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part01.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part02.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part02.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part03.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part03.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part04.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part04.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part05.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part05.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part06.png
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part06.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+# scp -r swift-cray-tutorial.html images *png login.ci.uchicago.edu:/ci/www/projects/swift/tutorials/cray
+
+tar zcf - --exclude-vcs *html *png images | ssh ci "cd /ci/www/projects/swift/tutorials/midway; tar zxf -"
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/p1.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/p1.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/p1.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,9 @@
+type file;
+
+app (file o) simulation ()
+{
+ simulate stdout=filename(o);
+}
+
+file f <"sim.out">;
+f = simulation();
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1 @@
+site=local
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/p1.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/p1.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/p1.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,9 @@
+type file;
+
+app (file o) simulation ()
+{
+ md 3 50 1000 stdout=filename(o);
+}
+
+file f <"sim.out">;
+f = simulation();
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,3 @@
+site=local
+ticker.date.format=HH:mm:ss
+ticker.prefix=
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/p2.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/p2.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/p2.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -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: SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1 @@
+site=local
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/p2.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/p2.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/p2.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,11 @@
+type file;
+
+app (file o) simulation ()
+{
+ sh "-c" "md 3 50 1000 >/dev/null; cat md.dat" stdout=filename(o);
+}
+
+foreach i in [0:9] {
+ file f <single_file_mapper; file=strcat("output/sim_",i,".out")>;
+ f = simulation();
+}
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,3 @@
+site=local
+ticker.date.format=HH:mm:ss
+ticker.prefix=
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/p3.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/p3.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/p3.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -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: SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1 @@
+site=local
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/p3.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/p3.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/p3.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,44 @@
+type file;
+
+/*
+ md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset
+ where
+ * nd is the spatial dimension (2 or 3);
+ * np is the number of particles (500, for instance);
+ * step_num is the number of time steps (500, for instance);
+ * print_step_num is the number of snapshot prints (10 for instance);
+ * dt is size of timestep;
+ * mass is particle mass;
+ * printinfo is a string to append to each particle coord
+ * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME)
+
+ e.g.:
+
+ md 3 50 30000 50 .0001 .005 "0.03 1.0 0.2 0.05 50.0 0.1" 2.5 2.0
+*/
+
+app (file o) simulation (string npart, string steps, string mass)
+{
+ sh "-c" strjoin(["md","3",npart,steps,">/dev/null; cat md.dat"]," ") stdout=filename(o);
+}
+
+app (file o) analyze (file s[])
+{
+ mdstats filenames(s) stdout=filename(o);
+}
+
+int nsim = toInt(arg("nsim","10"));
+string npart = arg("npart","50");
+string steps = arg("steps","1000");
+string mass = arg("mass",".0001");
+
+file sims[];
+
+foreach i in [0:nsim-1] {
+ file simout <single_file_mapper; file=strcat("output/sim_",i,".out")>;
+ simout = simulation(npart,steps,mass);
+ sims[i] = simout;
+}
+
+file stats<"output/average.out">;
+stats = analyze(sims);
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,3 @@
+site=local
+ticker.date.format=HH:mm:ss
+ticker.prefix=
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/p4.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/p4.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/p4.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -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: SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,2 @@
+site=midway-westmere
+site.westmere.slurm.exclusive=false
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/p5.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/p5.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/p5.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -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: SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,2 @@
+site=westmere
+site.westmere.slurm.exclusive=false
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/p6.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/p6.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/p6.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -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: SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,2 @@
+site=westmere
+site.westmere.slurm.exclusive=false
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/p6m.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/p6m.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/p6m.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,54 @@
+type file;
+
+(int result) randomInt ()
+{
+ float range = 9999999.0;
+ float rand = java("java.lang.Math","random");
+ string s[] = strsplit(toString(range*rand),"\\.");
+ result = toInt(s[0]);
+}
+
+app (file out, file traj) simulation (string npart, string steps, string mass, int randval)
+{
+# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt();
+ md 3 npart steps 10 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randval @out @traj;
+}
+
+app (file out) genconfig ()
+{
+ simulate "-n" 1 "-r" 1000000 stdout=filename(out);
+}
+
+app (file o) analyze (file s[])
+{
+ mdstats filenames(s) stdout=filename(o);
+}
+
+app (file o) maxkinetic (file s[])
+{
+ mdmaxk "3" filenames(s) stdout=filename(o);
+}
+
+app (file o) convert (file s[])
+{
+ convert filenames(s) filename(o);
+}
+
+int nsim = toInt(arg("nsim","10"));
+string npart = arg("npart","50");
+string steps = arg("steps","1000");
+string mass = arg("mass",".005");
+
+file sim[] <simple_mapper; prefix="output/sim_", suffix=".out">;
+file trj[] <simple_mapper; prefix="output/sim_", suffix=".trj.tgz">;
+
+foreach i in [0:nsim-1] {
+ int startstate = readData(genconfig());
+ (sim[i],trj[i]) = simulation(npart,steps,mass,startstate);
+}
+
+file stats_out<"output/average.out">;
+stats_out = analyze(sim);
+
+#file viz_all<"output/all.gif">;
+#viz_all = convert(gifs);
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,2 @@
+site=midway-westmere
+site.midway-westmere.slurm.exclusive=false
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,43 @@
+type file;
+
+(int result) randomInt ()
+{
+ float range = 9999999.0;
+ float rand = java("java.lang.Math","random");
+ string s[] = strsplit(toString(range*rand),"\\.");
+ result = toInt(s[0]);
+}
+
+app (file out, file traj) simulation (string npart, string steps, string mass)
+{
+# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt();
+ md 3 npart steps 10 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj;
+}
+
+app (file o) analyze (file s[])
+{
+ mdstats filenames(s) stdout=filename(o);
+}
+
+app (file o) convert (file s[])
+{
+ convert filenames(s) filename(o);
+}
+
+int nsim = toInt(arg("nsim","10"));
+string npart = arg("npart","50");
+string steps = arg("steps","1000");
+string mass = arg("mass",".005");
+
+file sim[] <simple_mapper; prefix="output/sim_", suffix=".out">;
+file trj[] <simple_mapper; prefix="output/sim_", suffix=".trj.tgz">;
+
+foreach i in [0:nsim-1] {
+ (sim[i],trj[i]) = simulation(npart,steps,mass);
+}
+
+file stats_out<"output/average.out">;
+stats_out = analyze(sim);
+
+#file viz_all<"output/all.gif">;
+#viz_all = convert(gifs);
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,78 @@
+type file;
+
+type kineticInfo {
+ int sim;
+ float energy;
+}
+
+(int result) randomInt ()
+{
+ float range = 9999999.0;
+ float rand = java("java.lang.Math","random");
+ string s[] = strsplit(toString(range*rand),"\\.");
+ result = toInt(s[0]);
+}
+
+app (file out, file traj) simulation (int npart, int steps, int trsnaps, float mass)
+{
+# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt();
+ md 3 npart steps trsnaps ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj;
+}
+
+app (file o) analyze (file s[])
+{
+ mdstats filenames(s) stdout=filename(o);
+}
+
+app (file o) kinetic (file s[])
+{
+ mdmaxk 9999 filenames(s) stdout=filename(o);
+}
+
+app (file o) render (file traj, int frame)
+{
+ renderframe filename(traj) filename(o) frame;
+}
+
+app (file o) convert (file s[])
+{
+ convert "-delay" 20 filenames(s) filename(o);
+}
+
+int nsim = toInt(arg("nsim","10"));
+int npart = toInt(arg("npart","50"));
+int steps = toInt(arg("steps","1000"));
+int trsnaps = 10;
+float mass = toFloat(arg("mass",".005"));
+
+file sim[] <simple_mapper; prefix="output/sim_", suffix=".out">;
+file trj[] <simple_mapper; prefix="output/sim_", suffix=".trj">;
+
+foreach i in [0:nsim-1] {
+ (sim[i],trj[i]) = simulation(npart,steps,trsnaps,mass);
+}
+
+file stats_out<"output/average.out">;
+stats_out = analyze(sim);
+
+file ke_out<"output/kinetic.out">;
+ke_out = kinetic(sim);
+
+kineticInfo kd[] = readData(ke_out);
+
+tracef("min eK simulation: %i eK: %f\n", kd[0].sim, kd[0].energy);
+tracef("max eK simulation: %i eK: %f\n", kd[nsim-1].sim, kd[nsim-1].energy);
+
+file mink[] <simple_mapper; prefix="output/mink/frame_", suffix=".png">;
+file maxk[] <simple_mapper; prefix="output/maxk/frame_", suffix=".png">;
+
+foreach i in [0:trsnaps-1] {
+ mink[i] = render(trj[kd[0].sim], i);
+ maxk[i] = render(trj[kd[nsim-1].sim], i);
+}
+
+file minkmovie <"output/mink.gif">;
+file maxkmovie <"output/maxk.gif">;
+
+minkmovie = convert(mink);
+maxkmovie = convert(maxk);
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,2 @@
+site=midway-sandyb
+site.midway-sandyb.slurm.exclusive=false
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/md.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/md.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/md.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,13 @@
+
+ at dispatch=WORKER
+(file outfile, file trjfile)
+simulate(int step_num, int step_print_num,
+ int step_print, int step_print_index,
+ int np, int nd,
+ float mass,
+ float dt,
+ int seed)
+"md" "0.0"
+[
+"simulate <<step_num>> <<step_print_num>> <<step_print>> <<step_print_index>> <<np>> <<nd>> <<mass>> <<dt>> <<seed>> [ lindex $<<outfile>> 0 ] [ lindex $<<trjfile>> 0 ]"
+];
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,10 @@
+#!/bin/sh -eu
+
+stc run-md.swift
+
+MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd )
+export TURBINE_USER_LIB=${MD_PKG}
+export TURBINE_LOG=0 ADLB_DEBUG=0
+turbine run-md.tcl
+
+
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,9 @@
+
+import md;
+
+main
+{
+ file out_txt<"out.txt">;
+ file out_trj<"out.trj">;
+ (out_txt, out_trj) = simulate(10, 10, 3, 0, 10, 2, 1, 0.1, 42);
+}
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,8 @@
+#!/bin/sh -eu
+
+stc run-mds.swift
+
+MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd )
+export TURBINE_USER_LIB=${MD_PKG}
+export TURBINE_LOG=0 ADLB_DEBUG=0
+turbine -n 2 run-mds.tcl --simulations=4 --steps=10
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.swift 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,17 @@
+
+import string;
+import sys;
+
+import md;
+
+main
+{
+ int simulations = toint(argv("simulations"));
+ int steps = toint(argv("steps"));
+ foreach i in [0:simulations-1]
+ {
+ file out_txt<sprintf("out-%i.txt",i)>;
+ file out_trj<sprintf("out-%i.trj",i)>;
+ (out_txt, out_trj) = simulate(steps, 10, 3, 0, 10, 2, 1, 0.1, 42);
+ }
+}
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.midway.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.midway.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.midway.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,13 @@
+# Load modules
+#module unload swift
+#module load swift/0.95-RC1
+
+module load ant
+
+#PATH=/home/wilde/swift/src/trunk/cog/modules/swift/dist/swift-svn/bin:$PATH
+
+echo Swift version is $(swift -version)
+
+# Add applications to $PATH
+TUTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+PATH=$TUTDIR/bin:$TUTDIR/app:$PATH
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/Makefile
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/Makefile (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/Makefile 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,23 @@
+#obj = c-ray-mt.o
+bin = c-ray
+
+CC = gcc
+CFLAGS = -O3 -ffast-math
+
+$(bin): $(obj)
+ $(CC) -o $@ $(bin).c -lm -lpthread
+
+#$(bin): $(obj)
+# $(CC) -o $@ $(obj) -lm -lpthread
+
+.PHONY: clean
+clean:
+ rm -f $(obj) $(bin)
+
+.PHONY: install
+install:
+ cp $(bin) ../../bin/$(bin)
+
+.PHONY: uninstall
+uninstall:
+ rm -f ../../bin/$(bin)
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/README
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/README (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/README 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,395 @@
+
+ C-Ray Simple Raytracing Tests
+
+ http://www.futuretech.blinkenlights.nl/c-ray.html
+
+ By: John Tsiombikas <nuclear at siggraph.org>
+
+ Test suite compiled by: Ian Mapleson <mapesdhs at yahoo.com>
+
+ Last Change: 10/Apr/2008
+
+
+1. Introduction
+2. The C-Ray Tests (how to compile)
+3. Running the Tests
+4. Submitting Results
+5. Background
+6. Appendix A: Invalid Tests
+
+**********************************************************************
+
+1. Introduction
+
+C-Ray is a simple raytracer written by John Tsiombikas; in his
+own words, it is:
+
+ "...an extremely small program I did one day to figure out how
+ would the simplest raytracer program look like in the least
+ ammount of code lines."
+
+The relevant discussion on Nekochan is at:
+
+ http://forums.nekochan.net/viewtopic.php?f=3&t=15719
+
+The default data set is very small, so C-ray really only tests the pure
+floating-point (fp) speed of a CPU core (or multiple CPUs/cores using the
+threaded version), ie. RAM speed is not a significant factor. John said:
+
+ This thing only measures 'floating point CPU performance' and
+ nothing more, and it's good that nothing else affects the results.
+ A real rendering program/scene would be still CPU-limited meaning
+ that by far the major part of the time spent would be CPU time in
+ the fpu, but it would have more overhead for disk I/O, shader
+ parsing, more strain for the memory bandwidth, and various other
+ things. So it's a good approximation being a renderer itself, but
+ it's definitely not representative."
+
+Nevertheless, the results are certainly interesting:
+
+ http://www.futuretech.blinkenlights.nl/c-ray.html
+
+If you wish to submit your own results, follow the instructions given
+below. Send the data to me, not to John, and I will add them to the
+relevant tables; please include all requested details.
+
+Comments and feedback welcome!
+
+Ian.
+
+mapesdhs at yahoo.com
+sgidepot at blueyonder.co.uk
+http://www.futuretech.blinkenlights.nl/sgidepot/
+
+**********************************************************************
+
+2. The C-Ray Tests
+
+Two programs are included in this archive for testing:
+
+c-ray-f:
+
+ This is for single-CPU systems, or for testing just a single core
+ of a multi-core CPU.
+
+c-ray-mt:
+
+ This is the multithreaded version for testing multi-CPU systems, and/or
+ systems with more than one CPU core. Note that on some systems c-ray-mt
+ with just one thread may be faster than c-ray-f. Use whichever version
+ gives you the best results in each case. Use the -t option to specify
+ the number of threads; without the -t option, only 1 thread is used.
+
+Compile the source files for your target platform with gcc or whatever
+compiler you have. Just enter 'make', though feel free to add any arch-
+specific optimizations for your compiler in CFLAGS first. By default,
+the Makefile is designed for use with GCC. If you are using an SGI and
+want to use MIPS Pro to compile the programs, then enter:
+
+ /bin/cp Makefile.mips Makefile
+
+and then enter 'make'.
+
+Note that the c-ray binaries as supplied were compiled for an SGI
+Octane2 R12K/R14 system (users of other SGI models should recompile
+if possible), while the example x86 binary in the x86 directory was
+compiled by John for a 3GHz P4.
+
+If you don't want to use make, then typical compile lines for each
+program on SGIs using MIPS Pro are as follows (in this case for an
+Octane system - use a different IP number for other SGI systems):
+
+ cc -O3 -mips4 -TARG:platform=ip30 -Ofast=ip30 c-ray-f.c -o c-ray-f -lm
+
+while for the threaded version the pthread library must be included:
+
+ cc -O3 -mips4 -TARG:platform=ip30 -Ofast=ip30 c-ray-mt.c -o c-ray-mt -lm -lpthread
+
+See the 'cc' man page for full details of available optimisation options.
+
+The file 'sgi.txt' has further example compile lines for SGI O2 and
+Octane machines, some with extra example optimisation options. Try
+them out, see which one works best on your system. Those using GCC
+should consult the gcc man page for full details of available options.
+
+NOTE: results for tests done with pre-run profiling/virtualisation
+compiler optimisations will NOT be accepted! (see Appendix A for details).
+
+Before running the tests, naturally you should shut down any other
+applications, processes, etc. which might interfere with the test.
+For example, on SGI systems, I shut down the mediad and sgi_apache
+daemons:
+
+ /etc/init.d/mediad stop
+ /etc/init.d/sgi_apache stop
+
+Better still, turn off timed, nsd, and rlogin remotely to run the tests.
+It should be possible to do the same thing on a Linux/BSD system.
+
+On a Windows machine, shut down all unnecessary processes, close any
+antivirus/firewall applications/processes, and it may be worthwhile
+forcing any pending idle tasks to complete before running the tests,
+ie. select Run from the Start menu and enter:
+
+ Rundll32.exe advapi32.dll,ProcessIdleTasks
+
+Assuming you are now ready to use the binary programs for the tests...
+
+**********************************************************************
+
+3. Running the Tests
+
+There are two data files used for the tests:
+
+'scene' is a simple environment, with just three reflective spheres.
+Examine scene.jpg to see the final image.
+
+'sphract' is a much more complex scenario, with dozens of spheres in
+a fractal pattern (see gen_fract.txt for details of how the scene
+description was created). Examine sphract.jpg to see the final image.
+
+There are four tests; the first is the shortest, the data from which
+are used for the main table on the results page. The tests are:
+
+
+ Test Data File Image Resolution Oversampling
+
+ 1. scene Default 800x600 NONE
+ 2. sphract Default 800x600 NONE
+ 3. sphract 1024 x 768 8X
+ 4. scene 7500 x 3500 NONE
+
+If you are using a single-CPU system which only has one core, or wish
+to test just one CPU/core of a multi-CPU/core system, then run the
+tests with c-ray-f, or with c-ray-mt using just 1 thread. For systems
+with multiple CPUs/cores, please submit results for just a single
+CPU/core aswell as the fastest results for using all CPUs/cores (this
+allows one to see how well parallel systems scale).
+
+On UNIX systems, the programs receive the scene description data from
+the standard input and send the results (the image created) to the
+standard output. To run the first test on a UNIX system, enter:
+
+ cat scene | ./c-ray-f > foo.ppm
+
+On a Windows system, enter the following in a Command window:
+
+ c-ray-f -i scene -o foo.ppm
+
+The output will resemble the following (in this case run on a R14000
+550MHz SGI Octane2):
+
+ Rendering took: 1 seconds (1888 milliseconds)
+
+The result to submit is the number of milliseconds. Run each test
+several times if possible to observe a typical result. It's up to
+you whether you submit a typical result or the fastest overall result.
+
+If you have a multi-CPU/core system, now run the test multithreaded with
+c-ray-mt, using the -t option to specify the number of threads, eg.
+
+ UNIX: cat scene | ./c-ray-mt -t 32 > foo.ppm
+ Windows: c-ray-mt -t 32 -i scene -o foo.ppm
+
+For multi-CPU/core systems, the optimum number of threads varies
+greatly from one system to another, though a good estimate is 16
+times the number of cores. Try different numbers, eg. 32, 64, 128,
+or some inbetween number such as 40, 60, etc. But also try smaller
+number too, eg. just 8 threads for a quad-core system.
+
+The maximum number of threads c-ray-mt can use is the vertical
+resolution of the output image. As the number of threads increases,
+eventually the speedup obtained by the parallel processing will be
+outweighed by the overhead cost of managing the threads. Experiment
+to find what works best for each test.
+
+Thus, for the other tests, the commands to enter on a UNIX system
+would be as follows, using 32 threads just as an example here:
+
+ cat sphract | ./c-ray-f > foo.ppm
+ cat sphract | ./c-ray-mt -t 32 > foo.ppm
+ cat sphract | ./c-ray-f -s 1024x768 -r 8 > foo.ppm
+ cat sphract | ./c-ray-mt -t 32 -s 1024x768 -r 8 > foo.ppm
+ cat scene | ./c-ray-f -s 7500x3500 > foo.ppm
+ cat scene | ./c-ray-mt -t 32 -s 7500x3500 > foo.ppm
+
+while on a Windows system these would be:
+
+ c-ray-f -i sphract -o foo.ppm
+ c-ray-mt -t 32 -i sphract -o foo.ppm
+ c-ray-f -s 1024x768 -r 8 -i sphract -o foo.ppm
+ c-ray-mt -t 32 -s 1024x768 -r 8 -i sphract -o foo.ppm
+ c-ray-f -s 7500x3500 -i scene -o foo.ppm
+ c-ray-mt -t 32 -s 7500x3500 -i scene -o foo.ppm
+
+If you don't want to bother experimenting, then the script RUN.full
+will execute all the tests, with the c-ray-mt tests done using 32
+threads, but remember 32 threads might not be optimal for your system.
+
+**********************************************************************
+
+4. Submitting Results
+
+Do not send any results to John; instead, send all results to me at
+both of my email addresses (include "C-Ray" in the subject line):
+
+ mapesdhs at yahoo.com
+ sgidepot at blueyonder.co.uk
+
+Apart from the run-times reported by each test, please remember
+to state which tests are multithreaded and how many threads were
+used. Better still, just copy the on-screen text for each test.
+
+With respect to system information, state the type of system (name
+and/or model number), CPU details (name/model, type/speed/cache,
+no. of CPUs/cores), OS name/version (eg. for Linux, what name,
+kernel version/build), what compiler was used (name/version) and
+what extra options if any were employed. The online results page
+also shows the host name where available, but this is optional.
+
+Thus, for example, a system description might look like this:
+
+ SUN Fire X2100, Solaris 10, host name 'kobe'
+ Sun Studio 10 Compiler
+ AMD Opteron 175 2.2 GHz 1MB L2
+
+while for an SGI it might be:
+
+ SGI Octane2, IRIX 6.5.26m
+ MIPS Pro 7.4.3m (7.3 EOE)
+ Dual-R12000 400MHz (2MB L2)
+
+or a Windows system (in this case my own setup):
+
+ WinXP-32bit PC (SP2), Asrock AM2NF3 motherboard, 4GB DDR2/800 RAM
+ Athlon64 X2 6000+ 3.15GHz (overclocked)
+ Supplied x86 binary used (1 core only)
+
+You can also mention the system's RAM, disk, or anything else, but
+they're not essential.
+
+Note for SGI users: you can find out what eoe/dev compiler versions
+your system has installed by entering:
+
+ versions -b | grep compiler_
+
+eg. on my Octane2 this gives:
+
+ I compiler_dev 05/14/2004 Base Compiler Development Environment, 7.3
+ I compiler_eoe 07/13/2005 IRIX Standard Execution Environment (Base Compiler Headers and Libraries, 7.4.3m)
+
+**********************************************************************
+
+5. Background
+
+When I asked John about why he created C-Ray, he said:
+
+ This is just an extremely small program I did one day to figure
+ out how would the simplest raytracer program look like in the
+ least amount of code lines :) It's not useful for anything apart
+ from benchmarking.
+
+ As part of my BSc dissertation project I did a really big and
+ feature-full ray tracer, which could be useful, supporting:
+ programmable shading, network rendering, monte carlo rendering
+ algorithms, etc. But it's big and buggy, slow, and incomplete
+ because I was rushing to finish it the last minute before the
+ deadline (as always) :)
+
+ So I scrapped the damn thing after that, and I'm starting from
+ scratch with a new design if I finish it and it proves to be
+ sucessful I'll let you know :)"
+
+
+I also asked John why the best c-ray-mt results seem to be obtained
+with a number of threads that is much larger than the number of
+CPUs/cores in a system, to which he replied:
+
+ Ian wrote:
+ > I also suspect more threads means the balanced load between
+ > the two CPUs is less affected by the possible differences in
+ > complexity between threads.
+
+ Bingo, each thread takes a bunch of scanlines, if the relative
+ complexity of the rendering calculations between the bunches(sic)
+ is not equal, then one thread may spend much more time calculating
+ than another thread. Of course that doesn't necessarily mean that
+ one "CPU" ends up calculating much more than the other since the
+ threads are not "bound" to any CPU, each CPU takes one of the
+ available ready-to-run threads each timeslice. Anyway having more
+ threads evens it out. I would guess about 4 times as many threads
+ as the CPUs [multiplied by the no. of cores per CPU] would be enough.
+
+
+I also asked John if there was any element of overhead processing
+to handle the results of the multiple threads. He said:
+
+ There's no such overhead. Each thread gets a pointer to the
+ appropriate location of the framebuffer, and stores every pixel
+ as it is calculated directly. Also any processing afterwards
+ (output of the PPM image) is done *after* timing stops.
+
+
+See the Nekochan thread for more discussion about C-Ray, including
+further comments by John.
+
+**********************************************************************
+
+6. Appendix A: Invalid Tests
+
+Results for tests done with pre-run profiling/virtualisation compiler
+optimisations will NOT be accepted! What does this mean? Read on...
+
+Someone emailed me to say they had been able to halve the test run
+times by using the following compilation/execution sequence:
+
+ XC="gcc -O3 -ffast-math -fomit-frame-pointer c-ray-f.c
+ -finline-limit=10000 -ftree-vectorize -fwhole-program
+ -fbranch-probabilities -ffunction-sections -o c-ray-f -lm" && $XC
+ -fprofile-generate && ./run > /dev/null 2>&1 && $XC -fprofile-use
+ && ./run && ./run && ./run && ./run
+
+with ./run containing:
+
+ #!/bin/sh
+ cat scene | ./c-ray-f > foo2.ppm
+
+The explanation was as follows:
+
+ What this does is to create an executable with profiling and
+ virtualization instructions, execute it in order to create "real life"
+ information and then recompile it using that information to better
+ optimize it without the need of "guessing" (which is what usually a
+ plain -O3 does). Doing this speeds up the execution a lot. Another
+ important thing was to increase the inline limit from 600 (or whatever
+ the default value is) to something big (like 10000) so more functions
+ will be inlined instead of called. The usage of "-fwhole-program" tells
+ to gcc that the .c file is the one and only source code file for the
+ program, so it will use all functions as static and will make all
+ "inline-able" functions, inline. This is another great speedup :-).
+
+My problem with this is that, by definition, the test has to be run
+multiple times in order to provide execution profiling data used to
+optimise the test for the final run. Thus, the real total run time spent
+to obtain the final result was not that much less or perhaps longer than
+just running the test a single time without this sort of execution
+profiling.
+
+I asked John about these optimisations; he said:
+
+ Hahaha :)
+ Yes I bet the biggest advantage was the profiling run and use of that
+ profiling information, and maybe also the whole program optimizations.
+ Both of which can't be done in real-life programs :)
+
+ The profiling information helps the compiler issue branch prediction
+ hints to the processor, and also do prefetches. The first one makes a
+ lot of difference in modern x86 CPUs with their huge execution
+ pipelines. If the branch prediction fails, you end up flushing the
+ pipeline and backtracking tens of instructions. Explicit prefetching,
+ would also make a big difference if the data set was bigger. I don't
+ think it helps here.
+
+This method of optimisation is certainly interesting, but I don't think
+it's appropriate for the C-Ray tests.
+
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/c-ray.c
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/c-ray.c (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/c-ray.c 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,671 @@
+/* c-ray-mt - a simple multithreaded raytracing filter.
+ * Copyright (C) 2006 John Tsiombikas <nuclear at siggraph.org>
+ *
+ * You are free to use, modify and redistribute this program under the
+ * terms of the GNU General Public License v2 or (at your option) later.
+ * see "http://www.gnu.org/licenses/gpl.txt" for details.
+ * ---------------------------------------------------------------------
+ * Usage:
+ * compile: just type make
+ * (add any arch-specific optimizations for your compiler in CFLAGS first)
+ * run: cat scene | ./c-ray-mt [-t num-threads] >foo.ppm
+ * (on broken systems such as windows try: c-ray-mt -i scene -o foo.ppm)
+ * enjoy: display foo.ppm
+ * (with imagemagick, or use your favorite image viewer)
+ * ---------------------------------------------------------------------
+ * Scene file format:
+ * # sphere (many)
+ * s x y z rad r g b shininess reflectivity
+ * # light (many)
+ * l x y z
+ * # camera (one)
+ * c x y z fov tx ty tz
+ * ---------------------------------------------------------------------
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <ctype.h>
+#include <errno.h>
+#include <pthread.h>
+
+#define VER_MAJOR 1
+#define VER_MINOR 1
+#define VER_STR "c-ray-mt v%d.%d\n"
+
+#if !defined(unix) && !defined(__unix__)
+#ifdef __MACH__
+#define unix 1
+#define __unix__ 1
+#endif /* __MACH__ */
+#endif /* unix */
+
+/* find the appropriate way to define explicitly sized types */
+/* for C99 or GNU libc (also mach's libc) we can use stdint.h */
+#if (__STDC_VERSION__ >= 199900) || defined(__GLIBC__) || defined(__MACH__)
+#include <stdint.h>
+#elif defined(unix) || defined(__unix__) /* some UNIX systems have them in sys/types.h */
+#include <sys/types.h>
+#elif defined(__WIN32__) || defined(WIN32) /* the nameless one */
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int32 uint32_t;
+#endif /* sized type detection */
+
+struct vec3 {
+ double x, y, z;
+};
+
+struct ray {
+ struct vec3 orig, dir;
+};
+
+struct material {
+ struct vec3 col; /* color */
+ double spow; /* specular power */
+ double refl; /* reflection intensity */
+};
+
+struct sphere {
+ struct vec3 pos;
+ double rad;
+ struct material mat;
+ struct sphere *next;
+};
+
+struct spoint {
+ struct vec3 pos, normal, vref; /* position, normal and view reflection */
+ double dist; /* parametric distance of intersection along the ray */
+};
+
+struct camera {
+ struct vec3 pos, targ;
+ double fov;
+};
+
+struct thread_data {
+ pthread_t tid;
+ int sl_start, sl_count;
+
+ uint32_t *pixels;
+};
+
+void render_scanline(int xsz, int ysz, int sl, uint32_t *fb, int samples);
+struct vec3 trace(struct ray ray, int depth);
+struct vec3 shade(struct sphere *obj, struct spoint *sp, int depth);
+struct vec3 reflect(struct vec3 v, struct vec3 n);
+struct vec3 cross_product(struct vec3 v1, struct vec3 v2);
+struct ray get_primary_ray(int x, int y, int sample);
+struct vec3 get_sample_pos(int x, int y, int sample);
+struct vec3 jitter(int x, int y, int s);
+int ray_sphere(const struct sphere *sph, struct ray ray, struct spoint *sp);
+void load_scene(FILE *fp);
+unsigned long get_msec(void);
+
+void *thread_func(void *tdata);
+
+#define MAX_LIGHTS 16 /* maximum number of lights */
+#define RAY_MAG 1000.0 /* trace rays of this magnitude */
+#define MAX_RAY_DEPTH 5 /* raytrace recursion limit */
+#define FOV 0.78539816 /* field of view in rads (pi/4) */
+#define HALF_FOV (FOV * 0.5)
+#define ERR_MARGIN 1e-6 /* an arbitrary error margin to avoid surface acne */
+
+/* bit-shift ammount for packing each color into a 32bit uint */
+#ifdef LITTLE_ENDIAN
+#define RSHIFT 16
+#define BSHIFT 0
+#else /* big endian */
+#define RSHIFT 0
+#define BSHIFT 16
+#endif /* endianess */
+#define GSHIFT 8 /* this is the same in both byte orders */
+
+/* some helpful macros... */
+#define SQ(x) ((x) * (x))
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define DOT(a, b) ((a).x * (b).x + (a).y * (b).y + (a).z * (b).z)
+#define NORMALIZE(a) do {\
+ double len = sqrt(DOT(a, a));\
+ (a).x /= len; (a).y /= len; (a).z /= len;\
+} while(0);
+
+/* global state */
+int xres = 800;
+int yres = 600;
+int rays_per_pixel = 1;
+double aspect = 1.333333;
+struct sphere *obj_list;
+struct vec3 lights[MAX_LIGHTS];
+int lnum = 0;
+struct camera cam;
+
+int thread_num = 1;
+struct thread_data *threads;
+
+int start = 0;
+pthread_mutex_t start_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t start_cond = PTHREAD_COND_INITIALIZER;
+
+#define NRAN 1024
+#define MASK (NRAN - 1)
+struct vec3 urand[NRAN];
+int irand[NRAN];
+
+const char *usage = {
+ "Usage: c-ray-mt [options]\n"
+ " Reads a scene file from stdin, writes the image to stdout, and stats to stderr.\n\n"
+ "Options:\n"
+ " -t <num> how many threads to use (default: 1)\n"
+ " -s WxH where W is the width and H the height of the image\n"
+ " -r <rays> shoot <rays> rays per pixel (antialiasing)\n"
+ " -i <file> read from <file> instead of stdin\n"
+ " -o <file> write to <file> instead of stdout\n"
+ " -h this help screen\n\n"
+};
+
+
+
+int main(int argc, char **argv) {
+ int i;
+ unsigned long rend_time, start_time;
+ uint32_t *pixels;
+ double sl, sl_per_thread;
+ FILE *infile = stdin, *outfile = stdout;
+
+ for(i=1; i<argc; i++) {
+ if(argv[i][0] == '-' && argv[i][2] == 0) {
+ char *sep;
+ switch(argv[i][1]) {
+ case 't':
+ if(!isdigit(argv[++i][0])) {
+ fprintf(stderr, "-t mus be followed by the number of worker threads to spawn\n");
+ return EXIT_FAILURE;
+ }
+ thread_num = atoi(argv[i]);
+ if(!thread_num) {
+ fprintf(stderr, "invalid number of threads specified: %d\n", thread_num);
+ return EXIT_FAILURE;
+ }
+ break;
+
+ case 's':
+ if(!isdigit(argv[++i][0]) || !(sep = strchr(argv[i], 'x')) || !isdigit(*(sep + 1))) {
+ fputs("-s must be followed by something like \"640x480\"\n", stderr);
+ return EXIT_FAILURE;
+ }
+ xres = atoi(argv[i]);
+ yres = atoi(sep + 1);
+ aspect = (double)xres / (double)yres;
+ break;
+
+ case 'i':
+ if(!(infile = fopen(argv[++i], "rb"))) {
+ fprintf(stderr, "failed to open input file %s: %s\n", argv[i], strerror(errno));
+ return EXIT_FAILURE;
+ }
+ break;
+
+ case 'o':
+ if(!(outfile = fopen(argv[++i], "wb"))) {
+ fprintf(stderr, "failed to open output file %s: %s\n", argv[i], strerror(errno));
+ return EXIT_FAILURE;
+ }
+ break;
+
+ case 'r':
+ if(!isdigit(argv[++i][0])) {
+ fputs("-r must be followed by a number (rays per pixel)\n", stderr);
+ return EXIT_FAILURE;
+ }
+ rays_per_pixel = atoi(argv[i]);
+ break;
+
+ case 'h':
+ fputs(usage, stdout);
+ return 0;
+
+ default:
+ fprintf(stderr, "unrecognized argument: %s\n", argv[i]);
+ fputs(usage, stderr);
+ return EXIT_FAILURE;
+ }
+ } else {
+ fprintf(stderr, "unrecognized argument: %s\n", argv[i]);
+ fputs(usage, stderr);
+ return EXIT_FAILURE;
+ }
+ }
+
+ if(!(pixels = malloc(xres * yres * sizeof *pixels))) {
+ perror("pixel buffer allocation failed");
+ return EXIT_FAILURE;
+ }
+ load_scene(infile);
+
+ /* initialize the random number tables for the jitter */
+ for(i=0; i<NRAN; i++) urand[i].x = (double)rand() / RAND_MAX - 0.5;
+ for(i=0; i<NRAN; i++) urand[i].y = (double)rand() / RAND_MAX - 0.5;
+ for(i=0; i<NRAN; i++) irand[i] = (int)(NRAN * ((double)rand() / RAND_MAX));
+
+ if(thread_num > yres) {
+ fprintf(stderr, "more threads than scanlines specified, reducing number of threads to %d\n", yres);
+ thread_num = yres;
+ }
+
+ if(!(threads = malloc(thread_num * sizeof *threads))) {
+ perror("failed to allocate thread table");
+ return EXIT_FAILURE;
+ }
+
+ sl = 0.0;
+ sl_per_thread = (double)yres / (double)thread_num;
+ for(i=0; i<thread_num; i++) {
+ threads[i].sl_start = (int)sl;
+ sl += sl_per_thread;
+ threads[i].sl_count = (int)sl - threads[i].sl_start;
+ threads[i].pixels = pixels;
+
+ if(pthread_create(&threads[i].tid, 0, thread_func, &threads[i]) != 0) {
+ perror("failed to spawn thread");
+ return EXIT_FAILURE;
+ }
+ }
+ threads[thread_num - 1].sl_count = yres - threads[thread_num - 1].sl_start;
+
+ fprintf(stderr, VER_STR, VER_MAJOR, VER_MINOR);
+
+ pthread_mutex_lock(&start_mutex);
+ start_time = get_msec();
+ start = 1;
+ pthread_cond_broadcast(&start_cond);
+ pthread_mutex_unlock(&start_mutex);
+
+ for(i=0; i<thread_num; i++) {
+ pthread_join(threads[i].tid, 0);
+ }
+ rend_time = get_msec() - start_time;
+
+ /* output statistics to stderr */
+ fprintf(stderr, "Rendering took: %lu seconds (%lu milliseconds)\n", rend_time / 1000, rend_time);
+
+ /* output the image */
+ fprintf(outfile, "P6\n%d %d\n255\n", xres, yres);
+ for(i=0; i<xres * yres; i++) {
+ fputc((pixels[i] >> RSHIFT) & 0xff, outfile);
+ fputc((pixels[i] >> GSHIFT) & 0xff, outfile);
+ fputc((pixels[i] >> BSHIFT) & 0xff, outfile);
+ }
+ fflush(outfile);
+
+ if(infile != stdin) fclose(infile);
+ if(outfile != stdout) fclose(outfile);
+ return 0;
+}
+
+/* render a frame of xsz/ysz dimensions into the provided framebuffer */
+void render_scanline(int xsz, int ysz, int sl, uint32_t *fb, int samples) {
+ int i, s;
+ double rcp_samples = 1.0 / (double)samples;
+
+ for(i=0; i<xsz; i++) {
+ double r, g, b;
+ r = g = b = 0.0;
+
+ for(s=0; s<samples; s++) {
+ struct vec3 col = trace(get_primary_ray(i, sl, s), 0);
+ r += col.x;
+ g += col.y;
+ b += col.z;
+ }
+
+ r = r * rcp_samples;
+ g = g * rcp_samples;
+ b = b * rcp_samples;
+
+ fb[sl * xsz + i] = ((uint32_t)(MIN(r, 1.0) * 255.0) & 0xff) << RSHIFT |
+ ((uint32_t)(MIN(g, 1.0) * 255.0) & 0xff) << GSHIFT |
+ ((uint32_t)(MIN(b, 1.0) * 255.0) & 0xff) << BSHIFT;
+ }
+}
+
+/* trace a ray throught the scene recursively (the recursion happens through
+ * shade() to calculate reflection rays if necessary).
+ */
+struct vec3 trace(struct ray ray, int depth) {
+ struct vec3 col;
+ struct spoint sp, nearest_sp;
+ struct sphere *nearest_obj = 0;
+ struct sphere *iter = obj_list->next;
+
+ /* if we reached the recursion limit, bail out */
+ if(depth >= MAX_RAY_DEPTH) {
+ col.x = col.y = col.z = 0.0;
+ return col;
+ }
+
+ /* find the nearest intersection ... */
+ while(iter) {
+ if(ray_sphere(iter, ray, &sp)) {
+ if(!nearest_obj || sp.dist < nearest_sp.dist) {
+ nearest_obj = iter;
+ nearest_sp = sp;
+ }
+ }
+ iter = iter->next;
+ }
+
+ /* and perform shading calculations as needed by calling shade() */
+ if(nearest_obj) {
+ col = shade(nearest_obj, &nearest_sp, depth);
+ } else {
+ col.x = col.y = col.z = 0.0;
+ }
+
+ return col;
+}
+
+/* Calculates direct illumination with the phong reflectance model.
+ * Also handles reflections by calling trace again, if necessary.
+ */
+struct vec3 shade(struct sphere *obj, struct spoint *sp, int depth) {
+ int i;
+ struct vec3 col = {0, 0, 0};
+
+ /* for all lights ... */
+ for(i=0; i<lnum; i++) {
+ double ispec, idiff;
+ struct vec3 ldir;
+ struct ray shadow_ray;
+ struct sphere *iter = obj_list->next;
+ int in_shadow = 0;
+
+ ldir.x = lights[i].x - sp->pos.x;
+ ldir.y = lights[i].y - sp->pos.y;
+ ldir.z = lights[i].z - sp->pos.z;
+
+ shadow_ray.orig = sp->pos;
+ shadow_ray.dir = ldir;
+
+ /* shoot shadow rays to determine if we have a line of sight with the light */
+ while(iter) {
+ if(ray_sphere(iter, shadow_ray, 0)) {
+ in_shadow = 1;
+ break;
+ }
+ iter = iter->next;
+ }
+
+ /* and if we're not in shadow, calculate direct illumination with the phong model. */
+ if(!in_shadow) {
+ NORMALIZE(ldir);
+
+ idiff = MAX(DOT(sp->normal, ldir), 0.0);
+ ispec = obj->mat.spow > 0.0 ? pow(MAX(DOT(sp->vref, ldir), 0.0), obj->mat.spow) : 0.0;
+
+ col.x += idiff * obj->mat.col.x + ispec;
+ col.y += idiff * obj->mat.col.y + ispec;
+ col.z += idiff * obj->mat.col.z + ispec;
+ }
+ }
+
+ /* Also, if the object is reflective, spawn a reflection ray, and call trace()
+ * to calculate the light arriving from the mirror direction.
+ */
+ if(obj->mat.refl > 0.0) {
+ struct ray ray;
+ struct vec3 rcol;
+
+ ray.orig = sp->pos;
+ ray.dir = sp->vref;
+ ray.dir.x *= RAY_MAG;
+ ray.dir.y *= RAY_MAG;
+ ray.dir.z *= RAY_MAG;
+
+ rcol = trace(ray, depth + 1);
+ col.x += rcol.x * obj->mat.refl;
+ col.y += rcol.y * obj->mat.refl;
+ col.z += rcol.z * obj->mat.refl;
+ }
+
+ return col;
+}
+
+/* calculate reflection vector */
+struct vec3 reflect(struct vec3 v, struct vec3 n) {
+ struct vec3 res;
+ double dot = v.x * n.x + v.y * n.y + v.z * n.z;
+ res.x = -(2.0 * dot * n.x - v.x);
+ res.y = -(2.0 * dot * n.y - v.y);
+ res.z = -(2.0 * dot * n.z - v.z);
+ return res;
+}
+
+struct vec3 cross_product(struct vec3 v1, struct vec3 v2) {
+ struct vec3 res;
+ res.x = v1.y * v2.z - v1.z * v2.y;
+ res.y = v1.z * v2.x - v1.x * v2.z;
+ res.z = v1.x * v2.y - v1.y * v2.x;
+ return res;
+}
+
+/* determine the primary ray corresponding to the specified pixel (x, y) */
+struct ray get_primary_ray(int x, int y, int sample) {
+ struct ray ray;
+ float m[3][3];
+ struct vec3 i, j = {0, 1, 0}, k, dir, orig, foo;
+
+ k.x = cam.targ.x - cam.pos.x;
+ k.y = cam.targ.y - cam.pos.y;
+ k.z = cam.targ.z - cam.pos.z;
+ NORMALIZE(k);
+
+ i = cross_product(j, k);
+ j = cross_product(k, i);
+ m[0][0] = i.x; m[0][1] = j.x; m[0][2] = k.x;
+ m[1][0] = i.y; m[1][1] = j.y; m[1][2] = k.y;
+ m[2][0] = i.z; m[2][1] = j.z; m[2][2] = k.z;
+
+ ray.orig.x = ray.orig.y = ray.orig.z = 0.0;
+ ray.dir = get_sample_pos(x, y, sample);
+ ray.dir.z = 1.0 / HALF_FOV;
+ ray.dir.x *= RAY_MAG;
+ ray.dir.y *= RAY_MAG;
+ ray.dir.z *= RAY_MAG;
+
+ dir.x = ray.dir.x + ray.orig.x;
+ dir.y = ray.dir.y + ray.orig.y;
+ dir.z = ray.dir.z + ray.orig.z;
+ foo.x = dir.x * m[0][0] + dir.y * m[0][1] + dir.z * m[0][2];
+ foo.y = dir.x * m[1][0] + dir.y * m[1][1] + dir.z * m[1][2];
+ foo.z = dir.x * m[2][0] + dir.y * m[2][1] + dir.z * m[2][2];
+
+ orig.x = ray.orig.x * m[0][0] + ray.orig.y * m[0][1] + ray.orig.z * m[0][2] + cam.pos.x;
+ orig.y = ray.orig.x * m[1][0] + ray.orig.y * m[1][1] + ray.orig.z * m[1][2] + cam.pos.y;
+ orig.z = ray.orig.x * m[2][0] + ray.orig.y * m[2][1] + ray.orig.z * m[2][2] + cam.pos.z;
+
+ ray.orig = orig;
+ ray.dir.x = foo.x + orig.x;
+ ray.dir.y = foo.y + orig.y;
+ ray.dir.z = foo.z + orig.z;
+
+ return ray;
+}
+
+
+struct vec3 get_sample_pos(int x, int y, int sample) {
+ struct vec3 pt;
+ static double sf = 0.0;
+
+ if(sf == 0.0) {
+ sf = 1.5 / (double)xres;
+ }
+
+ pt.x = ((double)x / (double)xres) - 0.5;
+ pt.y = -(((double)y / (double)yres) - 0.65) / aspect;
+
+ if(sample) {
+ struct vec3 jt = jitter(x, y, sample);
+ pt.x += jt.x * sf;
+ pt.y += jt.y * sf / aspect;
+ }
+ return pt;
+}
+
+/* jitter function taken from Graphics Gems I. */
+struct vec3 jitter(int x, int y, int s) {
+ struct vec3 pt;
+ pt.x = urand[(x + (y << 2) + irand[(x + s) & MASK]) & MASK].x;
+ pt.y = urand[(y + (x << 2) + irand[(y + s) & MASK]) & MASK].y;
+ return pt;
+}
+
+/* Calculate ray-sphere intersection, and return {1, 0} to signify hit or no hit.
+ * Also the surface point parameters like position, normal, etc are returned through
+ * the sp pointer if it is not NULL.
+ */
+int ray_sphere(const struct sphere *sph, struct ray ray, struct spoint *sp) {
+ double a, b, c, d, sqrt_d, t1, t2;
+
+ a = SQ(ray.dir.x) + SQ(ray.dir.y) + SQ(ray.dir.z);
+ b = 2.0 * ray.dir.x * (ray.orig.x - sph->pos.x) +
+ 2.0 * ray.dir.y * (ray.orig.y - sph->pos.y) +
+ 2.0 * ray.dir.z * (ray.orig.z - sph->pos.z);
+ c = SQ(sph->pos.x) + SQ(sph->pos.y) + SQ(sph->pos.z) +
+ SQ(ray.orig.x) + SQ(ray.orig.y) + SQ(ray.orig.z) +
+ 2.0 * (-sph->pos.x * ray.orig.x - sph->pos.y * ray.orig.y - sph->pos.z * ray.orig.z) - SQ(sph->rad);
+
+ if((d = SQ(b) - 4.0 * a * c) < 0.0) return 0;
+
+ sqrt_d = sqrt(d);
+ t1 = (-b + sqrt_d) / (2.0 * a);
+ t2 = (-b - sqrt_d) / (2.0 * a);
+
+ if((t1 < ERR_MARGIN && t2 < ERR_MARGIN) || (t1 > 1.0 && t2 > 1.0)) return 0;
+
+ if(sp) {
+ if(t1 < ERR_MARGIN) t1 = t2;
+ if(t2 < ERR_MARGIN) t2 = t1;
+ sp->dist = t1 < t2 ? t1 : t2;
+
+ sp->pos.x = ray.orig.x + ray.dir.x * sp->dist;
+ sp->pos.y = ray.orig.y + ray.dir.y * sp->dist;
+ sp->pos.z = ray.orig.z + ray.dir.z * sp->dist;
+
+ sp->normal.x = (sp->pos.x - sph->pos.x) / sph->rad;
+ sp->normal.y = (sp->pos.y - sph->pos.y) / sph->rad;
+ sp->normal.z = (sp->pos.z - sph->pos.z) / sph->rad;
+
+ sp->vref = reflect(ray.dir, sp->normal);
+ NORMALIZE(sp->vref);
+ }
+ return 1;
+}
+
+/* Load the scene from an extremely simple scene description file */
+#define DELIM " \t\n"
+void load_scene(FILE *fp) {
+ char line[256], *ptr, type;
+
+ obj_list = malloc(sizeof(struct sphere));
+ obj_list->next = 0;
+
+ while((ptr = fgets(line, 256, fp))) {
+ int i;
+ struct vec3 pos, col;
+ double rad, spow, refl;
+
+ while(*ptr == ' ' || *ptr == '\t') ptr++;
+ if(*ptr == '#' || *ptr == '\n') continue;
+
+ if(!(ptr = strtok(line, DELIM))) continue;
+ type = *ptr;
+
+ for(i=0; i<3; i++) {
+ if(!(ptr = strtok(0, DELIM))) break;
+ *((double*)&pos.x + i) = atof(ptr);
+ }
+
+ if(type == 'l') {
+ lights[lnum++] = pos;
+ continue;
+ }
+
+ if(!(ptr = strtok(0, DELIM))) continue;
+ rad = atof(ptr);
+
+ for(i=0; i<3; i++) {
+ if(!(ptr = strtok(0, DELIM))) break;
+ *((double*)&col.x + i) = atof(ptr);
+ }
+
+ if(type == 'c') {
+ cam.pos = pos;
+ cam.targ = col;
+ cam.fov = rad;
+ continue;
+ }
+
+ if(!(ptr = strtok(0, DELIM))) continue;
+ spow = atof(ptr);
+
+ if(!(ptr = strtok(0, DELIM))) continue;
+ refl = atof(ptr);
+
+ if(type == 's') {
+ struct sphere *sph = malloc(sizeof *sph);
+ sph->next = obj_list->next;
+ obj_list->next = sph;
+
+ sph->pos = pos;
+ sph->rad = rad;
+ sph->mat.col = col;
+ sph->mat.spow = spow;
+ sph->mat.refl = refl;
+ } else {
+ fprintf(stderr, "unknown type: %c\n", type);
+ }
+ }
+}
+
+
+/* provide a millisecond-resolution timer for each system */
+#if defined(unix) || defined(__unix__)
+#include <time.h>
+#include <sys/time.h>
+unsigned long get_msec(void) {
+ static struct timeval timeval, first_timeval;
+
+ gettimeofday(&timeval, 0);
+ if(first_timeval.tv_sec == 0) {
+ first_timeval = timeval;
+ return 0;
+ }
+ return (timeval.tv_sec - first_timeval.tv_sec) * 1000 + (timeval.tv_usec - first_timeval.tv_usec) / 1000;
+}
+#elif defined(__WIN32__) || defined(WIN32)
+#include <windows.h>
+unsigned long get_msec(void) {
+ return GetTickCount();
+}
+#else
+#error "I don't know how to measure time on your platform"
+#endif
+
+void *thread_func(void *tdata) {
+ int i;
+ struct thread_data *td = (struct thread_data*)tdata;
+
+ pthread_mutex_lock(&start_mutex);
+ while(!start) {
+ pthread_cond_wait(&start_cond, &start_mutex);
+ }
+ pthread_mutex_unlock(&start_mutex);
+
+ for(i=0; i<td->sl_count; i++) {
+ render_scanline(xres, yres, i + td->sl_start, td->pixels, rays_per_pixel);
+ }
+
+ return 0;
+}
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/scene.cr
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/scene.cr (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/scene.cr 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,18 @@
+# spheres
+# position radius color shininess reflectivity
+s -1.5 -0.3 -1 0.7 1.0 0.2 0.05 50.0 0.3
+s 1.5 -0.4 0 0.6 0.1 0.85 1.0 50.0 0.4
+
+# walls
+s 0 -1000 2 999 0.1 0.2 0.6 80.0 0.8
+
+# bouncing ball
+s 0 0 2 1 1.0 0.5 0.1 60.0 0.7
+
+# lights...
+l -50 100 -50
+l 40 40 150
+
+# camera (there can be only one!)
+# position FOV target
+c 0 6 -17 45 0 -1 0
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/sphfract.cr
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/sphfract.cr (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/sphfract.cr 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,192 @@
+s 0 0 0 1.0 0.25 0.25 0.25 50.0 0.65
+s 1.4 0 0 0.4 0.25 0.25 0.25 50.0 0.65
+s 1.96 0 0 0.16 0.25 0.25 0.25 50.0 0.65
+s 2.184 0 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.96 0.224 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.96 -0.224 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.96 0 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.96 0 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0.56 0 0.16 0.25 0.25 0.25 50.0 0.65
+s 1.624 0.56 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.176 0.56 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0.784 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0.56 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0.56 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 -0.56 0 0.16 0.25 0.25 0.25 50.0 0.65
+s 1.624 -0.56 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.176 -0.56 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 -0.784 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 -0.56 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 -0.56 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0 0.56 0.16 0.25 0.25 0.25 50.0 0.65
+s 1.624 0 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.176 0 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0.224 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 -0.224 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0 0.784 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0 -0.56 0.16 0.25 0.25 0.25 50.0 0.65
+s 1.624 0 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.176 0 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0.224 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 -0.224 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 1.4 0 -0.784 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0 0 0.4 0.25 0.25 0.25 50.0 0.65
+s -1.96 0 0 0.16 0.25 0.25 0.25 50.0 0.65
+s -2.184 0 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.96 0.224 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.96 -0.224 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.96 0 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.96 0 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0.56 0 0.16 0.25 0.25 0.25 50.0 0.65
+s -1.176 0.56 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.624 0.56 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0.784 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0.56 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0.56 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 -0.56 0 0.16 0.25 0.25 0.25 50.0 0.65
+s -1.176 -0.56 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.624 -0.56 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 -0.784 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 -0.56 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 -0.56 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0 0.56 0.16 0.25 0.25 0.25 50.0 0.65
+s -1.176 0 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.624 0 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0.224 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 -0.224 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0 0.784 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0 -0.56 0.16 0.25 0.25 0.25 50.0 0.65
+s -1.176 0 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.624 0 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0.224 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 -0.224 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -1.4 0 -0.784 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.4 0 0.4 0.25 0.25 0.25 50.0 0.65
+s 0.56 1.4 0 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.784 1.4 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 1.624 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 1.176 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 1.4 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 1.4 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 1.4 0 0.16 0.25 0.25 0.25 50.0 0.65
+s -0.784 1.4 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 1.624 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 1.176 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 1.4 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 1.4 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.96 0 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 1.96 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 1.96 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 2.184 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.96 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.96 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.4 0.56 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 1.4 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 1.4 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.624 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.176 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.4 0.784 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.4 -0.56 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 1.4 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 1.4 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.624 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.176 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 1.4 -0.784 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.4 0 0.4 0.25 0.25 0.25 50.0 0.65
+s 0.56 -1.4 0 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.784 -1.4 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 -1.176 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 -1.624 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 -1.4 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 -1.4 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 -1.4 0 0.16 0.25 0.25 0.25 50.0 0.65
+s -0.784 -1.4 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 -1.176 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 -1.624 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 -1.4 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 -1.4 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.96 0 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 -1.96 0 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 -1.96 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -2.184 0 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.96 0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.96 -0.224 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.4 0.56 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 -1.4 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 -1.4 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.176 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.624 0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.4 0.784 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.4 -0.56 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 -1.4 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 -1.4 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.176 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.624 -0.56 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -1.4 -0.784 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0 1.4 0.4 0.25 0.25 0.25 50.0 0.65
+s 0.56 0 1.4 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.784 0 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 0.224 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 -0.224 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 0 1.624 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 0 1.176 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 0 1.4 0.16 0.25 0.25 0.25 50.0 0.65
+s -0.784 0 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 0.224 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 -0.224 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 0 1.624 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 0 1.176 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.56 1.4 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 0.56 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 0.56 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.784 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.56 1.624 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.56 1.176 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.56 1.4 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 -0.56 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 -0.56 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.784 1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.56 1.624 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.56 1.176 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0 1.96 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 0 1.96 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 0 1.96 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.224 1.96 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.224 1.96 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0 2.184 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0 -1.4 0.4 0.25 0.25 0.25 50.0 0.65
+s 0.56 0 -1.4 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.784 0 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 0.224 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 -0.224 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 0 -1.176 0.064 0.25 0.25 0.25 50.0 0.65
+s 0.56 0 -1.624 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 0 -1.4 0.16 0.25 0.25 0.25 50.0 0.65
+s -0.784 0 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 0.224 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 -0.224 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 0 -1.176 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.56 0 -1.624 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.56 -1.4 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 0.56 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 0.56 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.784 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.56 -1.176 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.56 -1.624 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.56 -1.4 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 -0.56 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 -0.56 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.784 -1.4 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.56 -1.176 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.56 -1.624 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0 -1.96 0.16 0.25 0.25 0.25 50.0 0.65
+s 0.224 0 -1.96 0.064 0.25 0.25 0.25 50.0 0.65
+s -0.224 0 -1.96 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0.224 -1.96 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -0.224 -1.96 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 0 -2.184 0.064 0.25 0.25 0.25 50.0 0.65
+s 0 -10002.25 0 10000 0.2 0.35 0.5 80.0 0.4
+s 0 10100.00 0 10000 0.5 0.2 0.1 40.0 0.0
+l -50 68 -50
+l 40 40 150
+c -7 6 -12 45 0 -0.65 0
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,2 @@
+#!/bin/sh
+cat scene.cr | ./c-ray > scene.ppm
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/Makefile
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/Makefile (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/Makefile 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,59 @@
+bin = md
+
+CC = gcc
+INCLUDES :=
+OPTZ = -O0
+OPTS = -O3 -ffast-math
+CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 $(INCLUDES)
+
+SRC = main.c md.c
+OBJ = $(patsubst %.c,%.o,$(SRC))
+
+
+
+all: $(bin)
+
+# Link stand-alone executable:
+$(bin): $(OBJ)
+ $(CC) -o $(@) $(OBJ) -lm
+
+# Swift/T integration:
+
+USE_SWIFT = 1
+ifeq ($(USE_SWIFT),1)
+
+TCL_HOME = $(HOME)/sfw/tcl-8.6.0
+INCLUDES += -I $(TCL_HOME)/include
+TCLSH = $(TCL_HOME)/bin/tclsh8.6
+
+swift-pkg: pkgIndex.tcl
+
+md_wrap.c: md.i md.h
+ swig $(<)
+ sed -i s/Md_Init/Tclmd_Init/ $(@)
+
+libtclmd.so: md_wrap.o $(OBJ)
+ gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6
+
+pkgIndex.tcl: libtclmd.so
+ LEAF_PKG=md LEAF_VERSION=0.0 \
+ LEAF_SO=$(<) LEAF_TCL=md.tcl \
+ $(TCLSH) ./make-package.tcl > $(@)
+
+clean::
+ rm -fv pkgIndex.tcl libtclmd.so md_wrap.c
+
+endif # Swift/T
+
+.PHONY: clean
+clean::
+ rm -fv $(OBJ) $(bin)
+
+.PHONY: install
+install:
+ cp $(bin) ../../bin/$(bin)
+
+.PHONY: uninstall
+uninstall:
+ rm -f ../../bin/$(bin)
+
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,2 @@
+#! /bin/sh
+rm -f md??.trj md.dat
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/main.c
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/main.c (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/main.c 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,219 @@
+
+/*
+ * main.c
+ *
+ * Created on: Aug 13, 2014
+ * Author: wozniak
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "md.h"
+
+
+char *outfile = "md.dat";
+char *trjfile = "md.trj";
+
+
+/******************************************************************************/
+
+int main ( int argc, char *argv[] )
+
+/******************************************************************************/
+/*
+ Purpose:
+
+ MAIN is the main program for MD.
+
+ Discussion:
+
+ MD implements a simple molecular dynamics simulation.
+
+ The velocity Verlet time integration scheme is used.
+
+ The particles interact with a central pair potential.
+
+ Usage:
+
+ md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset seed outFile trajectoryFile
+ where
+ * nd is the spatial dimension (2 or 3);
+ * np is the number of particles (500, for instance);
+ * step_num is the number of time steps (500, for instance);
+ * print_step_num is the number of snapshot prints (10 for instance);
+ * dt is size of timestep;
+ * mass is particle mass;
+ * printinfo is a string to append to each particle coord
+ * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME)
+ * seed sets the initial configuration
+
+
+ Licensing:
+
+ This code is distributed under the GNU LGPL license.
+
+ Modified:
+
+ 05 November 2010
+
+ Author:
+
+ Original FORTRAN90 version by Bill Magro.
+ C version by John Burkardt.
+
+ Parameters:
+
+ None
+*/
+{
+
+ double ctime;
+ double ctime1;
+ double ctime2;
+ double dt = 0.0001;
+ int i;
+ int id;
+ double mass = 1.0 * .0001;
+ int nd;
+ int np;
+
+ int seed = 123456789;
+ int step;
+ int step_num;
+ int step_print;
+ int step_print_index = 0;
+ int step_print_num = 10;
+ double *vel;
+
+ timestamp ( );
+ printf ( "\n" );
+ printf ( "MD\n" );
+ printf ( " C version\n" );
+ printf ( " A molecular dynamics program.\n" );
+/*
+ Get the spatial dimension.
+*/
+ if ( 1 < argc )
+ {
+ nd = atoi ( argv[1] );
+ }
+ else
+ {
+ printf ( "\n" );
+ printf ( " Enter ND, the spatial dimension (2 or 3).\n" );
+ scanf ( "%d", &nd );
+ }
+//
+// Get the number of points.
+//
+ if ( 2 < argc )
+ {
+ np = atoi ( argv[2] );
+ }
+ else
+ {
+ printf ( "\n" );
+ printf ( " Enter NP, the number of points (500, for instance).\n" );
+ scanf ( "%d", &np );
+ }
+//
+// Get the number of time steps.
+//
+ if ( 3 < argc )
+ {
+ step_num = atoi ( argv[3] );
+ }
+ else
+ {
+ printf ( "\n" );
+ printf ( " Enter ND, the number of time steps (500 or 1000, for instance).\n" );
+ scanf ( "%d", &step_num );
+ }
+ /*
+ Get any additional args (command-line only)
+ md nd np step_num [ step__print_num dt mass printinfo scale_factor scale_offset randomseed outfile trjfile ]
+ */
+ if ( 4 < argc )
+ {
+ step_print_num = atoi ( argv[4] );
+ }
+ if ( 5 < argc )
+ {
+ dt = atof ( argv[5] );
+ }
+ if ( 6 < argc )
+ {
+ mass = atof ( argv[6] );
+ }
+ if ( 7 < argc )
+ {
+ printinfo = ( argv[7] );
+ }
+ if ( 8 < argc )
+ {
+ scale_factor = atof ( argv[8] );
+ }
+ if ( 9 < argc )
+ {
+ scale_offset = atof ( argv[9] );
+ }
+ if ( 10 < argc )
+ {
+ seed = atof ( argv[10] );
+ }
+ if ( 11 < argc )
+ {
+ outfile = argv[11];
+ }
+ if ( 12 < argc )
+ {
+ trjfile = argv[12];
+ }
+
+/*
+ Report.
+*/
+ printf ( "\n" );
+ printf ( " MD: Argument count: %d\n", argc );
+ printf ( " ND, the spatial dimension, is %d\n", nd );
+ printf ( " NP, the number of particles in the simulation, is %d\n", np );
+ printf ( " STEP_NUM, the number of time steps, is %d\n", step_num );
+ printf ( " STEP_PRINT_NUM, the number of snapshots to print, is %d\n", step_print_num );
+ printf ( " DT, the size of each time step, is %f\n", dt );
+ printf ( " MASS, the particle mass, is %f\n", mass );
+ printf ( " PRINTINFO, the pass-through info to c-ray, is %s\n", printinfo );
+ printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor );
+ printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset );
+ printf ( " SEED, the simulation randomization seed, is %d\n", seed );
+
+ ctime1 = cpu_time ( );
+
+ simulate (step_num, step_print_num, step_print, step_print_index,
+ np, nd, mass,
+ dt, seed, outfile, trjfile);
+
+ ctime2 = cpu_time ( );
+ ctime = ctime2 - ctime1;
+
+ printf ( "\n" );
+ printf ( " Elapsed cpu time for main computation:\n" );
+ printf ( " %f seconds.\n", ctime );
+
+#ifdef NOTDEF
+ char tarcmd[2000];
+ sprintf(tarcmd,"tar zcf %s md??.trj",trjfile);
+ system(tarcmd);
+#endif
+
+/*
+ Terminate.
+*/
+ printf ( "\n" );
+ printf ( "MD\n" );
+ printf ( " Normal end of execution.\n" );
+
+ printf ( "\n" );
+ timestamp ( );
+
+ return 0;
+}
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,9 @@
+
+set name $env(LEAF_PKG)
+set version $env(LEAF_VERSION)
+set leaf_so $env(LEAF_SO)
+set leaf_tcl $env(LEAF_TCL)
+
+puts [ ::pkg::create -name $name -version $version \
+ -load $leaf_so -source $leaf_tcl ]
+
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.c
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.c (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.c 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,613 @@
+# include <assert.h>
+# include <stdlib.h>
+# include <stdio.h>
+# include <time.h>
+# include <math.h>
+
+#include "md.h"
+
+double scale_factor = 2.5, scale_offset = -2.0;
+char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1";
+
+
+double dist ( int nd, double r1[], double r2[], double dr[] );
+
+double r8_uniform_01 ( int *seed );
+void update ( int np, int nd, double pos[], double vel[], double f[],
+ double acc[], double mass, double dt );
+void snap ( int np, int nd, int t, double pos[], double vel[], double f[],
+ double acc[], double mass, double dt );
+
+static void trj_file_open(char *trjfile);
+static void trj_file_close(void);
+
+void simulate (int step_num, int step_print_num,
+ int step_print, int step_print_index,
+ int np, int nd,
+ double mass,
+ double dt,
+ int seed,
+ char* outfile,
+ char* trjfile)
+{
+ /*
+ Allocate memory.
+ */
+ double* acc = ( double * ) malloc ( nd * np * sizeof ( double ) );
+ double* box = ( double * ) malloc ( nd * sizeof ( double ) );
+ double* force = ( double * ) malloc ( nd * np * sizeof ( double ) );
+ double* pos = ( double * ) malloc ( nd * np * sizeof ( double ) );
+ double* vel = ( double * ) malloc ( nd * np * sizeof ( double ) );
+ /*
+ Set the dimensions of the box.
+ */
+ for (int i = 0; i < nd; i++ )
+ {
+ box[i] = 10.0;
+ }
+
+ printf ( "\n" );
+ printf ( " Initializing positions, velocities, and accelerations.\n" );
+
+ trj_file_open(trjfile);
+
+ /*
+ Set initial positions, velocities, and accelerations.
+ */
+ initialize ( np, nd, box, &seed, pos, vel, acc );
+ /*
+ Compute the forces and energies.
+ */
+ printf ( "\n" );
+ printf ( " Computing initial forces and energies.\n" );
+
+ double potential, kinetic;
+ compute ( np, nd, pos, vel, mass, force, &potential, &kinetic );
+ double e0 = potential + kinetic;
+ /*
+ This is the main time stepping loop:
+ Compute forces and energies,
+ Update positions, velocities, accelerations.
+ */
+ printf ( "\n" );
+ printf ( " At each step, we report the potential and kinetic energies.\n" );
+ printf ( " The sum of these energies should be a constant.\n" );
+ printf ( " As an accuracy check, we also print the relative error\n" );
+ printf ( " in the total energy.\n" );
+ printf ( "\n" );
+ printf ( " Step Potential Kinetic (P+K-E0)/E0\n" );
+ printf ( " Energy P Energy K Relative Energy Error\n" );
+ printf ( "\n" );
+
+ FILE *ofile = fopen(outfile,"w");
+ fprintf (ofile, " Step Potential Kinetic RelativeErr\n" );
+
+ int step = 0;
+ printf ( " %8d %14f %14f %14e\n",
+ step, potential, kinetic, ( potential + kinetic - e0 ) / e0 );
+ fprintf ( ofile, " %8d %14f %14f %14e\n",
+ step, potential, kinetic, ( potential + kinetic - e0 ) / e0 );
+ step_print_index = step_print_index + 1;
+ step_print = ( step_print_index * step_num ) / step_print_num;
+
+
+ for (step = 1; step <= step_num; step++ )
+ {
+ compute ( np, nd, pos, vel, mass, force, &potential, &kinetic );
+
+ if ( step == step_print )
+ {
+ printf ( " %8d %14f %14f %14e\n", step, potential, kinetic,
+ ( potential + kinetic - e0 ) / e0 );
+ fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic,
+ ( potential + kinetic - e0 ) / e0 );
+ step_print_index = step_print_index + 1;
+ step_print = ( step_print_index * step_num ) / step_print_num;
+ snap (np, nd, step, pos, vel, force, acc, mass, dt );
+ }
+ update ( np, nd, pos, vel, force, acc, mass, dt );
+ }
+
+ free ( acc );
+ free ( box );
+ free ( force );
+ free ( pos );
+ free ( vel );
+
+ fclose(ofile);
+ trj_file_close();
+}
+
+/******************************************************************************/
+
+void compute ( int np, int nd, double pos[], double vel[],
+ double mass, double f[], double *pot, double *kin )
+
+/******************************************************************************/
+/*
+ Purpose:
+
+ COMPUTE computes the forces and energies.
+
+ Discussion:
+
+ The computation of forces and energies is fully parallel.
+
+ The potential function V(X) is a harmonic well which smoothly
+ saturates to a maximum value at PI/2:
+
+ v(x) = ( sin ( min ( x, PI2 ) ) )^2
+
+ The derivative of the potential is:
+
+ dv(x) = 2.0 * sin ( min ( x, PI2 ) ) * cos ( min ( x, PI2 ) )
+ = sin ( 2.0 * min ( x, PI2 ) )
+
+ Licensing:
+
+ This code is distributed under the GNU LGPL license.
+
+ Modified:
+
+ 21 November 2007
+
+ Author:
+
+ Original FORTRAN90 version by Bill Magro.
+ C version by John Burkardt.
+
+ Parameters:
+
+ Input, int NP, the number of particles.
+
+ Input, int ND, the number of spatial dimensions.
+
+ Input, double POS[ND*NP], the position of each particle.
+
+ Input, double VEL[ND*NP], the velocity of each particle.
+
+ Input, double MASS, the mass of each particle.
+
+ Output, double F[ND*NP], the forces.
+
+ Output, double *POT, the total potential energy.
+
+ Output, double *KIN, the total kinetic energy.
+*/
+{
+ double d;
+ double d2;
+ int i;
+ int j;
+ int k;
+ double ke;
+ double pe;
+ double PI2 = 3.141592653589793 / 2.0;
+ double rij[3];
+
+ pe = 0.0;
+ ke = 0.0;
+
+ for ( k = 0; k < np; k++ )
+ {
+/*
+ Compute the potential energy and forces.
+*/
+ for ( i = 0; i < nd; i++ )
+ {
+ f[i+k*nd] = 0.0;
+ }
+
+ for ( j = 0; j < np; j++ )
+ {
+ if ( k != j )
+ {
+ d = dist ( nd, pos+k*nd, pos+j*nd, rij );
+/*
+ Attribute half of the potential energy to particle J.
+*/
+ if ( d < PI2 )
+ {
+ d2 = d;
+ }
+ else
+ {
+ d2 = PI2;
+ }
+
+ pe = pe + 0.5 * pow ( sin ( d2 ), 2 );
+
+ for ( i = 0; i < nd; i++ )
+ {
+ f[i+k*nd] = f[i+k*nd] - rij[i] * sin ( 2.0 * d2 ) / d;
+ }
+ }
+ }
+/*
+ Compute the kinetic energy.
+*/
+ for ( i = 0; i < nd; i++ )
+ {
+ ke = ke + vel[i+k*nd] * vel[i+k*nd];
+ }
+ }
+
+ ke = ke * 0.5 * mass;
+
+ *pot = pe;
+ *kin = ke;
+
+ return;
+}
+/*******************************************************************************/
+
+double cpu_time ( void )
+
+/*******************************************************************************/
+/*
+ Purpose:
+
+ CPU_TIME reports the total CPU time for a program.
+
+ Licensing:
+
+ This code is distributed under the GNU LGPL license.
+
+ Modified:
+
+ 27 September 2005
+
+ Author:
+
+ John Burkardt
+
+ Parameters:
+
+ Output, double CPU_TIME, the current total elapsed CPU time in second.
+*/
+{
+ double value;
+
+ value = ( double ) clock ( ) / ( double ) CLOCKS_PER_SEC;
+
+ return value;
+}
+/******************************************************************************/
+
+double dist ( int nd, double r1[], double r2[], double dr[] )
+
+/******************************************************************************/
+/*
+ Purpose:
+
+ DIST computes the displacement (and its norm) between two particles.
+
+ Licensing:
+
+ This code is distributed under the GNU LGPL license.
+
+ Modified:
+
+ 21 November 2007
+
+ Author:
+
+ Original FORTRAN90 version by Bill Magro.
+ C version by John Burkardt.
+
+ Parameters:
+
+ Input, int ND, the number of spatial dimensions.
+
+ Input, double R1[ND], R2[ND], the positions of the particles.
+
+ Output, double DR[ND], the displacement vector.
+
+ Output, double D, the Euclidean norm of the displacement.
+*/
+{
+ double d;
+ int i;
+
+ d = 0.0;
+ for ( i = 0; i < nd; i++ )
+ {
+ dr[i] = r1[i] - r2[i];
+ d = d + dr[i] * dr[i];
+ }
+ d = sqrt ( d );
+
+ return d;
+}
+/******************************************************************************/
+
+void initialize ( int np, int nd, double box[], int *seed, double pos[],
+ double vel[], double acc[] )
+
+/******************************************************************************/
+/*
+ Purpose:
+
+ INITIALIZE initializes the positions, velocities, and accelerations.
+
+ Licensing:
+
+ This code is distributed under the GNU LGPL license.
+
+ Modified:
+
+ 20 July 2008
+
+ Author:
+
+ Original FORTRAN90 version by Bill Magro.
+ C version by John Burkardt.
+
+ Parameters:
+
+ Input, int NP, the number of particles.
+
+ Input, int ND, the number of spatial dimensions.
+
+ Input, double BOX[ND], specifies the maximum position
+ of particles in each dimension.
+
+ Input, int *SEED, a seed for the random number generator.
+
+ Output, double POS[ND*NP], the position of each particle.
+
+ Output, double VEL[ND*NP], the velocity of each particle.
+
+ Output, double ACC[ND*NP], the acceleration of each particle.
+*/
+{
+ int i;
+ int j;
+/*
+ Give the particles random positions within the box.
+*/
+ for ( j = 0; j < np; j++ )
+ {
+ for ( i = 0; i < nd; i++ )
+ {
+ pos[i+j*nd] = box[i] * r8_uniform_01 ( seed );
+ vel[i+j*nd] = 0.0;
+ acc[i+j*nd] = 0.0;
+ }
+ }
+ return;
+}
+/******************************************************************************/
+
+double r8_uniform_01 ( int *seed )
+
+/******************************************************************************/
+/*
+ Purpose:
+
+ R8_UNIFORM_01 is a unit pseudorandom R8.
+
+ Discussion:
+
+ This routine implements the recursion
+
+ seed = 16807 * seed mod ( 2^31 - 1 )
+ unif = seed / ( 2^31 - 1 )
+
+ The integer arithmetic never requires more than 32 bits,
+ including a sign bit.
+
+ Licensing:
+
+ This code is distributed under the GNU LGPL license.
+
+ Modified:
+
+ 11 August 2004
+
+ Author:
+
+ John Burkardt
+
+ Reference:
+
+ Paul Bratley, Bennett Fox, Linus Schrage,
+ A Guide to Simulation,
+ Springer Verlag, pages 201-202, 1983.
+
+ Bennett Fox,
+ Algorithm 647:
+ Implementation and Relative Efficiency of Quasirandom
+ Sequence Generators,
+ ACM Transactions on Mathematical Software,
+ Volume 12, Number 4, pages 362-376, 1986.
+
+ Parameters:
+
+ Input/output, int *SEED, a seed for the random number generator.
+
+ Output, double R8_UNIFORM_01, a new pseudorandom variate, strictly between
+ 0 and 1.
+*/
+{
+ int k;
+ double r;
+
+ k = *seed / 127773;
+
+ *seed = 16807 * ( *seed - k * 127773 ) - k * 2836;
+
+ if ( *seed < 0 )
+ {
+ *seed = *seed + 2147483647;
+ }
+
+ r = ( double ) ( *seed ) * 4.656612875E-10;
+
+ return r;
+}
+/******************************************************************************/
+
+void timestamp ( void )
+
+/******************************************************************************/
+/*
+ Purpose:
+
+ TIMESTAMP prints the current YMDHMS date as a time stamp.
+
+ Example:
+
+ 31 May 2001 09:45:54 AM
+
+ Licensing:
+
+ This code is distributed under the GNU LGPL license.
+
+ Modified:
+
+ 24 September 2003
+
+ Author:
+
+ John Burkardt
+
+ Parameters:
+
+ None
+*/
+{
+# define TIME_SIZE 40
+
+ static char time_buffer[TIME_SIZE];
+ const struct tm *tm;
+ size_t len;
+ time_t now;
+
+ now = time ( NULL );
+ tm = localtime ( &now );
+
+ len = strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm );
+
+ printf ( "%s\n", time_buffer );
+
+ return;
+# undef TIME_SIZE
+}
+/******************************************************************************/
+
+void update ( int np, int nd, double pos[], double vel[], double f[],
+ double acc[], double mass, double dt )
+
+/******************************************************************************/
+/*
+ Purpose:
+
+ UPDATE updates positions, velocities and accelerations.
+
+ Discussion:
+
+ The time integration is fully parallel.
+
+ A velocity Verlet algorithm is used for the updating.
+
+ x(t+dt) = x(t) + v(t) * dt + 0.5 * a(t) * dt * dt
+ v(t+dt) = v(t) + 0.5 * ( a(t) + a(t+dt) ) * dt
+ a(t+dt) = f(t) / m
+
+ Licensing:
+
+ This code is distributed under the GNU LGPL license.
+
+ Modified:
+
+ 21 November 2007
+
+ Author:
+
+ Original FORTRAN90 version by Bill Magro.
+ C version by John Burkardt.
+
+ Parameters:
+
+ Input, int NP, the number of particles.
+
+ Input, int ND, the number of spatial dimensions.
+
+ Input/output, double POS[ND*NP], the position of each particle.
+
+ Input/output, double VEL[ND*NP], the velocity of each particle.
+
+ Input, double F[ND*NP], the force on each particle.
+
+ Input/output, double ACC[ND*NP], the acceleration of each particle.
+
+ Input, double MASS, the mass of each particle.
+
+ Input, double DT, the time step.
+*/
+{
+ int i;
+ int j;
+ double rmass;
+
+ rmass = 1.0 / mass;
+
+ for ( j = 0; j < np; j++ )
+ {
+ for ( i = 0; i < nd; i++ )
+ {
+ pos[i+j*nd] = pos[i+j*nd] + vel[i+j*nd] * dt + 0.5 * acc[i+j*nd] * dt * dt;
+ vel[i+j*nd] = vel[i+j*nd] + 0.5 * dt * ( f[i+j*nd] * rmass + acc[i+j*nd] );
+ acc[i+j*nd] = f[i+j*nd] * rmass;
+ }
+ /*
+s -0.5 -0.3 -1 0.05 1.0 0.2 0.05 50.0 0.1
+s 0.5 -0.4 0 0.05 0.1 0.85 1.0 50.0 0.1
+ */
+ char *s = "0.05 1.0 0.2 0.05 50.0 0.1";
+ /* printf("s %f %f %f %s\n", pos[0+j*nd]/20.0, pos[1+j*nd]/20.0, pos[2+j*nd]/20.0, s); */
+ }
+
+ return;
+}
+
+
+double scale (double x)
+{
+ return( (x / scale_factor) - scale_offset);
+ /* return( (x / 2.5) - 2.0); */
+}
+
+static int snapid = 0;
+static FILE *trj_file = NULL;
+
+static void trj_file_open(char *trjfile)
+{
+#ifdef NOTDEF
+ char snapfile[100];
+ sprintf(snapfile, "md%02d.trj", snapid);
+#endif
+ trj_file = fopen(trjfile, "w");
+ assert(trj_file != NULL);
+}
+
+static void trj_file_close()
+{
+ fclose(trj_file);
+ trj_file = NULL;
+}
+
+void snap ( int np, int nd, int t, double pos[], double vel[], double f[],
+ double acc[], double mass, double dt )
+{
+ int j;
+
+ for ( j = 0; j < np; j++ )
+ {
+ fprintf(trj_file, "%d s %f %f %f %s\n",
+ snapid, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo);
+ }
+
+ snapid++;
+}
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.h
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.h (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.h 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,33 @@
+/*
+ * md.h
+ *
+ * Created on: Aug 13, 2014
+ * Author: wozniak
+ */
+
+#ifndef MD_H
+#define MD_H
+
+extern double scale_factor, scale_offset;
+extern char *printinfo;
+
+double cpu_time ( void );
+
+void timestamp ( void );
+
+void initialize ( int np, int nd, double box[], int *seed, double pos[],
+ double vel[], double acc[] );
+
+void compute ( int np, int nd, double pos[], double vel[],
+ double mass, double f[], double *pot, double *kin );
+
+void simulate (int step_num, int step_print_num,
+ int step_print, int step_print_index,
+ int np, int nd,
+ double mass,
+ double dt,
+ int seed,
+ char* outfile,
+ char* trjfile);
+
+#endif
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.i
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.i (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.i 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,6 @@
+
+%module md
+%include "md.h"
+%{
+ #include "md.h"
+%}
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.tcl
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.tcl (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.tcl 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,4 @@
+
+namespace eval md {
+ # Nothing
+}
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,10 @@
+#!/bin/sh -eu
+
+NPART=4
+STEPS=10
+MASS=1
+SEED=42
+OUT=output.txt
+TRJ=output.trj
+
+./md 3 ${NPART} ${STEPS} 10 ".0001" ${MASS} "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 ${SEED} ${OUT} ${TRJ}
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,7 @@
+#!/usr/bin/env tclsh8.6
+
+lappend auto_path $env(PWD)
+package require md 0.0
+
+simulate 4 2 0 0 10 2 1 0.1 9 out.txt
+
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+./md 3 50 1000
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+cr=../c-ray-1.1
+md=../mdlite
+
+for ((i=0;i<50;i++)); do
+ $md/md 3 50 30000 | tee md$i.trj | grep ^s:$i | cat - $cr/ts2 | $cr/cr >fr$i.ppm ; convert fr$i.ppm fr$i.png
+done
+convert fr*png t.gif; open -a Safari t.gif
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,13 @@
+#! /bin/sh
+
+cr=../c-ray-1.1
+md=../mdlite
+
+$md/md 3 50 30000
+
+for t in md??.trj; do
+ cat $t $cr/ts2 | $cr/cr >t.ppm
+ convert t.ppm $t.png
+done
+
+convert -delay 20 md??.trj.png t.gif; open -a Safari t.gif
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+cr=../c-ray-1.1
+md=../mdlite
+
+# $md/md 3 50 30000
+ $md/md 3 50 30000 50 .0001 .005 "0.03 1.0 0.2 0.05 50.0 0.1" 2.5 2.0
+
+for t in md??.trj; do
+ cat $t $cr/ts2 | $cr/cr >t.ppm
+ convert t.ppm $t.png
+done
+
+convert -delay 20 md??.trj.png t.gif; open -a Safari t.gif
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/tukey.properties
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/tukey.properties (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/tukey.properties 2014-08-13 23:14:19 UTC (rev 8164)
@@ -0,0 +1,18 @@
+site=tukey
+
+site.tukey {
+ jobmanager=localhost:cobalt
+ taskWalltime=00:15:00
+ workdir=/home/$USER/swiftwork
+ filesystem=local
+ maxJobs=10
+ tasksPerWorker=10
+ taskThrottle=300
+ initialscore=10000
+}
+
+app.tukey.md=$PWD/../app/md
+app.tukey.mdstats=$PWD/../app/mdstats
+app.tukey.mdmaxk=$PWD/../app/mdmaxk
+app.tukey.renderframe=$PWD/../app/renderframe
+app.tukey.convert=/usr/bin/convert
Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/tutorial.pptx
===================================================================
(Binary files differ)
Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/tutorial.pptx
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
More information about the Swift-commit
mailing list