[cig-commits] r4586 - mc/3D/CitcomS/trunk/visual

tan2 at geodynamics.org tan2 at geodynamics.org
Thu Sep 21 16:03:17 PDT 2006


Author: tan2
Date: 2006-09-21 16:03:16 -0700 (Thu, 21 Sep 2006)
New Revision: 4586

Added:
   mc/3D/CitcomS/trunk/visual/batchpaste2.sh
Modified:
   mc/3D/CitcomS/trunk/visual/autocombine.py
   mc/3D/CitcomS/trunk/visual/batchcombine.py
   mc/3D/CitcomS/trunk/visual/batchpaste.sh
Log:
Updated post-processing script for new output_format options. See issue53.


Modified: mc/3D/CitcomS/trunk/visual/autocombine.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/autocombine.py	2006-09-21 21:25:44 UTC (rev 4585)
+++ mc/3D/CitcomS/trunk/visual/autocombine.py	2006-09-21 23:03:16 UTC (rev 4586)
@@ -31,9 +31,20 @@
 usage: autocombine.py machinefile inputfile step1 [step2 [...] ]
 '''
 
+# default values for CitcomS input
+defaults = {'output_format': 'ascii-local',
+            'datadir': '.',
+            'nprocx': 1,
+            'nprocy': 1,
+            'nprocz': 1,
+            'nodex': 9,
+            'nodey': 9,
+            'nodez': 9}
+
 if __name__ == '__main__':
 
-    import sys, os
+    import sys
+    import batchcombine
 
     if len(sys.argv) < 4:
         print __doc__
@@ -41,15 +52,31 @@
 
     machinefile = sys.argv[1]
     inputfile = sys.argv[2]
+    timesteps = [int(i) for i in sys.argv[3:]]
 
     # parse input
     from parser import Parser
-    parser = Parser()
+    parser = Parser(defaults)
     parser.read(inputfile)
 
-    datadir = parser.getstr('datadir')
+    output_format = parser.getstr('output_format')
     datafile = parser.getstr('datafile')
 
+    if output_format == 'ascii-local':
+        import os.path
+        modeldir, modelname = os.path.split(datafile)
+        #print modeldir, modelname
+        datadir = os.path.abspath(modeldir)
+        datafile = modelname
+        combine_fn = batchcombine.combine
+    elif output_format == 'ascii':
+        datadir = parser.getstr('datadir')
+        combine_fn = batchcombine.combine2
+    else:
+        print "Error: don't know how to combine the output", \
+              "(output_format=%s)" % output_format
+        sys.exit(1)
+
     nodex = parser.getint('nodex')
     nodey = parser.getint('nodey')
     nodez = parser.getint('nodez')
@@ -58,11 +85,10 @@
     nprocy = parser.getint('nprocy')
     nprocz = parser.getint('nprocz')
 
-    import batchcombine as combine
     totalnodes = nprocx * nprocy * nprocz * ncap
-    nodelist = combine.machinefile2nodes(machinefile, totalnodes)
+    nodelist = batchcombine.machinefile2nodes(machinefile, totalnodes)
 
-    for timestep in sys.argv[3:]:
-        combine.combine(nodelist, datadir, datafile, int(timestep),
-                        nodex, nodey, nodez,
-                        ncap, nprocx, nprocy, nprocz)
+    for timestep in timesteps:
+        combine_fn(nodelist, datadir, datafile, timestep,
+                   nodex, nodey, nodez,
+                   ncap, nprocx, nprocy, nprocz)

Modified: mc/3D/CitcomS/trunk/visual/batchcombine.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/batchcombine.py	2006-09-21 21:25:44 UTC (rev 4585)
+++ mc/3D/CitcomS/trunk/visual/batchcombine.py	2006-09-21 23:03:16 UTC (rev 4586)
@@ -88,6 +88,36 @@
     return
 
 
+
+def combine2(nodes, datadir, datafile, timestep, nodex, nodey, nodez,
+             ncap, nprocx, nprocy, nprocz):
+    import os
+
+    # paste
+    cmd = 'batchpaste2.sh %(datadir)s %(datafile)s %(timestep)d %(nodes)s' \
+          % vars()
+    print cmd
+    os.system(cmd)
+
+    # combine
+    cmd = 'combine.py %(datafile)s %(timestep)d %(nodex)d %(nodey)d %(nodez)d %(ncap)d %(nprocx)d %(nprocy)d %(nprocz)d' % vars()
+    print cmd
+    os.system(cmd)
+
+    # delete
+    cmd = 'rm %(datafile)s.[0-9]*.%(timestep)d' % vars()
+    print cmd
+    os.system(cmd)
+
+    # create .general file
+    cmd = 'dxgeneral.sh %(datafile)s.cap*.%(timestep)d' % vars()
+    print cmd
+    os.system(cmd)
+
+    return
+
+
+
 if __name__ == '__main__':
 
     import sys

Modified: mc/3D/CitcomS/trunk/visual/batchpaste.sh
===================================================================
--- mc/3D/CitcomS/trunk/visual/batchpaste.sh	2006-09-21 21:25:44 UTC (rev 4585)
+++ mc/3D/CitcomS/trunk/visual/batchpaste.sh	2006-09-21 23:03:16 UTC (rev 4586)
@@ -48,9 +48,9 @@
     cmd_copy="cp $datafile.$rank.$timestep $cwd"
 
     if [ $4 == $HOSTNAME -o $4 == "localhost" ]; then
-	cd $datadir/$rank && $cmd_paste && $cmd_copy
+        cd $datadir && $cmd_paste && $cmd_copy
     else
- 	rsh $4 "cd $datadir/$rank && $cmd_paste && $cmd_copy"
+        rsh $4 "cd $datadir && $cmd_paste && $cmd_copy"
     fi
 
     shift

Copied: mc/3D/CitcomS/trunk/visual/batchpaste2.sh (from rev 4585, mc/3D/CitcomS/trunk/visual/batchpaste.sh)
===================================================================
--- mc/3D/CitcomS/trunk/visual/batchpaste.sh	2006-09-21 21:25:44 UTC (rev 4585)
+++ mc/3D/CitcomS/trunk/visual/batchpaste2.sh	2006-09-21 23:03:16 UTC (rev 4586)
@@ -0,0 +1,64 @@
+#!/bin/sh
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#<LicenseText>
+#
+# CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+# Copyright (C) 2002-2005, California Institute of Technology.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#</LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Run 'pasteCitcomData.sh' in a batch process
+#
+# Requirement: 1) current working directory must be mounted on master_ip too.
+#              2) the list of ip has the same order as the MPI machinefile
+
+if [ -z $4 ]; then
+    echo "Usage:" `basename $0` datadir datafile timestep ip1 [ip2 ... ]
+    exit
+fi
+
+paste_exe=`which pasteCitcomData.sh`
+cwd=`pwd`
+datadir=$1
+datafile=$2
+timestep=$3
+rank=0
+
+while [ "$4" ]
+do
+    cmd_paste="$paste_exe $datafile $rank $timestep"
+    cmd_copy="cp $datafile.$rank.$timestep $cwd"
+
+    if [ $4 == $HOSTNAME -o $4 == "localhost" ]; then
+        cd $datadir/$rank && $cmd_paste && $cmd_copy
+    else
+        rsh $4 "cd $datadir/$rank && $cmd_paste && $cmd_copy"
+    fi
+
+    shift
+    let n=n+1
+done
+
+
+# version
+# $Id$
+
+# End of file



More information about the cig-commits mailing list