Index: /BOL/Scripts_ce0l/ECDYN_ERA/ECDYN_ERA.sh
===================================================================
--- /BOL/Scripts_ce0l/ECDYN_ERA/ECDYN_ERA.sh	(revision 4905)
+++ /BOL/Scripts_ce0l/ECDYN_ERA/ECDYN_ERA.sh	(revision 4905)
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+# 
+# This script creates the file "ECDYN.nc" for a given date 
+# defined by year, month, day and hour between 0, 6, 12 or 18hGMT
+# using ERA5 data at IDRIS, spirit2, spirit1 or on your local machine using
+# data from spirit2, provided that you have an account on spirit2.
+#
+# You need to be in the UNIX group subipsl at IDRIS or in the
+# UNIX group ecmwf on spirit2, to access the data. 
+#
+# This main script is calling 2 scripts: get_ERA.sh and create_ECDYN_ERA.sh
+#
+# get_ERA.sh extracts the data (u, v, ta, r, etc; see $VARS below) 
+# from ERA reanalyses at the chosen date on your actual directory
+#
+# create_ECDYN_ERA.sh merges the data into ECDYN.nc, together with an ancien
+# CDSW field (see below) and renames different fields.
+# 
+# "ECDYN.nc" also contains ST and CDSW (which could be in "ECPHY.nc").
+# CDSW is not modified because we do not know what to put into it.
+#
+# NB: The field CDSW is coming from the file ECDYN_high_res.nc 
+# available here :
+# https://www.lmd.jussieu.fr/~lmdz/pub/3DInputData/Init/ECDYN_high_res.nc
+#
+# This script was largely inspired by the script "create_ECDYN.sh"
+# available at "https://lmdz.lmd.jussieu.fr/utilisateurs/utilisation-de-lmdz"
+# written by Lionel GUEZ.
+# It was completely rewritten and parameterized as follows:
+#
+# 1/ getting data fields (script get_ERA.sh) was separated from 
+#    the merging part (script create_ECDYN_ERA.sh)
+# 2/ it allows to get any day and hour of a given year and month. 
+# 3/ it allows to use ERA5 dataset
+#
+# Usage :
+#
+# ./ECDYN_ERA.sh $machine $year $month $day $hour
+#
+# For example, to create ECDYN.nc 
+# on spirit2 for 1995 year, January 1st at 0h,
+# launch ./ECDYN_ERA.sh as below :
+#
+# ./ECDYN_ERA.sh spirit2 1995 01 01 0
+#
+# Author: Ionela MUSAT, 1st April 2022
+#
+
+echo $host may be spirit2 or IDRIS
+host=$1
+year=$2
+month=$3
+day=$4
+hour=$5
+
+ana=ERA5
+mesolog=`whoami`
+resol=GLOBAL_025
+
+echo
+echo get the input data for ECDYN.nc for ${year}${month}${day} at ${hour}GMT
+echo 
+
+VARS="u v ta r geopt stl1 sp"
+
+for var in $VARS; do
+
+case $var in
+          ta) freq=hourly
+                    ddt=AN_PL
+                    suf=ap1e5
+                    ndpd=24 ;;
+          u|v|r) freq=4xdaily
+                    ddt=AN_PL
+                    suf=aphe5
+                    ndpd=4 ;;
+          geopt|stl1|sp) freq=hourly
+                    ddt=AN_SF
+                    suf=as1e5
+                    ndpd=24 ;;
+esac
+
+   ./get_ERA.sh ${ana} ${host} ${mesolog} ${resol} ${freq} ${ddt} ${suf} ${ndpd} ${year} ${month} ${day} ${hour} ${var}
+
+done
+
+echo
+echo merge input data into ECDYN.nc for ${year}${month}${day} at ${hour}GMT
+echo 
+
+./create_ECDYN_ERA.sh ${host} ${year} ${month} ${day} ${hour}
+
+exit
Index: /BOL/Scripts_ce0l/ECDYN_ERA/create_ECDYN_ERA.sh
===================================================================
--- /BOL/Scripts_ce0l/ECDYN_ERA/create_ECDYN_ERA.sh	(revision 4905)
+++ /BOL/Scripts_ce0l/ECDYN_ERA/create_ECDYN_ERA.sh	(revision 4905)
@@ -0,0 +1,72 @@
+#!/bin/ksh
+
+#
+# The original script "create_ECDYN.sh" written by Lionel GUEZ for ERAI
+# is available here:
+# https://lmdz.lmd.jussieu.fr/utilisateurs/utilisation-de-lmdz
+#
+# The actual script by Ionela MUSAT is merging the ERA* data
+# extracted by the get_ERA.sh script into the 
+# ECDYN_${year}${month}${day}_${hour}.nc file.
+#
+# This script has to be called following the execution of get_ERA.sh
+#
+# Author: Lionel GUEZ
+#
+# Changes: Ionela MUSAT, 1st April 2022
+#
+set -xe
+
+host=$1
+yr=$2
+mth=$3
+day=$4
+hr=$5
+fout=ECDYN_${yr}${mth}${day}_${hr}.nc
+
+date=${yr}${mth}${day}${hr}
+echo create ECDYN.nc for ${date} at ${hr} hour
+
+for var in u v ta r geopt stl1 sp
+do
+    chmod 600 ${var}.nc
+    ncpdq -U --dimension=time,0 --overwrite ${var}.nc \
+	${var}_new.nc
+done
+
+#
+# Get an old ECDYN called ECDYN_high_res.nc and extract the CDSW field from it
+#
+if [ ! -f ECDYN_high_res.nc ]; then
+    echo Copy ECDYN_high_res.nc from https://www.lmd.jussieu.fr/~lmdz/pub/3DInputData/Init
+    wget https://www.lmd.jussieu.fr/~lmdz/pub/3DInputData/Init/ECDYN_high_res.nc
+else
+    echo ECDYN_high_res.nc is here
+fi
+###
+# Get the CDSW field from ECDYN_high_res.nc file
+if [ ! -f CDSW_ECDYN_high_res.nc ]; then
+    ncks -v CDSW ECDYN_high_res.nc CDSW_ECDYN_high_res.nc
+fi
+###
+# Start from CDSW so that the time value is overwritten:
+###
+remap=remapcon,stl1_new.nc
+cdo $remap CDSW_ECDYN_high_res.nc ${fout}
+
+VARS="u v ta r geopt stl1 sp"
+for var in ${VARS}; do
+    ncks --append ${var}_new.nc ${fout}
+done
+
+ncrename --variable=u,U --variable=v,V --variable=ta,TEMP --variable=r,R \
+    --variable=geopt,Z --variable=stl1,ST --variable=sp,SP ${fout}
+
+# Clean up:
+for var in ${VARS}; do
+    echo $var
+    echo \rm ${var}.nc
+    echo \rm ${var}_new.nc
+done
+
+exit
Index: /BOL/Scripts_ce0l/ECDYN_ERA/get_ERA.sh
===================================================================
--- /BOL/Scripts_ce0l/ECDYN_ERA/get_ERA.sh	(revision 4905)
+++ /BOL/Scripts_ce0l/ECDYN_ERA/get_ERA.sh	(revision 4905)
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+###
+### This script (get_ERA.sh) extracts the data (u, v, ta, r, etc; see $VARS below) 
+### from ERA5 reanalyses for a given date on your actual directory
+### on spirit2 or spirit1, at IDRIS or on your PC (host=spirit2/IDRIS/local)
+###
+### Author : Ionela MUSAT, 1st April 2022
+
+ana=$1
+host=$2
+mesologin=$3
+resol=$4
+freq=$5
+ddt=$6
+suf=$7
+ndpd=$8
+yr=$9
+mth=${10}
+day=${11}
+hr=${12}
+var=${13}
+
+echo $var
+
+if [ "${host}" == "ciclad" ] || [ "${host}" == "spirit2" ] || [ "${host}" == "spirit1 ]; then
+din=/bdd/${ana}/NETCDF/${resol}/${freq}/${ddt}/${yr}
+elif [ "${host}" == "IDRIS" ]; then
+din=/gpfsstore/rech/psl/rpsl376/${ana}/NETCDF/${resol}/${freq}/${ddt}/${yr}
+else
+din=/bdd/${ana}/NETCDF/${resol}/${freq}/${ddt}/${yr}
+fi
+
+fin=${var}.${yr}${mth}.${suf}.${resol}.nc
+fout=${var}.nc
+
+let "nt = (${day} - 1)*${ndpd} + ${hr}/6 + 1"
+echo $nt
+
+if [ "${host}" == "ciclad" ] || [ "${host}" == "IDRIS" ] || [ "${host}" == "spirit2" ] || [ "${host}" == "spirit1 ]; then
+  if [ ! -f ${fout} ]; then
+    echo ncks -O -F -d time,${nt} ${din}/${fin} ${fout} 
+    ncks -O -F -d time,${nt} ${din}/${fin} ${fout} 
+  fi
+else
+  if [ "${mesologin}" != "" ]; then
+    if [ ! -f ${fout} ]; then
+      scp ${mesologin}@spirit2.ipsl.fr:${din}/${fin} .
+      echo ncks -O -F -d time,${nt} ${fin} ${fout} 
+      ncks -O -F -d time,${nt} ${fin} ${fout} 
+    fi
+  else
+    echo
+    echo Have to give your meso-center login as mesologin in 
+    echo the get_ERA.sh script in order to be able 
+    echo to get ERA5 data from IPSL meso-centre
+    echo
+    exit
+  fi
+fi
+
+exit
