From fec87188835b0a1cf660ba7a40b80017b7e38aa1 Mon Sep 17 00:00:00 2001 From: Marco van Hulten Date: Tue, 10 Dec 2024 09:54:31 +0100 Subject: [PATCH] Fixed bugs, made POSIX compliant, clearer messages (#47) * Improved logic for providing `tsmp2_env` and/or being on a non-JSC machine If we are on JSC and `tsmp2_var` is not yet set, it is set to a default. Then the environment is loaded iff `tsmp2_var` is set. Furthermore, the abort message format is made consistent with another abort location (where I did not add a suggestion as providing model component parameters is already in the README). Finally, I made messages for "things about to be done" contrast to aborts by making them present continuous tense and adding an ellipsis. * Removed non-POSIX verbose option (mkdir -v) This does, for instance, not work on OpenBSD. * Moved realpath to place where $tsmp2_env is defined, so we're sure realpath(1) gets an argument and not an empty string * Improved readability and added quotes in case of spaces --- build_tsmp2.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/build_tsmp2.sh b/build_tsmp2.sh index 80ea280..5bb9bf0 100755 --- a/build_tsmp2.sh +++ b/build_tsmp2.sh @@ -133,7 +133,7 @@ model_id="" model_count=0 cmake_comp_str="" -message "set model-id and component string" +message "Setting model-id and component string..." # fun set_component shell_name cmake_name set_component icon "ICON" set_component eclm "eCLM" @@ -143,14 +143,14 @@ set_component clm35 "CLM3.5" set_component pdaf "PDAF" if [ $model_count = 0 ];then - echo "No model component is chosen" + echo "ABORT: No model component is chosen" exit 1 elif [ $model_count -ge 2 ];then oasis=y fi ## CONCADINATE SOURCE CODE STRING -message "set component source dir" +message "Setting component source dir..." cmake_compsrc_str="" set_compsrc icon_src "ICON_SRC" set_compsrc eclm_src "eCLM_SRC" @@ -171,7 +171,7 @@ dwn_compsrc clm35 clm35_src "CLM3.5" ## CMAKE options -message "set CMAKE options" +message "Setting CMAKE options..." # build_type if [ -z "$build_type" ];then cmake_build_type="" @@ -212,17 +212,16 @@ build_log="$(dirname ${cmake_build_dir})/${model_id}_$(date +%Y-%m-%d_%H-%M).log ## source environment if on JSC or env file is provided if [[ -z "${tsmp2_env}" && ($SYSTEMNAME = "jurecadc" || $SYSTEMNAME = "juwels" || $SYSTEMNAME = "jusuf") ]]; then tsmp2_env="${cmake_tsmp2_dir}/env/jsc.2024_Intel.sh" -else - tsmp2_env="$(realpath ${tsmp2_env})" -fi # tsmp2_env -if [ ! -z "${tsmp2_env}" ]; then - message "source environment" - source $tsmp2_env +fi +if [ -n "${tsmp2_env}" ]; then + message "Sourcing environment..." + tsmp2_env="$(realpath "${tsmp2_env}")" + source "$tsmp2_env" fi ## CMAKE config # rm -rf ${cmake_build_dir} -mkdir -pv ${cmake_build_dir} $( echo "${cmake_install_dir}" |cut -d\= -f2) +mkdir -p ${cmake_build_dir} $( echo "${cmake_install_dir}" |cut -d\= -f2) message "====================" message "== TSMP2 settings ==" message "====================" @@ -260,7 +259,7 @@ cmake --install ${cmake_build_dir} |& tee -a $build_log message "== CMAKE INSTALL finished" ## Copy log and environment -message "Copy log and environment to install_dir" +message "Copying log and environment to install_dir..." cp ${tsmp2_env} $( echo "${cmake_install_dir}" |cut -d\= -f2) cp ${build_log} $( echo "${cmake_install_dir}" |cut -d\= -f2)