[cig-commits] r7243 - mc/3D/CitcomS/branches/compressible/visual

tan2 at geodynamics.org tan2 at geodynamics.org
Thu Jun 14 13:38:43 PDT 2007


Author: tan2
Date: 2007-06-14 13:38:42 -0700 (Thu, 14 Jun 2007)
New Revision: 7243

Modified:
   mc/3D/CitcomS/branches/compressible/visual/autocombine.py
   mc/3D/CitcomS/branches/compressible/visual/batchcombine.py
   mc/3D/CitcomS/branches/compressible/visual/pasteCitcomData.py
Log:
Porting r7236 from trunk

Modified: mc/3D/CitcomS/branches/compressible/visual/autocombine.py
===================================================================
--- mc/3D/CitcomS/branches/compressible/visual/autocombine.py	2007-06-14 20:28:55 UTC (rev 7242)
+++ mc/3D/CitcomS/branches/compressible/visual/autocombine.py	2007-06-14 20:38:42 UTC (rev 7243)
@@ -116,13 +116,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, ncompositions)
+                        'coord,velo,visc', 0)
 
+        # combining optional fields, if necessary
+        if optional_fields:
+            bc.batchcombine(nodelist, datadir, datafile, timestep,
+                            nodex, nodey, nodez,
+                            ncap, nprocx, nprocy, nprocz,
+                            optional_fields, ncompositions)
 
 
+
 # version
 # $Id$
 

Modified: mc/3D/CitcomS/branches/compressible/visual/batchcombine.py
===================================================================
--- mc/3D/CitcomS/branches/compressible/visual/batchcombine.py	2007-06-14 20:28:55 UTC (rev 7242)
+++ mc/3D/CitcomS/branches/compressible/visual/batchcombine.py	2007-06-14 20:38:42 UTC (rev 7243)
@@ -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 [ncompositions]
+Usage: batchcombine.py <machinefile | node-list> datadir datafile timestep nodex nodey nodez ncap nprocx nprocy nprocz [fields [ncompositions]]
 '''
 
 
@@ -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,20 +100,15 @@
 
 
 def batchcombine(nodes, datadir, datafile, timestep, nodex, nodey, nodez,
-                 ncap, nprocx, nprocy, nprocz, optional_fields,
-                 ncompositions=0):
+                 ncap, nprocx, nprocy, nprocz, fields,
+                 ncompositions):
     # paste
-    opts0 = 'coord,velo,visc'
-    opts1 = optional_fields
+    batchpaste(datadir, datafile, fields, timestep, nodes)
 
-    batchpaste(datadir, datafile, opts0, timestep, nodes)
-    if opts1: batchpaste(datadir, datafile, opts1, timestep, nodes)
-
     # combine
     import combine
-    combine.combine(datafile, opts0, timestep, nodex, nodey, nodez,
-                        ncap, nprocx, nprocy, nprocz)
-    if opts1: combine.combine(datafile, opts1, timestep, nodex, nodey, nodez,
+    combine.combine(datafile, fields, timestep,
+                    nodex, nodey, nodez,
                     ncap, nprocx, nprocy, nprocz)
 
     # delete pasted files
@@ -127,14 +122,15 @@
 
     # create .general file
     import dxgeneral
-    combined_files0 = []
-    combined_files1 = []
+    combined_files = []
+    if fields == 'coord,velo,visc':
+        fmt = '%(datafile)s.cap%(cap)02d.%(timestep)d'
+    else:
+        fmt = '%(datafile)s.opt%(cap)02d.%(timestep)d'
     for cap in range(ncap):
-        combined_files0.append('%(datafile)s.cap%(cap)02d.%(timestep)d' % vars())
-        if opts1: combined_files1.append('%(datafile)s.opt%(cap)02d.%(timestep)d' % vars())
+        combined_files.append(fmt % vars())
 
-    dxgeneral.write(opts0, 0, combined_files0)
-    if opts1: dxgeneral.write(opts1, ncompositions, combined_files1)
+    dxgeneral.write(fields, ncompositions, combined_files)
 
     return
 
@@ -144,7 +140,7 @@
 
     import sys
 
-    if len(sys.argv) < 12:
+    if not (12 <= len(sys.argv) <= 14):
         print __doc__
         sys.exit(1)
 
@@ -160,16 +156,21 @@
     nprocy = int(sys.argv[10])
     nprocz = int(sys.argv[11])
 
-    if len(sys.argv) < 13:
-        ncompositions = 0
+    if len(sys.argv) >= 13:
+        fields = sys.argv[12]
     else:
-        ncompositions = int(sys.argv[12])
+        fields = 'coord,velo,visc'
 
+    if len(sys.argv) == 14:
+        ncompositions = int(sys.argv[13])
+    else:
+        ncompositions = 0
+
     totalnodes = nprocx * nprocy * nprocz * ncap
     nodelist = machinefile2nodelist(machinefile, totalnodes)
 
     batchcombine(nodelist, datadir, datafile, timestep, nodex, nodey, nodez,
-                 ncap, nprocx, nprocy, nprocz, ncompositions)
+                 ncap, nprocx, nprocy, nprocz, fields, ncompositions)
 
 
 

Modified: mc/3D/CitcomS/branches/compressible/visual/pasteCitcomData.py
===================================================================
--- mc/3D/CitcomS/branches/compressible/visual/pasteCitcomData.py	2007-06-14 20:28:55 UTC (rev 7242)
+++ mc/3D/CitcomS/branches/compressible/visual/pasteCitcomData.py	2007-06-14 20:38:42 UTC (rev 7243)
@@ -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