[cig-commits] r7139 - cs/pythia/trunk/mpi

leif at geodynamics.org leif at geodynamics.org
Mon Jun 11 17:16:32 PDT 2007


Author: leif
Date: 2007-06-11 17:16:32 -0700 (Mon, 11 Jun 2007)
New Revision: 7139

Modified:
   cs/pythia/trunk/mpi/CartesianCommunicator.py
   cs/pythia/trunk/mpi/Communicator.py
   cs/pythia/trunk/mpi/CommunicatorGroup.py
   cs/pythia/trunk/mpi/_mpi.c
   cs/pythia/trunk/mpi/_mpi.pxd
   cs/pythia/trunk/mpi/_mpi.pyx
   cs/pythia/trunk/mpi/cmpi.pxd
   cs/pythia/trunk/mpi/pympi.h
Log:
Added MPI_Group_* stuff to Pythia's _mpi Pyrex module (for Exchanger).


Modified: cs/pythia/trunk/mpi/CartesianCommunicator.py
===================================================================
--- cs/pythia/trunk/mpi/CartesianCommunicator.py	2007-06-12 00:05:50 UTC (rev 7138)
+++ cs/pythia/trunk/mpi/CartesianCommunicator.py	2007-06-12 00:16:32 UTC (rev 7139)
@@ -11,6 +11,10 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 
+
+raise NotImplementedError() # 2007-06-11 lcs
+
+
 from Communicator import Communicator
 
 

Modified: cs/pythia/trunk/mpi/Communicator.py
===================================================================
--- cs/pythia/trunk/mpi/Communicator.py	2007-06-12 00:05:50 UTC (rev 7138)
+++ cs/pythia/trunk/mpi/Communicator.py	2007-06-12 00:16:32 UTC (rev 7139)
@@ -20,8 +20,8 @@
 
 
     def barrier(self):
-        import _mpi
-        return _mpi.communicatorBarrier(self._handle)
+        from mpi import MPI_Barrier
+        MPI_Barrier(self._handle)
 
 
     # communicator factories
@@ -32,39 +32,26 @@
 
      # communicator group interface
     def group(self):
-        import _mpi
-        grpHandle = _mpi.groupCreate(self._handle)
-
+        from mpi import MPI_Comm_group
         from CommunicatorGroup import CommunicatorGroup
+        grpHandle = MPI_Comm_group(self._handle)
         return CommunicatorGroup(grpHandle)
 
 
     def include(self, included):
+        from mpi import MPI_Comm_create
         grp = self.group().include(included)
-        if not grp:
-            return None
+        handle = MPI_Comm_create(self._handle, grp.handle())
+        return Communicator(handle)
 
-        import _mpi
-        handle = _mpi.communicatorCreate(self._handle, grp.handle())
-        if handle:
-            return Communicator(handle)
 
-        return None
-
-
     def exclude(self, excluded):
+        from mpi import MPI_Comm_create
         grp = self.group().exclude(excluded)
-        if not grp:
-            return None
+        handle = MPI_Comm_create(self._handle, grp.handle())
+        return Communicator(handle)
 
-        import _mpi
-        handle = _mpi.communicatorCreate(self._handle, grp.handle())
-        if  handle:
-            return Communicator(handle)
 
-        return None
-
-
     # ports
     def port(self, peer, tag):
         from Port import Port

Modified: cs/pythia/trunk/mpi/CommunicatorGroup.py
===================================================================
--- cs/pythia/trunk/mpi/CommunicatorGroup.py	2007-06-12 00:05:50 UTC (rev 7138)
+++ cs/pythia/trunk/mpi/CommunicatorGroup.py	2007-06-12 00:16:32 UTC (rev 7139)
@@ -20,28 +20,25 @@
 
 
     def include(self, included):
-        import _mpi
-        handle = _mpi.groupInclude(self._handle, included)
-        if handle:
-            return CommunicatorGroup(handle)
-        return None
+        from mpi import MPI_Group_incl
+        handle = MPI_Group_incl(self._handle, included)
+        return CommunicatorGroup(handle)
 
 
     def exclude(self, excluded):
-        import _mpi
-        handle = _mpi.groupExclude(self._handle, excluded)
-        if handle:
-            return CommunicatorGroup(handle)
+        from mpi import MPI_Group_excl
+        handle = MPI_Group_excl(self._handle, excluded)
+        return CommunicatorGroup(handle)
 
-        return None
 
-
     def __init__(self, handle):
-        import _mpi
 
         self._handle = handle
-        self.rank = _mpi.groupRank(handle)
-        self.size = _mpi.groupSize(handle)
+        
+        from mpi import MPI_Group_rank, MPI_Group_size
+        self.rank = MPI_Group_rank(self._handle)
+        self.size = MPI_Group_size(self._handle)
+        
         return
 
 

Modified: cs/pythia/trunk/mpi/_mpi.c
===================================================================
--- cs/pythia/trunk/mpi/_mpi.c	2007-06-12 00:05:50 UTC (rev 7138)
+++ cs/pythia/trunk/mpi/_mpi.c	2007-06-12 00:16:32 UTC (rev 7139)
@@ -1,4 +1,4 @@
-/* Generated by Pyrex 0.9.5.1a on Tue May 15 14:10:55 2007 */
+/* Generated by Pyrex 0.9.5.1a on Mon Jun 11 16:42:28 2007 */
 
 #include "Python.h"
 #include "structmember.h"
@@ -11,6 +11,7 @@
 #define __PYX_EXTERN_C extern
 #endif
 __PYX_EXTERN_C double pow(double, double);
+#include "stdlib.h"
 #include "mpi.h"
 
 
@@ -23,14 +24,16 @@
 static char *__pyx_filename;
 static char **__pyx_f;
 
+static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/
+
 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
 static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/
 
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
 static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
 
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
-
 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
 
 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
@@ -48,8 +51,16 @@
   MPI_Comm comm;
 };
 
+
+struct __pyx_obj_4_mpi_MPI_Group {
+  PyObject_HEAD
+  MPI_Group group;
+};
+
 static PyTypeObject *__pyx_ptype_4_mpi_MPI_Comm = 0;
+static PyTypeObject *__pyx_ptype_4_mpi_MPI_Group = 0;
 static char (__pyx_v_4_mpi_cstring[1024]);
+static PyObject *(__pyx_f_4_mpi__newWorld(void)); /*proto*/
 
 
 /* Implementation of _mpi */
@@ -58,9 +69,16 @@
 static PyObject *__pyx_n_cmpi;
 static PyObject *__pyx_n_MPI_COMM_WORLD;
 static PyObject *__pyx_n_MPI_Error;
+static PyObject *__pyx_n_MPI_Barrier;
+static PyObject *__pyx_n_MPI_Comm_create;
+static PyObject *__pyx_n_MPI_Comm_group;
 static PyObject *__pyx_n_MPI_Comm_rank;
 static PyObject *__pyx_n_MPI_Comm_size;
 static PyObject *__pyx_n_MPI_Error_string;
+static PyObject *__pyx_n_MPI_Group_excl;
+static PyObject *__pyx_n_MPI_Group_incl;
+static PyObject *__pyx_n_MPI_Group_rank;
+static PyObject *__pyx_n_MPI_Group_size;
 static PyObject *__pyx_n_EnvironmentError;
 static PyObject *__pyx_n___str__;
 
@@ -71,14 +89,168 @@
   if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
   Py_INCREF(__pyx_v_self);
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":7 */
-  ((struct __pyx_obj_4_mpi_MPI_Comm *)__pyx_v_self)->comm = MPI_COMM_WORLD;
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":12 */
+  ((struct __pyx_obj_4_mpi_MPI_Comm *)__pyx_v_self)->comm = MPI_COMM_NULL;
 
   __pyx_r = 0;
   Py_DECREF(__pyx_v_self);
   return __pyx_r;
 }
 
+static void __pyx_f_4_mpi_8MPI_Comm___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_f_4_mpi_8MPI_Comm___dealloc__(PyObject *__pyx_v_self) {
+  int __pyx_v_error;
+  int __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  Py_INCREF(__pyx_v_self);
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":16 */
+  __pyx_1 = (((struct __pyx_obj_4_mpi_MPI_Comm *)__pyx_v_self)->comm != MPI_COMM_WORLD);
+  if (__pyx_1) {
+    __pyx_1 = (((struct __pyx_obj_4_mpi_MPI_Comm *)__pyx_v_self)->comm != MPI_COMM_NULL);
+  }
+  if (__pyx_1) {
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":17 */
+    __pyx_v_error = MPI_Comm_free((&((struct __pyx_obj_4_mpi_MPI_Comm *)__pyx_v_self)->comm));
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":18 */
+    __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
+    if (__pyx_1) {
+
+      /* "/home/leif/dv/pythia/mpi/_mpi.pyx":20 */
+      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
+      __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
+      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
+      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
+      __pyx_3 = 0;
+      __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
+      Py_DECREF(__pyx_2); __pyx_2 = 0;
+      Py_DECREF(__pyx_4); __pyx_4 = 0;
+      __Pyx_Raise(__pyx_3, 0, 0);
+      Py_DECREF(__pyx_3); __pyx_3 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
+      goto __pyx_L3;
+    }
+    __pyx_L3:;
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":21 */
+  goto __pyx_L0;
+
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  __Pyx_AddTraceback("_mpi.MPI_Comm.__dealloc__");
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_self);
+}
+
+static int __pyx_f_4_mpi_9MPI_Group___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_f_4_mpi_9MPI_Group___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_r;
+  static char *__pyx_argnames[] = {0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
+  Py_INCREF(__pyx_v_self);
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":27 */
+  ((struct __pyx_obj_4_mpi_MPI_Group *)__pyx_v_self)->group = MPI_GROUP_NULL;
+
+  __pyx_r = 0;
+  Py_DECREF(__pyx_v_self);
+  return __pyx_r;
+}
+
+static void __pyx_f_4_mpi_9MPI_Group___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_f_4_mpi_9MPI_Group___dealloc__(PyObject *__pyx_v_self) {
+  int __pyx_v_error;
+  int __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  Py_INCREF(__pyx_v_self);
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":31 */
+  __pyx_1 = (((struct __pyx_obj_4_mpi_MPI_Group *)__pyx_v_self)->group != MPI_GROUP_NULL);
+  if (__pyx_1) {
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":32 */
+    __pyx_v_error = MPI_Group_free((&((struct __pyx_obj_4_mpi_MPI_Group *)__pyx_v_self)->group));
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":33 */
+    __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
+    if (__pyx_1) {
+
+      /* "/home/leif/dv/pythia/mpi/_mpi.pyx":34 */
+      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;}
+      __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;}
+      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;}
+      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
+      __pyx_3 = 0;
+      __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;}
+      Py_DECREF(__pyx_2); __pyx_2 = 0;
+      Py_DECREF(__pyx_4); __pyx_4 = 0;
+      __Pyx_Raise(__pyx_3, 0, 0);
+      Py_DECREF(__pyx_3); __pyx_3 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;}
+      goto __pyx_L3;
+    }
+    __pyx_L3:;
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":35 */
+  goto __pyx_L0;
+
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  __Pyx_AddTraceback("_mpi.MPI_Group.__dealloc__");
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_self);
+}
+
+static PyObject *__pyx_f_4_mpi__newWorld(void) {
+  struct __pyx_obj_4_mpi_MPI_Comm *__pyx_v_world;
+  PyObject *__pyx_r;
+  PyObject *__pyx_1 = 0;
+  __pyx_v_world = ((struct __pyx_obj_4_mpi_MPI_Comm *)Py_None); Py_INCREF(Py_None);
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":40 */
+  __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_4_mpi_MPI_Comm), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; goto __pyx_L1;}
+  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_4_mpi_MPI_Comm)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; goto __pyx_L1;}
+  Py_DECREF(((PyObject *)__pyx_v_world));
+  __pyx_v_world = ((struct __pyx_obj_4_mpi_MPI_Comm *)__pyx_1);
+  __pyx_1 = 0;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":41 */
+  __pyx_v_world->comm = MPI_COMM_WORLD;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":42 */
+  Py_INCREF(((PyObject *)__pyx_v_world));
+  __pyx_r = ((PyObject *)__pyx_v_world);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_1);
+  __Pyx_AddTraceback("_mpi._newWorld");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_world);
+  return __pyx_r;
+}
+
 static PyObject *__pyx_n_args;
 
 static PyObject *__pyx_f_4_mpi_9MPI_Error___str__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
@@ -94,17 +266,17 @@
   if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_self)) return 0;
   Py_INCREF(__pyx_v_self);
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":15 */
-  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error_string); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
-  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_args); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
-  __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
-  __pyx_4 = PyObject_GetItem(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":49 */
+  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error_string); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
+  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_args); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
+  __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
+  __pyx_4 = PyObject_GetItem(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
   Py_DECREF(__pyx_2); __pyx_2 = 0;
   Py_DECREF(__pyx_3); __pyx_3 = 0;
-  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
+  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
   PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
   __pyx_4 = 0;
-  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
+  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
   Py_DECREF(__pyx_1); __pyx_1 = 0;
   Py_DECREF(__pyx_2); __pyx_2 = 0;
   __pyx_r = __pyx_3;
@@ -125,12 +297,206 @@
   return __pyx_r;
 }
 
+static PyObject *__pyx_f_4_mpi_MPI_Barrier(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_4_mpi_MPI_Barrier(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_4_mpi_MPI_Comm *__pyx_v_comm = 0;
+  int __pyx_v_error;
+  PyObject *__pyx_r;
+  int __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  static char *__pyx_argnames[] = {"comm",0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_comm)) return 0;
+  Py_INCREF(__pyx_v_comm);
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_comm), __pyx_ptype_4_mpi_MPI_Comm, 1, "comm")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;}
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":54 */
+  __pyx_v_error = MPI_Barrier(__pyx_v_comm->comm);
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":55 */
+  __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
+  if (__pyx_1) {
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":56 */
+    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
+    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
+    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
+    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
+    __pyx_3 = 0;
+    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    Py_DECREF(__pyx_4); __pyx_4 = 0;
+    __Pyx_Raise(__pyx_3, 0, 0);
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":57 */
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  __Pyx_AddTraceback("_mpi.MPI_Barrier");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_comm);
+  return __pyx_r;
+}
+
+static PyObject *__pyx_f_4_mpi_MPI_Comm_create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_4_mpi_MPI_Comm_create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_4_mpi_MPI_Comm *__pyx_v_comm = 0;
+  struct __pyx_obj_4_mpi_MPI_Group *__pyx_v_group = 0;
+  int __pyx_v_error;
+  struct __pyx_obj_4_mpi_MPI_Comm *__pyx_v_comm_out;
+  PyObject *__pyx_r;
+  PyObject *__pyx_1 = 0;
+  int __pyx_2;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  static char *__pyx_argnames[] = {"comm","group",0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_comm, &__pyx_v_group)) return 0;
+  Py_INCREF(__pyx_v_comm);
+  Py_INCREF(__pyx_v_group);
+  __pyx_v_comm_out = ((struct __pyx_obj_4_mpi_MPI_Comm *)Py_None); Py_INCREF(Py_None);
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_comm), __pyx_ptype_4_mpi_MPI_Comm, 1, "comm")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; goto __pyx_L1;}
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_group), __pyx_ptype_4_mpi_MPI_Group, 1, "group")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; goto __pyx_L1;}
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":63 */
+  __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_4_mpi_MPI_Comm), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;}
+  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_4_mpi_MPI_Comm)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;}
+  Py_DECREF(((PyObject *)__pyx_v_comm_out));
+  __pyx_v_comm_out = ((struct __pyx_obj_4_mpi_MPI_Comm *)__pyx_1);
+  __pyx_1 = 0;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":64 */
+  __pyx_v_error = MPI_Comm_create(__pyx_v_comm->comm,__pyx_v_group->group,(&__pyx_v_comm_out->comm));
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":65 */
+  __pyx_2 = (__pyx_v_error != MPI_SUCCESS);
+  if (__pyx_2) {
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":66 */
+    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
+    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
+    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
+    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
+    __pyx_3 = 0;
+    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    Py_DECREF(__pyx_4); __pyx_4 = 0;
+    __Pyx_Raise(__pyx_3, 0, 0);
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":67 */
+  Py_INCREF(((PyObject *)__pyx_v_comm_out));
+  __pyx_r = ((PyObject *)__pyx_v_comm_out);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_1);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  __Pyx_AddTraceback("_mpi.MPI_Comm_create");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_comm_out);
+  Py_DECREF(__pyx_v_comm);
+  Py_DECREF(__pyx_v_group);
+  return __pyx_r;
+}
+
+static PyObject *__pyx_f_4_mpi_MPI_Comm_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_4_mpi_MPI_Comm_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_4_mpi_MPI_Comm *__pyx_v_comm = 0;
+  struct __pyx_obj_4_mpi_MPI_Group *__pyx_v_group;
+  PyObject *__pyx_v_error;
+  PyObject *__pyx_r;
+  PyObject *__pyx_1 = 0;
+  int __pyx_2;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  static char *__pyx_argnames[] = {"comm",0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_comm)) return 0;
+  Py_INCREF(__pyx_v_comm);
+  __pyx_v_group = ((struct __pyx_obj_4_mpi_MPI_Group *)Py_None); Py_INCREF(Py_None);
+  __pyx_v_error = Py_None; Py_INCREF(Py_None);
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_comm), __pyx_ptype_4_mpi_MPI_Comm, 1, "comm")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; goto __pyx_L1;}
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":72 */
+  __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_4_mpi_MPI_Group), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
+  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_4_mpi_MPI_Group)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
+  Py_DECREF(((PyObject *)__pyx_v_group));
+  __pyx_v_group = ((struct __pyx_obj_4_mpi_MPI_Group *)__pyx_1);
+  __pyx_1 = 0;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":73 */
+  __pyx_1 = PyInt_FromLong(MPI_Comm_group(__pyx_v_comm->comm,(&__pyx_v_group->group))); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; goto __pyx_L1;}
+  Py_DECREF(__pyx_v_error);
+  __pyx_v_error = __pyx_1;
+  __pyx_1 = 0;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":74 */
+  __pyx_1 = PyInt_FromLong(MPI_SUCCESS); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;}
+  if (PyObject_Cmp(__pyx_v_error, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;}
+  __pyx_2 = __pyx_2 != 0;
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  if (__pyx_2) {
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":75 */
+    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
+    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
+    Py_INCREF(__pyx_v_error);
+    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_error);
+    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    __Pyx_Raise(__pyx_4, 0, 0);
+    Py_DECREF(__pyx_4); __pyx_4 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":76 */
+  Py_INCREF(((PyObject *)__pyx_v_group));
+  __pyx_r = ((PyObject *)__pyx_v_group);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_1);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  __Pyx_AddTraceback("_mpi.MPI_Comm_group");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_group);
+  Py_DECREF(__pyx_v_error);
+  Py_DECREF(__pyx_v_comm);
+  return __pyx_r;
+}
+
 static PyObject *__pyx_f_4_mpi_MPI_Comm_rank(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 static PyObject *__pyx_f_4_mpi_MPI_Comm_rank(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_v_comm = 0;
+  struct __pyx_obj_4_mpi_MPI_Comm *__pyx_v_comm = 0;
   int __pyx_v_error;
   int __pyx_v_rank;
-  struct __pyx_obj_4_mpi_MPI_Comm *__pyx_v_c_comm;
   PyObject *__pyx_r;
   int __pyx_1;
   PyObject *__pyx_2 = 0;
@@ -139,39 +505,33 @@
   static char *__pyx_argnames[] = {"comm",0};
   if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_comm)) return 0;
   Py_INCREF(__pyx_v_comm);
-  __pyx_v_c_comm = ((struct __pyx_obj_4_mpi_MPI_Comm *)Py_None); Py_INCREF(Py_None);
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_comm), __pyx_ptype_4_mpi_MPI_Comm, 1, "comm")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":22 */
-  if (!__Pyx_TypeTest(__pyx_v_comm, __pyx_ptype_4_mpi_MPI_Comm)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;}
-  Py_INCREF(__pyx_v_comm);
-  Py_DECREF(((PyObject *)__pyx_v_c_comm));
-  __pyx_v_c_comm = ((struct __pyx_obj_4_mpi_MPI_Comm *)__pyx_v_comm);
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":82 */
+  __pyx_v_error = MPI_Comm_rank(__pyx_v_comm->comm,(&__pyx_v_rank));
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":23 */
-  __pyx_v_error = MPI_Comm_rank(__pyx_v_c_comm->comm,(&__pyx_v_rank));
-
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":24 */
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":83 */
   __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
   if (__pyx_1) {
 
-    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":25 */
-    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;}
-    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;}
-    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;}
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":84 */
+    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
+    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
+    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
     PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
     __pyx_3 = 0;
-    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;}
+    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
     Py_DECREF(__pyx_2); __pyx_2 = 0;
     Py_DECREF(__pyx_4); __pyx_4 = 0;
     __Pyx_Raise(__pyx_3, 0, 0);
     Py_DECREF(__pyx_3); __pyx_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;}
     goto __pyx_L2;
   }
   __pyx_L2:;
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":26 */
-  __pyx_2 = PyInt_FromLong(__pyx_v_rank); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;}
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":85 */
+  __pyx_2 = PyInt_FromLong(__pyx_v_rank); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;}
   __pyx_r = __pyx_2;
   __pyx_2 = 0;
   goto __pyx_L0;
@@ -185,17 +545,15 @@
   __Pyx_AddTraceback("_mpi.MPI_Comm_rank");
   __pyx_r = 0;
   __pyx_L0:;
-  Py_DECREF(__pyx_v_c_comm);
   Py_DECREF(__pyx_v_comm);
   return __pyx_r;
 }
 
 static PyObject *__pyx_f_4_mpi_MPI_Comm_size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 static PyObject *__pyx_f_4_mpi_MPI_Comm_size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  PyObject *__pyx_v_comm = 0;
+  struct __pyx_obj_4_mpi_MPI_Comm *__pyx_v_comm = 0;
   int __pyx_v_error;
   int __pyx_v_size;
-  struct __pyx_obj_4_mpi_MPI_Comm *__pyx_v_c_comm;
   PyObject *__pyx_r;
   int __pyx_1;
   PyObject *__pyx_2 = 0;
@@ -204,39 +562,33 @@
   static char *__pyx_argnames[] = {"comm",0};
   if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_comm)) return 0;
   Py_INCREF(__pyx_v_comm);
-  __pyx_v_c_comm = ((struct __pyx_obj_4_mpi_MPI_Comm *)Py_None); Py_INCREF(Py_None);
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_comm), __pyx_ptype_4_mpi_MPI_Comm, 1, "comm")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;}
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":33 */
-  if (!__Pyx_TypeTest(__pyx_v_comm, __pyx_ptype_4_mpi_MPI_Comm)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;}
-  Py_INCREF(__pyx_v_comm);
-  Py_DECREF(((PyObject *)__pyx_v_c_comm));
-  __pyx_v_c_comm = ((struct __pyx_obj_4_mpi_MPI_Comm *)__pyx_v_comm);
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":91 */
+  __pyx_v_error = MPI_Comm_size(__pyx_v_comm->comm,(&__pyx_v_size));
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":34 */
-  __pyx_v_error = MPI_Comm_size(__pyx_v_c_comm->comm,(&__pyx_v_size));
-
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":35 */
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":92 */
   __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
   if (__pyx_1) {
 
-    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":36 */
-    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;}
-    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;}
-    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;}
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":93 */
+    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
+    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
+    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
     PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
     __pyx_3 = 0;
-    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;}
+    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
     Py_DECREF(__pyx_2); __pyx_2 = 0;
     Py_DECREF(__pyx_4); __pyx_4 = 0;
     __Pyx_Raise(__pyx_3, 0, 0);
     Py_DECREF(__pyx_3); __pyx_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
     goto __pyx_L2;
   }
   __pyx_L2:;
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":37 */
-  __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":94 */
+  __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
   __pyx_r = __pyx_2;
   __pyx_2 = 0;
   goto __pyx_L0;
@@ -250,7 +602,6 @@
   __Pyx_AddTraceback("_mpi.MPI_Comm_size");
   __pyx_r = 0;
   __pyx_L0:;
-  Py_DECREF(__pyx_v_c_comm);
   Py_DECREF(__pyx_v_comm);
   return __pyx_r;
 }
@@ -276,55 +627,55 @@
   if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_errorcode)) return 0;
   __pyx_v_string = Py_None; Py_INCREF(Py_None);
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":45 */
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":102 */
   __pyx_v_error = MPI_Error_string(__pyx_v_errorcode,__pyx_v_4_mpi_cstring,(&__pyx_v_resultlen));
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":46 */
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":103 */
   __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
   if (__pyx_1) {
 
-    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":47 */
-    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
-    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
-    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":104 */
+    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;}
+    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;}
+    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;}
     PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
     __pyx_3 = 0;
-    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
+    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;}
     Py_DECREF(__pyx_2); __pyx_2 = 0;
     Py_DECREF(__pyx_4); __pyx_4 = 0;
     __Pyx_Raise(__pyx_3, 0, 0);
     Py_DECREF(__pyx_3); __pyx_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;}
     goto __pyx_L2;
   }
   __pyx_L2:;
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":48 */
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":105 */
   __pyx_1 = (__pyx_v_resultlen >= 1024);
   if (__pyx_1) {
 
-    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":49 */
-    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
-    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":106 */
+    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;}
+    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;}
     Py_INCREF(__pyx_k2p);
     PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k2p);
-    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
+    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;}
     Py_DECREF(__pyx_2); __pyx_2 = 0;
     Py_DECREF(__pyx_4); __pyx_4 = 0;
     __Pyx_Raise(__pyx_3, 0, 0);
     Py_DECREF(__pyx_3); __pyx_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":50 */
-  __pyx_2 = PyString_FromString(__pyx_v_4_mpi_cstring); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":107 */
+  __pyx_2 = PyString_FromString(__pyx_v_4_mpi_cstring); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;}
   Py_DECREF(__pyx_v_string);
   __pyx_v_string = __pyx_2;
   __pyx_2 = 0;
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":51 */
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":108 */
   Py_INCREF(__pyx_v_string);
   __pyx_r = __pyx_v_string;
   goto __pyx_L0;
@@ -342,17 +693,357 @@
   return __pyx_r;
 }
 
+static PyObject *__pyx_n_len;
+
+static PyObject *__pyx_f_4_mpi_MPI_Group_excl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_4_mpi_MPI_Group_excl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_4_mpi_MPI_Group *__pyx_v_group = 0;
+  PyObject *__pyx_v_members = 0;
+  int __pyx_v_error;
+  int __pyx_v_n;
+  int (*__pyx_v_ranks);
+  struct __pyx_obj_4_mpi_MPI_Group *__pyx_v_group_out;
+  PyObject *__pyx_v_i;
+  PyObject *__pyx_r;
+  PyObject *__pyx_1 = 0;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  int __pyx_4;
+  long __pyx_5;
+  int __pyx_6;
+  static char *__pyx_argnames[] = {"group","members",0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_group, &__pyx_v_members)) return 0;
+  Py_INCREF(__pyx_v_group);
+  Py_INCREF(__pyx_v_members);
+  __pyx_v_group_out = ((struct __pyx_obj_4_mpi_MPI_Group *)Py_None); Py_INCREF(Py_None);
+  __pyx_v_i = Py_None; Py_INCREF(Py_None);
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_group), __pyx_ptype_4_mpi_MPI_Group, 1, "group")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;}
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":117 */
+  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
+  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
+  Py_INCREF(__pyx_v_members);
+  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_members);
+  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_v_n = __pyx_4;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":118 */
+  __pyx_v_ranks = ((int (*))malloc((__pyx_v_n * (sizeof(int )))));
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":119 */
+  for (__pyx_5 = 0; __pyx_5 < __pyx_v_n; ++__pyx_5) {
+    __pyx_1 = PyInt_FromLong(__pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;}
+    Py_DECREF(__pyx_v_i);
+    __pyx_v_i = __pyx_1;
+    __pyx_1 = 0;
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":120 */
+    __pyx_2 = PyObject_GetItem(__pyx_v_members, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}
+    __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    __pyx_6 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}
+    (__pyx_v_ranks[__pyx_6]) = __pyx_4;
+  }
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":122 */
+  __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_4_mpi_MPI_Group), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;}
+  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_4_mpi_MPI_Group)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;}
+  Py_DECREF(((PyObject *)__pyx_v_group_out));
+  __pyx_v_group_out = ((struct __pyx_obj_4_mpi_MPI_Group *)__pyx_3);
+  __pyx_3 = 0;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":124 */
+  __pyx_v_error = MPI_Group_excl(__pyx_v_group->group,__pyx_v_n,__pyx_v_ranks,(&__pyx_v_group_out->group));
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":126 */
+  free(__pyx_v_ranks);
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":128 */
+  __pyx_4 = (__pyx_v_error != MPI_SUCCESS);
+  if (__pyx_4) {
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":129 */
+    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
+    __pyx_2 = PyInt_FromLong(__pyx_v_error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
+    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
+    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
+    __pyx_2 = 0;
+    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    __Pyx_Raise(__pyx_2, 0, 0);
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":131 */
+  Py_INCREF(((PyObject *)__pyx_v_group_out));
+  __pyx_r = ((PyObject *)__pyx_v_group_out);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_1);
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  __Pyx_AddTraceback("_mpi.MPI_Group_excl");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_group_out);
+  Py_DECREF(__pyx_v_i);
+  Py_DECREF(__pyx_v_group);
+  Py_DECREF(__pyx_v_members);
+  return __pyx_r;
+}
+
+static PyObject *__pyx_f_4_mpi_MPI_Group_incl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_4_mpi_MPI_Group_incl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_4_mpi_MPI_Group *__pyx_v_group = 0;
+  PyObject *__pyx_v_members = 0;
+  int __pyx_v_error;
+  int __pyx_v_n;
+  int (*__pyx_v_ranks);
+  struct __pyx_obj_4_mpi_MPI_Group *__pyx_v_group_out;
+  PyObject *__pyx_v_i;
+  PyObject *__pyx_r;
+  PyObject *__pyx_1 = 0;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  int __pyx_4;
+  long __pyx_5;
+  int __pyx_6;
+  static char *__pyx_argnames[] = {"group","members",0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_group, &__pyx_v_members)) return 0;
+  Py_INCREF(__pyx_v_group);
+  Py_INCREF(__pyx_v_members);
+  __pyx_v_group_out = ((struct __pyx_obj_4_mpi_MPI_Group *)Py_None); Py_INCREF(Py_None);
+  __pyx_v_i = Py_None; Py_INCREF(Py_None);
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_group), __pyx_ptype_4_mpi_MPI_Group, 1, "group")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;}
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":140 */
+  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}
+  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}
+  Py_INCREF(__pyx_v_members);
+  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_members);
+  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_v_n = __pyx_4;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":141 */
+  __pyx_v_ranks = ((int (*))malloc((__pyx_v_n * (sizeof(int )))));
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":142 */
+  for (__pyx_5 = 0; __pyx_5 < __pyx_v_n; ++__pyx_5) {
+    __pyx_1 = PyInt_FromLong(__pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;}
+    Py_DECREF(__pyx_v_i);
+    __pyx_v_i = __pyx_1;
+    __pyx_1 = 0;
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":143 */
+    __pyx_2 = PyObject_GetItem(__pyx_v_members, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;}
+    __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    __pyx_6 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;}
+    (__pyx_v_ranks[__pyx_6]) = __pyx_4;
+  }
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":145 */
+  __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_4_mpi_MPI_Group), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}
+  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_4_mpi_MPI_Group)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}
+  Py_DECREF(((PyObject *)__pyx_v_group_out));
+  __pyx_v_group_out = ((struct __pyx_obj_4_mpi_MPI_Group *)__pyx_3);
+  __pyx_3 = 0;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":147 */
+  __pyx_v_error = MPI_Group_incl(__pyx_v_group->group,__pyx_v_n,__pyx_v_ranks,(&__pyx_v_group_out->group));
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":149 */
+  free(__pyx_v_ranks);
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":151 */
+  __pyx_4 = (__pyx_v_error != MPI_SUCCESS);
+  if (__pyx_4) {
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":152 */
+    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L1;}
+    __pyx_2 = PyInt_FromLong(__pyx_v_error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L1;}
+    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L1;}
+    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
+    __pyx_2 = 0;
+    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L1;}
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    __Pyx_Raise(__pyx_2, 0, 0);
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L1;}
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":154 */
+  Py_INCREF(((PyObject *)__pyx_v_group_out));
+  __pyx_r = ((PyObject *)__pyx_v_group_out);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_1);
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  __Pyx_AddTraceback("_mpi.MPI_Group_incl");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_group_out);
+  Py_DECREF(__pyx_v_i);
+  Py_DECREF(__pyx_v_group);
+  Py_DECREF(__pyx_v_members);
+  return __pyx_r;
+}
+
+static PyObject *__pyx_f_4_mpi_MPI_Group_rank(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_4_mpi_MPI_Group_rank(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_4_mpi_MPI_Group *__pyx_v_group = 0;
+  int __pyx_v_error;
+  int __pyx_v_rank;
+  PyObject *__pyx_r;
+  int __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  static char *__pyx_argnames[] = {"group",0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_group)) return 0;
+  Py_INCREF(__pyx_v_group);
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_group), __pyx_ptype_4_mpi_MPI_Group, 1, "group")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":160 */
+  __pyx_v_error = MPI_Group_rank(__pyx_v_group->group,(&__pyx_v_rank));
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":161 */
+  __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
+  if (__pyx_1) {
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":162 */
+    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
+    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
+    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
+    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
+    __pyx_3 = 0;
+    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    Py_DECREF(__pyx_4); __pyx_4 = 0;
+    __Pyx_Raise(__pyx_3, 0, 0);
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":163 */
+  __pyx_2 = PyInt_FromLong(__pyx_v_rank); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L1;}
+  __pyx_r = __pyx_2;
+  __pyx_2 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  __Pyx_AddTraceback("_mpi.MPI_Group_rank");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_group);
+  return __pyx_r;
+}
+
+static PyObject *__pyx_f_4_mpi_MPI_Group_size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_4_mpi_MPI_Group_size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_4_mpi_MPI_Group *__pyx_v_group = 0;
+  int __pyx_v_error;
+  int __pyx_v_size;
+  PyObject *__pyx_r;
+  int __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_4 = 0;
+  static char *__pyx_argnames[] = {"group",0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_group)) return 0;
+  Py_INCREF(__pyx_v_group);
+  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_group), __pyx_ptype_4_mpi_MPI_Group, 1, "group")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":169 */
+  __pyx_v_error = MPI_Group_size(__pyx_v_group->group,(&__pyx_v_size));
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":170 */
+  __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
+  if (__pyx_1) {
+
+    /* "/home/leif/dv/pythia/mpi/_mpi.pyx":171 */
+    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
+    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
+    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
+    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
+    __pyx_3 = 0;
+    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    Py_DECREF(__pyx_4); __pyx_4 = 0;
+    __Pyx_Raise(__pyx_3, 0, 0);
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
+
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":172 */
+  __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; goto __pyx_L1;}
+  __pyx_r = __pyx_2;
+  __pyx_2 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  Py_XDECREF(__pyx_4);
+  __Pyx_AddTraceback("_mpi.MPI_Group_size");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_group);
+  return __pyx_r;
+}
+
 static __Pyx_InternTabEntry __pyx_intern_tab[] = {
   {&__pyx_n_EnvironmentError, "EnvironmentError"},
+  {&__pyx_n_MPI_Barrier, "MPI_Barrier"},
   {&__pyx_n_MPI_COMM_WORLD, "MPI_COMM_WORLD"},
+  {&__pyx_n_MPI_Comm_create, "MPI_Comm_create"},
+  {&__pyx_n_MPI_Comm_group, "MPI_Comm_group"},
   {&__pyx_n_MPI_Comm_rank, "MPI_Comm_rank"},
   {&__pyx_n_MPI_Comm_size, "MPI_Comm_size"},
   {&__pyx_n_MPI_Error, "MPI_Error"},
   {&__pyx_n_MPI_Error_string, "MPI_Error_string"},
+  {&__pyx_n_MPI_Group_excl, "MPI_Group_excl"},
+  {&__pyx_n_MPI_Group_incl, "MPI_Group_incl"},
+  {&__pyx_n_MPI_Group_rank, "MPI_Group_rank"},
+  {&__pyx_n_MPI_Group_size, "MPI_Group_size"},
   {&__pyx_n_RuntimeError, "RuntimeError"},
   {&__pyx_n___str__, "__str__"},
   {&__pyx_n_args, "args"},
   {&__pyx_n_cmpi, "cmpi"},
+  {&__pyx_n_len, "len"},
   {0, 0}
 };
 
@@ -367,6 +1058,15 @@
 }
 
 static void __pyx_tp_dealloc_4_mpi_MPI_Comm(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++o->ob_refcnt;
+    __pyx_f_4_mpi_8MPI_Comm___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --o->ob_refcnt;
+    PyErr_Restore(etype, eval, etb);
+  }
   (*o->ob_type->tp_free)(o);
 }
 
@@ -498,10 +1198,163 @@
   0, /*tp_weaklist*/
 };
 
+static PyObject *__pyx_tp_new_4_mpi_MPI_Group(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  return o;
+}
+
+static void __pyx_tp_dealloc_4_mpi_MPI_Group(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++o->ob_refcnt;
+    __pyx_f_4_mpi_9MPI_Group___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --o->ob_refcnt;
+    PyErr_Restore(etype, eval, etb);
+  }
+  (*o->ob_type->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_4_mpi_MPI_Group(PyObject *o, visitproc v, void *a) {
+  return 0;
+}
+
+static int __pyx_tp_clear_4_mpi_MPI_Group(PyObject *o) {
+  return 0;
+}
+
+static struct PyMethodDef __pyx_methods_4_mpi_MPI_Group[] = {
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_MPI_Group = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  0, /*nb_divide*/
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  0, /*nb_coerce*/
+  0, /*nb_int*/
+  0, /*nb_long*/
+  0, /*nb_float*/
+  0, /*nb_oct*/
+  0, /*nb_hex*/
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  0, /*nb_inplace_divide*/
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_MPI_Group = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_MPI_Group = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_MPI_Group = {
+  0, /*bf_getreadbuffer*/
+  0, /*bf_getwritebuffer*/
+  0, /*bf_getsegcount*/
+  0, /*bf_getcharbuffer*/
+};
+
+PyTypeObject __pyx_type_4_mpi_MPI_Group = {
+  PyObject_HEAD_INIT(0)
+  0, /*ob_size*/
+  "_mpi.MPI_Group", /*tp_name*/
+  sizeof(struct __pyx_obj_4_mpi_MPI_Group), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_4_mpi_MPI_Group, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  0, /*tp_compare*/
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_MPI_Group, /*tp_as_number*/
+  &__pyx_tp_as_sequence_MPI_Group, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_MPI_Group, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_MPI_Group, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_4_mpi_MPI_Group, /*tp_traverse*/
+  __pyx_tp_clear_4_mpi_MPI_Group, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_4_mpi_MPI_Group, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_f_4_mpi_9MPI_Group___init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_4_mpi_MPI_Group, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+};
+
 static struct PyMethodDef __pyx_methods[] = {
+  {"MPI_Barrier", (PyCFunction)__pyx_f_4_mpi_MPI_Barrier, METH_VARARGS|METH_KEYWORDS, 0},
+  {"MPI_Comm_create", (PyCFunction)__pyx_f_4_mpi_MPI_Comm_create, METH_VARARGS|METH_KEYWORDS, 0},
+  {"MPI_Comm_group", (PyCFunction)__pyx_f_4_mpi_MPI_Comm_group, METH_VARARGS|METH_KEYWORDS, 0},
   {"MPI_Comm_rank", (PyCFunction)__pyx_f_4_mpi_MPI_Comm_rank, METH_VARARGS|METH_KEYWORDS, 0},
   {"MPI_Comm_size", (PyCFunction)__pyx_f_4_mpi_MPI_Comm_size, METH_VARARGS|METH_KEYWORDS, 0},
   {"MPI_Error_string", (PyCFunction)__pyx_f_4_mpi_MPI_Error_string, METH_VARARGS|METH_KEYWORDS, 0},
+  {"MPI_Group_excl", (PyCFunction)__pyx_f_4_mpi_MPI_Group_excl, METH_VARARGS|METH_KEYWORDS, 0},
+  {"MPI_Group_incl", (PyCFunction)__pyx_f_4_mpi_MPI_Group_incl, METH_VARARGS|METH_KEYWORDS, 0},
+  {"MPI_Group_rank", (PyCFunction)__pyx_f_4_mpi_MPI_Group_rank, METH_VARARGS|METH_KEYWORDS, 0},
+  {"MPI_Group_size", (PyCFunction)__pyx_f_4_mpi_MPI_Group_size, METH_VARARGS|METH_KEYWORDS, 0},
   {0, 0, 0, 0}
 };
 
@@ -521,35 +1374,38 @@
   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
   if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
   if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
-  if (PyType_Ready(&__pyx_type_4_mpi_MPI_Comm) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
-  if (PyObject_SetAttrString(__pyx_m, "MPI_Comm", (PyObject *)&__pyx_type_4_mpi_MPI_Comm) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
+  if (PyType_Ready(&__pyx_type_4_mpi_MPI_Comm) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
+  if (PyObject_SetAttrString(__pyx_m, "MPI_Comm", (PyObject *)&__pyx_type_4_mpi_MPI_Comm) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
   __pyx_ptype_4_mpi_MPI_Comm = &__pyx_type_4_mpi_MPI_Comm;
+  if (PyType_Ready(&__pyx_type_4_mpi_MPI_Group) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;}
+  if (PyObject_SetAttrString(__pyx_m, "MPI_Group", (PyObject *)&__pyx_type_4_mpi_MPI_Group) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;}
+  __pyx_ptype_4_mpi_MPI_Group = &__pyx_type_4_mpi_MPI_Group;
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":10 */
-  __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_4_mpi_MPI_Comm), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_MPI_COMM_WORLD, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":44 */
+  __pyx_1 = __pyx_f_4_mpi__newWorld(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_MPI_COMM_WORLD, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;}
   Py_DECREF(__pyx_1); __pyx_1 = 0;
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":13 */
-  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
-  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_EnvironmentError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
-  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":47 */
+  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
+  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_EnvironmentError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
+  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
   PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
   __pyx_2 = 0;
-  __pyx_2 = __Pyx_CreateClass(__pyx_3, __pyx_1, __pyx_n_MPI_Error, "_mpi"); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
+  __pyx_2 = __Pyx_CreateClass(__pyx_3, __pyx_1, __pyx_n_MPI_Error, "_mpi"); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
   Py_DECREF(__pyx_3); __pyx_3 = 0;
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":14 */
-  __pyx_3 = PyCFunction_New(&__pyx_mdef_4_mpi_9MPI_Error___str__, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
-  __pyx_4 = PyMethod_New(__pyx_3, 0, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":48 */
+  __pyx_3 = PyCFunction_New(&__pyx_mdef_4_mpi_9MPI_Error___str__, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;}
+  __pyx_4 = PyMethod_New(__pyx_3, 0, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;}
   Py_DECREF(__pyx_3); __pyx_3 = 0;
-  if (PyObject_SetAttr(__pyx_2, __pyx_n___str__, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
+  if (PyObject_SetAttr(__pyx_2, __pyx_n___str__, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;}
   Py_DECREF(__pyx_4); __pyx_4 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_MPI_Error, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_MPI_Error, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
   Py_DECREF(__pyx_2); __pyx_2 = 0;
   Py_DECREF(__pyx_1); __pyx_1 = 0;
 
-  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":42 */
+  /* "/home/leif/dv/pythia/mpi/_mpi.pyx":166 */
   return;
   __pyx_L1:;
   Py_XDECREF(__pyx_1);
@@ -569,6 +1425,19 @@
   __pyx_f = __pyx_filenames;
 }
 
+static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name) {
+    if (!type) {
+        PyErr_Format(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if ((none_allowed && obj == Py_None) || PyObject_TypeCheck(obj, type))
+        return 1;
+    PyErr_Format(PyExc_TypeError,
+        "Argument '%s' has incorrect type (expected %s, got %s)",
+        name, type->tp_name, obj->ob_type->tp_name);
+    return 0;
+}
+
 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
     PyObject *result;
     result = PyObject_GetAttr(dict, name);
@@ -594,18 +1463,6 @@
     return result;
 }
 
-static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
-    if (!type) {
-        PyErr_Format(PyExc_SystemError, "Missing type object");
-        return 0;
-    }
-    if (obj == Py_None || PyObject_TypeCheck(obj, type))
-        return 1;
-    PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
-        obj->ob_type->tp_name, type->tp_name);
-    return 0;
-}
-
 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
     Py_XINCREF(type);
     Py_XINCREF(value);
@@ -664,6 +1521,18 @@
     return;
 }
 
+static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
+    if (!type) {
+        PyErr_Format(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (obj == Py_None || PyObject_TypeCheck(obj, type))
+        return 1;
+    PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
+        obj->ob_type->tp_name, type->tp_name);
+    return 0;
+}
+
 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
     while (t->p) {
         *t->p = PyString_InternFromString(t->s);

Modified: cs/pythia/trunk/mpi/_mpi.pxd
===================================================================
--- cs/pythia/trunk/mpi/_mpi.pxd	2007-06-12 00:05:50 UTC (rev 7138)
+++ cs/pythia/trunk/mpi/_mpi.pxd	2007-06-12 00:16:32 UTC (rev 7139)
@@ -9,4 +9,9 @@
     cdef cmpi.MPI_Comm comm
 
 
+cdef class MPI_Group:
+
+    cdef cmpi.MPI_Group group
+
+
 # end of file

Modified: cs/pythia/trunk/mpi/_mpi.pyx
===================================================================
--- cs/pythia/trunk/mpi/_mpi.pyx	2007-06-12 00:05:50 UTC (rev 7138)
+++ cs/pythia/trunk/mpi/_mpi.pyx	2007-06-12 00:16:32 UTC (rev 7139)
@@ -1,37 +1,94 @@
 # Process this file with Pyrex to produce mpi.c
 
 
+cdef extern from "stdlib.h":
+    void *malloc(int)
+    void free(void *)
+
+
 cdef class MPI_Comm:
 
     def __init__(MPI_Comm self):
-        self.comm = cmpi.MPI_COMM_WORLD
+        self.comm = cmpi.MPI_COMM_NULL
 
+    def __dealloc__(MPI_Comm self):
+        cdef int error
+        if self.comm != cmpi.MPI_COMM_WORLD and self.comm != cmpi.MPI_COMM_NULL:
+            error = cmpi.MPI_Comm_free(&self.comm)
+            if error != cmpi.MPI_SUCCESS:
+                # Will anyone hear our cries?
+                raise MPI_Error(error)
+        return
 
-MPI_COMM_WORLD = MPI_Comm()
 
+cdef class MPI_Group:
 
+    def __init__(MPI_Group self):
+        self.group = cmpi.MPI_GROUP_NULL
+
+    def __dealloc__(MPI_Group self):
+        cdef int error
+        if self.group != cmpi.MPI_GROUP_NULL:
+            error = cmpi.MPI_Group_free(&self.group)
+            if error != cmpi.MPI_SUCCESS:
+                raise MPI_Error(error)
+        return
+
+
+cdef _newWorld():
+    cdef MPI_Comm world
+    world = MPI_Comm()
+    world.comm = cmpi.MPI_COMM_WORLD
+    return world
+
+MPI_COMM_WORLD = _newWorld()
+
+
 class MPI_Error(EnvironmentError):
     def __str__(self):
         return MPI_Error_string(self.args[0])
 
 
-def MPI_Comm_rank(comm):
+def MPI_Barrier(MPI_Comm comm):
     cdef int error
+    error = cmpi.MPI_Barrier(comm.comm)
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    return
+
+
+def MPI_Comm_create(MPI_Comm comm, MPI_Group group):
+    cdef int error
+    cdef MPI_Comm comm_out
+    comm_out = MPI_Comm()
+    error = cmpi.MPI_Comm_create(comm.comm, group.group, &comm_out.comm)
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    return comm_out
+
+
+def MPI_Comm_group(MPI_Comm comm):
+    cdef MPI_Group group
+    group = MPI_Group()
+    error = cmpi.MPI_Comm_group(comm.comm, &group.group)
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    return group
+
+
+def MPI_Comm_rank(MPI_Comm comm):
+    cdef int error
     cdef int rank
-    cdef MPI_Comm c_comm
-    c_comm = comm
-    error = cmpi.MPI_Comm_rank(c_comm.comm, &rank)
+    error = cmpi.MPI_Comm_rank(comm.comm, &rank)
     if error != cmpi.MPI_SUCCESS:
         raise MPI_Error(error)
     return rank
 
 
-def MPI_Comm_size(comm):
+def MPI_Comm_size(MPI_Comm comm):
     cdef int error
     cdef int size
-    cdef MPI_Comm c_comm
-    c_comm = comm
-    error = cmpi.MPI_Comm_size(c_comm.comm, &size)
+    error = cmpi.MPI_Comm_size(comm.comm, &size)
     if error != cmpi.MPI_SUCCESS:
         raise MPI_Error(error)
     return size
@@ -49,6 +106,70 @@
         raise RuntimeError("buffer overflow")
     string = cstring
     return string
+
+
+def MPI_Group_excl(MPI_Group group, members):
+    cdef int error
+    cdef int n
+    cdef int *ranks
+    cdef MPI_Group group_out
     
+    n = len(members)
+    ranks = <int *>malloc(n * sizeof(int))
+    for i from 0 <= i < n:
+        ranks[i] = members[i]
 
+    group_out = MPI_Group()
+
+    error = cmpi.MPI_Group_excl(group.group, n, ranks, &group_out.group)
+    
+    free(ranks)
+    
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    
+    return group_out
+
+
+def MPI_Group_incl(MPI_Group group, members):
+    cdef int error
+    cdef int n
+    cdef int *ranks
+    cdef MPI_Group group_out
+    
+    n = len(members)
+    ranks = <int *>malloc(n * sizeof(int))
+    for i from 0 <= i < n:
+        ranks[i] = members[i]
+
+    group_out = MPI_Group()
+
+    error = cmpi.MPI_Group_incl(group.group, n, ranks, &group_out.group)
+    
+    free(ranks)
+    
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    
+    return group_out
+
+
+def MPI_Group_rank(MPI_Group group):
+    cdef int error
+    cdef int rank
+    error = cmpi.MPI_Group_rank(group.group, &rank)
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    return rank
+
+
+def MPI_Group_size(MPI_Group group):
+    cdef int error
+    cdef int size
+    error = cmpi.MPI_Group_size(group.group, &size)
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    return size
+
+
 # end of file

Modified: cs/pythia/trunk/mpi/cmpi.pxd
===================================================================
--- cs/pythia/trunk/mpi/cmpi.pxd	2007-06-12 00:05:50 UTC (rev 7138)
+++ cs/pythia/trunk/mpi/cmpi.pxd	2007-06-12 00:16:32 UTC (rev 7139)
@@ -8,12 +8,32 @@
     ctypedef struct MPI_Comm_Imp:
         pass
     ctypedef MPI_Comm_Imp *MPI_Comm
+    MPI_Comm MPI_COMM_NULL
     MPI_Comm MPI_COMM_WORLD
 
+    ctypedef struct MPI_Group_Imp:
+        pass
+    ctypedef MPI_Group_Imp *MPI_Group
+    MPI_Group MPI_GROUP_NULL
+
     int MPI_Init(int *, char ***)
     int MPI_Finalize()
+
+    int MPI_Barrier(MPI_Comm comm)
+    
+    int MPI_Comm_create(MPI_Comm, MPI_Group, MPI_Comm *)
+    int MPI_Comm_free(MPI_Comm *)
+    int MPI_Comm_group(MPI_Comm comm, MPI_Group *group)
     int MPI_Comm_rank(MPI_Comm, int *)
     int MPI_Comm_size(MPI_Comm, int *)
+    
     int MPI_Error_string(int, char *, int *)
 
+    int MPI_Group_excl(MPI_Group, int, int *, MPI_Group *)
+    int MPI_Group_free(MPI_Group *)
+    int MPI_Group_incl(MPI_Group, int, int *, MPI_Group *)
+    int MPI_Group_rank(MPI_Group, int *)
+    int MPI_Group_size(MPI_Group, int *)
+
+
 # end of file

Modified: cs/pythia/trunk/mpi/pympi.h
===================================================================
--- cs/pythia/trunk/mpi/pympi.h	2007-06-12 00:05:50 UTC (rev 7138)
+++ cs/pythia/trunk/mpi/pympi.h	2007-06-12 00:16:32 UTC (rev 7139)
@@ -26,6 +26,11 @@
         MPI_Comm comm;
     } PyMPICommObject;
 
+    typedef struct {
+        PyObject_HEAD
+        MPI_Group group;
+    } PyMPIGroupObject;
+
 #ifdef __cplusplus
 }
 #endif



More information about the cig-commits mailing list