# Fused field_operators and a Python granule for diffusion ###### tags: `functional cycle 12` Developers: Magdalena Appetite: full cycle ## Goal As a first step on the green EXCLAIM path we implement a first full Python granule: diffusion. This enables us to do several experiments: - scientific refactoring of ICON4Py for an isolated component - testing the granule interface > [name=Anurag Dipankar] (serialized) data-driven testing needs ensemble of data to represent variety of situations. For diffusion, I'd imagine a global dataset (not APE, with realistic topography)for different times of the day to be sufficient. Need to check if verification is grid resolution dependent. We are talking significant data volume if the verification turns out to be resolution dependent. - halo exchanges on the Python side and in GT4Py A first ingredient towards this granule is fusing field_operators. This allows experimenting with GT4Py optimizations (inlining vs temporaries, nesting reductions, ...). This part is therefore also an important contribution to the blue path of EXCLAIM. ## Steps ### Fusion of stencils Implement the following fused version of stencils. Fusion is limited to operators between halo exchanges in ICON Fortran. - [x] fused diffusion stencil 01 - [x] fused diffusion stencil 02 - [x] fused diffusion stencil 03 - [ ] fused diffusion stencil 04 - [ ] fused velocity advection - [ ] fused solve nonhydro predictor stencil 01 - [ ] fused solve nonhydro predictor stencil 02 - [ ] fused solve nonhydro corrector stencil 01 - [ ] fused solve nonhydro corrector stencil 02 - [ ] fused solve nonhydro corrector stencil 03 Until the preprocessor is available, we test the integration only for the fused diffusion stencils. Note: Fusing stencils might require a custom GT4Py branch due to a problem in the field view lowering: https://github.com/GridTools/gt4py/pull/965 ### Diffusion granule Implement a Python class/function that can execute a full diffusion step. https://github.com/C2SM/icon4py/tree/diffusion_granule Within the project, discuss how this granule can be tested. Some options are: - implement a Numpy version - serialize once before and at the end of the diffusion step (single node) - use `icon4pygen` to create the verification wrapper (single node) #### progress - [ ] diffusion granule for mch_ch_r04b09_dsl, single node - [x] numpy tests - [x] for fieldoperators, parameter calculation in init - [ ] ~~run diffusion step~~ - [ ] validate against serialized data - [x] init - [ ] run time step - [ ] limited_area == false - [ ] numpy tests - [ ] validate against serialized data ### Optional (if time left): granule interface prototype Explore - generating the Fortran interface to diffusion granule - generating Python bindings for Fortran diffusion granule (maybe with serialization interface) - low priority: how to do manual halo exchanges