[cig-commits] r5368 - in mc/3D/CitcomS/trunk: CitcomS/Components CitcomS/Components/Sphere CitcomS/Solver module

leif at geodynamics.org leif at geodynamics.org
Tue Nov 28 15:28:36 PST 2006


Author: leif
Date: 2006-11-28 15:28:36 -0800 (Tue, 28 Nov 2006)
New Revision: 5368

Modified:
   mc/3D/CitcomS/trunk/CitcomS/Components/IC.py
   mc/3D/CitcomS/trunk/CitcomS/Components/Sphere/FullSphere.py
   mc/3D/CitcomS/trunk/CitcomS/Components/Sphere/RegionalSphere.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py
   mc/3D/CitcomS/trunk/module/bindings.c
   mc/3D/CitcomS/trunk/module/getProperty.h
   mc/3D/CitcomS/trunk/module/misc.c
   mc/3D/CitcomS/trunk/module/misc.h
   mc/3D/CitcomS/trunk/module/setProperties.c
Log:
Fixed some bugs, some of which were introduced during the C -> C++
transition.

Using a pidXXXX.cfg file as input should "work" now, although it still
doesn't reproduce the original simulation, since at least one
parameter is missing ('steps').  I maintain that dumping the
configuration is really the job of the framework (Pyre).
Unfortunately, Pyre's current capabilities in this area are buggy in
the case of '.pml' files, and non-existent in the case of '.cfg'
files.

Note: 'nproc_surf' is now a real inventory item, instead of a fake
one.  It looks like it doesn't belong in the inventory at all, though.
(I left it there to avoid breakage.)


Modified: mc/3D/CitcomS/trunk/CitcomS/Components/IC.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Components/IC.py	2006-11-28 22:14:34 UTC (rev 5367)
+++ mc/3D/CitcomS/trunk/CitcomS/Components/IC.py	2006-11-28 23:28:36 UTC (rev 5368)
@@ -41,6 +41,12 @@
 
         from CitcomSLib import IC_set_properties
 
+        inv = self.inventory
+        inv.perturbmag = map(float, inv.perturbmag)
+        inv.perturbl = map(int, inv.perturbl)
+        inv.perturbm = map(int, inv.perturbm)
+        inv.blob_center = map(float, inv.blob_center)
+
         IC_set_properties(self.all_variables, self.inventory, stream)
 
         return

Modified: mc/3D/CitcomS/trunk/CitcomS/Components/Sphere/FullSphere.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Components/Sphere/FullSphere.py	2006-11-28 22:14:34 UTC (rev 5367)
+++ mc/3D/CitcomS/trunk/CitcomS/Components/Sphere/FullSphere.py	2006-11-28 23:28:36 UTC (rev 5368)
@@ -31,13 +31,6 @@
 class FullSphere(Sphere):
 
 
-    def __init__(self, name, facility):
-        Sphere.__init__(self, name, facility)
-	self.inventory.nproc_surf = 12
-        return
-
-
-
     def launch(self):
         from CitcomSLib import full_sphere_launch
         full_sphere_launch(self.all_variables)
@@ -45,7 +38,14 @@
 
 
 
+    class Inventory(Sphere.Inventory):
 
+        import pyre.inventory
+        
+        nproc_surf = pyre.inventory.int("nproc_surf", default=12)
+
+
+
 # version
 __id__ = "$Id$"
 

Modified: mc/3D/CitcomS/trunk/CitcomS/Components/Sphere/RegionalSphere.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Components/Sphere/RegionalSphere.py	2006-11-28 22:14:34 UTC (rev 5367)
+++ mc/3D/CitcomS/trunk/CitcomS/Components/Sphere/RegionalSphere.py	2006-11-28 23:28:36 UTC (rev 5368)
@@ -31,13 +31,6 @@
 class RegionalSphere(Sphere):
 
 
-    def __init__(self, name, facility):
-        Sphere.__init__(self, name, facility)
-	self.inventory.nproc_surf = 1
-        return
-
-
-
     def launch(self):
         from CitcomSLib import regional_sphere_launch
         regional_sphere_launch(self.all_variables)
@@ -49,6 +42,7 @@
 
         import pyre.inventory
 
+        nproc_surf = pyre.inventory.int("nproc_surf", default=1)
 
         # used only in Regional version, not in Full version
         theta_min = pyre.inventory.float("theta_min", default=1.0708)

Modified: mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py	2006-11-28 22:14:34 UTC (rev 5367)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py	2006-11-28 23:28:36 UTC (rev 5368)
@@ -96,12 +96,15 @@
         global_default_values(self.all_variables)
         set_signal()
 
-        #pid = self.all_variables.control.PID
-        from os import getpid
-        pid = getpid()
-        stream = open("pid%d.cfg" % pid, "w")
+        from CitcomSLib import return_rank, return_pid
+        rank = return_rank(self.all_variables)
+        if rank == 0:
+            pid = return_pid(self.all_variables)
+            stream = open("pid%d.cfg" % pid, "w")
+        else:
+            stream = None
+        
         self.setProperties(stream)
-        stream.close()
 
         self.restart = self.inventory.ic.inventory.restart
 

Modified: mc/3D/CitcomS/trunk/module/bindings.c
===================================================================
--- mc/3D/CitcomS/trunk/module/bindings.c	2006-11-28 22:14:34 UTC (rev 5367)
+++ mc/3D/CitcomS/trunk/module/bindings.c	2006-11-28 23:28:36 UTC (rev 5368)
@@ -135,6 +135,16 @@
      METH_VARARGS,
      pyCitcom_return_t__doc__},
 
+    {pyCitcom_return_rank__name__,
+     pyCitcom_return_rank,
+     METH_VARARGS,
+     pyCitcom_return_rank__doc__},
+
+    {pyCitcom_return_pid__name__,
+     pyCitcom_return_pid,
+     METH_VARARGS,
+     pyCitcom_return_pid__doc__},
+
     /* from advdiffu.h */
 
     {pyCitcom_PG_timestep_init__name__,

Modified: mc/3D/CitcomS/trunk/module/getProperty.h
===================================================================
--- mc/3D/CitcomS/trunk/module/getProperty.h	2006-11-28 22:14:34 UTC (rev 5367)
+++ mc/3D/CitcomS/trunk/module/getProperty.h	2006-11-28 23:28:36 UTC (rev 5368)
@@ -98,7 +98,7 @@
         }
         
 	if (fp)
-            fprintf(fp, FORMAT "%s", vector[i], (i == len ? "" : ","));
+            fprintf(fp, "%s" FORMAT, (i ? "," : ""), vector[i]);
     }
 
     if (fp)

Modified: mc/3D/CitcomS/trunk/module/misc.c
===================================================================
--- mc/3D/CitcomS/trunk/module/misc.c	2006-11-28 22:14:34 UTC (rev 5367)
+++ mc/3D/CitcomS/trunk/module/misc.c	2006-11-28 23:28:36 UTC (rev 5368)
@@ -360,6 +360,40 @@
 }
 
 
+char pyCitcom_return_rank__doc__[] = "";
+char pyCitcom_return_rank__name__[] = "return_rank";
+
+PyObject * pyCitcom_return_rank(PyObject *self, PyObject *args)
+{
+    PyObject *obj;
+    struct All_variables* E;
+
+    if (!PyArg_ParseTuple(args, "O:return_rank", &obj))
+        return NULL;
+
+    E = (struct All_variables*)(PyCObject_AsVoidPtr(obj));
+
+    return Py_BuildValue("i", E->parallel.me);
+}
+
+
+char pyCitcom_return_pid__doc__[] = "";
+char pyCitcom_return_pid__name__[] = "return_pid";
+
+PyObject * pyCitcom_return_pid(PyObject *self, PyObject *args)
+{
+    PyObject *obj;
+    struct All_variables* E;
+
+    if (!PyArg_ParseTuple(args, "O:return_pid", &obj))
+        return NULL;
+
+    E = (struct All_variables*)(PyCObject_AsVoidPtr(obj));
+
+    return Py_BuildValue("i", E->control.PID);
+}
+
+
 /*////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////*/
 

Modified: mc/3D/CitcomS/trunk/module/misc.h
===================================================================
--- mc/3D/CitcomS/trunk/module/misc.h	2006-11-28 22:14:34 UTC (rev 5367)
+++ mc/3D/CitcomS/trunk/module/misc.h	2006-11-28 23:28:36 UTC (rev 5368)
@@ -108,6 +108,16 @@
 PyObject * pyCitcom_return_t(PyObject *, PyObject *);
 
 
+extern char pyCitcom_return_rank__name__[];
+extern char pyCitcom_return_rank__doc__[];
+PyObject * pyCitcom_return_rank(PyObject *, PyObject *);
+
+
+extern char pyCitcom_return_pid__name__[];
+extern char pyCitcom_return_pid__doc__[];
+PyObject * pyCitcom_return_pid(PyObject *, PyObject *);
+
+
 #endif
 
 /* $Id$ */

Modified: mc/3D/CitcomS/trunk/module/setProperties.c
===================================================================
--- mc/3D/CitcomS/trunk/module/setProperties.c	2006-11-28 22:14:34 UTC (rev 5367)
+++ mc/3D/CitcomS/trunk/module/setProperties.c	2006-11-28 23:28:36 UTC (rev 5368)
@@ -489,7 +489,7 @@
     E = (struct All_variables*)(PyCObject_AsVoidPtr(obj));
     fp = get_output_stream(out, E);
 
-    PUTS(("[CitcomS.mesher]\n"));
+    PUTS(("[CitcomS.solver.mesher]\n"));
 
     getIntProperty(properties, "nproc_surf", E->parallel.nprocxy, fp);
 
@@ -751,12 +751,10 @@
 
 FILE *get_output_stream(PyObject *out, struct All_variables*E)
 {
-    int mute;
-
-    mute = E->parallel.me;
-    if (mute)
-	return NULL;
-    return PyFile_AsFile(out);
+    if (PyFile_Check(out)) {
+        return PyFile_AsFile(out);
+    }
+    return NULL;
 }
 
 



More information about the cig-commits mailing list