From cc0690a365e6ee4f5852b8c39c473d46e4522e92 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Mon, 22 Jun 2026 10:52:01 -0400 Subject: [PATCH 1/2] No need to check cli args anymore. --- src/mpi/orbit_mpi.cc | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/src/mpi/orbit_mpi.cc b/src/mpi/orbit_mpi.cc index 2dc97e71..f18ef402 100644 --- a/src/mpi/orbit_mpi.cc +++ b/src/mpi/orbit_mpi.cc @@ -8,42 +8,14 @@ #if !defined(DOXYGEN_SHOULD_SKIP_THIS) /** A C wrapper around MPI_Init. */ int ORBIT_MPI_Init(){ - int res = 0; #if USE_MPI > 0 - int len=0; - char** ch = NULL; - // Getting arguments from sys.argv - PyObject* sys_module = PyImport_ImportModule("sys"); - PyObject* argv_list = PyObject_GetAttrString(sys_module, "argv"); - - // Check if argv_list is a list - if (PyList_Check(argv_list)) { - // Access individual command-line arguments - len = PyList_Size(argv_list); - ch = (char**) malloc(sizeof(char*) * len); - for (Py_ssize_t i = 0; i < len; ++i) { - PyObject* item = PyList_GetItem(argv_list, i); - if (item && PyUnicode_Check(item)) { - ch[i] = const_cast(PyUnicode_AsUTF8(item)); - } - } - } - - // Release references - Py_XDECREF(argv_list); - Py_XDECREF(sys_module); - - res = MPI_Init(&len,&ch); - - free(ch); - ch = NULL; + // Ignoring result; if it fails, the proc is doomed anyway. + MPI_Init(NULL, NULL); // Registering MPI finalize method at cleanup stage Py_AtExit(ORBIT_MPI_Finalize); -#else - res = MPI_SUCCESS; #endif - return res; + return MPI_SUCCESS; } /** A C wrapper around MPI_Initialized. */ From 335e8475a16ad727bfd3ccef3bc10429b1bfb758 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Mon, 22 Jun 2026 10:55:46 -0400 Subject: [PATCH 2/2] Fix infinite recursion. --- src/mpi/orbit_mpi.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mpi/orbit_mpi.cc b/src/mpi/orbit_mpi.cc index f18ef402..a099f5f7 100644 --- a/src/mpi/orbit_mpi.cc +++ b/src/mpi/orbit_mpi.cc @@ -456,7 +456,7 @@ int ORBIT_MPI_Graphdims_get(MPI_Comm comm, int *nnodes, int *nedges){ int ORBIT_MPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int *index, int *edges){ int res = 0; #if USE_MPI > 0 - res = ORBIT_MPI_Graph_get(comm, maxindex, maxedges, index, edges); + res = MPI_Graph_get(comm, maxindex, maxedges, index, edges); #else res = MPI_SUCCESS; #endif