Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mpi launch fix #2574

Merged
merged 7 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions metomi/rose/scripts/rose-mpi-launch
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,22 @@ fi
ROSE_LAUNCHER_BASE=
if [[ -n $ROSE_LAUNCHER ]]; then
# Path
if ! ROSE_LAUNCHER_PATH="$(type -P "$ROSE_LAUNCHER")"; then
err "ROSE_LAUNCHER: $ROSE_LAUNCHER: command not found"
fi
ROSE_LAUNCHER_PATH=""
for command in ${ROSE_LAUNCHER}; do
if command="$(type -P "$command")"; then
ROSE_LAUNCHER_PATH="${ROSE_LAUNCHER_PATH} ${command}"
else
err "ROSE_LAUNCHER: $ROSE_LAUNCHER: command not found"
fi
done
ROSE_LAUNCHER=$ROSE_LAUNCHER_PATH
ROSE_LAUNCHER_BASE="$(basename "$ROSE_LAUNCHER")"
fi

#-------------------------------------------------------------------------------
# 3. Launch the program.
#-------------------------------------------------------------------------------

wxtim marked this conversation as resolved.
Show resolved Hide resolved
if [[ -n $ROSE_COMMAND_FILE ]]; then
if [[ -z $ROSE_LAUNCHER_BASE ]]; then
err "ROSE_LAUNCHER not defined, command file not supported."
Expand Down
52 changes: 52 additions & 0 deletions t/rose-mpi-launch/03-commands.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------
# Copyright (C) British Crown (Met Office) & Contributors.
#
# This file is part of Rose, a framework for meteorological suites.
#
# Rose is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Rose is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rose. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test "rose mpi-launch" with multiple commands; e.g.
# $ export ROSE_LAUNCHER="time mpiexec"
# $ rose mpi-launch -v true
#
# Should work through each command.
#
# Response to bug @https://github.com/metomi/rose/issues/2573
#-------------------------------------------------------------------------------
. $(dirname $0)/test_header
tests 4
#-------------------------------------------------------------------------------
true_path=$(which true)
ls_path=$(which ls)
time_path=$(which time)

# Control - test that having one command in "ROSE_LAUNCHER" still works.
TEST_NAME="${TEST_KEY_BASE}-check-single-path"
export ROSE_LAUNCHER="ls"
run_pass "${TEST_NAME}" rose mpi-launch -v true
file_grep \
"${TEST_NAME}-output" \
"exec ${ls_path} ${true_path}"\
"${TEST_NAME}.out"

# Test - test having multiple commands in "ROSE_LAUNCHER".
TEST_NAME="${TEST_KEY_BASE}-check-multiple-paths"
export ROSE_LAUNCHER="time ls"
run_pass "${TEST_NAME}" rose mpi-launch -v true

file_grep \
"${TEST_NAME}-output" \
"exec ${time_path} ${ls_path} ${true_path}"\
"${TEST_NAME}.out"