From 0092eaec60f6da85b9e2aa5f0074e27933f05b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Tint=C3=B3?= <oriol.tinto@lmu.de> Date: Wed, 24 May 2023 17:44:29 +0200 Subject: [PATCH] Fix prepare_date_local.sh and prepare_date_remote.sh --- .../real-from-dwd-ana/prepare_date_local.sh | 19 +++++-- .../real-from-dwd-ana/prepare_date_remote.sh | 51 ++++++------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/templates/real-from-dwd-ana/prepare_date_local.sh b/templates/real-from-dwd-ana/prepare_date_local.sh index 6cca59f..be2c990 100644 --- a/templates/real-from-dwd-ana/prepare_date_local.sh +++ b/templates/real-from-dwd-ana/prepare_date_local.sh @@ -1,8 +1,21 @@ #!/bin/bash -l -IS_LOCAL=%SIMULATION.INITIAL_CONDITIONS.LOCAL% +# This script is executed on the machine at which autosubmit is executed. +# and will be used if the initial conditions are in this same system. -if [ "${IS_LOCAL}" == "True" ]; then +# Because it can happen that the initial conditions as well and the execution happens in the local +# system we need to define these two variables: +DATA_IS_LOCAL=%SIMULATION.INITIAL_CONDITIONS.LOCAL% + +if [ "x%HPCARCH%" == "xlocal"]; then + RUN_MACHINE_IS_LOCAL="True" +else + RUN_MACHINE_IS_LOCAL="False" +fi + + + +if [ "${DATA_IS_LOCAL}" == "True" ]; then # Get some variables provided by autosubmit. WORKDIR=%HPCROOTDIR% STARTDATE=%SDATE% @@ -35,7 +48,7 @@ if [ "${IS_LOCAL}" == "True" ]; then # Check if we copy the initial conditions from the local system or the remote one - if [ "${IS_LOCAL}" != "True" ]; then + if [ "${RUN_MACHINE_IS_LOCAL}" != "True" ]; then # Create member folder ssh "${HPCUSER}@${HPCHOST}" mkdir -p ${COMMON_DATE_FOLDER} diff --git a/templates/real-from-dwd-ana/prepare_date_remote.sh b/templates/real-from-dwd-ana/prepare_date_remote.sh index 8fec0ce..29ad0aa 100644 --- a/templates/real-from-dwd-ana/prepare_date_remote.sh +++ b/templates/real-from-dwd-ana/prepare_date_remote.sh @@ -1,8 +1,11 @@ #!/bin/bash -l -IS_LOCAL=%SIMULATION.INITIAL_CONDITIONS.LOCAL% +# This script is executed on the remote system at which the simulation will happen +# and will be used if the initial conditions are in this same remote system. +DATA_IS_LOCAL=%SIMULATION.INITIAL_CONDITIONS.LOCAL% -if [ "${IS_LOCAL}" == "0" ]; then + +if [ "${DATA_IS_LOCAL}" != "True" ]; then # Get some variables provided by autosubmit. WORKDIR=%HPCROOTDIR% STARTDATE=%SDATE% @@ -34,40 +37,18 @@ if [ "${IS_LOCAL}" == "0" ]; then # Check if we copy the initial conditions from the local system or the remote one - if [ "${IS_LOCAL}" == "True" ]; then - # Create member folder - ssh "${HPCUSER}@${HPCHOST}" mkdir -p ${COMMON_DATE_FOLDER} - - # Save filenames to be used later by other scripts. - echo "${AN_FILE}" > an_file.txt - echo "${FG_FILE}" > fg_file.txt - rsync -v an_file.txt "${HPCUSER}@${HPCHOST}":"${COMMON_DATE_FOLDER}/an_file.txt" - rsync -v fg_file.txt "${HPCUSER}@${HPCHOST}":"${COMMON_DATE_FOLDER}/fg_file.txt" - - # Remove temporary files. - rm an_file.txt - rm fg_file.txt + # Create member folder and go there + mkdir -p ${COMMON_DATE_FOLDER} + cd ${COMMON_DATE_FOLDER} || exit - # Copy the first-guess and analysis files. - rsync -v "${FG_SOURCE}" "${HPCUSER}@${HPCHOST}":"${COMMON_DATE_FOLDER}/${FG_FILE}" - rsync -v "${AN_SOURCE}" "${HPCUSER}@${HPCHOST}":"${COMMON_DATE_FOLDER}/${AN_FILE}" + # Save filenames to be used later by other scripts. + echo "${AN_FILE}" > an_file.txt + echo "${FG_FILE}" > fg_file.txt - # Change permissions to read only. - ssh "${HPCUSER}@${HPCHOST}" chmod 440 "${COMMON_DATE_FOLDER}/*" - else - # Create member folder and go there - mkdir -p ${COMMON_DATE_FOLDER} - cd ${COMMON_DATE_FOLDER} || exit + # Copy the first-guess and analysis files. + cp "${FG_SOURCE}" "${FG_FILE}" + cp "${AN_SOURCE}" "${AN_FILE}" - # Save filenames to be used later by other scripts. - echo "${AN_FILE}" > an_file.txt - echo "${FG_FILE}" > fg_file.txt - - # Copy the first-guess and analysis files. - cp "${FG_SOURCE}" "${FG_FILE}" - cp "${AN_SOURCE}" "${AN_FILE}" - - # Change permissions to read only. - chmod 440 ./* - fi + # Change permissions to read only. + chmod 440 ./* fi \ No newline at end of file -- GitLab