[cig-commits] r3911 -
short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive
baagaard at geodynamics.org
baagaard at geodynamics.org
Mon Jul 3 13:36:49 PDT 2006
Author: baagaard
Date: 2006-07-03 13:36:49 -0700 (Mon, 03 Jul 2006)
New Revision: 3911
Added:
short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/runbm.py
Removed:
short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/runbm5.sh
short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/tutor.sh
Modified:
short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/tutor.py
Log:
Tutorial. Converted runbm5 from bash script to Python script. Changed name to runbm. This removes dependency on bash shell for running a job.
Added: short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/runbm.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/runbm.py 2006-07-03 19:38:36 UTC (rev 3910)
+++ short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/runbm.py 2006-07-03 20:36:49 UTC (rev 3911)
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+root="bmrsnog"
+
+# ----------------------------------------------------------------------
+def setupInput(nprocs):
+ dupext = [".fuldat", ".prop", ".statevar", ".time"]
+ sinext = [".coord", ".connect", ".bc", ".split"]
+
+ print "Setting up symbolic links with prefix '%s_%d':" % (root, nprocs)
+ import os
+
+ dirFiles = os.listdir(os.getcwd())
+ for ext in sinext:
+ src = "%s%s" % (root, ext)
+ dest = "%s_%s%s" % (root, nprocs, ext)
+ if not dest in dirFiles:
+ print " %s -> %s... created" % (dest, src)
+ os.symlink(src, dest)
+ else:
+ print " %s -> %s... already exists" % (dest, src)
+
+ for ext in dupext:
+ src = "%s%s" % (root, ext)
+ for iproc in range(nprocs):
+ dest = "%s_%s.%d%s" % (root, nprocs, iproc, ext)
+ if not dest in dirFiles:
+ print " %s -> %s... created" % (dest, src)
+ os.symlink(src, dest)
+ else:
+ print " %s -> %s... already exists" % (dest, src)
+ return
+
+# ----------------------------------------------------------------------
+def run(nprocs):
+ print "Running PyLith..."
+
+ # TODO: Replace the use of launching via 'system' with use
+ # of Leif's architecture independent utility.
+
+ cmd = "mpirun -np %d `which pylith3dapp.py` " \
+ "--typos=relaxed " \
+ "--scanner.fileRoot=%s_%d " \
+ "--scanner.asciiOutput=full " \
+ "--scanner.ucdOutput=ascii " \
+ "-log_summary -pc_type bjacobi -sub_pc_type ilu " \
+ "-ksp_monitor -ksp_view -ksp_rtol 1e-09" % (nprocs, root, nprocs)
+ import os
+ print cmd
+ os.system(cmd)
+ return
+
+# ----------------------------------------------------------------------
+if __name__ == "__main__":
+ from optparse import OptionParser
+
+ parser = OptionParser()
+ parser.add_option("-n", "--numprocs", dest="nprocs",
+ type="int", metavar="NPROCS",
+ help="Set number of processors.")
+ (options, args) = parser.parse_args()
+ if len(args) != 0:
+ parser.error("Incorrent number of arguments.")
+
+ nprocs = 1
+ if not options.nprocs is None:
+ nprocs = options.nprocs
+
+ setupInput(nprocs)
+ run(nprocs)
+
+# End of file
Property changes on: short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/runbm.py
___________________________________________________________________
Name: svn:executable
+ *
Deleted: short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/runbm5.sh
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/runbm5.sh 2006-07-03 19:38:36 UTC (rev 3910)
+++ short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/runbm5.sh 2006-07-03 20:36:49 UTC (rev 3911)
@@ -1,38 +0,0 @@
-#!/bin/bash
-# ======================================================================
-#
-# Shell script to run PyLith in tutorial using SCEC benchmark 5.
-#
-# ======================================================================
-
-if [ $# != 1 ]; then
- echo "usage: runbm5.sh NPROCS"
- exit 1
-fi
-nprocs=$1
-
-simroot="bm5"
-dupext="fuldat prop statevar time"
-sinext="coord connect bc split"
-
-echo "Setting up symbolic links with prefix ${simroot}_${nprocs}..."
-for ext in $sinext; do
- ln -s $simroot.$ext ${simroot}_$nprocs.$ext
-done
-for ext in $dupext; do
- for (( i=0; i < $nprocs; i+=1 )); do
- ln -s $simroot.$ext ${simroot}_$nprocs.$i.$ext
- done
-done
-
-echo "Running PyLith..."
-cmd="mpirun -np $nprocs `which pylith3dapp.py` \
- --typos=relaxed \
- --scanner.fileRoot=${simroot}_$nprocs \
- --scanner.asciiOutput=full \
- --scanner.ucdOutput=ascii \
- -log_summary -pc_type bjacobi -sub_pc_type ilu -ksp_monitor -ksp_view -ksp_rtol 1e-09"
-echo $cmd
-eval $cmd
-
-# end of file
Modified: short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/tutor.py
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/tutor.py 2006-07-03 19:38:36 UTC (rev 3910)
+++ short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/tutor.py 2006-07-03 20:36:49 UTC (rev 3911)
@@ -197,7 +197,4 @@
tutor(options.step, options.mode)
-# version
-__id__ = "$Id$"
-
# End of file
Deleted: short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/tutor.sh
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/tutor.sh 2006-07-03 19:38:36 UTC (rev 3910)
+++ short/3D/PyLith/branches/pylith-0.8/tutorials/reversenog/archive/tutor.sh 2006-07-03 20:36:49 UTC (rev 3911)
@@ -1,142 +0,0 @@
-#!/bin/bash
-# ======================================================================
-#
-# Tutor shell script to help user run tutorial using SCEC benchmark 5.
-#
-# ======================================================================
-
-archive="../archive"
-root="bm5"
-
-# ----------------------------------------------------------------------
-function show_usage () {
- echo "usage: tutor.sh MODE STEP"
- echo " Modes:"
- echo " check Check to make sure files necessary for step exist."
- echo " clean Remove old files that will be overwritten in this step."
- echo " retrieve Copy files (as needed) from archive needed in this step."
- echo " Steps:"
- echo " mesh Generating the finite-element mesh."
- echo " setup Setting up the PyLith input files."
- echo " run1 Running the simulation on 1 processor."
- echo " viz1 Visualizing the output from a simulation on 1 processor."
- echo " run2 Running the simulation on 2 processors."
- echo " viz2 Visualizing the output from a simulation on 2 processors."
- echo " all Apply mode to each step in succession."
-}
-
-# ----------------------------------------------------------------------
-function get_step_lists () {
- if [ "mesh" == $curstep ]; then
- files_input=$root.geo
- files_output=$root.netgen
-
- elif [ "setup" == $curstep ]; then
- files_input=`echo $root.{netgen,fault.par,par,aux}`
- files_output=`echo $root.{coord,connect,bc,w01.wink,1.fcoord,1.fbc,split}`
-
- elif [ "run1" == $curstep ]; then
- files_input="runbm5.sh"
- files_input="$files_input "`echo $root.{coord,connect,split,bc}`
- files_input="$files_input "`echo $root.{fuldat,prop,statevar,time}`
-
- files_output=`echo ${root}_1.{coord,connect,split,bc}`
- files_output="$files_output "`echo ${root}_1.[0-9]*.{bc,connect,coord,split}`
- files_output="$files_output "`echo ${root}_1.[0-9]*.{ascii,vtk}`
- files_output="$files_output "`echo ${root}_1.[0-9]*.{fuldat,prop,statevar,time}`
- files_output="$files_output "`echo ${root}_1.[0-9]*.gmesh{,.t10,.time.{00000,00010,00050,00100}}.inp`
- files_output="$files_output "`echo ${root}_1.[0-9]*.mesh{,.t10,{.time.{00000,00010,00050,00100}}}.inp`
- files_output="$files_output "`echo ${root}_1.[0-9]*.mesh.split.time.{00000,00010,00050,00100}.inp`
-
- elif [ "viz1" == $curstep ]; then
- files_input=`echo ${root}_1.0.mesh{,.time.00010}.inp`
- files_output="${root}_1.0.mesh.t00010.inp"
-
- elif [ "run2" == $curstep ]; then
- files_input="runbm5.sh"
- files_input="$files_input "`echo $root.{coord,connect,split,bc}`
- files_input="$files_input "`echo $root.{fuldat,prop,statevar,time}`
-
- files_output=`echo ${root}_2.{coord,connect,split,bc}`
- files_output="$files_output "`echo ${root}_2.[0-9]*.{bc,connect,coord,split}`
- files_output="$files_output "`echo ${root}_2.[0-9]*.{ascii,vtk}`
- files_output="$files_output "`echo ${root}_2.[0-9]*.{fuldat,prop,statevar,time}`
- files_output="$files_output "`echo ${root}_2.[0-9]*.gmesh{,.t10,.time.{00000,00010,00050,00100}}.inp`
- files_output="$files_output "`echo ${root}_2.[0-9]*.mesh{,.t10,{.time.{00000,00010,00050,00100}}}.inp`
- files_output="$files_output "`echo ${root}_2.[0-9]*.mesh.split.time.{00000,00010,00050,00100}.inp`
-
- elif [ "viz2" == $curstep ]; then
- files_input=`echo ${root}_2.{0,1}.mesh{,.time.00010}.inp`
- files_output=`echo ${root}_2.{0,1}.mesh.t00010.inp`
-
- else
- echo "Unrecognized step: $step"
- show_usage
- exit 1
- fi
-}
-
-# ----------------------------------------------------------------------
-function tutor () {
- get_step_lists
-
- if [ "check" == $mode ]; then
- echo "Checking to make sure you have the following files:"
- for file in $files_input; do
- echo -n " $file..."
- if [ -r $file ]; then
- echo "found"
- else
- echo "MISSING"
- fi
- done
- elif [ "clean" == $mode ]; then
- echo "Removing any old files:"
- for file in $files_output; do
- if [ -r $file ] || [ -L $file ]; then
- echo " $file...removed"
- rm $file
- fi
- done
- elif [ "retrieve" == $mode ]; then
- echo "Retrieving files from archive:"
- for file in $files_input; do
- echo -n " $file..."
- if [ -r $file ]; then
- echo "already present"
- else
- echo "retrieving from archive"
- cp $archive/$file .
- fi
- done
- else
- echo "Unrecognized mode: $mode"
- show_usage
- exit 1
- fi
-}
-
-# ----------------------------------------------------------------------
-# Check number of command line arguments
-if [ $# != 2 ]; then
- show_usage
- exit 1
-fi
-
-# Get command line arguments
-mode=$1
-step=$2
-
-allsteps="mesh setup run1 viz1 run2 viz2"
-
-if [ "all" == $step ]; then
- for curstep in $allsteps; do
- echo "Running tutor in mode $mode for step $curstep"
- tutor
- done
-else
- curstep=$step
- tutor
-fi
-
-# End of file
More information about the cig-commits
mailing list