{ "cells": [ { "cell_type": "markdown", "id": "9d00daa0-b7f1-4a33-93ef-e9201d659a2a", "metadata": { "tags": [] }, "source": [ "
\n", "\n", "# ICON Training - Hands-on Session

Exercise 5: Programming ICON - Running ICON\n", "\n", "In this notebook, we will set up and submit an ICON job on Levante based on the setup from the previous [Exercise 4: Running the ICON-LAM Setup](../../exercise_lam/icon_exercise_lam.ipynb).\n", "The output namelist will be amended by the new variable added to the code in [Exercise 5: Programming ICON](../icon_exercise_programming.ipynb)." ] }, { "cell_type": "markdown", "id": "96936d85-b598-4dd1-afae-12b0973f28f9", "metadata": {}, "source": [ "## General preparations (from the previous exercise)" ] }, { "cell_type": "markdown", "id": "36e5039f-7eb1-4ccc-9012-c01b5a1beb27", "metadata": {}, "source": [ " Base directory for ICON sources and binary:" ] }, { "cell_type": "code", "execution_count": null, "id": "fa169378-1a13-475c-8910-10572ce752e7", "metadata": { "tags": [] }, "outputs": [], "source": [ "export SCRATCHDIR=/scratch/${USER::1}/$USER\n", "export ICONDIR=$SCRATCHDIR/icon" ] }, { "cell_type": "markdown", "id": "3c52a96c-fea9-4e2c-85f7-a8791dce1be8", "metadata": {}, "source": [ "Absolute path to directory with plenty of space:" ] }, { "cell_type": "code", "execution_count": null, "id": "3ba2037f-c1e6-45b7-b225-617ba8b28172", "metadata": { "tags": [] }, "outputs": [], "source": [ "export EXPDIR=$SCRATCHDIR/exercise_programming\n", "if [ ! -d $EXPDIR ]; then\n", " mkdir -p $EXPDIR\n", "fi" ] }, { "cell_type": "markdown", "id": "95466b36-4272-4a1d-93fb-df1fdbe65e91", "metadata": {}, "source": [ "We start by preparing all the necessary data in the output directory. Note that the following block copies already prepared namelists [icon_master.namelist](../prepared/icon_master.namelist), [NAMELIST_ICON](../prepared/NAMELIST_ICON) and a [sbatch script](../prepared/icon-lam.sbatch) into the output directory." ] }, { "cell_type": "code", "execution_count": null, "id": "caf61e99-2c73-4596-a676-b733f666b707", "metadata": { "tags": [] }, "outputs": [], "source": [ "export SCRIPTDIR=$HOME/icon-training-scripts/exercise_programming\n", "cp $SCRIPTDIR/prepared/icon_master.namelist $EXPDIR/\n", "cp $SCRIPTDIR/prepared/NAMELIST_ICON $EXPDIR/\n", "cp $SCRIPTDIR/prepared/icon-lam.sbatch $EXPDIR/" ] }, { "cell_type": "code", "execution_count": null, "id": "b84a6165-0b4b-4802-bacc-8a179aaf58ca", "metadata": {}, "outputs": [], "source": [ "# directory with input grids and external data:\n", "export GRIDDIR=/pool/data/ICON/ICON_training/exercise_lam/grids\n", "# directory with initial data (takes reference data which is identical to the output of Ex. 4):\n", "export DATADIR=/pool/data/ICON/ICON_training/exercise_lam/data_lam\n", "\n", "cd ${EXPDIR}\n", "\n", "# Link data needed for radiation\n", "ln -sf ${ICONDIR}/externals/ecrad/data ecrad_data\n", "\n", "# grid files: link to output directory\n", "ln -sf ${GRIDDIR}/*.nc .\n", "# data files\n", "ln -sf ${DATADIR}/* .\n", "\n", "# dictionaries for the mapping: DWD GRIB2 names <-> ICON internal names\n", "ln -sf ${ICONDIR}/run/ana_varnames_map_file.txt .\n", "ln -sf ${GRIDDIR}/../exercise_lam/map_file.latbc .\n", "\n", "# For output: Dictionary for the mapping: names specified in the output nml <-> ICON internal names\n", "ln -sf ${ICONDIR}/run/dict.output.dwd dict.output.dwd" ] }, { "cell_type": "markdown", "id": "69a7f48b-14c3-4fca-8689-f1ad595ef253", "metadata": { "tags": [] }, "source": [ "## Adding a new output namelist" ] }, { "cell_type": "markdown", "id": "de95dea0-18a3-4507-a960-7889ef5b16c2", "metadata": { "tags": [] }, "source": [ "
\n", " Exercise: \n", " Add the variable you have implemented into ICON to the following output namelist on regular lon/lat grid.\n", "
" ] }, { "cell_type": "code", "execution_count": null, "id": "f30f78b6-b156-4f13-ac6e-511a31226469", "metadata": { "tags": [] }, "outputs": [], "source": [ "cat >> $EXPDIR/NAMELIST_ICON << EOF\n", "! output_nml: specifies an output stream --------------------------------------\n", "&output_nml\n", " filetype = 4 ! netcdf\n", " dom = 1\n", " output_bounds = 0., 10000000., 3600. ! start, end, increment\n", " steps_per_file = 1\n", " mode = 1\n", " include_last = .FALSE.\n", " steps_per_file_inclfirst = .FALSE.\n", " output_filename = 'Ex5_Diagnostic'\n", " filename_format = '_DOM_'\n", " output_grid = .FALSE.\n", " remap = 1 ! 1: remap to lat-lon grid\n", " reg_lon_def = 0.8,0.1,17.2\n", " reg_lat_def = 43.9,0.1,57.7\n", " ml_varlist = ????????\n", "/\n", "EOF" ] }, { "cell_type": "markdown", "id": "a03e7904-8bc1-4913-a0d6-69057dac1699", "metadata": { "tags": [] }, "source": [ "
\n", "Solution\n", "\n", "\n", " ml_varlist = 'process_id'\n", "\n", "\n", "
" ] }, { "cell_type": "markdown", "id": "062003c7-cbf1-4b1d-80e6-1bcce2f64fda", "metadata": { "tags": [] }, "source": [ "## The ICON batch job\n", "\n", "---" ] }, { "cell_type": "markdown", "id": "3b646c83-11eb-4502-ae61-911b22c3f079", "metadata": {}, "source": [ "Submit the job to the HPC cluster, using the Slurm command `sbatch`." ] }, { "cell_type": "code", "execution_count": null, "id": "4703ede8-e217-4854-bb89-531be7b987c0", "metadata": { "tags": [] }, "outputs": [], "source": [ "export ICONDIR=$ICONDIR\n", "cd $EXPDIR && sbatch --account=$SLURM_JOB_ACCOUNT icon-lam.sbatch" ] }, { "cell_type": "markdown", "id": "cd838943-ef91-4a02-bf65-9fae0547457c", "metadata": {}, "source": [ "---\n", "\n", "*Author info: Deutscher Wetterdienst (DWD) 2025 :: icon@dwd.de. For a full list of contributors, see CONTRIBUTING in the root directory. License info: see LICENSE file.*" ] } ], "metadata": { "kernelspec": { "display_name": "Bash", "language": "bash", "name": "bash" }, "language_info": { "codemirror_mode": "shell", "file_extension": ".sh", "mimetype": "text/x-sh", "name": "bash" } }, "nbformat": 4, "nbformat_minor": 5 }