From 76d1efd956d7709565d6a7c31c8c863c99e3bdfe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Oriol=20Tint=C3=B3?= <oriol.tinto@lmu.de>
Date: Tue, 23 May 2023 17:34:09 +0200
Subject: [PATCH] Fix prepare_date_local.sh and prepare_date_remote.sh

---
 .../real-from-dwd-ana/prepare_date_local.sh   | 46 +++++------------
 .../real-from-dwd-ana/prepare_date_remote.sh  | 49 ++++++-------------
 2 files changed, 27 insertions(+), 68 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..d077f3d 100644
--- a/templates/real-from-dwd-ana/prepare_date_local.sh
+++ b/templates/real-from-dwd-ana/prepare_date_local.sh
@@ -33,42 +33,18 @@ if [ "${IS_LOCAL}" == "True" ]; then
     exit 1
   fi
 
+  # Create member folder and go there
+  mkdir -p ${COMMON_DATE_FOLDER}
+  cd ${COMMON_DATE_FOLDER} || exit
 
-  # 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
 
-    # 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"
+  # Copy the first-guess and analysis files.
+  cp "${FG_SOURCE}" "${FG_FILE}"
+  cp "${AN_SOURCE}" "${AN_FILE}"
 
-    # Remove temporary files.
-    rm an_file.txt
-    rm fg_file.txt
-
-    # 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}"
-
-    # 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
-
-    # 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
diff --git a/templates/real-from-dwd-ana/prepare_date_remote.sh b/templates/real-from-dwd-ana/prepare_date_remote.sh
index 8fec0ce..9c0e956 100644
--- a/templates/real-from-dwd-ana/prepare_date_remote.sh
+++ b/templates/real-from-dwd-ana/prepare_date_remote.sh
@@ -2,7 +2,7 @@
 
 IS_LOCAL=%SIMULATION.INITIAL_CONDITIONS.LOCAL%
 
-if [ "${IS_LOCAL}" == "0" ]; then
+if [ "${IS_LOCAL}" == "False" ]; then
   # Get some variables provided by autosubmit.
   WORKDIR=%HPCROOTDIR%
   STARTDATE=%SDATE%
@@ -32,42 +32,25 @@ if [ "${IS_LOCAL}" == "0" ]; then
     exit 1
   fi
 
-
   # 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"
+  # Create member folder
+  ssh "${HPCUSER}@${HPCHOST}" mkdir -p ${COMMON_DATE_FOLDER}
 
-    # Remove temporary files.
-    rm an_file.txt
-    rm fg_file.txt
+  # 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"
 
-    # 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}"
+  # Remove temporary files.
+  rm an_file.txt
+  rm 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.
+  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}/*"
 
-    # 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
 fi
\ No newline at end of file
-- 
GitLab