[cig-commits] r5350 - mc/3D/CitcomS/trunk/visual
tan2 at geodynamics.org
tan2 at geodynamics.org
Mon Nov 27 14:37:28 PST 2006
Author: tan2
Date: 2006-11-27 14:37:27 -0800 (Mon, 27 Nov 2006)
New Revision: 5350
Added:
mc/3D/CitcomS/trunk/visual/execpaste.py
Removed:
mc/3D/CitcomS/trunk/visual/batchpaste2.sh
Modified:
mc/3D/CitcomS/trunk/visual/Makefile.am
mc/3D/CitcomS/trunk/visual/autocombine.py
mc/3D/CitcomS/trunk/visual/batchcombine.py
mc/3D/CitcomS/trunk/visual/batchpaste.sh
Log:
Changed postprocessing scripts for the new "datadir" parameter
Modified: mc/3D/CitcomS/trunk/visual/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/visual/Makefile.am 2006-11-27 21:27:15 UTC (rev 5349)
+++ mc/3D/CitcomS/trunk/visual/Makefile.am 2006-11-27 22:37:27 UTC (rev 5350)
@@ -40,6 +40,8 @@
combinesurf.py \
dxgeneral.sh \
dxgeneralsurf.sh \
+ estimate.py \
+ execpaste.py \
getcoord.sh \
getlog.sh \
getsurf.sh \
@@ -48,6 +50,8 @@
miff2mpg \
parser.py \
pasteCitcomData.sh \
+ plot_annulus.py \
+ plot_layer.py \
zslice.py
nobase_dist_visual_DATA = \
Modified: mc/3D/CitcomS/trunk/visual/autocombine.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/autocombine.py 2006-11-27 21:27:15 UTC (rev 5349)
+++ mc/3D/CitcomS/trunk/visual/autocombine.py 2006-11-27 22:37:27 UTC (rev 5350)
@@ -32,8 +32,7 @@
'''
# default values for CitcomS input
-defaults = {'output_format': 'ascii-local',
- 'datadir': '.',
+defaults = {'output_format': 'ascii',
'nprocx': 1,
'nprocy': 1,
'nprocz': 1,
@@ -44,7 +43,7 @@
if __name__ == '__main__':
import sys
- import batchcombine
+ import batchcombine as bc
if len(sys.argv) < 4:
print __doc__
@@ -59,20 +58,11 @@
parser = Parser(defaults)
parser.read(inputfile)
- output_format = parser.getstr('output_format')
+ datadir = parser.getstr('datadir')
datafile = parser.getstr('datafile')
+ output_format = parser.getstr('output_format')
- 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:
+ if output_format != 'ascii':
print "Error: don't know how to combine the output", \
"(output_format=%s)" % output_format
sys.exit(1)
@@ -86,10 +76,10 @@
nprocz = parser.getint('nprocz')
totalnodes = nprocx * nprocy * nprocz * ncap
- nodelist = batchcombine.machinefile2nodes(machinefile, totalnodes)
+ nodelist = bc.machinefile2nodes(machinefile, totalnodes)
for timestep in timesteps:
- combine_fn(nodelist, datadir, datafile, timestep,
+ bc.combine(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-11-27 21:27:15 UTC (rev 5349)
+++ mc/3D/CitcomS/trunk/visual/batchcombine.py 2006-11-27 22:37:27 UTC (rev 5350)
@@ -89,35 +89,6 @@
-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-11-27 21:27:15 UTC (rev 5349)
+++ mc/3D/CitcomS/trunk/visual/batchpaste.sh 2006-11-27 22:37:27 UTC (rev 5350)
@@ -35,27 +35,24 @@
exit
fi
-paste_exe=`which pasteCitcomData.sh`
+paste_exe=`which execpaste.py`
cwd=`pwd`
datadir=$1
datafile=$2
timestep=$3
rank=0
-while [ "$4" ]
+while [ x"$4" != "x" ]
do
- cmd_paste="$paste_exe $datafile $rank $timestep"
- cmd_copy="cp $datafile.$rank.$timestep $cwd"
-
- if [ $4 == $HOSTNAME -o $4 == "localhost" ]; then
- # using subshell, so that our working directory is unchanged
- (cd $datadir && $cmd_paste && $cmd_copy)
+ cmd_paste="$paste_exe $datadir $datafile $rank $timestep $cwd"
+ if [ $4 = $HOSTNAME -o $4 = "localhost" ]; then
+ $cmd_paste
else
- rsh $4 "cd $datadir && $cmd_paste && $cmd_copy"
+ rsh $4 "$cmd_paste"
fi
shift
- let rank=rank+1
+ rank=$(($rank+1))
done
Deleted: mc/3D/CitcomS/trunk/visual/batchpaste2.sh
===================================================================
--- mc/3D/CitcomS/trunk/visual/batchpaste2.sh 2006-11-27 21:27:15 UTC (rev 5349)
+++ mc/3D/CitcomS/trunk/visual/batchpaste2.sh 2006-11-27 22:37:27 UTC (rev 5350)
@@ -1,65 +0,0 @@
-#!/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
- # using subshell, so that our working directory is unchanged
- (cd $datadir/$rank && $cmd_paste && $cmd_copy)
- else
- rsh $4 "cd $datadir/$rank && $cmd_paste && $cmd_copy"
- fi
-
- shift
- let rank=rank+1
-done
-
-
-# version
-# $Id$
-
-# End of file
Added: mc/3D/CitcomS/trunk/visual/execpaste.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/execpaste.py 2006-11-27 21:27:15 UTC (rev 5349)
+++ mc/3D/CitcomS/trunk/visual/execpaste.py 2006-11-27 22:37:27 UTC (rev 5350)
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#<LicenseText>
+#
+# CitcomS.py by Eh Tan
+# Copyright (C) 2006, 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>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+"""Execute pasteCitcomData.sh to retrieve the pasted data
+
+Usage: execpaste.py datadir datafile processor_rank timestep save_dir
+
+datadir: same input parameter for CitcomS
+datafile: same input parameter for CitcomS
+processor_rank: MPI rank of current processor
+timestep: timestep to retrieve
+save_dir: which directory to save the retrieved data
+"""
+
+import sys
+
+if len(sys.argv) != 6:
+ print __doc__
+ sys.exit()
+
+datadir = sys.argv[1]
+datafile = sys.argv[2]
+rank = sys.argv[3]
+timestep = sys.argv[4]
+save_dir = sys.argv[5]
+
+import os
+paste_exe = "pasteCitcomData.sh"
+
+
+## expand datadir
+s = "%HOSTNAME"
+if s in datadir:
+ from socket import gethostname
+ datadir = datadir.replace(s, gethostname())
+
+s = "%RANK"
+if s in datadir:
+ datadir = datadir.replace(s, rank)
+
+if datadir == "%DATADIR":
+ fp = os.popen("citcoms_datadir", "r")
+ datadir = fp.readline().strip()
+ fp.close()
+
+
+## run paste_exe and copy the pasted data to save_dir
+os.chdir(datadir)
+cmd = """
+%(paste_exe)s %(datafile)s %(rank)s %(timestep)s && \
+cp %(datafile)s.%(rank)s.%(timestep)s %(save_dir)s
+""" % vars()
+os.system(cmd)
+
+
+# version
+# $Id$
+
+# End of file
Property changes on: mc/3D/CitcomS/trunk/visual/execpaste.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the cig-commits
mailing list