diff --git a/scripts/run_eg.sh b/scripts/run_eg.sh index 0de17ff8..bf1ec818 100755 --- a/scripts/run_eg.sh +++ b/scripts/run_eg.sh @@ -4,7 +4,7 @@ # Helper functions echo_usage() { echo "Usage:" - echo " $0 [solver_name] [example_name] <-n num_MPI> <-b build_dir>" + echo " $0 [solver_name] [example_name] <-n num_MPI> <-b build_dir/install_dir>" } execute() { @@ -30,8 +30,8 @@ generate_run_dir() { cp -r "$eg_dir" "$run_dir" } -set_default_build_dir() { - build_dir=$(find "$REPO_ROOT/builds" -mindepth 1 -maxdepth 1 -type d -printf "%TY-%Tm-%Td %TT %p\n" | sort -n|tail -1|cut -d " " -f 3) +set_default_exec_loc() { + exec_loc=$(find "$REPO_ROOT/views" -mindepth 1 -maxdepth 1 -type l -printf "%TY-%Tm-%Td %TT %p\n" | sort -n|tail -1|cut -d " " -f 3) } parse_args() { @@ -43,14 +43,14 @@ parse_args() { while [[ $# -gt 0 ]]; do case $1 in -b|--build-dir) - build_dir=$(realpath "$2") + exec_loc=$(realpath "$2") shift 2 ;; -n|--num_mpi) nmpi="$2" shift 2 ;; - -*|--*) + -*) echo "Unknown option $1" exit 2 ;; @@ -91,13 +91,22 @@ set_run_cmd() { fi } -validate_paths() { - local solver_exec=$1 +set_exec_paths_and_validate() { + local exec_loc=$1 local eg_dir=$2 - if [ ! -f "$solver_exec" ]; then - echo "No solver found at $solver_exec" + + # Check both build and install locations for solver executable + solver_build_exec="$exec_loc/solvers/$solver_name/$solver_name" + solver_install_exec="$exec_loc/bin/$solver_name" + if [ -f "$solver_build_exec" ]; then + solver_exec="$solver_build_exec" + elif [ -f "$solver_install_exec" ]; then + solver_exec="$solver_install_exec" + else + echo "No solver found at [$solver_build_exec] or [$solver_install_exec]" exit 3 fi + if [ ! -d "$eg_dir" ]; then echo "No example directory found at $eg_dir" exit 4 @@ -111,18 +120,17 @@ REPO_ROOT=$( cd -- "$(realpath $( dirname -- "${BASH_SOURCE[0]}" )/..)" &> /dev/ solver_name='Not set' eg_name='Not set' nmpi='4' -build_dir='Not set' -set_default_build_dir +exec_loc='Not set' +set_default_exec_loc # Parse command line args and report resulting options parse_args $* report_options -# Set paths to the solver executable and example directory -solver_exec="$build_dir/solvers/$solver_name/$solver_name" +solver_exec='Not set' eg_dir="$REPO_ROOT/examples/$solver_name/$eg_name" -# Validate exec, examples paths -validate_paths "$solver_exec" "$eg_dir" +# Find the executable inside $exec_loc and validate the examples paths +set_exec_paths_and_validate "$exec_loc" "$eg_dir" # Set up run directory, confirming overwrite if it already exists run_dir="$REPO_ROOT/runs/$solver_name/$eg_name"