# Diffusion
###### tags:
## ICON files
- `namelists/mo_diffusion_nml.f90`: diffusion namelist, contains also default values for those not set in experiment.
- `namelists/mo_turbdiff_nml.f90`
- `namelists/mo_nonhydrostatic_nml.f90`
- `namelists/mo_gridref_nml.f90`
- `namelist/mo_grid_nml.f90`
- `namelist/mo_dynamics_nml.f90`
- `namelist/mo_run_nml.f90`
- `configure_model/mo_diffusion_config.f90`: diffusion config
- `configure_model/mo_turbdiff_config.f90`:
- `configure_model/mo_nonhydrostatic_config.f90` : dycore config
- `configure_mdoel/mo_interpol_config.f90`
- `configure_model/mo_grid_config.f90`
- `configure_model/mo_gridref_config.f90`
- `atm_dyn_iconam/mo_nh_diffusion.f90` : diffusion module
- `atm_dyn_iconam/mo_vertical_grid.f90`
- `shared/mo_impl_constants.f90`
- `shr_horizontal/mo_intp_rbf.f90`
- `shr_horizonatl/mo_intp_data_str.f90`
- `shr_horizontal/mo_model_domimp_patches.f90`
## Configuration
| (local)-property | type | origin /name list |description | value MCH |
|--------- |---- |---------------------------------------- |---------------------------------|-----------|
| `lvert_nest` | boolean| `mo_run_nml.f90/lvert_nest`||`FALSE`|
|`iequations` | integer , enum| `mo_dynamics_nml.f90/iequations` | type of equations and prognostic variables | `3` (default`INH_ATMOSPHERE =3`, non-hydrost. atm)
| `l_limited_area`| boolean| `mo_grid_nml.f90/l_limited_area` | if `true` perform limited area perform limited area run | `true` (default=`false`)|
| `linit` |boolean| hard coded in `call diffusion(...)` in `mo_nh_stepping.f90` (only place `diffustion is called`)|| `true`/`false` |
|`discr_t` | integer |`mo_diffusion_config.f90/t_diffusion_config%itype_t_diffu`| options for discretizing the Smagorinsky temperature diffusion |||
|`discr_vn` | integer | `mo_diffusion_config.f90/t_diffusion_config%itype_vn_diffu` | options for discretizing the Smagorinsky momentum diffusion | 1|
|`diffu_type` |integer, enum value| `mo_diffusion_config.f90/t_diffusion_config%hdiff_order` |order of nabla operator for diffusion, there are values 1 to 5 | `5`|
| `ndyn_substeps`| integer | `mo_nonhydrostatic_config.f90/ndyn_substeps` |number of dynamics steps per fast-physics step|`5` (default)|
| `hdiff_efdt_ratio`|real| `mo_diffusion_nml.f90/hdiff_efdt_ratio` |ratio of e-folding time to (2*)time step| `24.0`|
|`lsmag_3d` |boolean |`mo_diffusion_config.f90/lsmag_3d` |if `true`, compute 3D Smagorinsky diffusion coefficient. |`false`|
|`lhdiff_w` |boolean|`mo_diffusion_nml.f90/lhdiff_w`|use diffusion on the vertical wind field | `true`|
|`lhdiff_rcf`| boolean|`mo_nonhydrostatic_config.f90/lhdiff_rcf`|if `true`, compute horizontal diffusion also at the large time step|`true`(default)|
|`denom_diffu_v`| real| `mo_gridref_nml.f90/denom_diffu_v`| Denominator for velocity boundary diffusion | `150.0`(default = 200)|
|`denom_diffu_t`| real| `mo_gridref_nml.f90/denom_diffu_t`| Denominator for temperature boundary diffusion | (default = 135)|
|`l_zdiffu_t`| boolean|`mo_nonhydrostatic_nml.f90/l_zdiffu_t`|truly horizontal temperature diffusion: specifies computation of Smagorinsky temperature diffusion| `true`(default)|
|`nudge_max_coeff`|real| `mo_interpol_config.f90/nudge_max_coeff`|NAMELIST||
|`nrdmax`|integer| `mo_vertical_grid.f90/nrdmax` | end index of damping layer, is determined base on the `damp_height` defined in `mo_nonhydro_nml.f90`| derived from `vert_coord_tables`, `num_lev` and `damp_height`|
|`damp_height`| real(max_dom)| `mo_nonhydro_nml.f90/damp_height`|Rayleigh damping of `w` above 45km |`12500` [m] default: `damp_height(1)= 45000, damp_height(2:max_dom) = -1` (dummy value)|
|`n_shift`, `n_shift_total`|integer|`namelist/mo_run_nml.f90` , `shr_horizontal/mo_model_domimp_patches.f90` | | `0`, (default)|
|`ltkeshs`|boolean|`mo_turbdff_config.f90/t_turbdiff_conf%ltkeshs`|NAMELIST, calculation separ. horiz. shear production for TKE|`true`|
|`itype_sher`|integer|`mo_turbdff_config.f90/t_turbdiff_conf%itype_sher`|NAMELIST, type of shear production for TKE|`2`|
|`l_limited_area`|boolean|`mo_grid_config.f90/l_limited_area`|limited area setup where forcing comes in from sides|`false`|
| `lfeedback`|array(boolean)|`mo_grid_config.f90/lfeedback(max_dom)`|specifies if feedback to parent grid is performed| `true`|
|`n_dom`|integer|`mo_grid_config.f90/n_dom`|number of model domains 1= global domain only||
|`p_test_run`|boolean| ? |true means verification run for MPI| `false`|
| `min_rledge_int` |integer, actually enum with values (1,...5)| `mo_impl_constants`| describes whether the edges and vertices of outer boundary prognostic cells are owned by the PE itself. min_rledge_int - 1: outer boundary edges of a prognostic cell not owned by the current PE (see below) | we don`t need this because we have 1 node|
### `min_rledge_int` and `min_rlvert_int`
** min_rledge_int**
- 1: outer boundary edges of a prognostic cell not owned by the current PE\\
- 2: edges connecting halo cells of the first row
- 3, 4, 5 : outer boundary edges of the first halo cells row, or edges connecting cells of the first halo cell row with cells of the second halo cell row. For n_ghost_rows = 2, an analogous setting applies to min_rledge_int - 4 and min_rledge_int -5
** min_rlvert_int**
- 1: outer boundary vertices of a prognostic cell not owned by the current PE
- 2: outer boundary vertices of the first halo cells row, or vertices connecting cellsof the first halo cell row with cells of the second halo cell row. For n_ghost_rows = 2, an analogous setting applies to min_rlvert_int - 3 (= min_rlvert).
## Initialization
| input value| `smag_offset :float `|`smag_limit: Field[[K], float]` |`diff_multfac_vn:Field[[K], float]`|
|--- |---|---|---|
|`linit = true` | `0.0_vp` | `0.125_wp-4._wp*diff_multfac_vn(:)`|`diffusion_config(jg)%k4/3._wp*diffusion_config(jg)%hdiff_efdt_ratio`|
|`linit = false & lhdiff_rcf & diffu_type=5`| `0.25_wp *diffusion_config(jg)%k4*REAL(ndyn_substeps,wp)`|`0.125_wp-4._wp*diff_multfac_vn(:)`| `MIN(1._wp/128._wp,diffusion_config(jg)%k4*REAL(ndyn_substeps,wp)/3._wp)`|
### other params in MCH b04r09_dsl experiment
- `jg`: `p_patch%id`: always 1 in diffusion
- `num_lev`: 65 will be more for production runs
- `n_shift`: 0
```
! diffusion_nml: horizontal (numerical) diffusion ----------------------------
&diffusion_nml
lhdiff_vn = .TRUE. ! diffusion on the horizontal wind field
lhdiff_temp = .TRUE. ! diffusion on the temperature field
lhdiff_w = .TRUE. ! diffusion on the vertical wind field
hdiff_order = 5 ! order of nabla operator for diffusion
itype_vn_diffu = 1 ! reconstruction method used for Smagorinsky diffusion
itype_t_diffu = 2 ! discretization of temperature diffusion
hdiff_efdt_ratio = 24.0 ! ratio of e-folding time to time step
hdiff_smag_fac = 0.025 ! scaling factor for Smagorinsky diffusion
/
```
### exclaim aquaplanet: exp.exclaim_ape_R2B04
* same parameter for `diffusion_nml` as for `b04r09_dsl`
* `turbdiff_nml`: is very different
* `l_limited_area`= `false`
## interface to subroutine diffusion
|name|type|description| *open points*|
|----|----|----|---|
|`p_nh_diag`|`t_nh_diag`, (inout)|diagnostic state||
|`p_nh_prog`|`t_nh_prog`, (inout)|prognostic state||
|`p_patch`|`t_patch`(inout)|local patch| why is `p_patch` inout? shouldn that be onlz in?|
|`p_nh_metrics`|`t_nh_metrics`, in|metric state||
|`p_int`|`t_int_state`, (in)|interpolation state||
|`d_time`|real, (in)|time stemp||
|`linit`|boolean, (in)|whether this is an inital call to subroutine or a runtime call| ???|
### other fields passed
| (local)-property | type | origin /name list |description
|--------- |---- |---------------------------------------- |---------------------------------|
| `vct_a`| `real, dimension(nlevp1)`| `mo_vertical_coord_table.f90` | physical (?) height in of K Levels|
## questions
- [x] why is `p_patch` passed as `INTENT(INOUT)`, is it changing during time loop? --> they probably didn't know better
- [x] @Will is the `vct_a` changed during the model run. (I believe it is a physical height, so the question is it in Meters or Baryonic ) -> metric
- [ ] what is the test run `p_test_run`?
- [ ] what is initial run the `linit = True`?
- [ ] how to enable pp_ser directives? response from David: in exlaim wiki for aqualplanet there is part on building with spack. there it is described what to enable preprocessor directive there. (or ask Will) Then you have to set the namelist parameter which is in the namelist description (ask Jonas)