From 2a97c7139bbbd6419ef1c2a727a78d27f25032e9 Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Wed, 20 Sep 2017 10:13:34 +0100
Subject: [PATCH] Add scripts to process cells dumps into active and edge
 analysis

---
 examples/process_cells        | 51 +++++++++++++++++++++++++++++++++++
 examples/process_cells_helper | 11 ++++++++
 2 files changed, 62 insertions(+)
 create mode 100755 examples/process_cells
 create mode 100755 examples/process_cells_helper

diff --git a/examples/process_cells b/examples/process_cells
new file mode 100755
index 0000000000..a9c72e4a09
--- /dev/null
+++ b/examples/process_cells
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Usage:
+#  process_cells nprocess
+#
+# Description:
+#  Process all the cell dumps in the current directory
+#
+#  Outputs file per rank with the active cells identified and marked
+#  as to whether they are near an edge or not.
+
+#  Handle command-line
+if test "$1" = ""; then
+    echo "Usage: $0 nprocess"
+    exit 1
+fi
+NPROCS=$1
+
+#  Locate script.
+SCRIPTHOME=$(dirname "$0")
+
+#  Find all files. Use version sort to get into correct order.
+files=$(ls -v cells_*.dat)
+if test $? != 0; then
+    echo "Failed to find any cell dump files"
+    exit 1
+fi
+
+#  Construct list of names need the number of ranks.
+ranks=$(ls -v cells_*.dat | sed 's,cells_\(.*\)_.*.dat,\1,' | sort | uniq | wc -l)
+echo "Number of ranks = $ranks"
+
+#  Now construct a list of files ordered by rank, not step.
+files=$(ls cells_*.dat | sort -t "_" -k 3,3 -n | xargs -n 4)
+
+#  And process them,
+echo "Processing cell dumps files..."
+echo $files | xargs -P $NPROCS -n 4 /bin/bash -c "${SCRIPTHOME}/process_cells_helper 20 20 20 \$0 \$1 \$2 \$3"
+
+#  Create summary.
+grep "top cells" step*-active-cells.dat | sort -h > active_cells.log
+
+#  And plot of active cells to edge cells.
+stilts plot2plane ifmt=ascii in=active_cells.log xmin=-0.1 xmax=1.1 ymin=-100 ymax=2200 grid=1 \
+       legend=false xpix=600 ypix=500 xlabel="Edge cells/Active cells" ylabel="Step" \
+       layer1=mark x1="col9/1.0/col6" y1="index*7" size1=3 shading1=aux auxmap=rainbow \
+       aux=col6 auxfunc=log auxlabel="Active cells" layer2=histogram x2="col9/1.0/col6" \
+       color2=grey binsize2=0.01 phase2=0.5 barform2=semi_steps weight2=30 thick2=1 \
+       out=active_cells.png
+
+exit
diff --git a/examples/process_cells_helper b/examples/process_cells_helper
new file mode 100755
index 0000000000..7862e7def0
--- /dev/null
+++ b/examples/process_cells_helper
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+#  Helper for process_cells.
+
+#  Locate script.
+SCRIPTHOME=$(dirname "$0")
+
+step=$(echo $4|sed 's,cells_\(.*\)_\(.*\).dat,\2,')
+${SCRIPTHOME}/analyse_dump_cells.py $* > step${step}-active-cells.dat
+
+exit
-- 
GitLab