From e7a4288f6b58a441ed933a1a32a09654eb22117c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Tint=C3=B3?= <oriol.tinto@lmu.de> Date: Fri, 26 May 2023 16:56:49 +0200 Subject: [PATCH] Refactor examples. --- examples/01_real-from-ideal+psp.sh | 14 ++++++-------- examples/01_real-from-ideal.sh | 15 +++++++-------- examples/02_real-from-dwd-ana.sh | 14 ++++++-------- examples/example_utils.sh | 26 +++++++++++++++++++------- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/examples/01_real-from-ideal+psp.sh b/examples/01_real-from-ideal+psp.sh index 259a988..6520e6e 100755 --- a/examples/01_real-from-ideal+psp.sh +++ b/examples/01_real-from-ideal+psp.sh @@ -1,9 +1,10 @@ #!/bin/bash ####################################################################################################################### -# Three variables are required to define the test case +# Variables that are required to define the test case EXPID="rfipsp" ICON_CASE="real-from-ideal" ICON_VERSION="psp" +PLATFORM="LOCAL" EXTRA_NAMELIST=$( cat <<-END atmosphere_namelist: | @@ -16,6 +17,7 @@ atmosphere_namelist_ideal: | psp_scale: 5.0 END ) +EXTRA_CONFIGURATION="" ####################################################################################################################### set -euo pipefail @@ -23,12 +25,8 @@ set -euo pipefail # Get path to the script directory SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -# Import the function setup_autoicon_example +# Import the function run_autoicon_example source ${SCRIPT_DIR}/example_utils.sh -# Setup the experiment -# setup_autoicon_example takes the following arguments: -# case: right now it can be real-from-ideal or real-from-dwd-ana -# ICON_VERSION: it can be master, psp, plexrt or a specific version like 2.6.5-nwp0 (the latest at that moment) -# EXTRA_NAMELIST: In case we want to provide extra parameters we can use it -run_autoicon_example "$EXPID" "$ICON_CASE" "$ICON_VERSION" "${EXTRA_NAMELIST}" +# Setup and run the experiment +run_autoicon_example "$EXPID" "$ICON_CASE" "$ICON_VERSION" "$PLATFORM" "${EXTRA_NAMELIST}" "${EXTRA_CONFIGURATION}" diff --git a/examples/01_real-from-ideal.sh b/examples/01_real-from-ideal.sh index 85d0cc6..62bab10 100755 --- a/examples/01_real-from-ideal.sh +++ b/examples/01_real-from-ideal.sh @@ -1,10 +1,12 @@ #!/bin/bash ####################################################################################################################### -# Three variables are required to define the test case +# Variables that are required to define the test case EXPID="rfi" ICON_CASE="real-from-ideal" ICON_VERSION="2.6.5-nwp0" +PLATFORM="LOCAL" EXTRA_NAMELIST="" +EXTRA_CONFIGURATION="" ####################################################################################################################### set -euo pipefail @@ -12,14 +14,11 @@ set -euo pipefail # Get path to the script directory SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -# Import the function setup_autoicon_example +# Import the function run_autoicon_example source ${SCRIPT_DIR}/example_utils.sh -# Setup the experiment -# setup_autoicon_example takes the following arguments: -# case: right now it can be real-from-ideal or real-from-dwd-ana -# ICON_VERSION: it can be master, psp, plexrt or a specific version like 2.6.5-nwp0 (the latest at that moment) -# EXTRA_NAMELIST: In case we want to provide extra parameters we can use it -run_autoicon_example "$EXPID" "$ICON_CASE" "$ICON_VERSION" "${EXTRA_NAMELIST}" +# Setup and run the experiment +run_autoicon_example "$EXPID" "$ICON_CASE" "$ICON_VERSION" "$PLATFORM" "${EXTRA_NAMELIST}" "${EXTRA_CONFIGURATION}" + diff --git a/examples/02_real-from-dwd-ana.sh b/examples/02_real-from-dwd-ana.sh index 7e3796a..f75b4b0 100755 --- a/examples/02_real-from-dwd-ana.sh +++ b/examples/02_real-from-dwd-ana.sh @@ -1,10 +1,12 @@ #!/bin/bash ####################################################################################################################### -# Three variables are required to define the test case +# Variables that are required to define the test case EXPID="rfda" ICON_CASE="real-from-dwd-ana" ICON_VERSION="2.6.5-nwp0" +PLATFORM="LOCAL" EXTRA_NAMELIST="" +EXTRA_CONFIGURATION="" ####################################################################################################################### set -euo pipefail @@ -12,12 +14,8 @@ set -euo pipefail # Get path to the script directory SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -# Import the function setup_autoicon_example +# Import the function run_autoicon_example source ${SCRIPT_DIR}/example_utils.sh -# Setup the experiment -# setup_autoicon_example takes the following arguments: -# case: right now it can be real-from-ideal or real-from-dwd-ana -# ICON_VERSION: it can be master, psp, plexrt or a specific version like 2.6.5-nwp0 (the latest at that moment) -# EXTRA_NAMELIST: In case we want to provide extra parameters we can use it -run_autoicon_example "$EXPID" "$ICON_CASE" "$ICON_VERSION" "${EXTRA_NAMELIST}" +# Setup and run the experiment +run_autoicon_example "$EXPID" "$ICON_CASE" "$ICON_VERSION" "$PLATFORM" "${EXTRA_NAMELIST}" "${EXTRA_CONFIGURATION}" diff --git a/examples/example_utils.sh b/examples/example_utils.sh index 1bb48de..c4f8b78 100644 --- a/examples/example_utils.sh +++ b/examples/example_utils.sh @@ -1,10 +1,14 @@ -# setup_autoicon_example function that sets up an AutoSub environment for the ICON model +#/bin/bash + +# run_autoicon_example function that sets up an Autosubmit environment for the ICON model function run_autoicon_example() { # Read the input parameters local EXPID=$1 local ICON_CASE=$2 local ICON_VERSION=$3 - local EXTRA_NAMELIST=$4 + local PLATFORM=$4 + local EXTRA_NAMELIST=${5:-""} + local EXTRA_CONFIGURATION=${6:-""} # Setup environment @@ -16,6 +20,7 @@ function run_autoicon_example() { # Set up project setup_project "$EXPID" + # Create and run the experiment create_and_run_experiment "$EXPID" } @@ -85,7 +90,7 @@ CONFIG: RETRIALS: 0 DEFAULT: EXPID: "$EXPID" - HPCARCH: "LOCAL" # use LMU to run on cluster + HPCARCH: "${PLATFORM}" # use LMU to run on cluster CUSTOM_CONFIG: PRE: - "%PROJDIR%/conf/common" @@ -123,14 +128,21 @@ icon: data_management: # Where do we put the output files afterwards? local_destination_folder: $OUTPUTDIR/ - Platforms: - DUMMY: - TYPE: ps + Dummy: + type: ps + EOF # If EXTRA_NAMELIST is provided, create and write the extra namelist file - if [ -z "$EXTRA_NAMELIST" ]; then + if [ ! -z "$EXTRA_CONFIGURATION" ]; then + cat >autosubmit/${EXPID}/conf/extra_conf.yml <<EOF +$EXTRA_CONFIGURATION +EOF + fi + + # If EXTRA_NAMELIST is provided, create and write the extra namelist file + if [ ! -z "$EXTRA_NAMELIST" ]; then cat >autosubmit/${EXPID}/conf/extra_namelist.yml <<EOF $EXTRA_NAMELIST EOF -- GitLab