[cig-commits] r5259 - mc/3D/CitcomS/trunk
leif at geodynamics.org
leif at geodynamics.org
Mon Nov 13 19:25:28 PST 2006
Author: leif
Date: 2006-11-13 19:25:28 -0800 (Mon, 13 Nov 2006)
New Revision: 5259
Modified:
mc/3D/CitcomS/trunk/Makefile.am
mc/3D/CitcomS/trunk/citcoms.in
mc/3D/CitcomS/trunk/pycitcoms.c
mc/3D/CitcomS/trunk/setup.py
Log:
Pythia v0.8.1.0b4: Fixed bugs relating to MPI launching:
Fix sys.path/PYTHONPATH automatically; don't touch 'argv'
until after MPI_Init().
Next, I may try to slurp 'pycitcoms.c' into the framework...
it contains a lot of implementation details which have
everything to do with Pyre and nothing to do with CitcomS.
Modified: mc/3D/CitcomS/trunk/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/Makefile.am 2006-11-14 03:20:23 UTC (rev 5258)
+++ mc/3D/CitcomS/trunk/Makefile.am 2006-11-14 03:25:28 UTC (rev 5259)
@@ -44,7 +44,7 @@
if COND_PYRE
if COND_EMBEDDING
- bin_PROGRAMS = pycitcoms
+ bin_PROGRAMS = pycitcoms mpipycitcoms
else
bin_PROGRAMS =
endif
@@ -128,11 +128,26 @@
$(pycitcoms_LDFLAGS) $(pycitcoms_OBJECTS) $(pycitcoms_LDADD) \
$(PYTHON_EGG_LDFLAGS) \
$(PYTHON_BLDLIBRARY) \
- $(MPILIBS) \
- $(FCLIBS) \
$(PYTHON_LIBS) $(PYTHON_MODLIBS) $(PYTHON_SYSLIBS) \
$(LIBS) \
$(PYTHON_LDLAST)
+# pycitcoms (libCitcomS + CitcomSLibmodule + embedded Python interpreter)
+mpipycitcoms_SOURCES = pycitcoms.c
+mpipycitcoms_CFLAGS = -DUSE_MPI
+mpipycitcoms_LDADD = \
+ $(top_builddir)/module/libCitcomSLibmodule.a \
+ $(libCitcomS)
+mpipycitcoms$(EXEEXT): $(mpipycitcoms_OBJECTS) $(mpipycitcoms_DEPENDENCIES)
+ @rm -f mpipycitcoms$(EXEEXT)
+ $(LINK) $(PYTHON_LDFLAGS) $(PYTHON_LINKFORSHARED) \
+ $(mpipycitcoms_LDFLAGS) $(mpipycitcoms_OBJECTS) $(mpipycitcoms_LDADD) \
+ $(PYTHON_EGG_LDFLAGS) \
+ $(PYTHON_BLDLIBRARY) \
+ $(PYTHON_LIBS) $(PYTHON_MODLIBS) $(PYTHON_SYSLIBS) \
+ $(LIBS) \
+ $(PYTHON_LDLAST)
+
+
## end of Makefile.am
Modified: mc/3D/CitcomS/trunk/citcoms.in
===================================================================
--- mc/3D/CitcomS/trunk/citcoms.in 2006-11-14 03:20:23 UTC (rev 5258)
+++ mc/3D/CitcomS/trunk/citcoms.in 2006-11-14 03:25:28 UTC (rev 5259)
@@ -27,6 +27,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
+__requires__ = "CitcomS"
# re-create the PYTHONPATH at 'configure' time
import os.path, sys
@@ -36,7 +37,6 @@
if directory:
directory = os.path.abspath(directory)
sys.path.insert(1, directory)
-import pythia
from CitcomS.SimpleApp import SimpleApp
app = SimpleApp()
Modified: mc/3D/CitcomS/trunk/pycitcoms.c
===================================================================
--- mc/3D/CitcomS/trunk/pycitcoms.c 2006-11-14 03:20:23 UTC (rev 5258)
+++ mc/3D/CitcomS/trunk/pycitcoms.c 2006-11-14 03:25:28 UTC (rev 5259)
@@ -26,10 +26,25 @@
*/
#include <Python.h>
+#include <stddef.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <mpi.h>
#include "CitcomSmodule.h"
+#define COMMAND \
+"import sys; " \
+"path = sys.argv[1]; " \
+"requires = sys.argv[2]; " \
+"entry = sys.argv[3]; " \
+"path = path.split(':'); " \
+"path.extend(sys.path); " \
+"sys.path = path; " \
+"from pyre.util import loadObject; " \
+"entry = loadObject(entry); " \
+"entry(sys.argv[3:], kwds={'requires': requires})"
+
/* include the implementation of _mpi */
#include "mpi/_mpi.c"
@@ -41,12 +56,47 @@
int main(int argc, char **argv)
{
+ int status;
+
+#ifdef USE_MPI
+ /* initialize MPI */
+ if (MPI_Init(&argc, &argv) != MPI_SUCCESS) {
+ fprintf(stderr, "%s: MPI_Init failed! Exiting ...", argv[0]);
+ return 1;
+ }
+#endif
+
/* add our extension module */
if (PyImport_ExtendInittab(inittab) == -1) {
fprintf(stderr, "%s: PyImport_ExtendInittab failed! Exiting...\n", argv[0]);
return 1;
}
- return Py_Main(argc, argv);
+
+ if (argc < 3 || strcmp(argv[1], "--pyre-start") != 0) {
+ return Py_Main(argc, argv);
+ }
+
+ /* make sure 'sys.executable' is set to the path of this program */
+ Py_SetProgramName(argv[0]);
+
+ /* initialize Python */
+ Py_Initialize();
+
+ /* initialize sys.argv */
+ PySys_SetArgv(argc - 1, argv + 1);
+
+ /* run the Python command */
+ status = PyRun_SimpleString(COMMAND) != 0;
+
+ /* shut down Python */
+ Py_Finalize();
+
+#ifdef USE_MPI
+ /* shut down MPI */
+ MPI_Finalize();
+#endif
+
+ return status;
}
/* End of file */
Modified: mc/3D/CitcomS/trunk/setup.py
===================================================================
--- mc/3D/CitcomS/trunk/setup.py 2006-11-14 03:20:23 UTC (rev 5258)
+++ mc/3D/CitcomS/trunk/setup.py 2006-11-14 03:25:28 UTC (rev 5259)
@@ -13,7 +13,7 @@
packages = find_packages(),
install_requires = [
- 'pythia[mpi] >= 0.8.1.0b3, < 0.8.2a',
+ 'pythia[mpi] >= 0.8.1.0b4, < 0.8.2a',
],
author = 'Louis Moresi, et al.',
More information about the cig-commits
mailing list