{
"cells": [
{
"cell_type": "markdown",
"id": "a878930e-f03f-4025-ab15-64292b3056f2",
"metadata": {
"tags": []
},
"source": [
"
\n",
"\n",
"
\n",
" In this step-by-step exercise we will learn how to implement new variables in the ICON source code. \n", " In the first and relatively easy part of the exercise we will modify the Fortran code directly:\n", "
| \n",
" \n",
" ![]() | \n",
"
/scratch/${USER::1}/$USER/icon
. To this end, follow these steps closely:\n",
"cython
, a tool that allows us to create interfaces between C or C++ and Python. We also modify the wrapper script with an additional linker flag:\n",
"Adding -Wl,--export-dynamic-symbol=yac_*
to both the host model and plugin linking flags ensures YAC is only loaded once, preventing duplicate copies of its internal lookup table.\n",
"src/atm_dyn_iconam
open the module mo_nonhydro_types
.process_id
of type REAL(wp)
to the derived type TYPE(t_nh_diag)
.\n",
"* Open the module mo_nonhydro_state
in the same subdirectory. new_nh_state_diag_list
\n",
" * set appropriate metadata variables for NetCDF.\n",
" \n",
" (standard_name
, units
, long_name
, datatype
; see t_cf_var
)\n",
"\n",
" * set the metadata also for GRIB2.\n",
" \n",
" (You may use dummy numbers: discipline = parameterCategory = parameterNumber = 255
)\n",
" * place the add_var
call for the new field.\n",
"\n",
" * Now, after the add_var
call, the new field has been allocated. Fill the data array with a constant value:\n",
" * process_id(:,:) = get_my_mpi_work_id()
\n",
" \n",
" This auxiliary function from the source code module mo_mpi
returns the MPI rank of the processor (see Section 9.2.4 of the [ICON tutorial](icon_exercise_programming.ipynb#Further-Reading-and-Resources))."
]
},
{
"cell_type": "markdown",
"id": "b889b576-d29d-4eb5-a28f-ce8c88f107af",
"metadata": {},
"source": [
"EX5:ProgrammingICON:AllocatingFields
)\n",
"\n",
"build
directory, where we have executed the configure wrapper for the \"Levante\" platform with the gcc
compiler (config/dkrz/levante.gcc
, see above).\n",
" Execute make
with 4 processes.\n",
" \n",
"
| \n",
" \n",
" ![]() | \n",
"
process_id
to the MPI rank of the processor only for prognostic cells. For all other cells, set process_id
to -1. To achieve this, you must write loops that iterate over the prognostic cells.\n",
"EX5:ProgrammingICON:LoopOverGridPoints
)\n",
"\n",
"