From 8b411e81a17d23e7dd55a4a9eb0bcd44e564f3dc Mon Sep 17 00:00:00 2001
From: FKHals <5229803-FKHals@users.noreply.gitlab.com>
Date: Tue, 6 Sep 2022 15:13:55 +0200
Subject: [PATCH] Fix exported PATH variables to prepend custom OMPI

to make sure to not use the default system MPI installation.
---
 rank-swapper-agent/Makefile  |  6 ++++--
 rank-swapper-agent/client.sh | 12 ++++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/rank-swapper-agent/Makefile b/rank-swapper-agent/Makefile
index b5d328f888..8645e801f6 100644
--- a/rank-swapper-agent/Makefile
+++ b/rank-swapper-agent/Makefile
@@ -1,6 +1,8 @@
 export OMPI := /home/openmpi-install
-export PATH := $(PATH):$(OMPI)/bin
-export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH):$(OMPI)/bin
+# BEWARE: the order (custom OpenMPI first/prepended) is important since the
+# first gets picked and there may be other MPI installations on the system!
+export PATH := $(OMPI)/bin:$(PATH)
+export LD_LIBRARY_PATH := $(OMPI)/bin:$(LD_LIBRARY_PATH)
 # requirement: GNU make, see https://unix.stackexchange.com/questions/11530/adding-directory-to-path-through-makefile/261844#261844
 
 CC = gcc
diff --git a/rank-swapper-agent/client.sh b/rank-swapper-agent/client.sh
index 249f6e8181..19dad87afc 100755
--- a/rank-swapper-agent/client.sh
+++ b/rank-swapper-agent/client.sh
@@ -1,9 +1,13 @@
 #!/bin/bash
 
-export OMPI=/home/openmpi-install
-export DPM_AGENT_SOCKET=$OMPI/dpm_socket_socket
-export PATH=$PATH:$OMPI/bin
-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OMPI/bin
+# the export not done directly since not all shells allow the value of a
+# variable to be set at the same time it is exported
+OMPI=/home/openmpi-install; export OMPI
+DPM_AGENT_SOCKET=$OMPI/dpm_socket_socket; export DPM_AGENT_SOCKET
+# BEWARE: the order (custom OpenMPI first/prepended) is important since the
+# first gets picked and there may be other MPI installations on the system!
+PATH=$OMPI/bin:$PATH; export PATH
+LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OMPI/bin; export LD_LIBRARY_PATH
 
 PROCESSES=1
 
-- 
GitLab