CONFIG: handle mpirunDebug stdin redirection before execution (#3389)

- previously handled stdin redirection as part of the run command but
  (as Alexey Matveichev noted) this meant the command would actually
  require an `eval` for this to work. Instead redirect before executing
  the run command.

- can always use 'echo -e' (bash builtin) in mpirunDebug

CONFIG: add removal of mpirun.files/ to CleanFunctions

- leave mpirun.log/ files untouched, since they may still be useful
  for later diagnosis
This commit is contained in:
Mark Olesen
2025-08-19 10:12:04 +02:00
parent 828693bc90
commit 8357b7e28b
2 changed files with 14 additions and 20 deletions

View File

@ -16,8 +16,7 @@
# mpirunDebug # mpirunDebug
# #
# Description # Description
# Invoke mpirun with separate per-processor log files # Invoke mpirun with separate per-processor log files etc.
# or running in separate XTerms.
# Requires bash on all processors. # Requires bash on all processors.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -100,15 +99,6 @@ methodNumberToName()
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Basic settings # Basic settings
case "$(uname -s)" in
Linux)
ECHO='echo -e'
;;
*)
ECHO='echo'
;;
esac
unset appName appArgs nProcs unset appName appArgs nProcs
unset method spawn optClean optValue opt_nocore unset method spawn optClean optValue opt_nocore
optConfirm=true optConfirm=true
@ -250,7 +240,7 @@ then
echo "Cleanup old mpirunDebug files..." echo "Cleanup old mpirunDebug files..."
rm -f gdbCommands mpirun.schema vgcore.* rm -f gdbCommands mpirun.schema vgcore.*
rm -f processor*.log processor*.sh rm -f processor*.log processor*.sh
rm -rf mpirun.log mpirun.files rm -rf mpirun.files mpirun.log
echo " gdbCommands mpirun.schema vgcore.*" echo " gdbCommands mpirun.schema vgcore.*"
echo " processor*.{log,sh}" echo " processor*.{log,sh}"
echo " mpirun.{files,log}/" echo " mpirun.{files,log}/"
@ -289,7 +279,7 @@ exec=$(command -v $appName)
if [ -z "$method" ] if [ -z "$method" ]
then then
echo "Choose running method: ${methodPrompt}" echo "Choose running method: ${methodPrompt}"
$ECHO "[normal] > \c" echo -e "[normal] > \c"
read input read input
: "${input:=0}" # Default (0) normal : "${input:=0}" # Default (0) normal
@ -301,7 +291,7 @@ fi
if [ -z "$spawn" ] if [ -z "$spawn" ]
then then
echo "Run all processes local or distributed? 1)local 2)remote" echo "Run all processes local or distributed? 1)local 2)remote"
$ECHO "[local] > \c" echo -e "[local] > \c"
read input read input
: "${input:=1}" # Default (1) local : "${input:=1}" # Default (1) local
@ -478,7 +468,7 @@ unset cmd
case "$WM_MPLIB" in case "$WM_MPLIB" in
*OPENMPI*) *OPENMPI*)
cmd="mpirun --oversubscribe -app "$schema_file" </dev/null" cmd="mpirun --oversubscribe -app "$schema_file""
;; ;;
MPICH) MPICH)
cmd="mpiexec" cmd="mpiexec"
@ -511,13 +501,14 @@ echo 1>&2
if [ -n "$optConfirm" ] if [ -n "$optConfirm" ]
then then
# Pause before running # Pause before running
$ECHO "Press return to execute.\c" echo -e "Press return to execute, or ^C to abort...\c"
read input read input
else
echo "starting: $(date '+%Y-%m-%d %H:%M:%S %z' 2>/dev/null)" 1>&2
echo 1>&2 echo 1>&2
fi fi
echo "starting: $(date '+%Y-%m-%d %H:%M:%S %z' 2>/dev/null)" 1>&2
echo 1>&2
exec </dev/null
exec $cmd exec $cmd
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -6,7 +6,7 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2015-2023 OpenCFD Ltd. # Copyright (C) 2015-2025 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -32,10 +32,13 @@ cleanTimeDirectories()
} }
# Various files (logs, paraview, etc) # Various files (logs, paraview, some mpirunDebug, etc)
# Note: leave mpirun.log/ files untouched, since they may still be useful
# for later diagnosis
cleanAuxiliary() cleanAuxiliary()
{ {
rm -rf \ rm -rf \
./mpirun.files \
./log ./log.* ./log-* ./logSummary.* \ ./log ./log.* ./log-* ./logSummary.* \
./.fxLock ./*.xml ./ParaView* ./paraFoam* \ ./.fxLock ./*.xml ./ParaView* ./paraFoam* \
./*.blockMesh ./*.foam ./*.OpenFOAM \ ./*.blockMesh ./*.foam ./*.OpenFOAM \