#!/bin/bash set -u # This script takes ORAS5 ocean reanalyses, reinterpolates them to the NEMO grid so that BDY data can be generated from it afterwards. # As of July 2021, input ORAS5 can be downloaded from # Author: C. Pelletier # Inclusive year range year_start=1979 year_stop=2018 # Input folder where input data files (in .tar.gz format) are. # This script expects member 'opa1' but you can change it below. in_folder="/mfast/pelletie/oras5/raw" # Folder where pre-interpolated datafiles will be dest_folder="/mfast/pelletie/oras5/preinterp" mkdir -p ${dest_folder} cd ${dest_folder} # min_lon, max_lon, min_lat, max_lat # To precut the input data prior to interpolation (not required, but less expensive if your source code is much bigger than the destination one, which is the case from global ORAS5 to the Southern Ocean (we d # Take a good margin (4-5 nodes bigger than the destination grid limit) latlon_cut="-180,180,-90,-28" # Script for converting EOS80 to TEOS-10 (look at the script comments for why it exists and what it does). eos10_script="/elic/home/pelletie/oras5/convert_eos10_new.py" # NEMO destination CDO grid description (see `cdo_get_griddes.sh`). dest_gridfile="/mfast/pelletie/oras5/eORCA025-SO_corners.grid" pid="$$" for((year=year_start;year<=year_stop;year++)); do # Loop over input years. module purge module load 2018b CDO # 1) Uncompress, concatenate, pre-cut and merge temperatures and salinities. tar -xvf ${in_folder}/votemper_ORAS5_1m_${year}_opa1.tar.gz cdo -O copy votemper_ORAS5_1m_${year}??_grid_T_02.nc tmp_pid${pid}.nc rm -f votemper_ORAS5_1m_${year}??_grid_T_02.nc cdo -O sellonlatbox,${latlon_cut} tmp_pid${pid}.nc tmp2_pid${pid}.nc tar -xvf ${in_folder}/vosaline_ORAS5_1m_${year}_opa1.tar.gz cdo -O copy vosaline_ORAS5_1m_${year}??_grid_T_02.nc tmp_pid${pid}.nc rm -f vosaline_ORAS5_1m_${year}??_grid_T_02.nc cdo -O sellonlatbox,${latlon_cut} tmp_pid${pid}.nc tmp3_pid${pid}.nc cdo -O merge tmp2_pid${pid}.nc tmp3_pid${pid}.nc tmp_pid${pid}.nc # 2) Convert EOS8 thermodynamics to TEOS-10 ones (look at the script to get why/what). module purge; module load ESMValTool; PYTHONPATH="/elic/home/pelletie/.local/lib/python3.6/site-packages:${PYTHONPATH}" python ${eos10_script} tmp_pid${pid}.nc tmp2_pid${pid}.nc # 3) Uncompress, concatenate, pre-cut and merge ssh with TEOS-10 temperatures and salinities. module purge module load 2018b CDO tar -xvf ${in_folder}/sossheig_ORAS5_1m_${year}_opa1.tar.gz cdo -O copy sossheig_ORAS5_1m_${year}??_grid_T_02.nc tmp_pid${pid}.nc rm -f sossheig_ORAS5_1m_${year}??_grid_T_02.nc cdo -O sellonlatbox,${latlon_cut} tmp_pid${pid}.nc tmp3_pid${pid}.nc cdo -O merge tmp3_pid${pid}.nc tmp2_pid${pid}.nc tmp_pid${pid}.nc # 4) Remap (bilinear) and drown all "T points" variables (temp/sal/ssh) to your NEMO grid. cdo remapbil,${dest_gridfile} tmp_pid${pid}.nc tmp2_pid${pid}.nc # For this interpolation, I have not put a src_gridfile, because this particular dataset (ORAS5) has 'good' netCDF attributes. # IF the input data has: # - a longitude variable with netCDF attributes standard_name="longitude", units="degrees East" # - a latitude variable with netCDF attributes standard_name="latitude", units="degrees North" # - at least one variable with a a netCDF attribute coordinates='