# Climate Modelling Lab, MSc Meteorology S2025 (280351 VU)

## Recipe for lecturer: generate a tarball with the icon model code for distribution to students

Work with VSC account `avoigt_teach`.

Get model code, use branch climmodlab_s2023:

```
git clone https://gitlab.phaidra.org/climate/icon-esm-univie.git
git checkout origin/climmodlab_s2023
```

Configure following the recipe for the students below. Then create a distribution tarball:

```
make dist
```
This leads to the file `icon-2.6.0.tar.bz2`, which can be distributed to the students.

## VSC reservation info and usage

To check the reservation: 
```
scontrol show reservation=p72044
```

To use the reservation on the command line:
```
--reservation=p72044
```

```
To use the reservation in a job script:
#SBATCH --reservation=p72044
```

## Recipe for students: how to get, configure and compile ICON on VSC4

Reserve a node for interactive use, do not work on the login nodes. See [VSC Wiki](https://docs.vsc.ac.at/running_jobs/interactive_jobs/).


```
salloc -N 1 --qos=skylake_0096 --partition=skylake_0096 --reservation=p72044 --exclusive -t 2:00:00
```

The ssh into the reserved node. You can check the reserved node with
```
squeue -u $USER
```

Get and untar the tarball and enter the model code directory:

```
cp  /gpfs/data/fs72044/avoigt_teach/icon-2.6.0.tar.bz2 /gpfs/data/fs72044/iconXY
tar xfv icon-2.6.0.tar.bz2
mv icon-2.6.0 icon-esm-univie
cd icon-esm-univie/
```

Configure the model, using MPI parallel communication (this step typically takes several minutes):

```
config/vsc/vsc4.intel-intelmpi_spack --enable-mpi
```

You can check for a successful configure step by looking at the last line of the file `config.log`. This line should read `configure: exit 0`.

Load the libraries that are needed for compilation of the model:

```
spack load /xg435ds  # intel-oneapi-compilers@2022.2.1 linux-almalinux8-skylake_avx512 / gcc@9.5.0
spack load /p7jisxw  # intel-oneapi-mkl@2022.2.1 linux-almalinux8-skylake_avx512 / intel@2021.7.1
spack load /6a7vghr  # netcdf-fortran@4.6.0 linux-almalinux8-skylake_avx512 / intel@2021.7.1
spack load /kqslczm  # libxml2@2.10.1 linux-almalinux8-skylake_avx512 / intel@2021.7.1
spack load /tlvfj62  # eccodes@2.25.0 linux-almalinux8-skylake_avx512 / intel@2021.7.1
```

Compile the model, using 8 cores for faster compilation  (this step typically takes several minutes):

```
make -j 8
```

A successful compilation should end with the following lines printed to screen

> FCLD     bin/icon
>
> support/util_file.o: In function `util_tmpnam':
>
> /home/fs72044/avoigt_teach/climlab_s2024/icon-esm-univie/support/util_file.c:63: warning: the use of `tmpnam' is dangerous, better use `mkstemp'
>
> make[1]: Leaving directory '/home/fs72044/avoigt_teach/climlab_s2024/icon-esm-univie'

The compilation leads to the binary `bin/icon`.

## Running an AMIP-like simulation

A runscript for an AMIP-like simulation is available in `runs/amip/`, the run script is `exp.amip.run`. The script is written for user `avoigt_teach` and needs to be adapted accordingly for others users (e.g., replacing `avoigt_teach` where needed and adapting some of the directory names.)

The simulation is AMIP-like because SSTs, sea ice etc. are prescribed as climatological averages and are the same for each year.


## Examples for boundary data remapped to a regular 360x180 deg lon-lat grid

See the directory `boundary-data-remapped`.

## Analysis

Example notebook for icon nextgems data is in `analysis/icon-nextgems/`.

## Preparing ICON-ESM input data

On Teachinghub, see `~/LEHRE/msc-climmodlab-s2025/icon-r2b4-inputdata` for how the icon R2B4 grid looks like and how the SST and sea ice files look like.

[CDO](https://code.mpimet.mpg.de/) might be helpful to remap from the Healpix grid to the R2B4 grid.