From ca5604490438a1c5a358d78a4dc9e4c38bda6c7c Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 6 Apr 2020 23:20:21 -0500 Subject: [PATCH 1/2] Making sure 'openmc' is always at the beginning of the argument list passed to the dynamic library. --- openmc/lib/core.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openmc/lib/core.py b/openmc/lib/core.py index d0fd41e6fa..3220fa343c 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -186,15 +186,15 @@ def init(args=None, intracomm=None): if args is not None: args = ['openmc'] + list(args) argc = len(args) - - # Create the argv array. Note that it is actually expected to be of - # length argc + 1 with the final item being a null pointer. - argv = (POINTER(c_char) * (argc + 1))() - for i, arg in enumerate(args): - argv[i] = create_string_buffer(arg.encode()) else: - argc = 0 - argv = None + args = ['openmc'] + argc = 1 + + # Create the argv array. Note that it is actually expected to be of + # length argc + 1 with the final item being a null pointer. + argv = (POINTER(c_char) * (argc + 1))() + for i, arg in enumerate(args): + argv[i] = create_string_buffer(arg.encode()) if intracomm is not None: # If an mpi4py communicator was passed, convert it to void* to be passed From 40a64f785f62cd74ca78d53ba47966cdbddcc885 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 8 Apr 2020 09:25:45 -0500 Subject: [PATCH 2/2] Set argc in one place as suggested by @paulromano. --- openmc/lib/core.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openmc/lib/core.py b/openmc/lib/core.py index 3220fa343c..54f33b6165 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -185,11 +185,10 @@ def init(args=None, intracomm=None): """ if args is not None: args = ['openmc'] + list(args) - argc = len(args) else: args = ['openmc'] - argc = 1 + argc = len(args) # Create the argv array. Note that it is actually expected to be of # length argc + 1 with the final item being a null pointer. argv = (POINTER(c_char) * (argc + 1))()