---
# System prepended metadata

title: icon-dsl build on todi

---

# icon-dsl build on todi

Below is a guide of how I compiled icon-dsl.

1. Prepare the uenv image. Details about uenv can be found on https://confluence.cscs.ch/display/KB/UENV+user+environments
```bash
uenv repo create                  # this will create .uenv_image in your account
uenv image pull icon-wcp/v1:rc4   # pull uenv image required to build icon
```

2. activate the environment
```bash
uenv start --view=icon icon-wcp/v1:rc4
```
You should see something as shown below when you type ```uenv status```
```bash
/user-environment:icon-wcp
  The tools required to build ICON
  views:
    icon (loaded)
    modules: activate modules
    spack: configure spack upstream
```

3. clone the repos. icon-exclaim repository is still not an open-source code yet. Make sure that you have the access rights to clone the repository. Please contact William Sawyer if you do not have the permission to clone icon-exclaim.
```bash
git clone -b gh_atmcirc git@github.com:C2SM/icon-exclaim.git
git clone -b v0.0.11 git@github.com:C2SM/icon4py.git
git clone -b v2.3.4 https://github.com/GridTools/gridtools.git
cd icon-exclaim
git submodule update --init --recursive
```

4. Change the gt4py branch in ```base-requirements.txt``` in the root directory of icon4py repository to
```bash
gt4py @ git+https://github.com/GridTools/gt4py.git@icon4py_20240521
```

5. create python virtual environment in icon4py by running the following script
```bash
pushd icon4py
  python3.10 -m venv .venv
  source .venv/bin/activate
  pip install --upgrade wheel
  pip install --upgrade pip
  pip install --upgrade setuptools
  pip install -r requirements.txt
  deactivate
popd
```

6. We build icon out of source by creating a directory in icon-exclaim folder.
```bash
cd icon-exclaim/
mkdir build_dsl
cd build_dsl
./../config/cscs/todi_nospack.dsl.nvidia_PPK --disable-rte-rrtmgp --enable-liskov=substitute --disable-liskov-fused 
make -j 20
```

# BUG FIX
A bug in the acc compiler may cause the following error during the linking stage when you build icon with native ecrad code
```bash
nvlink error   : entry function 'radiation_mcica_acc_sw_solver_mcica_acc_sw_291_gpu' with max regcount of 96 calls function 'radiation_cloud_generator_acc_cloud_generator_acc_' with regcount of 212
pgacclnk: child process exit status 2: /user-environment/linux-sles15-neoverse_v2/gcc-12.3.0/nvhpc-24.3-ti5vnjw2lq7oydromjw6bvnb7aliu6qa/Linux_aarch64/24.3/compilers/bin/tools/nvdd
```
If you see this error when building icon, please go to ```icon-exclaim/external/ecrad/radiation/radiation_mcica_acc_sw.f90``` and add ```0``` to the third input argument of the subroutine ```cloud_generator_acc``` as follows:
```bash
! Do cloudy-sky calculation
call cloud_generator_acc(ng, nlev, &
     &  single_level%iseed(jcol) + 0, & ! add a dummy zero here to fix the compiler bug
     &  config%cloud_fraction_threshold, &
     &  frac(:,jcol), overlap_param(:,jcol), &
     &  config%cloud_inhom_decorr_scaling, frac_std(:,jcol), &
     &  config%pdf_sampler%ncdf, config%pdf_sampler%nfsd, &
     &  config%pdf_sampler%fsd1, config%pdf_sampler%inv_fsd_interval, &
     &  sample_val, &
     &  od_scaling, total_cloud_cover, &
     &  ibegin(jcol), iend(jcol), &
     &  cum_cloud_cover=cum_cloud_cover(:,jcol), &
     &  pair_cloud_cover=pair_cloud_cover(:,jcol))
```
