diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_18.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/add_extra_diffusion_for_w_con_approaching_cfl.py similarity index 93% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_18.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/add_extra_diffusion_for_w_con_approaching_cfl.py index 65616ccc62..9ac4e80e8f 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_18.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/add_extra_diffusion_for_w_con_approaching_cfl.py @@ -28,7 +28,7 @@ @field_operator -def _mo_velocity_advection_stencil_18( +def _add_extra_diffusion_for_w_con_approaching_cfl( levmask: Field[[KDim], bool], cfl_clipping: Field[[CellDim, KDim], bool], owner_mask: Field[[CellDim], bool], @@ -42,6 +42,7 @@ def _mo_velocity_advection_stencil_18( cfl_w_limit: vpfloat, dtime: wpfloat, ) -> Field[[CellDim, KDim], vpfloat]: + """Formerly known as _mo_velocity_advection_stencil_18.""" z_w_con_c_wp, ddqz_z_half_wp, ddt_w_adv_wp, cfl_w_limit_wp = astype( (z_w_con_c, ddqz_z_half, ddt_w_adv, cfl_w_limit), wpfloat ) @@ -66,7 +67,7 @@ def _mo_velocity_advection_stencil_18( @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_18( +def add_extra_diffusion_for_w_con_approaching_cfl( levmask: Field[[KDim], bool], cfl_clipping: Field[[CellDim, KDim], bool], owner_mask: Field[[CellDim], bool], @@ -84,7 +85,7 @@ def mo_velocity_advection_stencil_18( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_18( + _add_extra_diffusion_for_w_con_approaching_cfl( levmask, cfl_clipping, owner_mask, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_20.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/add_extra_diffusion_for_wn_approaching_cfl.py similarity index 95% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_20.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/add_extra_diffusion_for_wn_approaching_cfl.py index 422515c25c..e4fb33d075 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_20.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/add_extra_diffusion_for_wn_approaching_cfl.py @@ -42,7 +42,7 @@ @field_operator -def _mo_velocity_advection_stencil_20( +def _add_extra_diffusion_for_wn_approaching_cfl( levelmask: Field[[KDim], bool], c_lin_e: Field[[EdgeDim, E2CDim], wpfloat], z_w_con_c_full: Field[[CellDim, KDim], vpfloat], @@ -58,6 +58,7 @@ def _mo_velocity_advection_stencil_20( scalfac_exdiff: wpfloat, dtime: wpfloat, ) -> Field[[EdgeDim, KDim], vpfloat]: + """Formerly known as _mo_velocity_advection_stencil_20.""" z_w_con_c_full_wp, ddqz_z_full_e_wp, ddt_vn_apc_wp, cfl_w_limit_wp = astype( (z_w_con_c_full, ddqz_z_full_e, ddt_vn_apc, cfl_w_limit), wpfloat ) @@ -97,7 +98,7 @@ def _mo_velocity_advection_stencil_20( @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_20( +def add_extra_diffusion_for_wn_approaching_cfl( levelmask: Field[[KDim], bool], c_lin_e: Field[[EdgeDim, E2CDim], wpfloat], z_w_con_c_full: Field[[CellDim, KDim], vpfloat], @@ -117,7 +118,7 @@ def mo_velocity_advection_stencil_20( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_20( + _add_extra_diffusion_for_wn_approaching_cfl( levelmask, c_lin_e, z_w_con_c_full, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_17.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/add_interpolated_horizontal_advection_of_w.py similarity index 89% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_17.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/add_interpolated_horizontal_advection_of_w.py index ba09193fbb..d3e0009698 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_17.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/add_interpolated_horizontal_advection_of_w.py @@ -20,18 +20,19 @@ @field_operator -def _mo_velocity_advection_stencil_17( +def _add_interpolated_horizontal_advection_of_w( e_bln_c_s: Field[[CEDim], wpfloat], z_v_grad_w: Field[[EdgeDim, KDim], vpfloat], ddt_w_adv: Field[[CellDim, KDim], vpfloat], ) -> Field[[CellDim, KDim], vpfloat]: + """Formerly known as _mo_velocity_advection_stencil_17.""" z_v_grad_w_wp, ddt_w_adv_wp = astype((z_v_grad_w, ddt_w_adv), wpfloat) ddt_w_adv_wp = ddt_w_adv_wp + neighbor_sum(z_v_grad_w_wp(C2E) * e_bln_c_s(C2CE), axis=C2EDim) return astype(ddt_w_adv_wp, vpfloat) @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_17( +def add_interpolated_horizontal_advection_of_w( e_bln_c_s: Field[[CEDim], wpfloat], z_v_grad_w: Field[[EdgeDim, KDim], vpfloat], ddt_w_adv: Field[[CellDim, KDim], vpfloat], @@ -40,7 +41,7 @@ def mo_velocity_advection_stencil_17( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_17( + _add_interpolated_horizontal_advection_of_w( e_bln_c_s, z_v_grad_w, ddt_w_adv, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_19.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_advective_normal_wind_tendency.py similarity index 94% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_19.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_advective_normal_wind_tendency.py index 066b41cdb4..6cc3bf1ff6 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_19.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_advective_normal_wind_tendency.py @@ -32,7 +32,7 @@ @field_operator -def _mo_velocity_advection_stencil_19( +def _compute_advective_normal_wind_tendency( z_kin_hor_e: Field[[EdgeDim, KDim], vpfloat], coeff_gradekin: Field[[ECDim], vpfloat], z_ekinh: Field[[CellDim, KDim], vpfloat], @@ -44,6 +44,7 @@ def _mo_velocity_advection_stencil_19( vn_ie: Field[[EdgeDim, KDim], vpfloat], ddqz_z_full_e: Field[[EdgeDim, KDim], vpfloat], ) -> Field[[EdgeDim, KDim], vpfloat]: + """Formerly known as _mo_velocity_advection_stencil_19.""" vt_wp, z_w_con_c_full_wp, ddqz_z_full_e_wp = astype( (vt, z_w_con_c_full, ddqz_z_full_e), wpfloat ) @@ -65,7 +66,7 @@ def _mo_velocity_advection_stencil_19( @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_19( +def compute_advective_normal_wind_tendency( z_kin_hor_e: Field[[EdgeDim, KDim], vpfloat], coeff_gradekin: Field[[ECDim], vpfloat], z_ekinh: Field[[CellDim, KDim], vpfloat], @@ -82,7 +83,7 @@ def mo_velocity_advection_stencil_19( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_19( + _compute_advective_normal_wind_tendency( z_kin_hor_e, coeff_gradekin, z_ekinh, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_16.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_advective_vertical_wind_tendency.py similarity index 90% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_16.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_advective_vertical_wind_tendency.py index 3af8d51ac8..ff9bf7e3e9 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_16.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_advective_vertical_wind_tendency.py @@ -20,12 +20,13 @@ @field_operator -def _mo_velocity_advection_stencil_16( +def _compute_advective_vertical_wind_tendency( z_w_con_c: Field[[CellDim, KDim], vpfloat], w: Field[[CellDim, KDim], wpfloat], coeff1_dwdz: Field[[CellDim, KDim], vpfloat], coeff2_dwdz: Field[[CellDim, KDim], vpfloat], ) -> Field[[CellDim, KDim], vpfloat]: + """Formerly known as _mo_velocity_advection_stencil_16.""" z_w_con_c_wp = astype(z_w_con_c, wpfloat) coeff1_dwdz_wp, coeff2_dwdz_wp = astype((coeff1_dwdz, coeff2_dwdz), wpfloat) @@ -38,7 +39,7 @@ def _mo_velocity_advection_stencil_16( @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_16( +def compute_advective_vertical_wind_tendency( z_w_con_c: Field[[CellDim, KDim], vpfloat], w: Field[[CellDim, KDim], wpfloat], coeff1_dwdz: Field[[CellDim, KDim], vpfloat], @@ -49,7 +50,7 @@ def mo_velocity_advection_stencil_16( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_16( + _compute_advective_vertical_wind_tendency( z_w_con_c, w, coeff1_dwdz, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_07.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_advection_term_for_vertical_velocity.py similarity index 90% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_07.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_advection_term_for_vertical_velocity.py index 514a370cb7..a7b40bff12 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_07.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_advection_term_for_vertical_velocity.py @@ -20,7 +20,7 @@ @field_operator -def _mo_velocity_advection_stencil_07( +def _compute_horizontal_advection_term_for_vertical_velocity( vn_ie: Field[[EdgeDim, KDim], vpfloat], inv_dual_edge_length: Field[[EdgeDim], wpfloat], w: Field[[CellDim, KDim], wpfloat], @@ -29,6 +29,7 @@ def _mo_velocity_advection_stencil_07( tangent_orientation: Field[[EdgeDim], wpfloat], z_w_v: Field[[VertexDim, KDim], vpfloat], ) -> Field[[EdgeDim, KDim], vpfloat]: + """Formerly know as _mo_velocity_advection_stencil_07.""" z_vt_ie_wp, vn_ie_wp = astype((z_vt_ie, vn_ie), wpfloat) z_v_grad_w_wp = vn_ie_wp * inv_dual_edge_length * ( @@ -40,7 +41,7 @@ def _mo_velocity_advection_stencil_07( @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_07( +def compute_horizontal_advection_term_for_vertical_velocity( vn_ie: Field[[EdgeDim, KDim], vpfloat], inv_dual_edge_length: Field[[EdgeDim], wpfloat], w: Field[[CellDim, KDim], wpfloat], @@ -54,7 +55,7 @@ def mo_velocity_advection_stencil_07( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_07( + _compute_horizontal_advection_term_for_vertical_velocity( vn_ie, inv_dual_edge_length, w, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_37.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_kinetic_energy.py similarity index 89% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_37.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_kinetic_energy.py index 7c13d717e5..8e492eb1ad 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_37.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_kinetic_energy.py @@ -20,7 +20,7 @@ @field_operator -def _mo_solve_nonhydro_stencil_37( +def _compute_horizontal_kinetic_energy( vn: Field[[EdgeDim, KDim], wpfloat], vt: Field[[EdgeDim, KDim], vpfloat], ) -> tuple[ @@ -28,7 +28,7 @@ def _mo_solve_nonhydro_stencil_37( Field[[EdgeDim, KDim], vpfloat], Field[[EdgeDim, KDim], vpfloat], ]: - + """Formerly known as _mo_solve_nonhydro_stencil_37 or _mo_velocity_advection_stencil_05.""" vn_ie_wp = vn z_vt_ie_vp = vt z_kin_hor_e_wp = wpfloat("0.5") * (vn * vn + astype(vt * vt, wpfloat)) @@ -36,7 +36,7 @@ def _mo_solve_nonhydro_stencil_37( @program(grid_type=GridType.UNSTRUCTURED) -def mo_solve_nonhydro_stencil_37( +def compute_horizontal_kinetic_energy( vn: Field[[EdgeDim, KDim], wpfloat], vt: Field[[EdgeDim, KDim], vpfloat], vn_ie: Field[[EdgeDim, KDim], vpfloat], @@ -47,7 +47,7 @@ def mo_solve_nonhydro_stencil_37( vertical_start: int32, vertical_end: int32, ): - _mo_solve_nonhydro_stencil_37( + _compute_horizontal_kinetic_energy( vn, vt, out=(vn_ie, z_vt_ie, z_kin_hor_e), diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_14.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py similarity index 90% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_14.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py index d2afbf7ce3..6c1897ff18 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_14.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py @@ -27,7 +27,7 @@ @field_operator -def _mo_velocity_advection_stencil_14( +def _compute_maximum_cfl_and_clip_contravariant_vertical_velocity( ddqz_z_half: Field[[CellDim, KDim], vpfloat], z_w_con_c: Field[[CellDim, KDim], vpfloat], cfl_w_limit: vpfloat, @@ -37,6 +37,7 @@ def _mo_velocity_advection_stencil_14( Field[[CellDim, KDim], vpfloat], Field[[CellDim, KDim], vpfloat], ]: + """Formerly know as _mo_velocity_advection_stencil_14.""" z_w_con_c_wp, ddqz_z_half_wp = astype((z_w_con_c, ddqz_z_half), wpfloat) cfl_clipping = where( @@ -64,7 +65,7 @@ def _mo_velocity_advection_stencil_14( @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_14( +def compute_maximum_cfl_and_clip_contravariant_vertical_velocity( ddqz_z_half: Field[[CellDim, KDim], vpfloat], z_w_con_c: Field[[CellDim, KDim], vpfloat], cfl_clipping: Field[[CellDim, KDim], bool], @@ -76,7 +77,7 @@ def mo_velocity_advection_stencil_14( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_14( + _compute_maximum_cfl_and_clip_contravariant_vertical_velocity( ddqz_z_half, z_w_con_c, cfl_w_limit, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_01.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_tangential_wind.py similarity index 91% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_01.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_tangential_wind.py index 43a5abfb8b..8f965638d9 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_01.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_tangential_wind.py @@ -20,16 +20,17 @@ @field_operator -def _mo_velocity_advection_stencil_01( +def _compute_tangential_wind( vn: Field[[EdgeDim, KDim], wpfloat], rbf_vec_coeff_e: Field[[EdgeDim, E2C2EDim], wpfloat], ) -> Field[[EdgeDim, KDim], vpfloat]: + """Formerly knowan as _mo_velocity_advection_stencil_01.""" vt_wp = neighbor_sum(rbf_vec_coeff_e * vn(E2C2E), axis=E2C2EDim) return astype(vt_wp, vpfloat) @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_01( +def compute_tangential_wind( vn: Field[[EdgeDim, KDim], wpfloat], rbf_vec_coeff_e: Field[[EdgeDim, E2C2EDim], wpfloat], vt: Field[[EdgeDim, KDim], vpfloat], @@ -38,7 +39,7 @@ def mo_velocity_advection_stencil_01( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_01( + _compute_tangential_wind( vn, rbf_vec_coeff_e, out=vt, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_13.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/correct_contravariant_vertical_velocity.py similarity index 88% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_13.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/correct_contravariant_vertical_velocity.py index 45bb6aa5c5..5d9b3912f8 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_13.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/correct_contravariant_vertical_velocity.py @@ -20,16 +20,17 @@ @field_operator -def _mo_velocity_advection_stencil_13( +def _correct_contravariant_vertical_velocity( z_w_con_c: Field[[CellDim, KDim], vpfloat], w_concorr_c: Field[[CellDim, KDim], vpfloat], ) -> Field[[CellDim, KDim], vpfloat]: + """Formerly known as _mo_velocity_advection_stencil_13.""" z_w_con_c_vp = z_w_con_c - w_concorr_c return z_w_con_c_vp @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_13( +def correct_contravariant_vertical_velocity( w_concorr_c: Field[[CellDim, KDim], vpfloat], z_w_con_c: Field[[CellDim, KDim], vpfloat], horizontal_start: int32, @@ -37,7 +38,7 @@ def mo_velocity_advection_stencil_13( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_13( + _correct_contravariant_vertical_velocity( z_w_con_c, w_concorr_c, out=z_w_con_c, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_15_to_18.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_15_to_18.py index b0568dbf23..3224f320a3 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_15_to_18.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_15_to_18.py @@ -14,17 +14,17 @@ from gt4py.next.ffront.decorator import field_operator, program from gt4py.next.ffront.fbuiltins import broadcast, int32, maximum, where -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_15 import ( - _mo_velocity_advection_stencil_15, +from icon4py.model.atmosphere.dycore.add_extra_diffusion_for_w_con_approaching_cfl import ( + _add_extra_diffusion_for_w_con_approaching_cfl, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_16 import ( - _mo_velocity_advection_stencil_16, +from icon4py.model.atmosphere.dycore.add_interpolated_horizontal_advection_of_w import ( + _add_interpolated_horizontal_advection_of_w, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_17 import ( - _mo_velocity_advection_stencil_17, +from icon4py.model.atmosphere.dycore.compute_advective_vertical_wind_tendency import ( + _compute_advective_vertical_wind_tendency, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_18 import ( - _mo_velocity_advection_stencil_18, +from icon4py.model.atmosphere.dycore.interpolate_contravatiant_vertical_verlocity_to_full_levels import ( + _interpolate_contravatiant_vertical_verlocity_to_full_levels, ) from icon4py.model.common.dimension import C2E2CODim, CEDim, CellDim, EdgeDim, KDim from icon4py.model.common.type_alias import vpfloat, wpfloat @@ -60,19 +60,19 @@ def _fused_velocity_advection_stencil_16_to_18( ddt_w_adv = where( (cell_lower_bound <= cell < cell_upper_bound) & (int32(1) <= k), - _mo_velocity_advection_stencil_16(z_w_con_c, w, coeff1_dwdz, coeff2_dwdz), + _compute_advective_vertical_wind_tendency(z_w_con_c, w, coeff1_dwdz, coeff2_dwdz), ddt_w_adv, ) ddt_w_adv = where( (cell_lower_bound <= cell < cell_upper_bound) & (int32(1) <= k), - _mo_velocity_advection_stencil_17(e_bln_c_s, z_v_grad_w, ddt_w_adv), + _add_interpolated_horizontal_advection_of_w(e_bln_c_s, z_v_grad_w, ddt_w_adv), ddt_w_adv, ) ddt_w_adv = ( where( (cell_lower_bound <= cell < cell_upper_bound) & (maximum(2, nrdmax - 2) <= k < nlev - 3), - _mo_velocity_advection_stencil_18( + _add_extra_diffusion_for_w_con_approaching_cfl( levelmask, cfl_clipping, owner_mask, @@ -122,7 +122,7 @@ def _fused_velocity_advection_stencil_15_to_18( lvn_only: bool, extra_diffu: bool, ) -> tuple[Field[[CellDim, KDim], vpfloat], Field[[CellDim, KDim], vpfloat]]: - z_w_con_c_full = _mo_velocity_advection_stencil_15(z_w_con_c) + z_w_con_c_full = _interpolate_contravatiant_vertical_verlocity_to_full_levels(z_w_con_c) ddt_w_adv = ( _fused_velocity_advection_stencil_16_to_18( z_w_con_c, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_19_to_20.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_19_to_20.py index f8dd74c157..f1fc49f5f5 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_19_to_20.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_19_to_20.py @@ -14,14 +14,14 @@ from gt4py.next.ffront.decorator import field_operator, program from gt4py.next.ffront.fbuiltins import int32, maximum, where -from icon4py.model.atmosphere.dycore.mo_math_divrot_rot_vertex_ri_dsl import ( - _mo_math_divrot_rot_vertex_ri_dsl, +from icon4py.model.atmosphere.dycore.add_extra_diffusion_for_wn_approaching_cfl import ( + _add_extra_diffusion_for_wn_approaching_cfl, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_19 import ( - _mo_velocity_advection_stencil_19, +from icon4py.model.atmosphere.dycore.compute_advective_normal_wind_tendency import ( + _compute_advective_normal_wind_tendency, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_20 import ( - _mo_velocity_advection_stencil_20, +from icon4py.model.atmosphere.dycore.mo_math_divrot_rot_vertex_ri_dsl import ( + _mo_math_divrot_rot_vertex_ri_dsl, ) from icon4py.model.common.dimension import ( CellDim, @@ -64,7 +64,7 @@ def _fused_velocity_advection_stencil_19_to_20( ) -> Field[[EdgeDim, KDim], vpfloat]: zeta = _mo_math_divrot_rot_vertex_ri_dsl(vn, geofac_rot) - ddt_vn_apc = _mo_velocity_advection_stencil_19( + ddt_vn_apc = _compute_advective_normal_wind_tendency( z_kin_hor_e, coeff_gradekin, z_ekinh, @@ -80,7 +80,7 @@ def _fused_velocity_advection_stencil_19_to_20( ddt_vn_apc = ( where( maximum(2, nrdmax - 2) <= k < nlev - 3, - _mo_velocity_advection_stencil_20( + _add_extra_diffusion_for_wn_approaching_cfl( levelmask, c_lin_e, z_w_con_c_full, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_1_to_7.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_1_to_7.py index b4b55aa847..4fe3a25466 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_1_to_7.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_1_to_7.py @@ -17,24 +17,20 @@ from icon4py.model.atmosphere.dycore.compute_contravariant_correction import ( _compute_contravariant_correction, ) -from icon4py.model.atmosphere.dycore.extrapolate_at_top import _extrapolate_at_top -from icon4py.model.atmosphere.dycore.mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl import ( - _mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl, -) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_01 import ( - _mo_velocity_advection_stencil_01, +from icon4py.model.atmosphere.dycore.compute_horizontal_advection_term_for_vertical_velocity import ( + _compute_horizontal_advection_term_for_vertical_velocity, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_02 import ( - _mo_velocity_advection_stencil_02, +from icon4py.model.atmosphere.dycore.compute_horizontal_kinetic_energy import ( + _compute_horizontal_kinetic_energy, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_03 import ( - _mo_velocity_advection_stencil_03, -) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_05 import ( - _mo_velocity_advection_stencil_05, +from icon4py.model.atmosphere.dycore.compute_tangential_wind import _compute_tangential_wind +from icon4py.model.atmosphere.dycore.extrapolate_at_top import _extrapolate_at_top +from icon4py.model.atmosphere.dycore.interpolate_vn_to_ie_and_compute_ekin_on_edges import ( + _interpolate_vn_to_ie_and_compute_ekin_on_edges, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_07 import ( - _mo_velocity_advection_stencil_07, +from icon4py.model.atmosphere.dycore.interpolate_vt_to_ie import _interpolate_vt_to_ie +from icon4py.model.atmosphere.dycore.mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl import ( + _mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl, ) from icon4py.model.common.dimension import CellDim, E2C2EDim, EdgeDim, KDim, V2CDim, VertexDim from icon4py.model.common.type_alias import vpfloat, wpfloat @@ -65,20 +61,20 @@ def _fused_velocity_advection_stencil_1_to_6( ]: vt = where( k < nlevp1, - _mo_velocity_advection_stencil_01(vn, rbf_vec_coeff_e), + _compute_tangential_wind(vn, rbf_vec_coeff_e), vt, ) vn_ie, z_kin_hor_e = where( 1 < k < nlevp1, - _mo_velocity_advection_stencil_02(wgtfac_e, vn, vt), + _interpolate_vn_to_ie_and_compute_ekin_on_edges(wgtfac_e, vn, vt), (vn_ie, z_kin_hor_e), ) z_vt_ie = ( where( 1 < k < nlevp1, - _mo_velocity_advection_stencil_03(wgtfac_e, vt), + _interpolate_vt_to_ie(wgtfac_e, vt), z_vt_ie, ) if not lvn_only @@ -87,7 +83,7 @@ def _fused_velocity_advection_stencil_1_to_6( (vn_ie, z_vt_ie, z_kin_hor_e) = where( k == int32(0), - _mo_velocity_advection_stencil_05(vn, vt), + _compute_horizontal_kinetic_energy(vn, vt), (vn_ie, z_vt_ie, z_kin_hor_e), ) @@ -165,7 +161,7 @@ def _fused_velocity_advection_stencil_1_to_7( z_v_grad_w = ( where( (lateral_boundary_7 < edge < halo_1) & (k < nlevp1), - _mo_velocity_advection_stencil_07( + _compute_horizontal_advection_term_for_vertical_velocity( vn_ie, inv_dual_edge_length, w, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_8_to_14.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_8_to_14.py index f7e1cc70fd..89ff0a5d7d 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_8_to_14.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/fused_velocity_advection_stencil_8_to_14.py @@ -14,17 +14,17 @@ from gt4py.next.ffront.decorator import field_operator, program from gt4py.next.ffront.fbuiltins import int32, maximum, where -from icon4py.model.atmosphere.dycore.copy_cell_kdim_field_to_vp import _copy_cell_kdim_field_to_vp -from icon4py.model.atmosphere.dycore.interpolate_to_cell_center import _interpolate_to_cell_center -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_10 import ( - _mo_velocity_advection_stencil_10, +from icon4py.model.atmosphere.dycore.compute_maximum_cfl_and_clip_contravariant_vertical_velocity import ( + _compute_maximum_cfl_and_clip_contravariant_vertical_velocity, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_13 import ( - _mo_velocity_advection_stencil_13, +from icon4py.model.atmosphere.dycore.copy_cell_kdim_field_to_vp import _copy_cell_kdim_field_to_vp +from icon4py.model.atmosphere.dycore.correct_contravariant_vertical_velocity import ( + _correct_contravariant_vertical_velocity, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_14 import ( - _mo_velocity_advection_stencil_14, +from icon4py.model.atmosphere.dycore.interpolate_contravariant_correct_to_interface_levels import ( + _interpolate_contravariant_correct_to_interface_levels, ) +from icon4py.model.atmosphere.dycore.interpolate_to_cell_center import _interpolate_to_cell_center from icon4py.model.atmosphere.dycore.set_cell_kdim_field_to_zero_vp import ( _set_cell_kdim_field_to_zero_vp, ) @@ -80,7 +80,7 @@ def _fused_velocity_advection_stencil_8_to_14( w_concorr_c = ( where( nflatlev + 1 < k < nlev, - _mo_velocity_advection_stencil_10(z_w_concorr_mc, wgtfac_c), + _interpolate_contravariant_correct_to_interface_levels(z_w_concorr_mc, wgtfac_c), w_concorr_c, ) if istep == 1 @@ -95,12 +95,14 @@ def _fused_velocity_advection_stencil_8_to_14( z_w_con_c = where( nflatlev + 1 < k < nlev, - _mo_velocity_advection_stencil_13(z_w_con_c, w_concorr_c), + _correct_contravariant_vertical_velocity(z_w_con_c, w_concorr_c), z_w_con_c, ) cfl_clipping, vcfl, z_w_con_c = where( maximum(3, nrdmax - 2) < k < nlev - 3, - _mo_velocity_advection_stencil_14(ddqz_z_half, z_w_con_c, cfl_w_limit, dtime), + _compute_maximum_cfl_and_clip_contravariant_vertical_velocity( + ddqz_z_half, z_w_con_c, cfl_w_limit, dtime + ), (cfl_clipping, vcfl, z_w_con_c), ) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_10.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_contravariant_correct_to_interface_levels.py similarity index 87% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_10.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_contravariant_correct_to_interface_levels.py index 17d9536c61..b31bfd4b4c 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_10.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_contravariant_correct_to_interface_levels.py @@ -20,10 +20,11 @@ @field_operator -def _mo_velocity_advection_stencil_10( +def _interpolate_contravariant_correct_to_interface_levels( z_w_concorr_mc: Field[[CellDim, KDim], vpfloat], wgtfac_c: Field[[CellDim, KDim], vpfloat], ) -> Field[[CellDim, KDim], vpfloat]: + """Formerly know as _mo_velocity_advection_stencil_10.""" w_concorr_c_vp = wgtfac_c * z_w_concorr_mc + (vpfloat("1.0") - wgtfac_c) * z_w_concorr_mc( Koff[-1] ) @@ -32,7 +33,7 @@ def _mo_velocity_advection_stencil_10( @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_10( +def interpolate_contravariant_correct_to_interface_levels( z_w_concorr_mc: Field[[CellDim, KDim], vpfloat], wgtfac_c: Field[[CellDim, KDim], vpfloat], w_concorr_c: Field[[CellDim, KDim], vpfloat], @@ -41,7 +42,7 @@ def mo_velocity_advection_stencil_10( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_10( + _interpolate_contravariant_correct_to_interface_levels( z_w_concorr_mc, wgtfac_c, out=w_concorr_c, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_15.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_contravatiant_vertical_verlocity_to_full_levels.py similarity index 84% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_15.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_contravatiant_vertical_verlocity_to_full_levels.py index ce0a7f13fb..80a38ecc93 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_15.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_contravatiant_vertical_verlocity_to_full_levels.py @@ -20,15 +20,16 @@ @field_operator -def _mo_velocity_advection_stencil_15( +def _interpolate_contravatiant_vertical_verlocity_to_full_levels( z_w_con_c: Field[[CellDim, KDim], vpfloat], ) -> Field[[CellDim, KDim], vpfloat]: + """Formerly know as _mo_velocity_advection_stencil_15.""" z_w_con_c_full_vp = vpfloat("0.5") * (z_w_con_c + z_w_con_c(Koff[1])) return z_w_con_c_full_vp @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_15( +def interpolate_contravatiant_vertical_verlocity_to_full_levels( z_w_con_c: Field[[CellDim, KDim], vpfloat], z_w_con_c_full: Field[[CellDim, KDim], vpfloat], horizontal_start: int32, @@ -36,7 +37,7 @@ def mo_velocity_advection_stencil_15( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_15( + _interpolate_contravatiant_vertical_verlocity_to_full_levels( z_w_con_c, out=z_w_con_c_full, domain={ diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_02.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_vn_to_ie_and_compute_ekin_on_edges.py similarity index 81% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_02.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_vn_to_ie_and_compute_ekin_on_edges.py index a154e64db2..ebfbebab11 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_02.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_vn_to_ie_and_compute_ekin_on_edges.py @@ -15,29 +15,30 @@ from gt4py.next.ffront.decorator import field_operator, program from gt4py.next.ffront.fbuiltins import Field, astype, int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_05 import ( - _mo_velocity_advection_stencil_05, +from icon4py.model.atmosphere.dycore.compute_horizontal_kinetic_energy import ( + _compute_horizontal_kinetic_energy, ) from icon4py.model.common.dimension import EdgeDim, KDim, Koff from icon4py.model.common.type_alias import vpfloat, wpfloat @field_operator -def _mo_velocity_advection_stencil_02( +def _interpolate_vn_to_ie_and_compute_ekin_on_edges( wgtfac_e: Field[[EdgeDim, KDim], vpfloat], vn: Field[[EdgeDim, KDim], wpfloat], vt: Field[[EdgeDim, KDim], vpfloat], ) -> tuple[Field[[EdgeDim, KDim], vpfloat], Field[[EdgeDim, KDim], vpfloat]]: + """Formerly known as _mo_velocity_advection_stencil_02.""" wgtfac_e_wp = astype(wgtfac_e, wpfloat) vn_ie_wp = wgtfac_e_wp * vn + (wpfloat("1.0") - wgtfac_e_wp) * vn(Koff[-1]) - _, _, z_kin_hor_e = _mo_velocity_advection_stencil_05(vn=vn, vt=vt) + _, _, z_kin_hor_e = _compute_horizontal_kinetic_energy(vn=vn, vt=vt) return astype(vn_ie_wp, vpfloat), z_kin_hor_e @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_02( +def interpolate_vn_to_ie_and_compute_ekin_on_edges( wgtfac_e: Field[[EdgeDim, KDim], vpfloat], vn: Field[[EdgeDim, KDim], wpfloat], vt: Field[[EdgeDim, KDim], vpfloat], @@ -48,7 +49,7 @@ def mo_velocity_advection_stencil_02( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_02( + _interpolate_vn_to_ie_and_compute_ekin_on_edges( wgtfac_e, vn, vt, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_03.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_vt_to_ie.py similarity index 92% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_03.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_vt_to_ie.py index 8bafe21735..6b1c89cfe2 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_03.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/interpolate_vt_to_ie.py @@ -20,10 +20,11 @@ @field_operator -def _mo_velocity_advection_stencil_03( +def _interpolate_vt_to_ie( wgtfac_e: Field[[EdgeDim, KDim], vpfloat], vt: Field[[EdgeDim, KDim], vpfloat], ) -> Field[[EdgeDim, KDim], vpfloat]: + """Formerly known as _mo_velocity_advection_stencil_03.""" wgtfac_e_wp, vt_wp = astype((wgtfac_e, vt), wpfloat) z_vt_ie_wp = astype(wgtfac_e * vt, wpfloat) + (wpfloat("1.0") - wgtfac_e_wp) * vt_wp(Koff[-1]) @@ -32,7 +33,7 @@ def _mo_velocity_advection_stencil_03( @program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_03( +def interpolate_vt_to_ie( wgtfac_e: Field[[EdgeDim, KDim], vpfloat], vt: Field[[EdgeDim, KDim], vpfloat], z_vt_ie: Field[[EdgeDim, KDim], vpfloat], @@ -41,7 +42,7 @@ def mo_velocity_advection_stencil_03( vertical_start: int32, vertical_end: int32, ): - _mo_velocity_advection_stencil_03( + _interpolate_vt_to_ie( wgtfac_e, vt, out=z_vt_ie, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_30.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_30.py index 984df48742..a8637a17d2 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_30.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_30.py @@ -15,12 +15,10 @@ from gt4py.next.ffront.decorator import field_operator, program from gt4py.next.ffront.fbuiltins import Field, astype, int32, neighbor_sum +from icon4py.model.atmosphere.dycore.compute_tangential_wind import _compute_tangential_wind from icon4py.model.atmosphere.dycore.mo_solve_nonhydro_stencil_31 import ( _mo_solve_nonhydro_stencil_31, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_01 import ( - _mo_velocity_advection_stencil_01, -) from icon4py.model.common.dimension import E2C2EO, E2C2EDim, E2C2EODim, EdgeDim, KDim from icon4py.model.common.type_alias import vpfloat, wpfloat @@ -38,7 +36,7 @@ def _mo_solve_nonhydro_stencil_30( ]: z_vn_avg_wp = _mo_solve_nonhydro_stencil_31(e_flx_avg=e_flx_avg, vn=vn) z_graddiv_vn_vp = astype(neighbor_sum(geofac_grdiv * vn(E2C2EO), axis=E2C2EODim), vpfloat) - vt_vp = _mo_velocity_advection_stencil_01(vn=vn, rbf_vec_coeff_e=rbf_vec_coeff_e) + vt_vp = _compute_tangential_wind(vn=vn, rbf_vec_coeff_e=rbf_vec_coeff_e) return z_vn_avg_wp, z_graddiv_vn_vp, vt_vp diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_36.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_36.py index a20b752761..23b5140e2e 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_36.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_solve_nonhydro_stencil_36.py @@ -15,12 +15,10 @@ from gt4py.next.ffront.decorator import field_operator, program from gt4py.next.ffront.fbuiltins import Field, int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_02 import ( - _mo_velocity_advection_stencil_02, -) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_03 import ( - _mo_velocity_advection_stencil_03, +from icon4py.model.atmosphere.dycore.interpolate_vn_to_ie_and_compute_ekin_on_edges import ( + _interpolate_vn_to_ie_and_compute_ekin_on_edges, ) +from icon4py.model.atmosphere.dycore.interpolate_vt_to_ie import _interpolate_vt_to_ie from icon4py.model.common.dimension import EdgeDim, KDim from icon4py.model.common.type_alias import vpfloat, wpfloat @@ -35,8 +33,10 @@ def _mo_solve_nonhydro_stencil_36( Field[[EdgeDim, KDim], vpfloat], Field[[EdgeDim, KDim], vpfloat], ]: - z_vt_ie = _mo_velocity_advection_stencil_03(wgtfac_e=wgtfac_e, vt=vt) - vn_ie, z_kin_hor_e = _mo_velocity_advection_stencil_02(wgtfac_e=wgtfac_e, vn=vn, vt=vt) + z_vt_ie = _interpolate_vt_to_ie(wgtfac_e=wgtfac_e, vt=vt) + vn_ie, z_kin_hor_e = _interpolate_vn_to_ie_and_compute_ekin_on_edges( + wgtfac_e=wgtfac_e, vn=vn, vt=vt + ) return vn_ie, z_vt_ie, z_kin_hor_e diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_05.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_05.py deleted file mode 100644 index 8eeca2e161..0000000000 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/mo_velocity_advection_stencil_05.py +++ /dev/null @@ -1,58 +0,0 @@ -# ICON4Py - ICON inspired code in Python and GT4Py -# -# Copyright (c) 2022, ETH Zurich and MeteoSwiss -# All rights reserved. -# -# This file is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or any later -# version. See the LICENSE.txt file at the top-level directory of this -# distribution for a copy of the license or check . -# -# SPDX-License-Identifier: GPL-3.0-or-later - -from gt4py.next.common import GridType -from gt4py.next.ffront.decorator import field_operator, program -from gt4py.next.ffront.fbuiltins import Field, astype, int32 - -from icon4py.model.common.dimension import EdgeDim, KDim -from icon4py.model.common.type_alias import vpfloat, wpfloat - - -@field_operator -def _mo_velocity_advection_stencil_05( - vn: Field[[EdgeDim, KDim], wpfloat], - vt: Field[[EdgeDim, KDim], vpfloat], -) -> tuple[ - Field[[EdgeDim, KDim], vpfloat], - Field[[EdgeDim, KDim], vpfloat], - Field[[EdgeDim, KDim], vpfloat], -]: - - vn_ie_wp = vn - z_vt_ie_vp = vt - z_kin_hor_e_wp = wpfloat("0.5") * ((vn * vn) + astype(vt * vt, wpfloat)) - return astype(vn_ie_wp, vpfloat), z_vt_ie_vp, astype(z_kin_hor_e_wp, vpfloat) - - -@program(grid_type=GridType.UNSTRUCTURED) -def mo_velocity_advection_stencil_05( - vn: Field[[EdgeDim, KDim], wpfloat], - vt: Field[[EdgeDim, KDim], vpfloat], - vn_ie: Field[[EdgeDim, KDim], vpfloat], - z_vt_ie: Field[[EdgeDim, KDim], vpfloat], - z_kin_hor_e: Field[[EdgeDim, KDim], vpfloat], - horizontal_start: int32, - horizontal_end: int32, - vertical_start: int32, - vertical_end: int32, -): - _mo_velocity_advection_stencil_05( - vn, - vt, - out=(vn_ie, z_vt_ie, z_kin_hor_e), - domain={ - EdgeDim: (horizontal_start, horizontal_end), - KDim: (vertical_start, vertical_end), - }, - ) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro_program.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro_program.py index 9b6cde3c8e..0ee7744563 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro_program.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro_program.py @@ -17,6 +17,9 @@ from icon4py.model.atmosphere.dycore.compute_contravariant_correction import ( _compute_contravariant_correction, ) +from icon4py.model.atmosphere.dycore.compute_horizontal_kinetic_energy import ( + _compute_horizontal_kinetic_energy, +) from icon4py.model.atmosphere.dycore.compute_pertubation_of_rho_and_theta import ( _compute_pertubation_of_rho_and_theta, ) @@ -48,9 +51,6 @@ from icon4py.model.atmosphere.dycore.mo_solve_nonhydro_stencil_36 import ( _mo_solve_nonhydro_stencil_36, ) -from icon4py.model.atmosphere.dycore.mo_solve_nonhydro_stencil_37 import ( - _mo_solve_nonhydro_stencil_37, -) from icon4py.model.atmosphere.dycore.mo_solve_nonhydro_stencil_39 import ( _mo_solve_nonhydro_stencil_39, ) @@ -531,7 +531,7 @@ def predictor_stencils_37_38( vertical_start: int32, vertical_end: int32, ): - _mo_solve_nonhydro_stencil_37( + _compute_horizontal_kinetic_energy( vn, vt, out=(vn_ie, z_vt_ie, z_kin_hor_e), diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/velocity/velocity_advection.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/velocity/velocity_advection.py index 0dc22b571b..ca8e980eaf 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/velocity/velocity_advection.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/velocity/velocity_advection.py @@ -22,36 +22,32 @@ ) import icon4py.model.atmosphere.dycore.velocity.velocity_advection_program as velocity_prog -from icon4py.model.atmosphere.dycore.interpolate_to_cell_center import interpolate_to_cell_center -from icon4py.model.atmosphere.dycore.mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl import ( - mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl, -) -from icon4py.model.atmosphere.dycore.mo_math_divrot_rot_vertex_ri_dsl import ( - mo_math_divrot_rot_vertex_ri_dsl, +from icon4py.model.atmosphere.dycore.add_extra_diffusion_for_w_con_approaching_cfl import ( + add_extra_diffusion_for_w_con_approaching_cfl, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_01 import ( - mo_velocity_advection_stencil_01, +from icon4py.model.atmosphere.dycore.add_extra_diffusion_for_wn_approaching_cfl import ( + add_extra_diffusion_for_wn_approaching_cfl, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_02 import ( - mo_velocity_advection_stencil_02, +from icon4py.model.atmosphere.dycore.compute_advective_normal_wind_tendency import ( + compute_advective_normal_wind_tendency, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_03 import ( - mo_velocity_advection_stencil_03, +from icon4py.model.atmosphere.dycore.compute_horizontal_advection_term_for_vertical_velocity import ( + compute_horizontal_advection_term_for_vertical_velocity, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_07 import ( - mo_velocity_advection_stencil_07, +from icon4py.model.atmosphere.dycore.compute_tangential_wind import compute_tangential_wind +from icon4py.model.atmosphere.dycore.interpolate_contravatiant_vertical_verlocity_to_full_levels import ( + interpolate_contravatiant_vertical_verlocity_to_full_levels, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_15 import ( - mo_velocity_advection_stencil_15, -) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_18 import ( - mo_velocity_advection_stencil_18, +from icon4py.model.atmosphere.dycore.interpolate_to_cell_center import interpolate_to_cell_center +from icon4py.model.atmosphere.dycore.interpolate_vn_to_ie_and_compute_ekin_on_edges import ( + interpolate_vn_to_ie_and_compute_ekin_on_edges, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_19 import ( - mo_velocity_advection_stencil_19, +from icon4py.model.atmosphere.dycore.interpolate_vt_to_ie import interpolate_vt_to_ie +from icon4py.model.atmosphere.dycore.mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl import ( + mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_20 import ( - mo_velocity_advection_stencil_20, +from icon4py.model.atmosphere.dycore.mo_math_divrot_rot_vertex_ri_dsl import ( + mo_math_divrot_rot_vertex_ri_dsl, ) from icon4py.model.atmosphere.dycore.state_utils.states import ( DiagnosticStateNonHydro, @@ -190,7 +186,7 @@ def run_predictor_step( }, ) - mo_velocity_advection_stencil_01.with_backend(backend)( + compute_tangential_wind.with_backend(backend)( vn=prognostic_state.vn, rbf_vec_coeff_e=self.interpolation_state.rbf_vec_coeff_e, vt=diagnostic_state.vt, @@ -203,7 +199,7 @@ def run_predictor_step( }, ) - mo_velocity_advection_stencil_02.with_backend(backend)( + interpolate_vn_to_ie_and_compute_ekin_on_edges.with_backend(backend)( wgtfac_e=self.metric_state.wgtfac_e, vn=prognostic_state.vn, vt=diagnostic_state.vt, @@ -219,7 +215,7 @@ def run_predictor_step( ) if not vn_only: - mo_velocity_advection_stencil_03.with_backend(backend)( + interpolate_vt_to_ie.with_backend(backend)( wgtfac_e=self.metric_state.wgtfac_e, vt=diagnostic_state.vt, z_vt_ie=z_vt_ie, @@ -260,7 +256,7 @@ def run_predictor_step( ) if not vn_only: - mo_velocity_advection_stencil_07.with_backend(backend)( + compute_horizontal_advection_term_for_vertical_velocity.with_backend(backend)( vn_ie=diagnostic_state.vn_ie, inv_dual_edge_length=self.edge_params.inverse_dual_edge_lengths, w=prognostic_state.w, @@ -343,7 +339,7 @@ def run_predictor_step( self._update_levmask_from_cfl_clipping() - mo_velocity_advection_stencil_15.with_backend(backend)( + interpolate_contravatiant_vertical_verlocity_to_full_levels.with_backend(backend)( z_w_con_c=self.z_w_con_c, z_w_con_c_full=self.z_w_con_c_full, horizontal_start=start_cell_lb_plus3, @@ -373,7 +369,7 @@ def run_predictor_step( }, ) - mo_velocity_advection_stencil_18.with_backend(run_gtfn)( + add_extra_diffusion_for_w_con_approaching_cfl.with_backend(run_gtfn)( levmask=self.levmask, cfl_clipping=self.cfl_clipping, owner_mask=self.c_owner_mask, @@ -397,7 +393,7 @@ def run_predictor_step( self.levelmask = self.levmask - mo_velocity_advection_stencil_19.with_backend(backend)( + compute_advective_normal_wind_tendency.with_backend(backend)( z_kin_hor_e=z_kin_hor_e, coeff_gradekin=self.metric_state.coeff_gradekin, z_ekinh=self.z_ekinh, @@ -421,7 +417,7 @@ def run_predictor_step( }, ) - mo_velocity_advection_stencil_20.with_backend(backend)( + add_extra_diffusion_for_wn_approaching_cfl.with_backend(backend)( levelmask=self.levelmask, c_lin_e=self.interpolation_state.c_lin_e, z_w_con_c_full=self.z_w_con_c_full, @@ -528,7 +524,7 @@ def run_corrector_step( ) if not vn_only: - mo_velocity_advection_stencil_07.with_backend(backend)( + compute_horizontal_advection_term_for_vertical_velocity.with_backend(backend)( vn_ie=diagnostic_state.vn_ie, inv_dual_edge_length=self.edge_params.inverse_dual_edge_lengths, w=prognostic_state.w, @@ -591,7 +587,7 @@ def run_corrector_step( self._update_levmask_from_cfl_clipping() - mo_velocity_advection_stencil_15.with_backend(backend)( + interpolate_contravatiant_vertical_verlocity_to_full_levels.with_backend(backend)( z_w_con_c=self.z_w_con_c, z_w_con_c_full=self.z_w_con_c_full, horizontal_start=start_cell_lb_plus3, @@ -620,7 +616,7 @@ def run_corrector_step( }, ) - mo_velocity_advection_stencil_18.with_backend(backend)( + add_extra_diffusion_for_w_con_approaching_cfl.with_backend(backend)( levmask=self.levmask, cfl_clipping=self.cfl_clipping, owner_mask=self.c_owner_mask, @@ -645,7 +641,7 @@ def run_corrector_step( # This behaviour needs to change for multiple blocks self.levelmask = self.levmask - mo_velocity_advection_stencil_19.with_backend(backend)( + compute_advective_normal_wind_tendency.with_backend(backend)( z_kin_hor_e=z_kin_hor_e, coeff_gradekin=self.metric_state.coeff_gradekin, z_ekinh=self.z_ekinh, @@ -669,7 +665,7 @@ def run_corrector_step( }, ) - mo_velocity_advection_stencil_20.with_backend(backend)( + add_extra_diffusion_for_wn_approaching_cfl.with_backend(backend)( levelmask=self.levelmask, c_lin_e=self.interpolation_state.c_lin_e, z_w_con_c_full=self.z_w_con_c_full, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/velocity/velocity_advection_program.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/velocity/velocity_advection_program.py index d390a09519..8346e385a3 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/velocity/velocity_advection_program.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/velocity/velocity_advection_program.py @@ -14,30 +14,30 @@ from gt4py.next.ffront.decorator import field_operator, program from gt4py.next.ffront.fbuiltins import int32, where -from icon4py.model.atmosphere.dycore.compute_contravariant_correction import ( - _compute_contravariant_correction, +from icon4py.model.atmosphere.dycore.add_interpolated_horizontal_advection_of_w import ( + _add_interpolated_horizontal_advection_of_w, ) -from icon4py.model.atmosphere.dycore.copy_cell_kdim_field_to_vp import _copy_cell_kdim_field_to_vp -from icon4py.model.atmosphere.dycore.extrapolate_at_top import _extrapolate_at_top -from icon4py.model.atmosphere.dycore.interpolate_to_cell_center import _interpolate_to_cell_center -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_05 import ( - _mo_velocity_advection_stencil_05, +from icon4py.model.atmosphere.dycore.compute_advective_vertical_wind_tendency import ( + _compute_advective_vertical_wind_tendency, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_10 import ( - _mo_velocity_advection_stencil_10, +from icon4py.model.atmosphere.dycore.compute_contravariant_correction import ( + _compute_contravariant_correction, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_13 import ( - _mo_velocity_advection_stencil_13, +from icon4py.model.atmosphere.dycore.compute_horizontal_kinetic_energy import ( + _compute_horizontal_kinetic_energy, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_14 import ( - _mo_velocity_advection_stencil_14, +from icon4py.model.atmosphere.dycore.compute_maximum_cfl_and_clip_contravariant_vertical_velocity import ( + _compute_maximum_cfl_and_clip_contravariant_vertical_velocity, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_16 import ( - _mo_velocity_advection_stencil_16, +from icon4py.model.atmosphere.dycore.copy_cell_kdim_field_to_vp import _copy_cell_kdim_field_to_vp +from icon4py.model.atmosphere.dycore.correct_contravariant_vertical_velocity import ( + _correct_contravariant_vertical_velocity, ) -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_17 import ( - _mo_velocity_advection_stencil_17, +from icon4py.model.atmosphere.dycore.extrapolate_at_top import _extrapolate_at_top +from icon4py.model.atmosphere.dycore.interpolate_contravariant_correct_to_interface_levels import ( + _interpolate_contravariant_correct_to_interface_levels, ) +from icon4py.model.atmosphere.dycore.interpolate_to_cell_center import _interpolate_to_cell_center from icon4py.model.atmosphere.dycore.set_cell_kdim_field_to_zero_vp import ( _set_cell_kdim_field_to_zero_vp, ) @@ -71,7 +71,7 @@ def _fused_stencils_4_5( (vn_ie, z_vt_ie, z_kin_hor_e) = where( k_field == int32(0), - _mo_velocity_advection_stencil_05(vn, vt), + _compute_horizontal_kinetic_energy(vn, vt), (vn_ie, z_vt_ie, z_kin_hor_e), ) @@ -156,7 +156,7 @@ def _fused_stencils_9_10( w_concorr_c = where( (k_field >= nflatlev_startindex + int32(1)) & (k_field < nlev), - _mo_velocity_advection_stencil_10(local_z_w_concorr_mc, wgtfac_c), + _interpolate_contravariant_correct_to_interface_levels(local_z_w_concorr_mc, wgtfac_c), w_concorr_c, ) @@ -214,7 +214,7 @@ def _fused_stencils_11_to_13( local_z_w_con_c = where( (k_field >= (nflatlev_startindex + int32(1))) & (k_field < nlev), - _mo_velocity_advection_stencil_13(local_z_w_con_c, w_concorr_c), + _correct_contravariant_vertical_velocity(local_z_w_con_c, w_concorr_c), local_z_w_con_c, ) return local_z_w_con_c @@ -255,7 +255,11 @@ def _fused_stencil_14( cfl_w_limit: float, dtime: float, ): - (local_cfl_clipping, local_vcfl, local_z_w_con_c,) = _mo_velocity_advection_stencil_14( + ( + local_cfl_clipping, + local_vcfl, + local_z_w_con_c, + ) = _compute_maximum_cfl_and_clip_contravariant_vertical_velocity( ddqz_z_half, local_z_w_con_c, cfl_w_limit, @@ -300,9 +304,11 @@ def _fused_stencils_16_to_17( coeff1_dwdz: Field[[CellDim, KDim], float], coeff2_dwdz: Field[[CellDim, KDim], float], ) -> Field[[CellDim, KDim], float]: - ddt_w_adv = _mo_velocity_advection_stencil_16(local_z_w_con_c, w, coeff1_dwdz, coeff2_dwdz) + ddt_w_adv = _compute_advective_vertical_wind_tendency( + local_z_w_con_c, w, coeff1_dwdz, coeff2_dwdz + ) - ddt_w_adv = _mo_velocity_advection_stencil_17(e_bln_c_s, local_z_v_grad_w, ddt_w_adv) + ddt_w_adv = _add_interpolated_horizontal_advection_of_w(e_bln_c_s, local_z_v_grad_w, ddt_w_adv) return ddt_w_adv diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_18.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_add_extra_diffusion_for_w_con_approaching_cfl.py similarity index 92% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_18.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_add_extra_diffusion_for_w_con_approaching_cfl.py index 1ff9221ba7..efef8b3792 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_18.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_add_extra_diffusion_for_w_con_approaching_cfl.py @@ -15,15 +15,15 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_18 import ( - mo_velocity_advection_stencil_18, +from icon4py.model.atmosphere.dycore.add_extra_diffusion_for_w_con_approaching_cfl import ( + add_extra_diffusion_for_w_con_approaching_cfl, ) from icon4py.model.common.dimension import C2E2CODim, CellDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field, random_mask from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_18_numpy( +def add_extra_diffusion_for_w_con_approaching_cfl_numpy( grid, levmask: np.array, cfl_clipping: np.array, @@ -72,7 +72,7 @@ def mo_velocity_advection_stencil_18_numpy( class TestMoVelocityAdvectionStencil18(StencilTest): - PROGRAM = mo_velocity_advection_stencil_18 + PROGRAM = add_extra_diffusion_for_w_con_approaching_cfl OUTPUTS = ("ddt_w_adv",) @staticmethod @@ -92,7 +92,7 @@ def reference( dtime: wpfloat, **kwargs, ): - ddt_w_adv = mo_velocity_advection_stencil_18_numpy( + ddt_w_adv = add_extra_diffusion_for_w_con_approaching_cfl_numpy( grid, levmask, cfl_clipping, diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_20.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_add_extra_diffusion_for_wn_approaching_cfl.py similarity index 94% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_20.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_add_extra_diffusion_for_wn_approaching_cfl.py index 3a497700c9..f06de67b30 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_20.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_add_extra_diffusion_for_wn_approaching_cfl.py @@ -15,8 +15,8 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_20 import ( - mo_velocity_advection_stencil_20, +from icon4py.model.atmosphere.dycore.add_extra_diffusion_for_wn_approaching_cfl import ( + add_extra_diffusion_for_wn_approaching_cfl, ) from icon4py.model.common.dimension import ( CellDim, @@ -31,7 +31,7 @@ from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_20_numpy( +def add_extra_diffusion_for_wn_approaching_cfl_numpy( grid, levelmask: np.array, c_lin_e: np.array, @@ -107,7 +107,7 @@ def mo_velocity_advection_stencil_20_numpy( class TestMoVelocityAdvectionStencil20(StencilTest): - PROGRAM = mo_velocity_advection_stencil_20 + PROGRAM = add_extra_diffusion_for_wn_approaching_cfl OUTPUTS = ("ddt_vn_apc",) @pytest.fixture @@ -166,7 +166,7 @@ def reference( dtime, **kwargs, ) -> dict: - ddt_vn_apc = mo_velocity_advection_stencil_20_numpy( + ddt_vn_apc = add_extra_diffusion_for_wn_approaching_cfl_numpy( grid, levelmask, c_lin_e, diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_17.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_add_interpolated_horizontal_advection_of_w.py similarity index 84% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_17.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_add_interpolated_horizontal_advection_of_w.py index e888f25c6e..24aace1307 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_17.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_add_interpolated_horizontal_advection_of_w.py @@ -15,15 +15,15 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_17 import ( - mo_velocity_advection_stencil_17, +from icon4py.model.atmosphere.dycore.add_interpolated_horizontal_advection_of_w import ( + add_interpolated_horizontal_advection_of_w, ) from icon4py.model.common.dimension import C2EDim, CEDim, CellDim, EdgeDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, as_1D_sparse_field, random_field from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_17_numpy( +def add_interpolated_horizontal_advection_of_w_numpy( grid, e_bln_c_s: np.array, z_v_grad_w: np.array, ddt_w_adv: np.array, **kwargs ) -> np.array: e_bln_c_s = np.expand_dims(e_bln_c_s, axis=-1) @@ -35,14 +35,16 @@ def mo_velocity_advection_stencil_17_numpy( class TestMoVelocityAdvectionStencil17(StencilTest): - PROGRAM = mo_velocity_advection_stencil_17 + PROGRAM = add_interpolated_horizontal_advection_of_w OUTPUTS = ("ddt_w_adv",) @staticmethod def reference( grid, e_bln_c_s: np.array, z_v_grad_w: np.array, ddt_w_adv: np.array, **kwargs ) -> dict: - ddt_w_adv = mo_velocity_advection_stencil_17_numpy(grid, e_bln_c_s, z_v_grad_w, ddt_w_adv) + ddt_w_adv = add_interpolated_horizontal_advection_of_w_numpy( + grid, e_bln_c_s, z_v_grad_w, ddt_w_adv + ) return dict(ddt_w_adv=ddt_w_adv) @pytest.fixture diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_19.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_advective_normal_wind_tendency.py similarity index 93% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_19.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_advective_normal_wind_tendency.py index 3216cab75f..479e904937 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_19.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_advective_normal_wind_tendency.py @@ -15,8 +15,8 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_19 import ( - mo_velocity_advection_stencil_19, +from icon4py.model.atmosphere.dycore.compute_advective_normal_wind_tendency import ( + compute_advective_normal_wind_tendency, ) from icon4py.model.common.dimension import CellDim, E2CDim, E2VDim, ECDim, EdgeDim, KDim, VertexDim from icon4py.model.common.test_utils.helpers import ( @@ -28,7 +28,7 @@ from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_19_numpy( +def compute_advective_normal_wind_tendency_numpy( grid, z_kin_hor_e: np.array, coeff_gradekin: np.array, @@ -60,7 +60,7 @@ def mo_velocity_advection_stencil_19_numpy( class TestMoVelocityAdvectionStencil19(StencilTest): - PROGRAM = mo_velocity_advection_stencil_19 + PROGRAM = compute_advective_normal_wind_tendency OUTPUTS = ("ddt_vn_apc",) @staticmethod @@ -78,7 +78,7 @@ def reference( ddqz_z_full_e: np.array, **kwargs, ) -> dict: - ddt_vn_apc = mo_velocity_advection_stencil_19_numpy( + ddt_vn_apc = compute_advective_normal_wind_tendency_numpy( grid, z_kin_hor_e, coeff_gradekin, diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_16.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_advective_vertical_wind_tendency.py similarity index 86% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_16.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_advective_vertical_wind_tendency.py index 025d9cd249..d4e8a44fdf 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_16.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_advective_vertical_wind_tendency.py @@ -15,15 +15,15 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_16 import ( - mo_velocity_advection_stencil_16, +from icon4py.model.atmosphere.dycore.compute_advective_vertical_wind_tendency import ( + compute_advective_vertical_wind_tendency, ) from icon4py.model.common.dimension import CellDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_16_numpy( +def compute_advective_vertical_wind_tendency_numpy( z_w_con_c: np.array, w: np.array, coeff1_dwdz: np.array, @@ -40,7 +40,7 @@ def mo_velocity_advection_stencil_16_numpy( class TestMoVelocityAdvectionStencil16(StencilTest): - PROGRAM = mo_velocity_advection_stencil_16 + PROGRAM = compute_advective_vertical_wind_tendency OUTPUTS = ("ddt_w_adv",) @staticmethod @@ -52,7 +52,9 @@ def reference( coeff2_dwdz: np.array, **kwargs, ) -> dict: - ddt_w_adv = mo_velocity_advection_stencil_16_numpy(z_w_con_c, w, coeff1_dwdz, coeff2_dwdz) + ddt_w_adv = compute_advective_vertical_wind_tendency_numpy( + z_w_con_c, w, coeff1_dwdz, coeff2_dwdz + ) return dict(ddt_w_adv=ddt_w_adv) @pytest.fixture diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_07.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_horizontal_advection_term_for_vertical_velocity.py similarity index 90% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_07.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_horizontal_advection_term_for_vertical_velocity.py index b1a7897af3..6c59db21bf 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_07.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_horizontal_advection_term_for_vertical_velocity.py @@ -15,15 +15,15 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_07 import ( - mo_velocity_advection_stencil_07, +from icon4py.model.atmosphere.dycore.compute_horizontal_advection_term_for_vertical_velocity import ( + compute_horizontal_advection_term_for_vertical_velocity, ) from icon4py.model.common.dimension import CellDim, E2CDim, E2VDim, EdgeDim, KDim, VertexDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_07_numpy( +def compute_horizontal_advection_term_for_vertical_velocity_numpy( grid, vn_ie: np.array, inv_dual_edge_length: np.array, @@ -51,7 +51,7 @@ def mo_velocity_advection_stencil_07_numpy( class TestMoVelocityAdvectionStencil07(StencilTest): - PROGRAM = mo_velocity_advection_stencil_07 + PROGRAM = compute_horizontal_advection_term_for_vertical_velocity OUTPUTS = ("z_v_grad_w",) @staticmethod @@ -66,7 +66,7 @@ def reference( z_w_v: np.array, **kwargs, ) -> dict: - z_v_grad_w = mo_velocity_advection_stencil_07_numpy( + z_v_grad_w = compute_horizontal_advection_term_for_vertical_velocity_numpy( grid, vn_ie, inv_dual_edge_length, diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_05.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_horizontal_kinetic_energy.py similarity index 85% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_05.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_horizontal_kinetic_energy.py index 0c8b34279e..b9b6a7507e 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_05.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_horizontal_kinetic_energy.py @@ -15,15 +15,15 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_05 import ( - mo_velocity_advection_stencil_05, +from icon4py.model.atmosphere.dycore.compute_horizontal_kinetic_energy import ( + compute_horizontal_kinetic_energy, ) from icon4py.model.common.dimension import EdgeDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_05_numpy(vn: np.array, vt: np.array) -> tuple: +def compute_horizontal_kinetic_energy_numpy(vn: np.array, vt: np.array) -> tuple: vn_ie = vn z_vt_ie = vt z_kin_hor_e = 0.5 * ((vn * vn) + (vt * vt)) @@ -31,12 +31,12 @@ def mo_velocity_advection_stencil_05_numpy(vn: np.array, vt: np.array) -> tuple: class TestMoVelocityAdvectionStencil05(StencilTest): - PROGRAM = mo_velocity_advection_stencil_05 + PROGRAM = compute_horizontal_kinetic_energy OUTPUTS = ("vn_ie", "z_vt_ie", "z_kin_hor_e") @staticmethod def reference(grid, vn: np.array, vt: np.array, **kwargs) -> dict: - vn_ie, z_vt_ie, z_kin_hor_e = mo_velocity_advection_stencil_05_numpy(vn, vt) + vn_ie, z_vt_ie, z_kin_hor_e = compute_horizontal_kinetic_energy_numpy(vn, vt) return dict(vn_ie=vn_ie, z_vt_ie=z_vt_ie, z_kin_hor_e=z_kin_hor_e) @pytest.fixture diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_14.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py similarity index 85% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_14.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py index 7cf6a1d5e8..8e663845ca 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_14.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py @@ -15,8 +15,8 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_14 import ( - mo_velocity_advection_stencil_14, +from icon4py.model.atmosphere.dycore.compute_maximum_cfl_and_clip_contravariant_vertical_velocity import ( + compute_maximum_cfl_and_clip_contravariant_vertical_velocity, ) from icon4py.model.common.dimension import CellDim, KDim from icon4py.model.common.test_utils.helpers import ( @@ -28,7 +28,7 @@ from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_14_numpy( +def compute_maximum_cfl_and_clip_contravariant_vertical_velocity_numpy( mesh, ddqz_z_half: np.array, z_w_con_c: np.array, cfl_w_limit, dtime ) -> tuple: num_rows, num_cols = z_w_con_c.shape @@ -52,14 +52,18 @@ def mo_velocity_advection_stencil_14_numpy( class TestMoVelocityAdvectionStencil14(StencilTest): - PROGRAM = mo_velocity_advection_stencil_14 + PROGRAM = compute_maximum_cfl_and_clip_contravariant_vertical_velocity OUTPUTS = ("cfl_clipping", "vcfl", "z_w_con_c") @staticmethod def reference( grid, ddqz_z_half: np.array, z_w_con_c: np.array, cfl_w_limit, dtime, **kwargs ) -> dict: - cfl_clipping, vcfl, z_w_con_c = mo_velocity_advection_stencil_14_numpy( + ( + cfl_clipping, + vcfl, + z_w_con_c, + ) = compute_maximum_cfl_and_clip_contravariant_vertical_velocity_numpy( grid, ddqz_z_half, z_w_con_c, cfl_w_limit, dtime ) diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_01.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_tangential_wind.py similarity index 83% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_01.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_tangential_wind.py index 33035a58f3..b8d88c816a 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_01.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_compute_tangential_wind.py @@ -15,17 +15,13 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_01 import ( - mo_velocity_advection_stencil_01, -) +from icon4py.model.atmosphere.dycore.compute_tangential_wind import compute_tangential_wind from icon4py.model.common.dimension import E2C2EDim, EdgeDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_01_numpy( - grid, vn: np.array, rbf_vec_coeff_e: np.array -) -> np.array: +def compute_tangential_wind_numpy(grid, vn: np.array, rbf_vec_coeff_e: np.array) -> np.array: rbf_vec_coeff_e = np.expand_dims(rbf_vec_coeff_e, axis=-1) e2c2e = grid.connectivities[E2C2EDim] vt = np.sum(np.where((e2c2e != -1)[:, :, np.newaxis], vn[e2c2e] * rbf_vec_coeff_e, 0), axis=1) @@ -33,12 +29,12 @@ def mo_velocity_advection_stencil_01_numpy( class TestMoVelocityAdvectionStencil01(StencilTest): - PROGRAM = mo_velocity_advection_stencil_01 + PROGRAM = compute_tangential_wind OUTPUTS = ("vt",) @staticmethod def reference(grid, vn: np.array, rbf_vec_coeff_e: np.array, **kwargs) -> dict: - vt = mo_velocity_advection_stencil_01_numpy(grid, vn, rbf_vec_coeff_e) + vt = compute_tangential_wind_numpy(grid, vn, rbf_vec_coeff_e) return dict(vt=vt) @pytest.fixture diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_13.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_correct_contravariant_vertical_velocity.py similarity index 80% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_13.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_correct_contravariant_vertical_velocity.py index 05a11791b0..983d4385f0 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_13.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_correct_contravariant_vertical_velocity.py @@ -15,26 +15,28 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_13 import ( - mo_velocity_advection_stencil_13, +from icon4py.model.atmosphere.dycore.correct_contravariant_vertical_velocity import ( + correct_contravariant_vertical_velocity, ) from icon4py.model.common.dimension import CellDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field from icon4py.model.common.type_alias import vpfloat -def mo_velocity_advection_stencil_13_numpy(w_concorr_c: np.array, z_w_con_c: np.array) -> np.array: +def correct_contravariant_vertical_velocity_numpy( + w_concorr_c: np.array, z_w_con_c: np.array +) -> np.array: z_w_con_c = z_w_con_c - w_concorr_c return z_w_con_c class TestMoVelocityAdvectionStencil13(StencilTest): - PROGRAM = mo_velocity_advection_stencil_13 + PROGRAM = correct_contravariant_vertical_velocity OUTPUTS = ("z_w_con_c",) @staticmethod def reference(grid, w_concorr_c: np.array, z_w_con_c: np.array, **kwargs) -> dict: - z_w_con_c = mo_velocity_advection_stencil_13_numpy(w_concorr_c, z_w_con_c) + z_w_con_c = correct_contravariant_vertical_velocity_numpy(w_concorr_c, z_w_con_c) return dict(z_w_con_c=z_w_con_c) @pytest.fixture diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_15_to_18.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_15_to_18.py index a8785512f9..006321895d 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_15_to_18.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_15_to_18.py @@ -27,10 +27,18 @@ zero_field, ) -from .test_mo_velocity_advection_stencil_15 import mo_velocity_advection_stencil_15_numpy -from .test_mo_velocity_advection_stencil_16 import mo_velocity_advection_stencil_16_numpy -from .test_mo_velocity_advection_stencil_17 import mo_velocity_advection_stencil_17_numpy -from .test_mo_velocity_advection_stencil_18 import mo_velocity_advection_stencil_18_numpy +from .test_add_extra_diffusion_for_w_con_approaching_cfl import ( + add_extra_diffusion_for_w_con_approaching_cfl_numpy, +) +from .test_add_interpolated_horizontal_advection_of_w import ( + add_interpolated_horizontal_advection_of_w_numpy, +) +from .test_compute_advective_vertical_wind_tendency import ( + compute_advective_vertical_wind_tendency_numpy, +) +from .test_interpolate_contravatiant_vertical_verlocity_to_full_levels import ( + interpolate_contravatiant_vertical_verlocity_to_full_levels_numpy, +) class TestFusedVelocityAdvectionStencil15To18(StencilTest): @@ -73,13 +81,17 @@ def _fused_velocity_advection_stencil_16_to_18( ddt_w_adv = np.where( condition1, - mo_velocity_advection_stencil_16_numpy(z_w_con_c[:, :-1], w, coeff1_dwdz, coeff2_dwdz), + compute_advective_vertical_wind_tendency_numpy( + z_w_con_c[:, :-1], w, coeff1_dwdz, coeff2_dwdz + ), ddt_w_adv, ) ddt_w_adv = np.where( condition1, - mo_velocity_advection_stencil_17_numpy(grid, e_bln_c_s, z_v_grad_w, ddt_w_adv), + add_interpolated_horizontal_advection_of_w_numpy( + grid, e_bln_c_s, z_v_grad_w, ddt_w_adv + ), ddt_w_adv, ) @@ -93,7 +105,7 @@ def _fused_velocity_advection_stencil_16_to_18( if extra_diffu: ddt_w_adv = np.where( condition2, - mo_velocity_advection_stencil_18_numpy( + add_extra_diffusion_for_w_con_approaching_cfl_numpy( grid, levelmask, cfl_clipping, @@ -143,7 +155,9 @@ def reference( extra_diffu, **kwargs, ): - z_w_con_c_full = mo_velocity_advection_stencil_15_numpy(grid, z_w_con_c) + z_w_con_c_full = interpolate_contravatiant_vertical_verlocity_to_full_levels_numpy( + grid, z_w_con_c + ) if not lvn_only: ddt_w_adv = cls._fused_velocity_advection_stencil_16_to_18( diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_19_to_20.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_19_to_20.py index 23955d7fce..b5fda57eab 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_19_to_20.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_19_to_20.py @@ -36,9 +36,13 @@ zero_field, ) +from .test_add_extra_diffusion_for_wn_approaching_cfl import ( + add_extra_diffusion_for_wn_approaching_cfl_numpy, +) +from .test_compute_advective_normal_wind_tendency import ( + compute_advective_normal_wind_tendency_numpy, +) from .test_mo_math_divrot_rot_vertex_ri_dsl import mo_math_divrot_rot_vertex_ri_dsl_numpy -from .test_mo_velocity_advection_stencil_19 import mo_velocity_advection_stencil_19_numpy -from .test_mo_velocity_advection_stencil_20 import mo_velocity_advection_stencil_20_numpy class TestFusedVelocityAdvectionStencil19To20(StencilTest): @@ -77,7 +81,7 @@ def reference( coeff_gradekin = np.reshape(coeff_gradekin, (grid.num_edges, 2)) - ddt_vn_apc = mo_velocity_advection_stencil_19_numpy( + ddt_vn_apc = compute_advective_normal_wind_tendency_numpy( grid, z_kin_hor_e, coeff_gradekin, @@ -93,7 +97,7 @@ def reference( condition = (np.maximum(2, nrdmax - 2) <= k) & (k < nlev - 3) - ddt_vn_apc_extra_diffu = mo_velocity_advection_stencil_20_numpy( + ddt_vn_apc_extra_diffu = add_extra_diffusion_for_wn_approaching_cfl_numpy( grid, levelmask, c_lin_e, diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py index 0500c92b97..4413001100 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py @@ -23,15 +23,19 @@ from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from .test_compute_contravariant_correction import compute_contravariant_correction_numpy +from .test_compute_horizontal_advection_term_for_vertical_velocity import ( + compute_horizontal_advection_term_for_vertical_velocity_numpy, +) +from .test_compute_horizontal_kinetic_energy import compute_horizontal_kinetic_energy_numpy +from .test_compute_tangential_wind import compute_tangential_wind_numpy from .test_extrapolate_at_top import extrapolate_at_top_numpy +from .test_interpolate_vn_to_ie_and_compute_ekin_on_edges import ( + interpolate_vn_to_ie_and_compute_ekin_on_edges_numpy, +) +from .test_interpolate_vt_to_ie import interpolate_vt_to_ie_numpy from .test_mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl import ( mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl_numpy, ) -from .test_mo_velocity_advection_stencil_01 import mo_velocity_advection_stencil_01_numpy -from .test_mo_velocity_advection_stencil_02 import mo_velocity_advection_stencil_02_numpy -from .test_mo_velocity_advection_stencil_03 import mo_velocity_advection_stencil_03_numpy -from .test_mo_velocity_advection_stencil_05 import mo_velocity_advection_stencil_05_numpy -from .test_mo_velocity_advection_stencil_07 import mo_velocity_advection_stencil_07_numpy class TestFusedVelocityAdvectionStencil1To7(StencilTest): @@ -67,26 +71,22 @@ def _fused_velocity_advection_stencil_1_to_6_numpy( k = k[np.newaxis, :] condition1 = k < nlevp1 - vt = np.where( - condition1, mo_velocity_advection_stencil_01_numpy(grid, vn, rbf_vec_coeff_e), vt - ) + vt = np.where(condition1, compute_tangential_wind_numpy(grid, vn, rbf_vec_coeff_e), vt) condition2 = (1 < k) & (k < nlevp1) vn_ie, z_kin_hor_e = np.where( condition2, - mo_velocity_advection_stencil_02_numpy(grid, wgtfac_e, vn, vt), + interpolate_vn_to_ie_and_compute_ekin_on_edges_numpy(grid, wgtfac_e, vn, vt), (vn_ie, z_kin_hor_e), ) if not lvn_only: - z_vt_ie = np.where( - condition2, mo_velocity_advection_stencil_03_numpy(grid, wgtfac_e, vt), z_vt_ie - ) + z_vt_ie = np.where(condition2, interpolate_vt_to_ie_numpy(grid, wgtfac_e, vt), z_vt_ie) condition3 = k == 0 vn_ie, z_vt_ie, z_kin_hor_e = np.where( condition3, - mo_velocity_advection_stencil_05_numpy(vn, vt), + compute_horizontal_kinetic_energy_numpy(vn, vt), (vn_ie, z_vt_ie, z_kin_hor_e), ) @@ -168,7 +168,7 @@ def reference( if not lvn_only: z_v_grad_w = np.where( condition_mask, - mo_velocity_advection_stencil_07_numpy( + compute_horizontal_advection_term_for_vertical_velocity_numpy( grid, vn_ie, inv_dual_edge_length, diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_8_to_14.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_8_to_14.py index 8caa46e7ad..9911c752ca 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_8_to_14.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_8_to_14.py @@ -27,11 +27,17 @@ zero_field, ) +from .test_compute_maximum_cfl_and_clip_contravariant_vertical_velocity import ( + compute_maximum_cfl_and_clip_contravariant_vertical_velocity_numpy, +) from .test_copy_cell_kdim_field_to_vp import copy_cell_kdim_field_to_vp_numpy +from .test_correct_contravariant_vertical_velocity import ( + correct_contravariant_vertical_velocity_numpy, +) +from .test_interpolate_contravariant_correct_to_interface_levels import ( + interpolate_contravariant_correct_to_interface_levels_numpy, +) from .test_interpolate_to_cell_center import interpolate_to_cell_center_numpy -from .test_mo_velocity_advection_stencil_10 import mo_velocity_advection_stencil_10_numpy -from .test_mo_velocity_advection_stencil_13 import mo_velocity_advection_stencil_13_numpy -from .test_mo_velocity_advection_stencil_14 import mo_velocity_advection_stencil_14_numpy from .test_set_cell_kdim_field_to_zero_vp import set_cell_kdim_field_to_zero_vp_numpy @@ -87,7 +93,9 @@ def reference( w_concorr_c = np.where( (nflatlev + 1 < k) & (k < nlev), - mo_velocity_advection_stencil_10_numpy(grid, z_w_concorr_mc, wgtfac_c), + interpolate_contravariant_correct_to_interface_levels_numpy( + grid, z_w_concorr_mc, wgtfac_c + ), w_concorr_c, ) @@ -99,12 +107,16 @@ def reference( z_w_con_c = np.where( (nflatlev + 1 < k) & (k < nlev), - mo_velocity_advection_stencil_13_numpy(z_w_con_c, w_concorr_c), + correct_contravariant_vertical_velocity_numpy(z_w_con_c, w_concorr_c), z_w_con_c, ) condition = (np.maximum(3, nrdmax - 2) < k) & (k < nlev - 3) - cfl_clipping_new, vcfl_new, z_w_con_c_new = mo_velocity_advection_stencil_14_numpy( + ( + cfl_clipping_new, + vcfl_new, + z_w_con_c_new, + ) = compute_maximum_cfl_and_clip_contravariant_vertical_velocity_numpy( grid, ddqz_z_half, z_w_con_c, cfl_w_limit, dtime ) diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_10.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_contravariant_correct_to_interface_levels.py similarity index 81% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_10.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_contravariant_correct_to_interface_levels.py index e452928d55..65b3520940 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_10.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_contravariant_correct_to_interface_levels.py @@ -15,15 +15,15 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_10 import ( - mo_velocity_advection_stencil_10, +from icon4py.model.atmosphere.dycore.interpolate_contravariant_correct_to_interface_levels import ( + interpolate_contravariant_correct_to_interface_levels, ) from icon4py.model.common.dimension import CellDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from icon4py.model.common.type_alias import vpfloat -def mo_velocity_advection_stencil_10_numpy( +def interpolate_contravariant_correct_to_interface_levels_numpy( grid, wgtfac_c: np.array, z_w_concorr_mc: np.array ) -> np.array: z_w_concorr_mc_k_minus_1 = np.roll(z_w_concorr_mc, shift=1, axis=1) @@ -33,12 +33,14 @@ def mo_velocity_advection_stencil_10_numpy( class TestMoVelocityAdvectionStencil10(StencilTest): - PROGRAM = mo_velocity_advection_stencil_10 + PROGRAM = interpolate_contravariant_correct_to_interface_levels OUTPUTS = ("w_concorr_c",) @staticmethod def reference(grid, wgtfac_c: np.array, z_w_concorr_mc: np.array, **kwargs) -> dict: - w_concorr_c = mo_velocity_advection_stencil_10_numpy(grid, wgtfac_c, z_w_concorr_mc) + w_concorr_c = interpolate_contravariant_correct_to_interface_levels_numpy( + grid, wgtfac_c, z_w_concorr_mc + ) return dict(w_concorr_c=w_concorr_c) @pytest.fixture diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_15.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_contravatiant_vertical_verlocity_to_full_levels.py similarity index 77% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_15.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_contravatiant_vertical_verlocity_to_full_levels.py index 2d15ea1dd0..faec7428e6 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_15.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_contravatiant_vertical_verlocity_to_full_levels.py @@ -15,26 +15,28 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_15 import ( - mo_velocity_advection_stencil_15, +from icon4py.model.atmosphere.dycore.interpolate_contravatiant_vertical_verlocity_to_full_levels import ( + interpolate_contravatiant_vertical_verlocity_to_full_levels, ) from icon4py.model.common.dimension import CellDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from icon4py.model.common.type_alias import vpfloat -def mo_velocity_advection_stencil_15_numpy(grid, z_w_con_c: np.array): +def interpolate_contravatiant_vertical_verlocity_to_full_levels_numpy(grid, z_w_con_c: np.array): z_w_con_c_full = 0.5 * (z_w_con_c[:, :-1] + z_w_con_c[:, 1:]) return z_w_con_c_full class TestMoVelocityAdvectionStencil15(StencilTest): - PROGRAM = mo_velocity_advection_stencil_15 + PROGRAM = interpolate_contravatiant_vertical_verlocity_to_full_levels OUTPUTS = ("z_w_con_c_full",) @staticmethod def reference(grid, z_w_con_c: np.array, **kwargs) -> dict: - z_w_con_c_full = mo_velocity_advection_stencil_15_numpy(grid, z_w_con_c) + z_w_con_c_full = interpolate_contravatiant_vertical_verlocity_to_full_levels_numpy( + grid, z_w_con_c + ) return dict(z_w_con_c_full=z_w_con_c_full) @pytest.fixture diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_02.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_vn_to_ie_and_compute_ekin_on_edges.py similarity index 76% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_02.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_vn_to_ie_and_compute_ekin_on_edges.py index 5ba7a5460a..651b1f1684 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_02.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_vn_to_ie_and_compute_ekin_on_edges.py @@ -15,32 +15,36 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_02 import ( - mo_velocity_advection_stencil_02, +from icon4py.model.atmosphere.dycore.interpolate_vn_to_ie_and_compute_ekin_on_edges import ( + interpolate_vn_to_ie_and_compute_ekin_on_edges, ) from icon4py.model.common.dimension import EdgeDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from icon4py.model.common.type_alias import vpfloat, wpfloat -def mo_velocity_advection_stencil_02_vn_ie_numpy(wgtfac_e: np.array, vn: np.array) -> np.array: +def interpolate_vn_to_ie_and_compute_ekin_on_edges_vn_ie_numpy( + wgtfac_e: np.array, vn: np.array +) -> np.array: vn_ie_k_minus_1 = np.roll(vn, shift=1, axis=1) vn_ie = wgtfac_e * vn + (1.0 - wgtfac_e) * vn_ie_k_minus_1 vn_ie[:, 0] = 0 return vn_ie -def mo_velocity_advection_stencil_02_z_kin_hor_e_numpy(vn: np.array, vt: np.array) -> np.array: +def interpolate_vn_to_ie_and_compute_ekin_on_edges_z_kin_hor_e_numpy( + vn: np.array, vt: np.array +) -> np.array: z_kin_hor_e = 0.5 * (vn * vn + vt * vt) z_kin_hor_e[:, 0] = 0 return z_kin_hor_e -def mo_velocity_advection_stencil_02_numpy( +def interpolate_vn_to_ie_and_compute_ekin_on_edges_numpy( grid, wgtfac_e: np.array, vn: np.array, vt: np.array, **kwargs ) -> tuple: - vn_ie = mo_velocity_advection_stencil_02_vn_ie_numpy(wgtfac_e, vn) - z_kin_hor_e = mo_velocity_advection_stencil_02_z_kin_hor_e_numpy(vn, vt) + vn_ie = interpolate_vn_to_ie_and_compute_ekin_on_edges_vn_ie_numpy(wgtfac_e, vn) + z_kin_hor_e = interpolate_vn_to_ie_and_compute_ekin_on_edges_z_kin_hor_e_numpy(vn, vt) return ( vn_ie, z_kin_hor_e, @@ -48,12 +52,14 @@ def mo_velocity_advection_stencil_02_numpy( class TestMoVelocityAdvectionStencil02VnIe(StencilTest): - PROGRAM = mo_velocity_advection_stencil_02 + PROGRAM = interpolate_vn_to_ie_and_compute_ekin_on_edges OUTPUTS = ("vn_ie", "z_kin_hor_e") @classmethod def reference(cls, grid, wgtfac_e: np.array, vn: np.array, vt: np.array, **kwargs) -> dict: - vn_ie, z_kin_hor_e = mo_velocity_advection_stencil_02_numpy(grid, wgtfac_e, vn, vt) + vn_ie, z_kin_hor_e = interpolate_vn_to_ie_and_compute_ekin_on_edges_numpy( + grid, wgtfac_e, vn, vt + ) return dict( vn_ie=vn_ie[int32(1) : int32(grid.num_cells), int32(1) : int32(grid.num_levels)], z_kin_hor_e=z_kin_hor_e[ diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_03.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_vt_to_ie.py similarity index 84% rename from model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_03.py rename to model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_vt_to_ie.py index f4e32000dd..91d9a4410e 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_velocity_advection_stencil_03.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_interpolate_vt_to_ie.py @@ -15,17 +15,13 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_03 import ( - mo_velocity_advection_stencil_03, -) +from icon4py.model.atmosphere.dycore.interpolate_vt_to_ie import interpolate_vt_to_ie from icon4py.model.common.dimension import EdgeDim, KDim from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from icon4py.model.common.type_alias import vpfloat -def mo_velocity_advection_stencil_03_numpy( - grid, wgtfac_e: np.array, vt: np.array, **kwargs -) -> np.array: +def interpolate_vt_to_ie_numpy(grid, wgtfac_e: np.array, vt: np.array, **kwargs) -> np.array: vt_k_minus_1 = np.roll(vt, shift=1, axis=1) z_vt_ie = wgtfac_e * vt + (1.0 - wgtfac_e) * vt_k_minus_1 z_vt_ie[:, 0] = 0 @@ -33,12 +29,12 @@ def mo_velocity_advection_stencil_03_numpy( class TestMoVelocityAdvectionStencil03(StencilTest): - PROGRAM = mo_velocity_advection_stencil_03 + PROGRAM = interpolate_vt_to_ie OUTPUTS = ("z_vt_ie",) @staticmethod def reference(grid, wgtfac_e: np.array, vt: np.array, **kwargs) -> dict: - z_vt_ie = mo_velocity_advection_stencil_03_numpy(grid, wgtfac_e, vt) + z_vt_ie = interpolate_vt_to_ie_numpy(grid, wgtfac_e, vt) return dict( z_vt_ie=z_vt_ie[int32(1) : int32(grid.num_cells), int32(1) : int32(grid.num_levels)] ) diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_solve_nonhydro_stencil_37.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_solve_nonhydro_stencil_37.py deleted file mode 100644 index 53417f450d..0000000000 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_mo_solve_nonhydro_stencil_37.py +++ /dev/null @@ -1,55 +0,0 @@ -# ICON4Py - ICON inspired code in Python and GT4Py -# -# Copyright (c) 2022, ETH Zurich and MeteoSwiss -# All rights reserved. -# -# This file is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or any later -# version. See the LICENSE.txt file at the top-level directory of this -# distribution for a copy of the license or check . -# -# SPDX-License-Identifier: GPL-3.0-or-later - -import numpy as np -import pytest -from gt4py.next.ffront.fbuiltins import int32 - -from icon4py.model.atmosphere.dycore.mo_solve_nonhydro_stencil_37 import ( - mo_solve_nonhydro_stencil_37, -) -from icon4py.model.common.dimension import EdgeDim, KDim -from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field -from icon4py.model.common.type_alias import vpfloat, wpfloat - - -class TestMoSolveNonhydroStencil37(StencilTest): - PROGRAM = mo_solve_nonhydro_stencil_37 - OUTPUTS = ("vn_ie", "z_vt_ie", "z_kin_hor_e") - - @staticmethod - def reference(grid, vn: np.array, vt: np.array, **kwargs) -> dict: - vn_ie = vn - z_vt_ie = vt - z_kin_hor_e = 0.5 * (pow(vn, 2) + pow(vt, 2)) - return dict(vn_ie=vn_ie, z_vt_ie=z_vt_ie, z_kin_hor_e=z_kin_hor_e) - - @pytest.fixture - def input_data(self, grid): - vt = random_field(grid, EdgeDim, KDim, dtype=vpfloat) - vn = random_field(grid, EdgeDim, KDim, dtype=wpfloat) - vn_ie = zero_field(grid, EdgeDim, KDim, dtype=vpfloat) - z_kin_hor_e = zero_field(grid, EdgeDim, KDim, dtype=vpfloat) - z_vt_ie = zero_field(grid, EdgeDim, KDim, dtype=vpfloat) - - return dict( - vn=vn, - vt=vt, - vn_ie=vn_ie, - z_vt_ie=z_vt_ie, - z_kin_hor_e=z_kin_hor_e, - horizontal_start=int32(0), - horizontal_end=int32(grid.num_edges), - vertical_start=int32(0), - vertical_end=int32(grid.num_levels), - ) diff --git a/tools/README.md b/tools/README.md index 2a2d5c29c6..c77c90dcb9 100644 --- a/tools/README.md +++ b/tools/README.md @@ -278,6 +278,10 @@ The `END DELETE` indicates the ending line from which on code is deleted. This directive generates an `#endif` statement. +### ICON-Liskov integration style-guide + +Check out `tools/docs/ICON_Liskov_integration_style_guide.md` for having a unique look and feel in the fortran integration. + ### `f2ser` This tool is designed to parse a well-defined Fortran granule interface and generate ppser statements for each variable in the interface. It uses the `f2py` library to perform the parsing and `liskov` for the generation tasks. diff --git a/tools/docs/ICON_Liskov_integration_style_guide.md b/tools/docs/ICON_Liskov_integration_style_guide.md new file mode 100644 index 0000000000..cd5f573563 --- /dev/null +++ b/tools/docs/ICON_Liskov_integration_style_guide.md @@ -0,0 +1,140 @@ +# ICON-Liskov integration style-guide + +The idea of the style-guide is to have a unique style, to make reading and maintaining as easy as possible. +The code should look as clean and concise as possible. Also it should be similar to the ACC style-guide: https://gitlab.dkrz.de/icon/wiki/-/wikis/GPU-development/ICON-OpenAcc-style-and-implementation-guide. + +## General: + +- indentation as original surrounding code. +- no empty line between following `!$DSL`-statements of the same kind. + +## Specific DSL statements: + +- `!$DSL IMPORTS()` after last `USE` statement and before `IMPLICIT NONE`, one empty line before and after. +- `!$DSL DECLARE` after last variable declaration and before code block, one empty line before and after. +- `!$DSL START STENCIL` as close as possible to the start of the original stencil section, one empty line before, no empty line after. +- `!$DSL END STENCIL` as close as possible to the end of the original stencil section, no empty line before, one empty line after. +- `!$DSL START FUSED STENCIL` should be placed before the `!$DSL START STENCIL` of the first stencil in the fused batch, one empty line before, one empty line after. +- `!$DSL END FUSED STENCIL` should be placed after the `!$DSL END STENCIL` of the last stencil in the fused batch, one empty line before, one empty line after. +- `!$DSL INSERT` one empty line before and after, unless the inserted code is part of an `ACC` data region. +- `!$DSL START CREATE` after the `!$ACC CREATE` block, no empty line before and one empty line after. + +## Example + +```fortran + +... + +MODULE mo_nh_diffusion + +... + +USE mo_vertical_grid, ONLY: nrdmax + +!$DSL IMPORTS() + +IMPLICIT NONE + +... + +SUBROUTINE diffusion(p_nh_prog,p_nh_diag,p_nh_metrics,p_patch,p_int,dtime,linit) + + ... + + INTEGER :: i_startblk, i_endblk, i_startidx, i_endidx + + !$DSL INSERT(INTEGER :: start_interior_idx_c, end_interior_idx_c, start_nudging_idx_c, end_halo_1_idx_c) + !$DSL INSERT(INTEGER :: start_2nd_nudge_line_idx_e, end_interior_idx_e, start_bdydiff_idx_e) + + INTEGER :: rl_start, rl_end + + ... + + REAL(wp) :: r_dtimensubsteps + + !$DSL DECLARE(vn=nproma,p_patch%nlev,p_patch%nblks_e; & + !$DSL exner=nproma,p_patch%nlev,p_patch%nblks_c; type=REAL(wp)) + !$DSL DECLARE(kh_c=nproma,p_patch%nlev; & + !$DSL z_nabla2_c=nproma,p_patch%nlev,p_patch%nblks_e; type=REAL(vp)) + + !$DSL INSERT(REAL(vp) :: smallest_vpfloat = -HUGE(0._vp)) + + !-------------------------------------------------------------------------- + + ... + + !$ACC DATA CREATE(div, kh_c, kh_smag_e, kh_smag_ec, u_vert, v_vert, u_cell, v_cell, z_w_v, z_temp) & + !$ACC CREATE(z_vn_ie, z_vt_ie) & + !$DSL INSERT(!$ACC CREATE(w_old) &) + !$DSL INSERT(!$ACC COPYIN(vertical_idx, horizontal_idx) &) + !$ACC PRESENT(ividx, ivblk, iecidx, iecblk, icidx, icblk, ieidx, ieblk) & + !$ACC IF(i_am_accel_node) + + ... + + + ! Computation of wind field deformation + !$DSL START STENCIL(name=calculate_nabla2_and_smag_coefficients_for_vn; smag_offset=smag_offset; & + !$DSL kh_smag_e_rel_tol=1e-10_wp; kh_smag_ec_rel_tol=1e-10_wp; z_nabla2_e_rel_tol=1e-07_wp; & + !$DSL vertical_lower=1; vertical_upper=nlev; horizontal_lower=i_startidx; horizontal_upper=i_endidx) + !$ACC PARALLEL LOOP DEFAULT(PRESENT) GANG VECTOR COLLAPSE(2) ASYNC(1) IF(i_am_accel_node) + +!$NEC outerloop_unroll(4) +DO jk = 1, nlev +DO je = i_startidx, i_endidx + + ... + + ENDDO + ENDDO + !$ACC END PARALLEL LOOP + !$DSL END STENCIL(name=calculate_nabla2_and_smag_coefficients_for_vn) + + ENDDO ! block jb + + ... + + CALL get_indices_c(p_patch, jb, i_startblk, i_endblk, & + i_startidx, i_endidx, rl_start, rl_end) + + !$DSL START FUSED STENCIL(name=calculate_diagnostic_quantities_for_turbulence; & + !$DSL hdef_ic=p_nh_diag%hdef_ic(:,:,1); & + !$DSL div_ic_abs_tol=1e-18_wp; vertical_lower=2; & + !$DSL vertical_upper=nlev; horizontal_lower=i_startidx; horizontal_upper=i_endidx) + + !$DSL START STENCIL(name=temporary_fields_for_turbulence_diagnostics; kh_smag_ec=kh_smag_ec(:,:,1); vn=p_nh_prog%vn(:,:,1); & + !$DSL diff_multfac_smag=diff_multfac_smag(:); kh_c=kh_c(:,:); div=div(:,:); & + !$DSL vertical_lower=1; vertical_upper=nlev; horizontal_lower=i_startidx; & + !$DSL horizontal_upper=i_endidx) + !$ACC PARALLEL LOOP DEFAULT(PRESENT) GANG VECTOR COLLAPSE(2) ASYNC(1) IF(i_am_accel_node) + DO jk = 1, nlev + DO jc = i_startidx, i_endidx + + ... + + ENDDO + ENDDO + !$ACC END PARALLEL LOOP + !$DSL END STENCIL(name=temporary_fields_for_turbulence_diagnostics) + + !$DSL START STENCIL(name=calculate_diagnostics_for_turbulence; div=div; kh_c=kh_c; wgtfac_c=p_nh_metrics%wgtfac_c(:,:,1); & + !$DSL vertical_lower=2; vertical_upper=nlev; horizontal_lower=i_startidx; horizontal_upper=i_endidx) + !$ACC PARALLEL LOOP DEFAULT(PRESENT) GANG VECTOR COLLAPSE(2) ASYNC(1) IF(i_am_accel_node) + DO jk = 2, nlev ! levels 1 and nlevp1 are unused + +!DIR$ IVDEP +DO jc = i_startidx, i_endidx + + ... + + ENDDO + ENDDO + !$ACC END PARALLEL LOOP + !$DSL END STENCIL(name=calculate_diagnostics_for_turbulence) + + !$DSL END FUSED STENCIL(name=calculate_diagnostic_quantities_for_turbulence) + + + ... + +```