Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoicon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2w
autoicon
Commits
9d644304
Commit
9d644304
authored
1 year ago
by
Oriol Tintó
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/event-generator/interpolate_sst.sh
+33
-11
33 additions, 11 deletions
templates/event-generator/interpolate_sst.sh
with
33 additions
and
11 deletions
templates/event-generator/interpolate_sst.sh
+
33
−
11
View file @
9d644304
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
}
}
#
#
#
#
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment