From 2d2c0eb739684977199b95e225fbb2123a649837 Mon Sep 17 00:00:00 2001 From: Till Ehrengruber Date: Wed, 11 Sep 2024 16:09:45 +0200 Subject: [PATCH 1/5] Fix _compute_hydrostatic_correction_term --- .../compute_hydrostatic_correction_term.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_hydrostatic_correction_term.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_hydrostatic_correction_term.py index 478b224f48..6358aab5be 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_hydrostatic_correction_term.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_hydrostatic_correction_term.py @@ -35,24 +35,24 @@ def _compute_hydrostatic_correction_term( """Formerly known as _mo_solve_nonhydro_stencil_21.""" zdiff_gradp_wp = astype(zdiff_gradp, wpfloat) - theta_v_0 = theta_v(as_offset(Koff, ikoffset(E2EC[0]))) - theta_v_1 = theta_v(as_offset(Koff, ikoffset(E2EC[1]))) + theta_v_0 = theta_v(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]))) + theta_v_1 = theta_v(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]))) - theta_v_ic_0 = theta_v_ic(as_offset(Koff, ikoffset(E2EC[0]))) - theta_v_ic_1 = theta_v_ic(as_offset(Koff, ikoffset(E2EC[1]))) + theta_v_ic_0 = theta_v_ic(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]))) + theta_v_ic_1 = theta_v_ic(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]))) - theta_v_ic_p1_0 = theta_v_ic(as_offset(Koff, ikoffset(E2EC[0]) + 1)) - theta_v_ic_p1_1 = theta_v_ic(as_offset(Koff, ikoffset(E2EC[1]) + 1)) + theta_v_ic_p1_0 = theta_v_ic(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]) + 1)) + theta_v_ic_p1_1 = theta_v_ic(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]) + 1)) - inv_ddqz_z_full_0_wp = astype(inv_ddqz_z_full(as_offset(Koff, ikoffset(E2EC[0]))), wpfloat) - inv_ddqz_z_full_1_wp = astype(inv_ddqz_z_full(as_offset(Koff, ikoffset(E2EC[1]))), wpfloat) + inv_ddqz_z_full_0_wp = astype(inv_ddqz_z_full(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]))), wpfloat) + inv_ddqz_z_full_1_wp = astype(inv_ddqz_z_full(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]))), wpfloat) - z_theta_0 = theta_v_0(E2C[0]) + zdiff_gradp_wp(E2EC[0]) * ( - theta_v_ic_0(E2C[0]) - theta_v_ic_p1_0(E2C[0]) - ) * inv_ddqz_z_full_0_wp(E2C[0]) - z_theta_1 = theta_v_1(E2C[1]) + zdiff_gradp_wp(E2EC[1]) * ( - theta_v_ic_1(E2C[1]) - theta_v_ic_p1_1(E2C[1]) - ) * inv_ddqz_z_full_1_wp(E2C[1]) + z_theta_0 = theta_v_0 + zdiff_gradp_wp(E2EC[0]) * ( + theta_v_ic_0 - theta_v_ic_p1_0 + ) * inv_ddqz_z_full_0_wp + z_theta_1 = theta_v_1 + zdiff_gradp_wp(E2EC[1]) * ( + theta_v_ic_1 - theta_v_ic_p1_1 + ) * inv_ddqz_z_full_1_wp z_hydro_corr_wp = ( grav_o_cpd * inv_dual_edge_length From ac78f35e00400829a69f80844c6ba5364c390559 Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Wed, 11 Sep 2024 16:39:14 +0200 Subject: [PATCH 2/5] Fix _compute_horizontal_gradient_of_exner_pressure_for_multiple_levels --- ...t_of_exner_pressure_for_multiple_levels.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_gradient_of_exner_pressure_for_multiple_levels.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_gradient_of_exner_pressure_for_multiple_levels.py index a13c509ae7..03faca6cc7 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_gradient_of_exner_pressure_for_multiple_levels.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_horizontal_gradient_of_exner_pressure_for_multiple_levels.py @@ -32,26 +32,26 @@ def _compute_horizontal_gradient_of_exner_pressure_for_multiple_levels( z_dexner_dz_c_2: fa.CellKField[vpfloat], ) -> fa.EdgeKField[vpfloat]: """Formerly known as _mo_solve_nonhydro_stencil_20.""" - z_exner_ex_pr_0 = z_exner_ex_pr(as_offset(Koff, ikoffset(E2EC[0]))) - z_exner_ex_pr_1 = z_exner_ex_pr(as_offset(Koff, ikoffset(E2EC[1]))) + z_exner_ex_pr_0 = z_exner_ex_pr(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]))) + z_exner_ex_pr_1 = z_exner_ex_pr(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]))) - z_dexner_dz_c1_0 = z_dexner_dz_c_1(as_offset(Koff, ikoffset(E2EC[0]))) - z_dexner_dz_c1_1 = z_dexner_dz_c_1(as_offset(Koff, ikoffset(E2EC[1]))) + z_dexner_dz_c1_0 = z_dexner_dz_c_1(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]))) + z_dexner_dz_c1_1 = z_dexner_dz_c_1(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]))) - z_dexner_dz_c2_0 = z_dexner_dz_c_2(as_offset(Koff, ikoffset(E2EC[0]))) - z_dexner_dz_c2_1 = z_dexner_dz_c_2(as_offset(Koff, ikoffset(E2EC[1]))) + z_dexner_dz_c2_0 = z_dexner_dz_c_2(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]))) + z_dexner_dz_c2_1 = z_dexner_dz_c_2(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]))) z_gradh_exner_wp = inv_dual_edge_length * ( astype( ( - z_exner_ex_pr_1(E2C[1]) + z_exner_ex_pr_1 + zdiff_gradp(E2EC[1]) - * (z_dexner_dz_c1_1(E2C[1]) + zdiff_gradp(E2EC[1]) * z_dexner_dz_c2_1(E2C[1])) + * (z_dexner_dz_c1_1 + zdiff_gradp(E2EC[1]) * z_dexner_dz_c2_1) ) - ( - z_exner_ex_pr_0(E2C[0]) + z_exner_ex_pr_0 + zdiff_gradp(E2EC[0]) - * (z_dexner_dz_c1_0(E2C[0]) + zdiff_gradp(E2EC[0]) * z_dexner_dz_c2_0(E2C[0])) + * (z_dexner_dz_c1_0 + zdiff_gradp(E2EC[0]) * z_dexner_dz_c2_0) ), wpfloat, ) From a04349525cf440ca55d30d08661961ca589cac6b Mon Sep 17 00:00:00 2001 From: Edoardo Paone Date: Wed, 11 Sep 2024 16:44:44 +0200 Subject: [PATCH 3/5] Fix code format --- .../compute_hydrostatic_correction_term.py | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_hydrostatic_correction_term.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_hydrostatic_correction_term.py index 6358aab5be..a2b1bd4a50 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_hydrostatic_correction_term.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_hydrostatic_correction_term.py @@ -44,15 +44,21 @@ def _compute_hydrostatic_correction_term( theta_v_ic_p1_0 = theta_v_ic(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]) + 1)) theta_v_ic_p1_1 = theta_v_ic(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]) + 1)) - inv_ddqz_z_full_0_wp = astype(inv_ddqz_z_full(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]))), wpfloat) - inv_ddqz_z_full_1_wp = astype(inv_ddqz_z_full(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]))), wpfloat) + inv_ddqz_z_full_0_wp = astype( + inv_ddqz_z_full(E2C[0])(as_offset(Koff, ikoffset(E2EC[0]))), wpfloat + ) + inv_ddqz_z_full_1_wp = astype( + inv_ddqz_z_full(E2C[1])(as_offset(Koff, ikoffset(E2EC[1]))), wpfloat + ) - z_theta_0 = theta_v_0 + zdiff_gradp_wp(E2EC[0]) * ( - theta_v_ic_0 - theta_v_ic_p1_0 - ) * inv_ddqz_z_full_0_wp - z_theta_1 = theta_v_1 + zdiff_gradp_wp(E2EC[1]) * ( - theta_v_ic_1 - theta_v_ic_p1_1 - ) * inv_ddqz_z_full_1_wp + z_theta_0 = ( + theta_v_0 + + zdiff_gradp_wp(E2EC[0]) * (theta_v_ic_0 - theta_v_ic_p1_0) * inv_ddqz_z_full_0_wp + ) + z_theta_1 = ( + theta_v_1 + + zdiff_gradp_wp(E2EC[1]) * (theta_v_ic_1 - theta_v_ic_p1_1) * inv_ddqz_z_full_1_wp + ) z_hydro_corr_wp = ( grav_o_cpd * inv_dual_edge_length From 82c07c65e1b65ba97e8e6e3a9cb7c52013080768 Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Thu, 12 Sep 2024 10:54:59 +0200 Subject: [PATCH 4/5] fix as_offset in truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py --- ...fusion_nabla_of_theta_over_steep_points.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/stencils/truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py b/model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/stencils/truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py index 039a45bb3a..008011df1c 100644 --- a/model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/stencils/truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py +++ b/model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/stencils/truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py @@ -35,30 +35,30 @@ def _truly_horizontal_diffusion_nabla_of_theta_over_steep_points( ) -> fa.CellKField[vpfloat]: z_temp_wp = astype(z_temp, wpfloat) - theta_v_0 = theta_v(as_offset(Koff, zd_vertoffset(C2CEC[0]))) - theta_v_1 = theta_v(as_offset(Koff, zd_vertoffset(C2CEC[1]))) - theta_v_2 = theta_v(as_offset(Koff, zd_vertoffset(C2CEC[2]))) + theta_v_0 = theta_v(C2E2C[0])(as_offset(Koff, zd_vertoffset(C2CEC[0]))) + theta_v_1 = theta_v(C2E2C[1])(as_offset(Koff, zd_vertoffset(C2CEC[1]))) + theta_v_2 = theta_v(C2E2C[2])(as_offset(Koff, zd_vertoffset(C2CEC[2]))) - theta_v_0_m1 = theta_v(as_offset(Koff, zd_vertoffset(C2CEC[0]) + 1)) - theta_v_1_m1 = theta_v(as_offset(Koff, zd_vertoffset(C2CEC[1]) + 1)) - theta_v_2_m1 = theta_v(as_offset(Koff, zd_vertoffset(C2CEC[2]) + 1)) + theta_v_0_m1 = theta_v(C2E2C[0])(as_offset(Koff, zd_vertoffset(C2CEC[0]) + 1)) + theta_v_1_m1 = theta_v(C2E2C[1])(as_offset(Koff, zd_vertoffset(C2CEC[1]) + 1)) + theta_v_2_m1 = theta_v(C2E2C[2])(as_offset(Koff, zd_vertoffset(C2CEC[2]) + 1)) sum_tmp = ( theta_v * geofac_n2s_c + geofac_n2s_nbh(C2CEC[0]) * ( - vcoef(C2CEC[0]) * theta_v_0(C2E2C[0]) - + (wpfloat("1.0") - vcoef(C2CEC[0])) * theta_v_0_m1(C2E2C[0]) + vcoef(C2CEC[0]) * theta_v_0 + + (wpfloat("1.0") - vcoef(C2CEC[0])) * theta_v_0_m1 ) + geofac_n2s_nbh(C2CEC[1]) * ( - vcoef(C2CEC[1]) * theta_v_1(C2E2C[1]) - + (wpfloat("1.0") - vcoef(C2CEC[1])) * theta_v_1_m1(C2E2C[1]) + vcoef(C2CEC[1]) * theta_v_1 + + (wpfloat("1.0") - vcoef(C2CEC[1])) * theta_v_1_m1 ) + geofac_n2s_nbh(C2CEC[2]) * ( - vcoef(C2CEC[2]) * theta_v_2(C2E2C[2]) - + (wpfloat("1.0") - vcoef(C2CEC[2])) * theta_v_2_m1(C2E2C[2]) + vcoef(C2CEC[2]) * theta_v_2 + + (wpfloat("1.0") - vcoef(C2CEC[2])) * theta_v_2_m1 ) ) From 5398658cc3470e30c5e20697e49bac2364ffe61a Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Thu, 12 Sep 2024 11:36:42 +0200 Subject: [PATCH 5/5] pre-commit --- ..._diffusion_nabla_of_theta_over_steep_points.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/stencils/truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py b/model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/stencils/truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py index 008011df1c..6a276979e3 100644 --- a/model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/stencils/truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py +++ b/model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/stencils/truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py @@ -46,20 +46,11 @@ def _truly_horizontal_diffusion_nabla_of_theta_over_steep_points( sum_tmp = ( theta_v * geofac_n2s_c + geofac_n2s_nbh(C2CEC[0]) - * ( - vcoef(C2CEC[0]) * theta_v_0 - + (wpfloat("1.0") - vcoef(C2CEC[0])) * theta_v_0_m1 - ) + * (vcoef(C2CEC[0]) * theta_v_0 + (wpfloat("1.0") - vcoef(C2CEC[0])) * theta_v_0_m1) + geofac_n2s_nbh(C2CEC[1]) - * ( - vcoef(C2CEC[1]) * theta_v_1 - + (wpfloat("1.0") - vcoef(C2CEC[1])) * theta_v_1_m1 - ) + * (vcoef(C2CEC[1]) * theta_v_1 + (wpfloat("1.0") - vcoef(C2CEC[1])) * theta_v_1_m1) + geofac_n2s_nbh(C2CEC[2]) - * ( - vcoef(C2CEC[2]) * theta_v_2 - + (wpfloat("1.0") - vcoef(C2CEC[2])) * theta_v_2_m1 - ) + * (vcoef(C2CEC[2]) * theta_v_2 + (wpfloat("1.0") - vcoef(C2CEC[2])) * theta_v_2_m1) ) z_temp_wp = where(