mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: FOAM_INST_DIR not preserved across versions in foamExec, foamJob
This commit is contained in:
23
bin/foamExec
23
bin/foamExec
@ -33,7 +33,7 @@
|
|||||||
#
|
#
|
||||||
# Can also be used for parallel runs e.g.
|
# Can also be used for parallel runs e.g.
|
||||||
# mpirun -np <nProcs> \
|
# mpirun -np <nProcs> \
|
||||||
# foamExec -v <foamVersion> <foamCommand> ... -parallel
|
# foamExec -version <foamVersion> <foamCommand> ... -parallel
|
||||||
#
|
#
|
||||||
# SeeAlso
|
# SeeAlso
|
||||||
# foamEtcFile
|
# foamEtcFile
|
||||||
@ -46,9 +46,11 @@ usage() {
|
|||||||
Usage: ${0##*/} [OPTION] <application> ...
|
Usage: ${0##*/} [OPTION] <application> ...
|
||||||
|
|
||||||
options:
|
options:
|
||||||
|
-prefix <dir> specify an alternative installation prefix
|
||||||
|
pass through to foamEtcFile and set as FOAM_INST_DIR
|
||||||
-version <ver> specify an alternative OpenFOAM version
|
-version <ver> specify an alternative OpenFOAM version
|
||||||
pass through to foamEtcFile
|
pass through to foamEtcFile
|
||||||
-help this usage
|
-help print the usage
|
||||||
|
|
||||||
* run a particular OpenFOAM version of <application>
|
* run a particular OpenFOAM version of <application>
|
||||||
|
|
||||||
@ -63,7 +65,7 @@ USAGE
|
|||||||
# foamEtcFile must be found in the same directory as this script
|
# foamEtcFile must be found in the same directory as this script
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
unset etcOpts version
|
unset etcOpts prefix version
|
||||||
# parse options
|
# parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
@ -71,14 +73,20 @@ do
|
|||||||
-h | -help)
|
-h | -help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
-v | -version)
|
-m | -mode)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
version="$2"
|
|
||||||
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-m | -mode | -p | -prefix)
|
-p | -prefix)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
|
prefix="$2"
|
||||||
|
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-v | -version)
|
||||||
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
|
version="$2"
|
||||||
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -111,6 +119,9 @@ sourceRc()
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# extra safety when sourcing the bashrc
|
||||||
|
[ -n "$prefix" ] && export FOAM_INST_DIR="$prefix"
|
||||||
|
|
||||||
. $foamDotFile
|
. $foamDotFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
72
bin/foamJob
72
bin/foamJob
@ -26,6 +26,8 @@
|
|||||||
# foamJob
|
# foamJob
|
||||||
#
|
#
|
||||||
# Description
|
# Description
|
||||||
|
# Run an OpenFOAM job in background.
|
||||||
|
# Redirects the output to 'log' in the case directory.
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
usage() {
|
usage() {
|
||||||
@ -36,9 +38,9 @@ usage() {
|
|||||||
Usage: ${0##*/} [OPTION] <application> ...
|
Usage: ${0##*/} [OPTION] <application> ...
|
||||||
options:
|
options:
|
||||||
-case <dir> specify alternative case directory, default is the cwd
|
-case <dir> specify alternative case directory, default is the cwd
|
||||||
-p parallel run of processors
|
-parallel parallel run of processors
|
||||||
-s also sends output to screen
|
-screen also sends output to screen
|
||||||
-v <ver> specify OpenFOAM version
|
-version <ver> specify an alternative OpenFOAM version
|
||||||
-help print the usage
|
-help print the usage
|
||||||
|
|
||||||
* run an OpenFOAM job in background.
|
* run an OpenFOAM job in background.
|
||||||
@ -95,23 +97,22 @@ do
|
|||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
-case)
|
-case)
|
||||||
[ "$#" -ge 2 ] || usage "'-case' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
caseDir=$2
|
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
||||||
shift 2
|
shift 2
|
||||||
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'"
|
|
||||||
;;
|
;;
|
||||||
-p)
|
-p | -parallel)
|
||||||
parallelOpt=true
|
parallelOpt=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-s)
|
-s | -screen)
|
||||||
screenOpt=true
|
screenOpt=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-v)
|
-v | -version)
|
||||||
shift
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
version=$1
|
version="$2"
|
||||||
shift
|
shift 2
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
@ -126,29 +127,32 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$#" -lt 1 ]
|
[ "$#" -ge 1 ] || usage "No application specified"
|
||||||
then
|
|
||||||
usage "No application specified"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# use foamExec for a specified version and for remote (parallel) runs
|
|
||||||
|
# use foamExec for a specified version
|
||||||
|
# also need foamExec for remote (parallel) runs
|
||||||
if [ -n "$version" -o "$parallelOpt" = true ]
|
if [ -n "$version" -o "$parallelOpt" = true ]
|
||||||
then
|
then
|
||||||
APPLICATION=`findExec foamExec`
|
# when possible, determine if application even exists
|
||||||
if [ $? -ne 0 ]
|
if [ -z "$version" ]
|
||||||
then
|
then
|
||||||
usage "'foamExec' not found"
|
findExec $1 >/dev/null || usage "Application '$1' not found"
|
||||||
fi
|
fi
|
||||||
if [ -n "$version" ]
|
|
||||||
|
# use foamExec for dispatching
|
||||||
|
APPLICATION=`findExec foamExec` || usage "'foamExec' not found"
|
||||||
|
|
||||||
|
[ -n "$version" ] && APPLICATION="$APPLICATION -version $version"
|
||||||
|
|
||||||
|
# attempt to preserve the installation directory 'FOAM_INST_DIR'
|
||||||
|
if [ -d "$FOAM_INST_DIR" ]
|
||||||
then
|
then
|
||||||
APPLICATION="$APPLICATION -v $version"
|
APPLICATION="$APPLICATION -prefix $FOAM_INST_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
APPLICATION=`findExec $1`
|
APPLICATION=`findExec $1` || usage "Application '$1' not found"
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
usage "Application '$1' executable not found"
|
|
||||||
fi
|
|
||||||
echo "Application : $1"
|
echo "Application : $1"
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
@ -182,11 +186,7 @@ then
|
|||||||
#
|
#
|
||||||
# locate mpirun
|
# locate mpirun
|
||||||
#
|
#
|
||||||
mpirun=`findExec mpirun`
|
mpirun=`findExec mpirun` || usage "'mpirun' not found"
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
usage "'mpirun' not found"
|
|
||||||
fi
|
|
||||||
mpiopts="-np $NPROCS"
|
mpiopts="-np $NPROCS"
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -217,10 +217,10 @@ then
|
|||||||
#
|
#
|
||||||
if [ "$screenOpt" = true ]
|
if [ "$screenOpt" = true ]
|
||||||
then
|
then
|
||||||
echo "Executing: mpirun $mpiopts $APPLICATION $@ -parallel | tee log"
|
echo "Executing: $mpirun $mpiopts $APPLICATION $@ -parallel | tee log"
|
||||||
$mpirun $mpiopts $APPLICATION $@ -parallel | tee log
|
$mpirun $mpiopts $APPLICATION $@ -parallel | tee log
|
||||||
else
|
else
|
||||||
echo "Executing: mpirun $mpiopts $APPLICATION $@ -parallel > log 2>&1"
|
echo "Executing: $mpirun $mpiopts $APPLICATION $@ -parallel > log 2>&1"
|
||||||
$mpirun $mpiopts $APPLICATION $@ -parallel > log 2>&1 &
|
$mpirun $mpiopts $APPLICATION $@ -parallel > log 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -237,8 +237,6 @@ else
|
|||||||
echo "Executing: $APPLICATION $@ > log 2>&1 &"
|
echo "Executing: $APPLICATION $@ > log 2>&1 &"
|
||||||
$APPLICATION $@ > log 2>&1 &
|
$APPLICATION $@ > log 2>&1 &
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user