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

tan2 at geodynamics.org tan2 at geodynamics.org
Fri Sep 22 15:29:02 PDT 2006


Author: tan2
Date: 2006-09-22 15:29:02 -0700 (Fri, 22 Sep 2006)
New Revision: 4593

Modified:
   mc/3D/CitcomS/trunk/visual/batchsurf.py
Log:
* Fixed issue55 "surf files got deleted by batchsurf.py"
* Refactored the codes on machinefile -> nodelist


Modified: mc/3D/CitcomS/trunk/visual/batchsurf.py
===================================================================
--- mc/3D/CitcomS/trunk/visual/batchsurf.py	2006-09-22 22:14:37 UTC (rev 4592)
+++ mc/3D/CitcomS/trunk/visual/batchsurf.py	2006-09-22 22:29:02 UTC (rev 4593)
@@ -52,27 +52,14 @@
     nprocy = int(sys.argv[10])
     nprocz = int(sys.argv[11])
 
-    try:
-        nodelist = file(machinefile).readlines()
-    except IOError:
-        nodelist = machinefile.split()
-
-    # check the length of nodelist
+    # generate a string of machine names
+    from batchcombine import machinefile2nodes
     totalnodes = nprocx * nprocy * nprocz * ncap
-    n = len(nodelist)
-    if not n == totalnodes:
-        print 'WARNING: length of machinefile does not match number of processors'
-        if (totalnodes > n) and ((totalnodes % n) == 0):
-            # try to match number of processors by duplicating nodelist
-            nodelist *= (totalnodes / n)
-        else:
-            print 'ERROR: incorrect machinefile size'
-            sys.exit(1)
+    nodes = machinefile2nodes(machinefile, totalnodes)
 
-    # generate a string of machine names
-    nodes = ''
-    for n in range(nprocz-1, totalnodes, nprocz):
-        nodes += '%s ' % nodelist[n].strip()
+    # extract machines at the surface
+    tmp = nodes.split()[(nprocz-1)::nprocz]
+    nodes = ' '.join(tmp)
 
     # get coordinate, if necessary
     coord_exist = True
@@ -95,10 +82,13 @@
     print cmd
     os.system(cmd)
 
-    # delete
-    cmd = 'rm %(modelname)s.surf.[0-9]*.%(timestep)d' % vars()
-    print cmd
-    os.system(cmd)
+    # delete modelname.surf.* files, only if the originial data is not
+    # stored in the current directory, ie. if velofile exists
+    velofile = '%(modelname)s.velo.0.%(timestep)d' % vars()
+    if not os.path.exists(velofile):
+        cmd = 'rm %(modelname)s.surf.[0-9]*.%(timestep)d' % vars()
+        print cmd
+        os.system(cmd)
 
     # create .general file
     cmd = 'dxgeneralsurf.sh %(modelname)s.surf[0-9]*.%(timestep)d' % vars()



More information about the cig-commits mailing list