[cig-commits] r7236 - mc/3D/CitcomS/trunk/visual
tan2 at geodynamics.org
tan2 at geodynamics.org
Thu Jun 14 10:55:32 PDT 2007
Author: tan2
Date: 2007-06-14 10:55:31 -0700 (Thu, 14 Jun 2007)
New Revision: 7236
Modified:
mc/3D/CitcomS/trunk/visual/autocombine.py
mc/3D/CitcomS/trunk/visual/batchcombine.py
mc/3D/CitcomS/trunk/visual/pasteCitcomData.py
Log:
A better fix for issue110
Modified: mc/3D/CitcomS/trunk/visual/autocombine.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/autocombine.py 2007-06-14 17:12:12 UTC (rev 7235)
+++ mc/3D/CitcomS/trunk/visual/autocombine.py 2007-06-14 17:55:31 UTC (rev 7236)
@@ -101,13 +101,21 @@
nodelist = bc.machinefile2nodelist(machinefile, totalnodes)
for timestep in timesteps:
+ # combining coord, velo, temp, and visc
bc.batchcombine(nodelist, datadir, datafile, timestep,
nodex, nodey, nodez,
ncap, nprocx, nprocy, nprocz,
- optional_fields)
+ 'coord,velo,visc')
+ # combining optional fields, if necessary
+ if optional_fields:
+ bc.batchcombine(nodelist, datadir, datafile, timestep,
+ nodex, nodey, nodez,
+ ncap, nprocx, nprocy, nprocz,
+ optional_fields)
+
# version
# $Id$
Modified: mc/3D/CitcomS/trunk/visual/batchcombine.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/batchcombine.py 2007-06-14 17:12:12 UTC (rev 7235)
+++ mc/3D/CitcomS/trunk/visual/batchcombine.py 2007-06-14 17:55:31 UTC (rev 7236)
@@ -29,7 +29,7 @@
'''
Paste and combine Citcom data
-Usage: batchcombine.py <machinefile | node-list> datadir datafile timestep nodex nodey nodez ncap nprocx nprocy nprocz
+Usage: batchcombine.py <machinefile | node-list> datadir datafile timestep nodex nodey nodez ncap nprocx nprocy nprocz [fields]
'''
@@ -73,7 +73,7 @@
-def batchpaste(datadir, datafile, opts, timestep, nodes):
+def batchpaste(datadir, datafile, fields, timestep, nodes):
from socket import gethostname
hostname = gethostname()
@@ -84,7 +84,7 @@
if node == 'localhost' or node == hostname:
# local paste
import pasteCitcomData
- pasteCitcomData.run(datadir, datafile, opts, rank, timestep, cwd)
+ pasteCitcomData.run(datadir, datafile, fields, rank, timestep, cwd)
else:
# remote paste
@@ -92,7 +92,7 @@
# replace 'rsh' with 'ssh' if necessary
remote_shell = 'rsh'
- cmd = '%(remote_shell)s %(node)s pasteCitcomData.py %(datadir)s %(datafile)s %(opts)s %(rank)d %(timestep)d %(cwd)s' % vars()
+ cmd = '%(remote_shell)s %(node)s pasteCitcomData.py %(datadir)s %(datafile)s %(fields)s %(rank)d %(timestep)d %(cwd)s' % vars()
os.system(cmd)
return
@@ -100,21 +100,18 @@
def batchcombine(nodes, datadir, datafile, timestep, nodex, nodey, nodez,
- ncap, nprocx, nprocy, nprocz, optional_fields):
+ ncap, nprocx, nprocy, nprocz, fields):
# paste
- opts0 = 'coord,velo,visc'
- opts1 = optional_fields
+ batchpaste(datadir, datafile, fields, timestep, nodes)
- batchpaste(datadir, datafile, opts0, timestep, nodes)
- batchpaste(datadir, datafile, opts1, timestep, nodes)
# combine
import combine
- combine.combine(datafile, opts0, timestep, nodex, nodey, nodez,
- ncap, nprocx, nprocy, nprocz)
- combine.combine(datafile, opts1, timestep, nodex, nodey, nodez,
+ combine.combine(datafile, fields, timestep,
+ nodex, nodey, nodez,
ncap, nprocx, nprocy, nprocz)
+
# delete pasted files
import glob
filenames = glob.glob('%(datafile)s.*.%(timestep)d.pasted' % vars())
@@ -126,14 +123,11 @@
# create .general file
import dxgeneral
- combined_files0 = []
- combined_files1 = []
+ combined_files = []
for cap in range(ncap):
- combined_files0.append('%(datafile)s.cap%(cap)02d.%(timestep)d' % vars())
- combined_files1.append('%(datafile)s.opt%(cap)02d.%(timestep)d' % vars())
+ combined_files.append('%(datafile)s.cap%(cap)02d.%(timestep)d' % vars())
- dxgeneral.write(opts0, combined_files0)
- dxgeneral.write(opts1, combined_files1)
+ dxgeneral.write(fields, combined_files)
return
@@ -143,7 +137,7 @@
import sys
- if not len(sys.argv) == 12:
+ if not (12 <= len(sys.argv) <= 13):
print __doc__
sys.exit(1)
@@ -158,12 +152,16 @@
nprocx = int(sys.argv[9])
nprocy = int(sys.argv[10])
nprocz = int(sys.argv[11])
+ if len(sys.argv) == 13:
+ fields = sys.argv[12]
+ else:
+ fields = 'coord,velo,visc'
totalnodes = nprocx * nprocy * nprocz * ncap
nodelist = machinefile2nodelist(machinefile, totalnodes)
batchcombine(nodelist, datadir, datafile, timestep, nodex, nodey, nodez,
- ncap, nprocx, nprocy, nprocz)
+ ncap, nprocx, nprocy, nprocz, fields)
Modified: mc/3D/CitcomS/trunk/visual/pasteCitcomData.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/pasteCitcomData.py 2007-06-14 17:12:12 UTC (rev 7235)
+++ mc/3D/CitcomS/trunk/visual/pasteCitcomData.py 2007-06-14 17:55:31 UTC (rev 7236)
@@ -29,25 +29,26 @@
'''
Paste CitcomS data together
- Usage: pasteCitcomData.py datadir datafile infix1,infix2[,...] rank step save_dir
+ Usage: pasteCitcomData.py datadir datafile field1,field2[,...] rank step save_dir
datadir: directory of the output files
datafile: prefix of the output files
-infix1, infix2, ...: the infix to be pasted (e.g.: coord, velo)
+field1, field2, ...: the fields to be pasted (e.g.: coord, velo)
rank: MPI rank of the output
step: time step of the output
save_dir: directory for the pasted file
'''
-def run(datadir, datafile, opts, rank, step, save_dir):
+def run(datadir, datafile, fields, rank, step, save_dir):
datadir = expand_datadir(datadir, rank)
- outfile = '%s/%s.%s.%d.%d.pasted' % (save_dir, datafile, opts, rank, step)
+ outfile = '%s/%s.%s.%d.%d.pasted' % (save_dir, datafile, fields,
+ rank, step)
f = open(outfile, 'w')
try:
- paste(datadir, datafile, opts, rank, step, f)
+ paste(datadir, datafile, fields, rank, step, f)
finally:
f.close()
@@ -55,13 +56,13 @@
-def paste(datadir, datafile, opts, rank, step, stream=None):
+def paste(datadir, datafile, fields, rank, step, stream=None):
if stream is None:
import sys
stream = sys.stdout
files = []
- for infix in opts.split(','):
+ for infix in fields.split(','):
f = open_file(datadir, datafile, infix, rank, step)
strip_headerlines(f, infix)
files.append(f)
@@ -161,12 +162,12 @@
datadir = sys.argv[1]
datafile = sys.argv[2]
- opts = sys.argv[3]
+ fields = sys.argv[3]
rank = int(sys.argv[4])
step = int(sys.argv[5])
save_dir = sys.argv[6]
- run(datadir, datafile, opts, rank, step, save_dir)
+ run(datadir, datafile, fields, rank, step, save_dir)
# End of file
More information about the cig-commits
mailing list