From 314a3553d96dcaa6988fc69bb858015b079a1f8f Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Mon, 15 Jun 2009 02:41:03 -0400
Subject: [PATCH] MPI relaunch: Allow user to query if MPI relaunch is in
 progress.

---
 pytools/mpi.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/pytools/mpi.py b/pytools/mpi.py
index d67106f..c20c3cc 100644
--- a/pytools/mpi.py
+++ b/pytools/mpi.py
@@ -1,9 +1,12 @@
-def run_with_mpi_ranks(py_script, ranks, callable, *args, **kwargs):
+def in_mpi_relaunch():
     import os
-    if "BOOSTMPI_RUN_WITHIN_MPI" in os.environ:
+    return "BOOSTMPI_RUN_WITHIN_MPI" in os.environ
+
+def run_with_mpi_ranks(py_script, ranks, callable, *args, **kwargs):
+    if in_mpi_relaunch():
         callable(*args, **kwargs)
     else:
-        import sys
+        import sys, os
         newenv = os.environ.copy()
         newenv["BOOSTMPI_RUN_WITHIN_MPI"] = "1"
 
-- 
GitLab