Skip to content
Snippets Groups Projects
Commit 9d644304 authored by Oriol Tintó's avatar Oriol Tintó
Browse files

Add logic to identify if it is necessary to interpolate the extpar file.

parent c2360494
No related branches found
No related tags found
No related merge requests found
function interpolate_SST() { function interpolate_SST() {
local GRID_FILE="$1" local DYNAMICS_GRID_FILE="$1"
local SST_INPUT="$2" local SST_INPUT="$2"
local SST_OUTPUT="$3" local SST_OUTPUT="$3"
...@@ -9,7 +9,7 @@ function interpolate_SST() { ...@@ -9,7 +9,7 @@ function interpolate_SST() {
&remap_nml &remap_nml
in_filename = "${SST_INPUT}" in_filename = "${SST_INPUT}"
in_type = 1 in_type = 1
out_grid_filename = "${GRID_FILE}" out_grid_filename = "${DYNAMICS_GRID_FILE}"
out_filename = "${SST_OUTPUT}" out_filename = "${SST_OUTPUT}"
out_type = 2 out_type = 2
out_filetype = 4 out_filetype = 4
...@@ -31,27 +31,46 @@ END ...@@ -31,27 +31,46 @@ END
} }
#!/bin/bash
# Define the function
function grid_filename_from_extpar() {
# Assuming the filename is given as the first argument to the function
filename="$1"
# This extracts the grid identifier from the filename
grid_id="${filename:12:12}"
# This constructs the new filename
grid_filename="icon_grid_${grid_id}.nc"
# This prints out the new filename
echo "${grid_filename}"
}
function interpolate_extpar() { function interpolate_extpar() {
local GRID_FILE="$1" local DYNAMICS_GRID_FILE="$1"
local EXTERNAL_PARAMETERS_FILE="$2" local EXTERNAL_PARAMETERS_FILE="$2"
echo "Converting extpar file to ICON grid" echo "Converting extpar file to ICON grid"
cat >remap.nml <<END EXTERNAL_PARAMETERS_GRID_FILE=$(grid_filename_from_extpar ${EXTERNAL_PARAMETERS_FILE})
if [ "${DYNAMICS_GRID_FILE}" != "${EXTERNAL_PARAMETERS_GRID_FILE}" ]; then
cat >remap.nml <<END
&remap_nml &remap_nml
in_filename = "${EXTERNAL_PARAMETERS_FILE}" in_filename = "${EXTERNAL_PARAMETERS_FILE}"
in_grid_filename = "${EXTERNAL_PARAMETERS_GRID}" in_grid_filename = "${EXTERNAL_PARAMETERS_GRID_FILE}"
in_type = 2 in_type = 2
out_grid_filename = "${GRID_FILE}" out_grid_filename = "${DYNAMICS_GRID_FILE}"
out_filename = "extpar.nc" out_filename = "extpar.nc"
out_type = 2 out_type = 2
out_filetype = 4 out_filetype = 4
/ /
END END
cat <<END >extend_remap_namelist.py cat <<END >extend_remap_namelist.py
import xarray as xr import xarray as xr
with xr.open_dataset("${EXTERNAL_PARAMETERS_FILE}") as ds, open('remap.nml', 'a') as file: with xr.open_dataset("${EXTERNAL_PARAMETERS_FILE}") as ds, open('remap.nml', 'a') as file:
...@@ -64,11 +83,14 @@ with xr.open_dataset("${EXTERNAL_PARAMETERS_FILE}") as ds, open('remap.nml', 'a' ...@@ -64,11 +83,14 @@ with xr.open_dataset("${EXTERNAL_PARAMETERS_FILE}") as ds, open('remap.nml', 'a'
file.write('/\n\n') file.write('/\n\n')
END END
python3 extend_remap_namelist.py python3 extend_remap_namelist.py
ulimit -s unlimited ulimit -s unlimited
OMP_NUM_THREADS=1 iconremap --remap_nml remap.nml #-vvv OMP_NUM_THREADS=1 iconremap --remap_nml remap.nml #-vvv
rm remap.nml rm remap.nml
else
ln -sf "${EXTERNAL_PARAMETERS_FILE}" "extpar.nc"
fi
} }
# #
# #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment