---
# System prepended metadata

title: Improve ICON-gt4py integration
tags: [functional cycle 9]

---

# Improve ICON-gt4py integration

###### tags: `functional cycle 9`

Developers: Matthias, (Christoph, (Rico, Hannes))
Appetite:

## Problem

1. ☑ Scalar arguments to stencils
2. ☑ Improve passing of indices
3. Test datatypes aside from `float64`
4. ☑ nbh reductions (sparse fields, which nbh list to pass)
5. ☑ Code cleanup of bindings generator
6. Make the cmake depend on gt4py (cmueller)
7. Rework verification methods for fields with dimension other than `double`
8. ☑ Enable passing threads_per_block and blocksize from cmake to bindings generator
9. (Optional) Optimize set of integral constants in `fortran_array_view`
10. ☑  (Optional) Get rid of cpp_bindgen

## Background

Bindings between gt4py and ICON cannot handle nbh reductions and scalars yet and datatypes aside from `float64` need testing. [Work from last cycle](https://hackmd.io/iaeW7GMJT7G43N8_7E-5wQ).
Also the code is not in a clean state yet.

During development, it would be nice if changes to gt4py result in a rebuild of stencils when running the ICON make.

## Appetite

## Known steps

### Scalar arguments

- Pass metdata with `Field[[], dtype=float64]`
- Adjust parser, generate direct copies for scalars in interfaces instead of the already existing pointer copies for fields

### Test other datatypes

- Translate stencil with Boolean mask, test if bindings work

### nbh reductions
- In bindings generator, sparse dimensions need to be introduced
- If one can pass nbh table from ICON during runtime:
    - Give meta information from gt4py to be able to pick correct nbh table by passing nbh chain list in string offsetName
- If nbh table has to be passed in fieldview
    - Parse nbh tables out of grid file and hand them to gt4py
    
### Code cleanup of bindings generator

- Delete dead code, get rid of dependencies to dawn header files, simplify.

### Make cmake depend on gt4py

Known possibilities, evaluate as part of the project:
1. Recursively search for all .py files in gt4py folder and make them dependence.
2. Compare git hashes and check if working directory is clean.

## Things to keep in mind

- The icon grid file in netcdf format can be easily read from python. This is important to keep in mind if nbh lists are to be imported from the grid file. Example usage [here](https://github.com/dawn-ico/grid-experiments/blob/882d73d2dc2f3dadeeb71dde6731c21397f37092/grid_types.py#L54).

## Potential Rabbit Holes

- For nbh reductions: If runtime passing of nbh tables requires significant time investment, go for parsing from grid file.
- Do not invest too much time on code cleanup of bindings generator, condense code so that requirements for python port are easy to formulate