diff --git a/model/atmosphere/dycore/docs/scidoc/icon4py.model.atmosphere.dycore.solve_nonhydro.SolveNonhydro.run_predictor_step.rst b/model/atmosphere/dycore/docs/scidoc/icon4py.model.atmosphere.dycore.solve_nonhydro.SolveNonhydro.run_predictor_step.rst index 341a35804a..d540ecae96 100644 --- a/model/atmosphere/dycore/docs/scidoc/icon4py.model.atmosphere.dycore.solve_nonhydro.SolveNonhydro.run_predictor_step.rst +++ b/model/atmosphere/dycore/docs/scidoc/icon4py.model.atmosphere.dycore.solve_nonhydro.SolveNonhydro.run_predictor_step.rst @@ -176,7 +176,6 @@ Inputs: - $\exnerprimegradh{\ntilde}{\e}{\k}$ : z_gradh_exner - $\exnhydrocorr{\e}$ : hydro_corr_horizontal - $(h_k - h_{k^*})$ : pg_exdist - - $\IDXpg$ : ipeidx_dsl scidoc: Outputs: diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/dycore_states.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/dycore_states.py index 30e7478fcf..d280b45a70 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/dycore_states.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/dycore_states.py @@ -275,11 +275,15 @@ class MetricStateNonHydro: vertoffset_gradp: gtx.Field[gtx.Dims[dims.EdgeDim, dims.E2CDim, dims.KDim], gtx.int32] zdiff_gradp: gtx.Field[gtx.Dims[dims.EdgeDim, dims.E2CDim, dims.KDim], ta.vpfloat] nflat_gradp: gtx.int32 - """The minimum height index at which the height of the center of an edge lies within two neighboring cells so that + """ + The minimum height index at which the height of the center of an edge lies within two neighboring cells so that horizontal pressure gradient can be computed by first order discretization scheme. """ - pg_edgeidx_dsl: fa.EdgeKField[bool] + pg_exdist: fa.EdgeKField[ta.vpfloat] + """ + Extrapolation distance needed for HorizontalPressureDiscretizationType.TAYLOR_HYDRO. + """ exner_w_explicit_weight_parameter: fa.CellField[ta.wpfloat] """ diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/solve_nonhydro.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/solve_nonhydro.py index a8e6dfa4fb..ba08105e05 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/solve_nonhydro.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/solve_nonhydro.py @@ -456,7 +456,6 @@ def __init__( "c_lin_e": self._interpolation_state.c_lin_e, "ikoffset": self._metric_state_nonhydro.vertoffset_gradp, "zdiff_gradp": self._metric_state_nonhydro.zdiff_gradp, - "ipeidx_dsl": self._metric_state_nonhydro.pg_edgeidx_dsl, "pg_exdist": self._metric_state_nonhydro.pg_exdist, "inv_dual_edge_length": self._edge_geometry.inverse_dual_edge_lengths, "iau_wgt_dyn": self._config.iau_wgt_dyn, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/stencils/apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/stencils/apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure.py deleted file mode 100644 index ccc9659342..0000000000 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/stencils/apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure.py +++ /dev/null @@ -1,48 +0,0 @@ -# ICON4Py - ICON inspired code in Python and GT4Py -# -# Copyright (c) 2022-2024, ETH Zurich and MeteoSwiss -# All rights reserved. -# -# Please, refer to the LICENSE file in the root directory. -# SPDX-License-Identifier: BSD-3-Clause -import gt4py.next as gtx -from gt4py.next import where - -from icon4py.model.common import dimension as dims, field_type_aliases as fa -from icon4py.model.common.type_alias import vpfloat - - -@gtx.field_operator -def _apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure( - ipeidx_dsl: fa.EdgeKField[bool], - pg_exdist: fa.EdgeKField[vpfloat], - z_hydro_corr: fa.EdgeField[vpfloat], - z_gradh_exner: fa.EdgeKField[vpfloat], -) -> fa.EdgeKField[vpfloat]: - """Formerly known as _mo_solve_nonhydro_stencil_22.""" - z_gradh_exner_vp = where(ipeidx_dsl, z_gradh_exner + z_hydro_corr * pg_exdist, z_gradh_exner) - return z_gradh_exner_vp - - -@gtx.program(grid_type=gtx.GridType.UNSTRUCTURED) -def apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure( - ipeidx_dsl: fa.EdgeKField[bool], - pg_exdist: fa.EdgeKField[vpfloat], - z_hydro_corr: fa.EdgeField[vpfloat], - z_gradh_exner: fa.EdgeKField[vpfloat], - horizontal_start: gtx.int32, - horizontal_end: gtx.int32, - vertical_start: gtx.int32, - vertical_end: gtx.int32, -): - _apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure( - ipeidx_dsl, - pg_exdist, - z_hydro_corr, - z_gradh_exner, - out=z_gradh_exner, - domain={ - dims.EdgeDim: (horizontal_start, horizontal_end), - dims.KDim: (vertical_start, vertical_end), - }, - ) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/stencils/compute_edge_diagnostics_for_dycore_and_update_vn.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/stencils/compute_edge_diagnostics_for_dycore_and_update_vn.py index 9ec982bfc3..af22200ed2 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/stencils/compute_edge_diagnostics_for_dycore_and_update_vn.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/stencils/compute_edge_diagnostics_for_dycore_and_update_vn.py @@ -9,7 +9,7 @@ import gt4py.next as gtx from gt4py.eve import utils as eve_utils -from gt4py.next import broadcast +from gt4py.next import broadcast, where from gt4py.next.experimental import concat_where from icon4py.model.atmosphere.dycore.stencils.add_analysis_increments_to_vn import ( @@ -30,9 +30,6 @@ from icon4py.model.atmosphere.dycore.stencils.apply_4th_order_divergence_damping import ( _apply_4th_order_divergence_damping, ) -from icon4py.model.atmosphere.dycore.stencils.apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure import ( - _apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure, -) from icon4py.model.atmosphere.dycore.stencils.apply_weighted_2nd_and_4th_order_divergence_damping import ( _apply_weighted_2nd_and_4th_order_divergence_damping, ) @@ -79,6 +76,20 @@ def apply_on_vertical_level( ) +@gtx.field_operator +def apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure( + pg_exdist: fa.EdgeKField[ta.vpfloat], + z_hydro_corr: fa.EdgeField[ta.wpfloat], + z_gradh_exner: fa.EdgeKField[ta.vpfloat], +) -> fa.EdgeKField[ta.vpfloat]: + # Note: In the original Fortran code `pg_exdist` is implemented as a list, + # in ICON4Py it's a full field intialized with zeros for points that are not in the list. + z_gradh_exner_vp = where( + pg_exdist != 0.0, z_gradh_exner + z_hydro_corr * pg_exdist, z_gradh_exner + ) + return z_gradh_exner_vp + + @gtx.field_operator def _compute_horizontal_pressure_gradient( temporal_extrapolation_of_perturbed_exner: fa.CellKField[ta.vpfloat], @@ -89,7 +100,6 @@ def _compute_horizontal_pressure_gradient( c_lin_e: gtx.Field[[dims.EdgeDim, dims.E2CDim], ta.wpfloat], ikoffset: gtx.Field[[dims.EdgeDim, dims.E2CDim, dims.KDim], gtx.int32], zdiff_gradp: gtx.Field[[dims.EdgeDim, dims.E2CDim, dims.KDim], ta.vpfloat], - ipeidx_dsl: fa.EdgeKField[bool], pg_exdist: fa.EdgeKField[ta.vpfloat], inv_dual_edge_length: fa.EdgeField[ta.wpfloat], nflatlev: gtx.int32, @@ -120,8 +130,7 @@ def _compute_horizontal_pressure_gradient( ), ) - return _apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure( - ipeidx_dsl=ipeidx_dsl, + return apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure( pg_exdist=pg_exdist, z_hydro_corr=hydrostatic_correction_on_lowest_level, z_gradh_exner=horizontal_pressure_gradient, @@ -157,7 +166,6 @@ def _compute_rho_theta_pgrad_and_update_vn( c_lin_e: gtx.Field[[dims.EdgeDim, dims.E2CDim], ta.wpfloat], ikoffset: gtx.Field[[dims.EdgeDim, dims.E2CDim, dims.KDim], gtx.int32], zdiff_gradp: gtx.Field[[dims.EdgeDim, dims.E2CDim, dims.KDim], ta.vpfloat], - ipeidx_dsl: fa.EdgeKField[bool], pg_exdist: fa.EdgeKField[ta.vpfloat], inv_dual_edge_length: fa.EdgeField[ta.wpfloat], dtime: ta.wpfloat, @@ -218,7 +226,6 @@ def _compute_rho_theta_pgrad_and_update_vn( c_lin_e=c_lin_e, ikoffset=ikoffset, zdiff_gradp=zdiff_gradp, - ipeidx_dsl=ipeidx_dsl, pg_exdist=pg_exdist, inv_dual_edge_length=inv_dual_edge_length, nflatlev=nflatlev, @@ -401,7 +408,6 @@ def compute_rho_theta_pgrad_and_update_vn( c_lin_e: gtx.Field[[dims.EdgeDim, dims.E2CDim], ta.wpfloat], ikoffset: gtx.Field[[dims.EdgeDim, dims.E2CDim, dims.KDim], gtx.int32], zdiff_gradp: gtx.Field[[dims.EdgeDim, dims.E2CDim, dims.KDim], ta.vpfloat], - ipeidx_dsl: fa.EdgeKField[bool], pg_exdist: fa.EdgeKField[ta.vpfloat], inv_dual_edge_length: fa.EdgeField[ta.wpfloat], dtime: ta.wpfloat, @@ -458,7 +464,6 @@ def compute_rho_theta_pgrad_and_update_vn( - c_lin_e: interpolation coefficient for computation of interpolating a cell-based variables to an edge-based variable - ikoffset: k offset index (offset from the lowest k index where the neighboring cell centers lie within the thickness of the layer) for hyrostatic correction - zdiff_gradp: vertical distance between current cell height and neighboring cell height for pressure gradient over multiple levels [m] - - ipeidx_dsl: A mask for hydrostatic correction - pg_exdist: vertical distance between current cell height and neighboring cell height for hydrostatic correction [m] - inv_dual_edge_length: inverse dual edge length [m] - dtime: time step [s] @@ -508,7 +513,6 @@ def compute_rho_theta_pgrad_and_update_vn( c_lin_e=c_lin_e, ikoffset=ikoffset, zdiff_gradp=zdiff_gradp, - ipeidx_dsl=ipeidx_dsl, pg_exdist=pg_exdist, inv_dual_edge_length=inv_dual_edge_length, dtime=dtime, diff --git a/model/atmosphere/dycore/tests/dycore/integration_tests/test_benchmark_solve_nonhydro.py b/model/atmosphere/dycore/tests/dycore/integration_tests/test_benchmark_solve_nonhydro.py index 3224ce7065..2395cda5d9 100644 --- a/model/atmosphere/dycore/tests/dycore/integration_tests/test_benchmark_solve_nonhydro.py +++ b/model/atmosphere/dycore/tests/dycore/integration_tests/test_benchmark_solve_nonhydro.py @@ -175,7 +175,6 @@ def solve_nonhydro( zdiff_gradp=metrics_field_source.get(metrics_attributes.ZDIFF_GRADP), vertoffset_gradp=metrics_field_source.get(metrics_attributes.VERTOFFSET_GRADP), nflat_gradp=metrics_field_source.get(metrics_attributes.NFLAT_GRADP), - pg_edgeidx_dsl=metrics_field_source.get(metrics_attributes.PG_EDGEIDX_DSL), pg_exdist=metrics_field_source.get(metrics_attributes.PG_EDGEDIST_DSL), ddqz_z_full_e=metrics_field_source.get(metrics_attributes.DDQZ_Z_FULL_E), ddxt_z_full=metrics_field_source.get(metrics_attributes.DDXT_Z_FULL), diff --git a/model/atmosphere/dycore/tests/dycore/integration_tests/test_solve_nonhydro.py b/model/atmosphere/dycore/tests/dycore/integration_tests/test_solve_nonhydro.py index f00a231235..9ed4926167 100644 --- a/model/atmosphere/dycore/tests/dycore/integration_tests/test_solve_nonhydro.py +++ b/model/atmosphere/dycore/tests/dycore/integration_tests/test_solve_nonhydro.py @@ -1513,7 +1513,6 @@ def test_compute_rho_theta_pgrad_and_update_vn( c_lin_e=interpolation_savepoint.c_lin_e(), ikoffset=metrics_savepoint.vertoffset_gradp(), zdiff_gradp=metrics_savepoint.zdiff_gradp(), - ipeidx_dsl=metrics_savepoint.pg_edgeidx_dsl(), pg_exdist=metrics_savepoint.pg_exdist(), inv_dual_edge_length=grid_savepoint.inv_dual_edge_length(), dtime=savepoint_nonhydro_init.get_metadata("dtime").get("dtime"), diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure.py deleted file mode 100644 index 7189d02661..0000000000 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure.py +++ /dev/null @@ -1,73 +0,0 @@ -# ICON4Py - ICON inspired code in Python and GT4Py -# -# Copyright (c) 2022-2024, ETH Zurich and MeteoSwiss -# All rights reserved. -# -# Please, refer to the LICENSE file in the root directory. -# SPDX-License-Identifier: BSD-3-Clause -from typing import Any - -import gt4py.next as gtx -import numpy as np -import pytest - -from icon4py.model.atmosphere.dycore.stencils.apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure import ( - apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure, -) -from icon4py.model.common import dimension as dims -from icon4py.model.common.grid import base -from icon4py.model.common.states import utils as state_utils -from icon4py.model.common.type_alias import vpfloat -from icon4py.model.common.utils.data_allocation import random_field, random_mask -from icon4py.model.testing.stencil_tests import StencilTest - - -def apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure_numpy( - ipeidx_dsl: np.ndarray, - pg_exdist: np.ndarray, - z_hydro_corr: np.ndarray, - z_gradh_exner: np.ndarray, -) -> np.ndarray: - z_hydro_corr = np.repeat(np.expand_dims(z_hydro_corr, axis=-1), z_gradh_exner.shape[1], axis=1) - z_gradh_exner = np.where(ipeidx_dsl, z_gradh_exner + z_hydro_corr * pg_exdist, z_gradh_exner) - return z_gradh_exner - - -class TestApplyHydrostaticCorrectionToHorizontalGradientOfExnerPressure(StencilTest): - PROGRAM = apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure - OUTPUTS = ("z_gradh_exner",) - - @staticmethod - def reference( - connectivities: dict[gtx.Dimension, np.ndarray], - ipeidx_dsl: np.ndarray, - pg_exdist: np.ndarray, - z_hydro_corr: np.ndarray, - z_gradh_exner: np.ndarray, - **kwargs: Any, - ) -> dict: - z_gradh_exner = apply_hydrostatic_correction_to_horizontal_gradient_of_exner_pressure_numpy( - ipeidx_dsl, - pg_exdist, - z_hydro_corr, - z_gradh_exner, - ) - return dict(z_gradh_exner=z_gradh_exner) - - @pytest.fixture - def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: - ipeidx_dsl = random_mask(grid, dims.EdgeDim, dims.KDim) - pg_exdist = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) - z_hydro_corr = random_field(grid, dims.EdgeDim, dtype=vpfloat) - z_gradh_exner = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) - - return dict( - ipeidx_dsl=ipeidx_dsl, - pg_exdist=pg_exdist, - z_hydro_corr=z_hydro_corr, - z_gradh_exner=z_gradh_exner, - horizontal_start=0, - horizontal_end=gtx.int32(grid.num_edges), - vertical_start=0, - vertical_end=gtx.int32(grid.num_levels), - ) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_theta_rho_face_values_and_pressure_gradient_and_update_vn.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_theta_rho_face_values_and_pressure_gradient_and_update_vn.py index 73943f8a7b..ec566da678 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_theta_rho_face_values_and_pressure_gradient_and_update_vn.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_theta_rho_face_values_and_pressure_gradient_and_update_vn.py @@ -193,7 +193,6 @@ def reference( c_lin_e: np.ndarray, ikoffset: np.ndarray, zdiff_gradp: np.ndarray, - ipeidx_dsl: np.ndarray, pg_exdist: np.ndarray, inv_dual_edge_length: np.ndarray, dtime: ta.wpfloat, @@ -395,10 +394,8 @@ def at_neighbor(i: int) -> np.ndarray: horizontal_pressure_gradient.shape[1], axis=1, ) - horizontal_pressure_gradient = np.where( - ipeidx_dsl, - horizontal_pressure_gradient + hydrostatic_correction * pg_exdist, - horizontal_pressure_gradient, + horizontal_pressure_gradient = ( + horizontal_pressure_gradient + hydrostatic_correction * pg_exdist ) next_vn = np.where( @@ -477,8 +474,9 @@ def input_data(self, request: pytest.FixtureRequest, grid: base.Grid) -> dict: ) hydrostatic_correction_on_lowest_level = data_alloc.random_field(grid, dims.EdgeDim) zdiff_gradp = data_alloc.random_field(grid, dims.EdgeDim, dims.E2CDim, dims.KDim) - ipeidx_dsl = data_alloc.random_mask(grid, dims.EdgeDim, dims.KDim) - pg_exdist = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) + pg_exdist = data_alloc.random_field( + grid, dims.EdgeDim, dims.KDim + ) # TODO(havogt): should be allocated with a sparse pattern inv_dual_edge_length = data_alloc.random_field(grid, dims.EdgeDim) predictor_normal_wind_advective_tendency = data_alloc.random_field( grid, dims.EdgeDim, dims.KDim @@ -554,7 +552,6 @@ def input_data(self, request: pytest.FixtureRequest, grid: base.Grid) -> dict: c_lin_e=c_lin_e, ikoffset=ikoffset, zdiff_gradp=zdiff_gradp, - ipeidx_dsl=ipeidx_dsl, pg_exdist=pg_exdist, inv_dual_edge_length=inv_dual_edge_length, dtime=dtime, diff --git a/model/atmosphere/dycore/tests/dycore/utils.py b/model/atmosphere/dycore/tests/dycore/utils.py index fdcba0cc84..a7eb6568bd 100644 --- a/model/atmosphere/dycore/tests/dycore/utils.py +++ b/model/atmosphere/dycore/tests/dycore/utils.py @@ -67,7 +67,6 @@ def construct_metric_state( zdiff_gradp=metrics_savepoint.zdiff_gradp(), vertoffset_gradp=metrics_savepoint.vertoffset_gradp(), nflat_gradp=grid_savepoint.nflat_gradp(), - pg_edgeidx_dsl=metrics_savepoint.pg_edgeidx_dsl(), pg_exdist=metrics_savepoint.pg_exdist(), ddqz_z_full_e=metrics_savepoint.ddqz_z_full_e(), ddxt_z_full=metrics_savepoint.ddxt_z_full(), diff --git a/model/common/src/icon4py/model/common/metrics/metric_fields.py b/model/common/src/icon4py/model/common/metrics/metric_fields.py index 8d3df9f887..9dc96f0ad5 100644 --- a/model/common/src/icon4py/model/common/metrics/metric_fields.py +++ b/model/common/src/icon4py/model/common/metrics/metric_fields.py @@ -635,7 +635,7 @@ def _compute_pressure_gradient_downward_extrapolation_mask_distance( k_lev: fa.KField[gtx.int32], horizontal_start_distance: int32, horizontal_end_distance: int32, -) -> tuple[fa.EdgeKField[bool], fa.EdgeKField[wpfloat]]: +) -> fa.EdgeKField[wpfloat]: """ Compute an edge mask and extrapolation distance for grid points requiring downward extrapolation of the pressure gradient. @@ -653,7 +653,6 @@ def _compute_pressure_gradient_downward_extrapolation_mask_distance( horizontal_end_distance: end index in edge fields until where extrapolation distance is computed Returns: - pg_edge_mask: edge index mask for points requiring downward extrapolation pg_exdist_dsl: extrapolation distance """ @@ -667,9 +666,6 @@ def _compute_pressure_gradient_downward_extrapolation_mask_distance( downward_distance, 0.0, ) - flatness_condition = (k_lev >= (flat_idx_max + 1)) & (z_me < downward_distance) & e_owner_mask - pg_edgeidx, pg_vertidx = where(flatness_condition, (e_lev, k_lev), (0, 0)) - pg_edge_mask = (pg_edgeidx > 0) & (pg_vertidx > 0) pg_exdist_dsl = where( (k_lev >= (flat_idx_max + 1)) & (z_me < extrapolation_distance) & e_owner_mask, @@ -677,7 +673,7 @@ def _compute_pressure_gradient_downward_extrapolation_mask_distance( 0.0, ) - return pg_edge_mask, pg_exdist_dsl + return pg_exdist_dsl @gtx.program(grid_type=gtx.GridType.UNSTRUCTURED) @@ -689,7 +685,6 @@ def compute_pressure_gradient_downward_extrapolation_mask_distance( flat_idx_max: fa.EdgeField[gtx.int32], e_lev: fa.EdgeField[gtx.int32], k_lev: fa.KField[gtx.int32], - pg_edgeidx_dsl: fa.EdgeKField[bool], pg_exdist_dsl: fa.EdgeKField[wpfloat], horizontal_start_distance: int32, horizontal_end_distance: int32, @@ -708,7 +703,7 @@ def compute_pressure_gradient_downward_extrapolation_mask_distance( k_lev=k_lev, horizontal_start_distance=horizontal_start_distance, horizontal_end_distance=horizontal_end_distance, - out=(pg_edgeidx_dsl, pg_exdist_dsl), + out=pg_exdist_dsl, domain={ dims.EdgeDim: (horizontal_start, horizontal_end), dims.KDim: (vertical_start, vertical_end), diff --git a/model/common/src/icon4py/model/common/metrics/metrics_attributes.py b/model/common/src/icon4py/model/common/metrics/metrics_attributes.py index 6979e50270..1b811d6abd 100644 --- a/model/common/src/icon4py/model/common/metrics/metrics_attributes.py +++ b/model/common/src/icon4py/model/common/metrics/metrics_attributes.py @@ -49,7 +49,6 @@ WGTFAC_E: Final[str] = "wgtfac_e" FLAT_IDX_MAX: Final[str] = "flat_idx_max" NFLAT_GRADP: Final[str] = "nflat_gradp" -PG_EDGEIDX_DSL: Final[str] = "edge_mask_for_pressure_gradient_extrapolation" PG_EDGEDIST_DSL: Final[str] = "distance_for_pressure_gradient_extrapolation" MASK_PROG_HALO_C: Final[str] = "mask_prog_halo_c" HORIZONTAL_MASK_FOR_3D_DIVDAMP: Final[str] = "horizontal_mask_for_3d_divdamp" @@ -302,14 +301,6 @@ icon_var_name="flat_idx_max", dtype=ta.wpfloat, ), - PG_EDGEIDX_DSL: dict( - standard_name=PG_EDGEIDX_DSL, - long_name="edge mask for pressure gradient downward extrapolation", - units="", - dims=(dims.EdgeDim, dims.KDim), - icon_var_name="pg_edgeidx_dsl", - dtype=bool, - ), PG_EDGEDIST_DSL: dict( standard_name=PG_EDGEDIST_DSL, long_name="extrapolation distance for pressure gradient downward extrapolation", diff --git a/model/common/src/icon4py/model/common/metrics/metrics_factory.py b/model/common/src/icon4py/model/common/metrics/metrics_factory.py index 386ecbd3dc..87bd9cf27e 100644 --- a/model/common/src/icon4py/model/common/metrics/metrics_factory.py +++ b/model/common/src/icon4py/model/common/metrics/metrics_factory.py @@ -708,7 +708,7 @@ def _register_computed_fields(self) -> None: # noqa: PLR0915 [too-many-statemen vertical_domain(v_grid.Zone.BOTTOM), ), }, - fields={"pg_edgeidx_dsl": attrs.PG_EDGEIDX_DSL, "pg_exdist_dsl": attrs.PG_EDGEDIST_DSL}, + fields={"pg_exdist_dsl": attrs.PG_EDGEDIST_DSL}, do_exchange=False, ) self.register_provider(pressure_gradient_fields) diff --git a/model/common/tests/common/metrics/mpi_tests/test_parallel_metrics.py b/model/common/tests/common/metrics/mpi_tests/test_parallel_metrics.py index a3c37dfdc9..bd8b4b7799 100644 --- a/model/common/tests/common/metrics/mpi_tests/test_parallel_metrics.py +++ b/model/common/tests/common/metrics/mpi_tests/test_parallel_metrics.py @@ -102,7 +102,6 @@ def test_distributed_metrics_attrs( (attrs.EXNER_W_IMPLICIT_WEIGHT_PARAMETER, "vwind_impl_wgt"), (attrs.EXNER_W_EXPLICIT_WEIGHT_PARAMETER, "vwind_expl_wgt"), (attrs.PG_EDGEDIST_DSL, "pg_exdist"), - (attrs.PG_EDGEIDX_DSL, "pg_edgeidx_dsl"), (attrs.MASK_PROG_HALO_C, "mask_prog_halo_c"), (attrs.HORIZONTAL_MASK_FOR_3D_DIVDAMP, "hmask_dd3d"), (attrs.WGTFAC_C, "wgtfac_c"), diff --git a/model/common/tests/common/metrics/unit_tests/test_metric_fields.py b/model/common/tests/common/metrics/unit_tests/test_metric_fields.py index 70c4fe16af..22836428b0 100644 --- a/model/common/tests/common/metrics/unit_tests/test_metric_fields.py +++ b/model/common/tests/common/metrics/unit_tests/test_metric_fields.py @@ -407,7 +407,6 @@ def test_compute_pressure_gradient_downward_extrapolation_mask_distance( backend: gtx_typing.Backend, ) -> None: pg_exdist_ref = metrics_savepoint.pg_exdist() - pg_edgeidx_dsl_ref = metrics_savepoint.pg_edgeidx_dsl() nlev = icon_grid.num_levels z_mc = metrics_savepoint.z_mc() @@ -418,9 +417,6 @@ def test_compute_pressure_gradient_downward_extrapolation_mask_distance( k = data_alloc.index_field(icon_grid, dim=dims.KDim, extend={dims.KDim: 1}, allocator=backend) edges = data_alloc.index_field(icon_grid, dim=dims.EdgeDim, allocator=backend) - edge_mask = data_alloc.zero_field( - icon_grid, dims.EdgeDim, dims.KDim, dtype=bool, allocator=backend - ) ex_distance = data_alloc.zero_field(icon_grid, dims.EdgeDim, dims.KDim, allocator=backend) start_edge_nudging = icon_grid.end_index(edge_domain(horizontal.Zone.NUDGING)) @@ -446,7 +442,6 @@ def test_compute_pressure_gradient_downward_extrapolation_mask_distance( flat_idx_max=flat_idx, e_lev=edges, k_lev=k, - pg_edgeidx_dsl=edge_mask, pg_exdist_dsl=ex_distance, horizontal_start_distance=start_edge_nudging, horizontal_end_distance=icon_grid.num_edges, @@ -461,7 +456,6 @@ def test_compute_pressure_gradient_downward_extrapolation_mask_distance( ) assert testing_helpers.dallclose(pg_exdist_ref.asnumpy(), ex_distance.asnumpy(), rtol=1.0e-9) - assert testing_helpers.dallclose(pg_edgeidx_dsl_ref.asnumpy(), edge_mask.asnumpy()) @pytest.mark.datatest diff --git a/model/common/tests/common/metrics/unit_tests/test_metrics_factory.py b/model/common/tests/common/metrics/unit_tests/test_metrics_factory.py index d86d24008d..ac9cef190d 100644 --- a/model/common/tests/common/metrics/unit_tests/test_metrics_factory.py +++ b/model/common/tests/common/metrics/unit_tests/test_metrics_factory.py @@ -431,7 +431,6 @@ def test_factory_pressure_gradient_fields( backend: gtx_typing.Backend | None, ) -> None: field_1_ref = metrics_savepoint.pg_exdist() - field_2_ref = metrics_savepoint.pg_edgeidx_dsl() factory = _get_metrics_factory( backend=backend, experiment=experiment, @@ -440,8 +439,6 @@ def test_factory_pressure_gradient_fields( ) field_1 = factory.get(attrs.PG_EDGEDIST_DSL) assert test_helpers.dallclose(field_1_ref.asnumpy(), field_1.asnumpy(), atol=1.0e-5) - field_2 = factory.get(attrs.PG_EDGEIDX_DSL) - assert test_helpers.dallclose(field_2_ref.asnumpy(), field_2.asnumpy()) @pytest.mark.datatest diff --git a/model/driver/src/icon4py/model/driver/initialization_utils.py b/model/driver/src/icon4py/model/driver/initialization_utils.py index 4f749f6565..42a9148708 100644 --- a/model/driver/src/icon4py/model/driver/initialization_utils.py +++ b/model/driver/src/icon4py/model/driver/initialization_utils.py @@ -508,7 +508,6 @@ def read_static_fields( zdiff_gradp=metrics_savepoint.zdiff_gradp(), vertoffset_gradp=metrics_savepoint.vertoffset_gradp(), nflat_gradp=grid_savepoint.nflat_gradp(), - pg_edgeidx_dsl=metrics_savepoint.pg_edgeidx_dsl(), pg_exdist=metrics_savepoint.pg_exdist(), ddqz_z_full_e=metrics_savepoint.ddqz_z_full_e(), ddxt_z_full=metrics_savepoint.ddxt_z_full(), diff --git a/model/driver/tests/driver/integration_tests/test_icon4py.py b/model/driver/tests/driver/integration_tests/test_icon4py.py index 32dbcf8bf5..7ece8f886c 100644 --- a/model/driver/tests/driver/integration_tests/test_icon4py.py +++ b/model/driver/tests/driver/integration_tests/test_icon4py.py @@ -226,7 +226,6 @@ def test_run_timeloop_single_step( zdiff_gradp=metrics_savepoint.zdiff_gradp(), vertoffset_gradp=metrics_savepoint.vertoffset_gradp(), nflat_gradp=grid_savepoint.nflat_gradp(), - pg_edgeidx_dsl=metrics_savepoint.pg_edgeidx_dsl(), pg_exdist=metrics_savepoint.pg_exdist(), ddqz_z_full_e=metrics_savepoint.ddqz_z_full_e(), ddxt_z_full=metrics_savepoint.ddxt_z_full(), diff --git a/model/standalone_driver/src/icon4py/model/standalone_driver/driver_utils.py b/model/standalone_driver/src/icon4py/model/standalone_driver/driver_utils.py index a2b66ccce3..b0dc2e6050 100644 --- a/model/standalone_driver/src/icon4py/model/standalone_driver/driver_utils.py +++ b/model/standalone_driver/src/icon4py/model/standalone_driver/driver_utils.py @@ -293,7 +293,6 @@ def initialize_granules( zdiff_gradp=metrics_field_source.get(metrics_attributes.ZDIFF_GRADP), vertoffset_gradp=metrics_field_source.get(metrics_attributes.VERTOFFSET_GRADP), nflat_gradp=metrics_field_source.get(metrics_attributes.NFLAT_GRADP), - pg_edgeidx_dsl=metrics_field_source.get(metrics_attributes.PG_EDGEIDX_DSL), pg_exdist=metrics_field_source.get(metrics_attributes.PG_EDGEDIST_DSL), ddqz_z_full_e=metrics_field_source.get(metrics_attributes.DDQZ_Z_FULL_E), ddxt_z_full=metrics_field_source.get(metrics_attributes.DDXT_Z_FULL), diff --git a/model/testing/src/icon4py/model/testing/serialbox.py b/model/testing/src/icon4py/model/testing/serialbox.py index dfbd0d7cfa..10e9f6c36c 100644 --- a/model/testing/src/icon4py/model/testing/serialbox.py +++ b/model/testing/src/icon4py/model/testing/serialbox.py @@ -751,9 +751,6 @@ def mask_prog_halo_c(self): def pg_exdist(self): return self._get_field("pg_exdist_dsl", dims.EdgeDim, dims.KDim) - def pg_edgeidx_dsl(self): - return self._get_field("pg_edgeidx_dsl", dims.EdgeDim, dims.KDim, dtype=bool) - def rayleigh_w(self): return self._get_field("rayleigh_w", dims.KDim) diff --git a/tools/src/icon4py/tools/py2fgen/wrappers/dycore_wrapper.py b/tools/src/icon4py/tools/py2fgen/wrappers/dycore_wrapper.py index f09a5a17b0..8b8dec2492 100644 --- a/tools/src/icon4py/tools/py2fgen/wrappers/dycore_wrapper.py +++ b/tools/src/icon4py/tools/py2fgen/wrappers/dycore_wrapper.py @@ -85,7 +85,6 @@ def solve_nh_init( ddxn_z_full: gtx.Field[gtx.Dims[dims.EdgeDim, dims.KDim], gtx.float64], zdiff_gradp: gtx.Field[gtx.Dims[dims.EdgeDim, dims.E2CDim, dims.KDim], gtx.float64], vertoffset_gradp: gtx.Field[gtx.Dims[dims.EdgeDim, dims.E2CDim, dims.KDim], gtx.int32], - ipeidx_dsl: gtx.Field[gtx.Dims[dims.EdgeDim, dims.KDim], bool], pg_exdist: gtx.Field[gtx.Dims[dims.EdgeDim, dims.KDim], gtx.float64], ddqz_z_full_e: gtx.Field[gtx.Dims[dims.EdgeDim, dims.KDim], gtx.float64], ddxt_z_full: gtx.Field[gtx.Dims[dims.EdgeDim, dims.KDim], gtx.float64], @@ -204,7 +203,6 @@ def solve_nh_init( zdiff_gradp=zdiff_gradp, vertoffset_gradp=vertoffset_gradp, nflat_gradp=gtx.int32(nflat_gradp - 1), # Fortran vs Python indexing - pg_edgeidx_dsl=ipeidx_dsl, pg_exdist=pg_exdist, ddqz_z_full_e=ddqz_z_full_e, ddxt_z_full=ddxt_z_full, diff --git a/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.f90 b/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.f90 index bdabd5ae00..795dfa5035 100644 --- a/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.f90 +++ b/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.f90 @@ -461,9 +461,6 @@ function solve_nh_init_wrapper(c_lin_e, & vertoffset_gradp_size_0, & vertoffset_gradp_size_1, & vertoffset_gradp_size_2, & - ipeidx_dsl, & - ipeidx_dsl_size_0, & - ipeidx_dsl_size_1, & pg_exdist, & pg_exdist_size_0, & pg_exdist_size_1, & @@ -738,12 +735,6 @@ function solve_nh_init_wrapper(c_lin_e, & integer(c_int), value :: vertoffset_gradp_size_2 - type(c_ptr), value, target :: ipeidx_dsl - - integer(c_int), value :: ipeidx_dsl_size_0 - - integer(c_int), value :: ipeidx_dsl_size_1 - type(c_ptr), value, target :: pg_exdist integer(c_int), value :: pg_exdist_size_0 @@ -1501,7 +1492,6 @@ subroutine solve_nh_init(c_lin_e, & ddxn_z_full, & zdiff_gradp, & vertoffset_gradp, & - ipeidx_dsl, & pg_exdist, & ddqz_z_full_e, & ddxt_z_full, & @@ -1615,8 +1605,6 @@ subroutine solve_nh_init(c_lin_e, & integer(c_int), dimension(:, :, :), target :: vertoffset_gradp - logical(c_int), dimension(:, :), target :: ipeidx_dsl - real(c_double), dimension(:, :), target :: pg_exdist real(c_double), dimension(:, :), target :: ddqz_z_full_e @@ -1835,10 +1823,6 @@ subroutine solve_nh_init(c_lin_e, & integer(c_int) :: vertoffset_gradp_size_2 - integer(c_int) :: ipeidx_dsl_size_0 - - integer(c_int) :: ipeidx_dsl_size_1 - integer(c_int) :: pg_exdist_size_0 integer(c_int) :: pg_exdist_size_1 @@ -1918,7 +1902,6 @@ subroutine solve_nh_init(c_lin_e, & !$acc host_data use_device(ddxn_z_full) !$acc host_data use_device(zdiff_gradp) !$acc host_data use_device(vertoffset_gradp) - !$acc host_data use_device(ipeidx_dsl) !$acc host_data use_device(pg_exdist) !$acc host_data use_device(ddqz_z_full_e) !$acc host_data use_device(ddxt_z_full) @@ -2044,9 +2027,6 @@ subroutine solve_nh_init(c_lin_e, & vertoffset_gradp_size_1 = SIZE(vertoffset_gradp, 2) vertoffset_gradp_size_2 = SIZE(vertoffset_gradp, 3) - ipeidx_dsl_size_0 = SIZE(ipeidx_dsl, 1) - ipeidx_dsl_size_1 = SIZE(ipeidx_dsl, 2) - pg_exdist_size_0 = SIZE(pg_exdist, 1) pg_exdist_size_1 = SIZE(pg_exdist, 2) @@ -2185,9 +2165,6 @@ subroutine solve_nh_init(c_lin_e, & vertoffset_gradp_size_0=vertoffset_gradp_size_0, & vertoffset_gradp_size_1=vertoffset_gradp_size_1, & vertoffset_gradp_size_2=vertoffset_gradp_size_2, & - ipeidx_dsl=c_loc(ipeidx_dsl), & - ipeidx_dsl_size_0=ipeidx_dsl_size_0, & - ipeidx_dsl_size_1=ipeidx_dsl_size_1, & pg_exdist=c_loc(pg_exdist), & pg_exdist_size_0=pg_exdist_size_0, & pg_exdist_size_1=pg_exdist_size_1, & @@ -2295,7 +2272,6 @@ subroutine solve_nh_init(c_lin_e, & !$acc end host_data !$acc end host_data !$acc end host_data - !$acc end host_data end subroutine solve_nh_init end module \ No newline at end of file diff --git a/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.h b/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.h index 7f202a0a92..40ecd7ef05 100644 --- a/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.h +++ b/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.h @@ -75,8 +75,7 @@ extern int solve_nh_init_wrapper( double *ddxn_z_full, int ddxn_z_full_size_0, int ddxn_z_full_size_1, double *zdiff_gradp, int zdiff_gradp_size_0, int zdiff_gradp_size_1, int zdiff_gradp_size_2, int *vertoffset_gradp, int vertoffset_gradp_size_0, - int vertoffset_gradp_size_1, int vertoffset_gradp_size_2, int *ipeidx_dsl, - int ipeidx_dsl_size_0, int ipeidx_dsl_size_1, double *pg_exdist, + int vertoffset_gradp_size_1, int vertoffset_gradp_size_2, double *pg_exdist, int pg_exdist_size_0, int pg_exdist_size_1, double *ddqz_z_full_e, int ddqz_z_full_e_size_0, int ddqz_z_full_e_size_1, double *ddxt_z_full, int ddxt_z_full_size_0, int ddxt_z_full_size_1, double *wgtfac_e, diff --git a/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.py b/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.py index f6afd55aa4..a936b6dbc3 100644 --- a/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.py +++ b/tools/tests/tools/py2fgen/wrappers/references/dycore/dycore.py @@ -1276,9 +1276,6 @@ def solve_nh_init_wrapper( vertoffset_gradp_size_0, vertoffset_gradp_size_1, vertoffset_gradp_size_2, - ipeidx_dsl, - ipeidx_dsl_size_0, - ipeidx_dsl_size_1, pg_exdist, pg_exdist_size_0, pg_exdist_size_1, @@ -1680,16 +1677,6 @@ def solve_nh_init_wrapper( False, ) - ipeidx_dsl = ( - ipeidx_dsl, - ( - ipeidx_dsl_size_0, - ipeidx_dsl_size_1, - ), - on_gpu, - False, - ) - pg_exdist = ( pg_exdist, ( @@ -1831,7 +1818,6 @@ def solve_nh_init_wrapper( ddxn_z_full=ddxn_z_full, zdiff_gradp=zdiff_gradp, vertoffset_gradp=vertoffset_gradp, - ipeidx_dsl=ipeidx_dsl, pg_exdist=pg_exdist, ddqz_z_full_e=ddqz_z_full_e, ddxt_z_full=ddxt_z_full, @@ -2464,22 +2450,6 @@ def solve_nh_init_wrapper( ) logger.debug(msg) - ipeidx_dsl_arr = ( - _conversion.as_array(ffi, ipeidx_dsl, _definitions.BOOL) - if ipeidx_dsl is not None - else None - ) - msg = "shape of ipeidx_dsl after computation = %s" % str( - ipeidx_dsl_arr.shape if ipeidx_dsl is not None else "None" - ) - logger.debug(msg) - msg = ( - "ipeidx_dsl after computation: %s" % str(ipeidx_dsl_arr) - if ipeidx_dsl is not None - else "None" - ) - logger.debug(msg) - pg_exdist_arr = ( _conversion.as_array(ffi, pg_exdist, _definitions.FLOAT64) if pg_exdist is not None diff --git a/tools/tests/tools/py2fgen/wrappers/test_dycore_wrapper.py b/tools/tests/tools/py2fgen/wrappers/test_dycore_wrapper.py index abb00a1d6c..a1a8170e3e 100644 --- a/tools/tests/tools/py2fgen/wrappers/test_dycore_wrapper.py +++ b/tools/tests/tools/py2fgen/wrappers/test_dycore_wrapper.py @@ -101,7 +101,6 @@ def solve_nh_init( ) vertoffset_gradp = test_utils.array_to_array_info(vertoffset_gradp_field.ndarray) - pg_edgeidx_dsl = test_utils.array_to_array_info(metrics_savepoint.pg_edgeidx_dsl().ndarray) pg_exdist = test_utils.array_to_array_info(metrics_savepoint.pg_exdist().ndarray) ddqz_z_full_e = test_utils.array_to_array_info(metrics_savepoint.ddqz_z_full_e().ndarray) ddxt_z_full = test_utils.array_to_array_info(metrics_savepoint.ddxt_z_full().ndarray) @@ -190,7 +189,6 @@ def solve_nh_init( ddxn_z_full=ddxn_z_full, zdiff_gradp=zdiff_gradp, vertoffset_gradp=vertoffset_gradp, - ipeidx_dsl=pg_edgeidx_dsl, pg_exdist=pg_exdist, ddqz_z_full_e=ddqz_z_full_e, ddxt_z_full=ddxt_z_full, @@ -342,7 +340,6 @@ def test_dycore_wrapper_granule_inputs( ) vertoffset_gradp = test_utils.array_to_array_info(vertoffset_gradp_field.ndarray) - pg_edgeidx_dsl = test_utils.array_to_array_info(metrics_savepoint.pg_edgeidx_dsl().ndarray) pg_exdist = test_utils.array_to_array_info(metrics_savepoint.pg_exdist().ndarray) ddqz_z_full_e = test_utils.array_to_array_info(metrics_savepoint.ddqz_z_full_e().ndarray) ddxt_z_full = test_utils.array_to_array_info(metrics_savepoint.ddxt_z_full().ndarray) @@ -492,7 +489,6 @@ def test_dycore_wrapper_granule_inputs( zdiff_gradp=metrics_savepoint.zdiff_gradp(), nflat_gradp=grid_savepoint.nflat_gradp(), vertoffset_gradp=metrics_savepoint.vertoffset_gradp(), - pg_edgeidx_dsl=metrics_savepoint.pg_edgeidx_dsl(), pg_exdist=metrics_savepoint.pg_exdist(), ddqz_z_full_e=metrics_savepoint.ddqz_z_full_e(), ddxt_z_full=metrics_savepoint.ddxt_z_full(), @@ -613,7 +609,6 @@ def test_dycore_wrapper_granule_inputs( ddxn_z_full=ddxn_z_full, zdiff_gradp=zdiff_gradp, vertoffset_gradp=vertoffset_gradp, - ipeidx_dsl=pg_edgeidx_dsl, pg_exdist=pg_exdist, ddqz_z_full_e=ddqz_z_full_e, ddxt_z_full=ddxt_z_full,