From 96a4637b46a1e4392d18572ff5b0e3836c9e1815 Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Wed, 6 Dec 2023 07:04:04 +0100 Subject: [PATCH 01/10] move states classes of dycore into one file --- .../dycore/nh_solve/solve_nonhydro.py | 9 +- .../dycore/state_utils/interpolation_state.py | 63 ------------- .../dycore/state_utils/metric_state.py | 87 ----------------- .../{diagnostic_state.py => states.py} | 94 ++++++++++++++++++- .../dycore/velocity/velocity_advection.py | 8 +- .../tests/dycore_tests/test_solve_nonhydro.py | 2 +- .../dycore_tests/test_velocity_advection.py | 2 +- .../common/test_utils/serialbox_utils.py | 22 +---- .../src/icon4py/model/driver/io_utils.py | 9 +- 9 files changed, 115 insertions(+), 181 deletions(-) delete mode 100644 model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/interpolation_state.py delete mode 100644 model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/metric_state.py rename model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/{diagnostic_state.py => states.py} (52%) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py index 43e6d5ba76..ae23273aae 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py @@ -13,7 +13,6 @@ import logging from typing import Final, Optional -import numpy as np from gt4py.next import as_field from gt4py.next.common import Field from gt4py.next.ffront.fbuiltins import int32 @@ -138,9 +137,11 @@ from icon4py.model.atmosphere.dycore.mo_solve_nonhydro_stencil_68 import ( mo_solve_nonhydro_stencil_68, ) -from icon4py.model.atmosphere.dycore.state_utils.diagnostic_state import DiagnosticStateNonHydro -from icon4py.model.atmosphere.dycore.state_utils.interpolation_state import InterpolationState -from icon4py.model.atmosphere.dycore.state_utils.metric_state import MetricStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import ( + InterpolationState, + MetricStateNonHydro, + DiagnosticStateNonHydro, +) from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.utils import ( diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/interpolation_state.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/interpolation_state.py deleted file mode 100644 index 440c4a4b9c..0000000000 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/interpolation_state.py +++ /dev/null @@ -1,63 +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 dataclasses import dataclass - -from gt4py.next.common import Field - -from icon4py.model.common.dimension import ( - C2E2CODim, - CEDim, - CellDim, - E2C2EDim, - E2C2EODim, - E2CDim, - ECDim, - EdgeDim, - V2CDim, - V2EDim, - VertexDim, -) - - -@dataclass -class InterpolationState: - """Represents the ICON interpolation state used int SolveNonHydro.""" - - e_bln_c_s: Field[[CEDim], float] # coefficent for bilinear interpolation from edge to cell () - rbf_coeff_1: Field[ - [VertexDim, V2EDim], float - ] # rbf_vec_coeff_v_1(nproma, rbf_vec_dim_v, nblks_v) - rbf_coeff_2: Field[ - [VertexDim, V2EDim], float - ] # rbf_vec_coeff_v_2(nproma, rbf_vec_dim_v, nblks_v) - - geofac_div: Field[[CEDim], float] # factor for divergence (nproma,cell_type,nblks_c) - - geofac_n2s: Field[ - [CellDim, C2E2CODim], float - ] # factor for nabla2-scalar (nproma,cell_type+1,nblks_c) - geofac_grg_x: Field[[CellDim, C2E2CODim], float] - geofac_grg_y: Field[ - [CellDim, C2E2CODim], float - ] # factors for green gauss gradient (nproma,4,nblks_c,2) - nudgecoeff_e: Field[[EdgeDim], float] # Nudgeing coeffients for edges - - c_lin_e: Field[[EdgeDim, E2CDim], float] - geofac_grdiv: Field[[EdgeDim, E2C2EODim], float] - rbf_vec_coeff_e: Field[[EdgeDim, E2C2EDim], float] - c_intp: Field[[VertexDim, V2CDim], float] - geofac_rot: Field[[VertexDim, V2EDim], float] - pos_on_tplane_e_1: Field[[ECDim], float] - pos_on_tplane_e_2: Field[[ECDim], float] - e_flx_avg: Field[[EdgeDim, E2C2EODim], float] diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/metric_state.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/metric_state.py deleted file mode 100644 index 3d32d340b9..0000000000 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/metric_state.py +++ /dev/null @@ -1,87 +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 dataclasses import dataclass - -from gt4py.next.common import Field -from numpy import int32 - -from icon4py.model.common.dimension import CECDim, CellDim, ECDim, EdgeDim, KDim - - -@dataclass -class MetricState: - mask_hdiff: Field[[CellDim, KDim], bool] - theta_ref_mc: Field[[CellDim, KDim], float] - wgtfac_c: Field[ - [CellDim, KDim], float - ] # weighting factor for interpolation from full to half levels (nproma,nlevp1,nblks_c) - zd_vertidx: Field[[CECDim, KDim], int32] - zd_diffcoef: Field[[CellDim, KDim], float] - zd_intcoef: Field[[CECDim, KDim], float] - - coeff_gradekin: Field[[ECDim], float] - ddqz_z_full_e: Field[[EdgeDim, KDim], float] - wgtfac_e: Field[[EdgeDim, KDim], float] - wgtfacq_e_dsl: Field[[EdgeDim, KDim], float] - ddxn_z_full: Field[[EdgeDim, KDim], float] - ddxt_z_full: Field[[EdgeDim, KDim], float] - ddqz_z_half: Field[[CellDim, KDim], float] # half KDim ? - coeff1_dwdz: Field[[CellDim, KDim], float] - coeff2_dwdz: Field[[CellDim, KDim], float] - zd_vertoffset: Field[[CECDim, KDim], int32] - - -@dataclass -class MetricStateNonHydro: - bdy_halo_c: Field[[CellDim], bool] - # Finally, a mask field that excludes boundary halo points - mask_prog_halo_c: Field[[CellDim, KDim], bool] - rayleigh_w: Field[[KDim], float] - - wgtfac_c: Field[[CellDim, KDim], float] - wgtfacq_c_dsl: Field[[CellDim, KDim], float] - wgtfac_e: Field[[EdgeDim, KDim], float] - wgtfacq_e_dsl: Field[[EdgeDim, KDim], float] - - exner_exfac: Field[[CellDim, KDim], float] - exner_ref_mc: Field[[CellDim, KDim], float] - rho_ref_mc: Field[[CellDim, KDim], float] - theta_ref_mc: Field[[CellDim, KDim], float] - rho_ref_me: Field[[EdgeDim, KDim], float] - theta_ref_me: Field[[EdgeDim, KDim], float] - theta_ref_ic: Field[[CellDim, KDim], float] - - d_exner_dz_ref_ic: Field[[CellDim, KDim], float] - ddqz_z_half: Field[[CellDim, KDim], float] # half KDim ? - d2dexdz2_fac1_mc: Field[[CellDim, KDim], float] - d2dexdz2_fac2_mc: Field[[CellDim, KDim], float] - ddxn_z_full: Field[[EdgeDim, KDim], float] - ddqz_z_full_e: Field[[EdgeDim, KDim], float] - ddxt_z_full: Field[[EdgeDim, KDim], float] - inv_ddqz_z_full: Field[[CellDim, KDim], float] - - vertoffset_gradp: Field[[ECDim, KDim], float] - zdiff_gradp: Field[[ECDim, KDim], float] - ipeidx_dsl: Field[[EdgeDim, KDim], bool] - pg_exdist: Field[[EdgeDim, KDim], float] - - vwind_expl_wgt: Field[[CellDim], float] - vwind_impl_wgt: Field[[CellDim], float] - - hmask_dd3d: Field[[EdgeDim], float] - scalfac_dd3d: Field[[KDim], float] - - coeff1_dwdz: Field[[CellDim, KDim], float] - coeff2_dwdz: Field[[CellDim, KDim], float] - coeff_gradekin: Field[[ECDim], float] diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/diagnostic_state.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py similarity index 52% rename from model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/diagnostic_state.py rename to model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py index f12aa39b55..2d1fe5c90f 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/diagnostic_state.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py @@ -12,9 +12,23 @@ # SPDX-License-Identifier: GPL-3.0-or-later from dataclasses import dataclass +from gt4py.next import Field from gt4py.next.common import Field -from icon4py.model.common.dimension import CellDim, EdgeDim, KDim +from icon4py.model.common.dimension import ( + CellDim, + EdgeDim, + KDim, + CEDim, + VertexDim, + V2EDim, + C2E2CODim, + E2CDim, + E2C2EODim, + E2C2EDim, + V2CDim, + ECDim, +) @dataclass @@ -86,3 +100,81 @@ def ddt_w_adv_pc( self, ) -> tuple[Field[[CellDim, KDim], float], Field[[CellDim, KDim], float]]: return (self.ddt_w_adv_ntl1, self.ddt_w_adv_ntl2) + + +@dataclass +class InterpolationState: + """Represents the ICON interpolation state used int SolveNonHydro.""" + + e_bln_c_s: Field[[CEDim], float] # coefficent for bilinear interpolation from edge to cell () + rbf_coeff_1: Field[ + [VertexDim, V2EDim], float + ] # rbf_vec_coeff_v_1(nproma, rbf_vec_dim_v, nblks_v) + rbf_coeff_2: Field[ + [VertexDim, V2EDim], float + ] # rbf_vec_coeff_v_2(nproma, rbf_vec_dim_v, nblks_v) + + geofac_div: Field[[CEDim], float] # factor for divergence (nproma,cell_type,nblks_c) + + geofac_n2s: Field[ + [CellDim, C2E2CODim], float + ] # factor for nabla2-scalar (nproma,cell_type+1,nblks_c) + geofac_grg_x: Field[[CellDim, C2E2CODim], float] + geofac_grg_y: Field[ + [CellDim, C2E2CODim], float + ] # factors for green gauss gradient (nproma,4,nblks_c,2) + nudgecoeff_e: Field[[EdgeDim], float] # Nudgeing coeffients for edges + + c_lin_e: Field[[EdgeDim, E2CDim], float] + geofac_grdiv: Field[[EdgeDim, E2C2EODim], float] + rbf_vec_coeff_e: Field[[EdgeDim, E2C2EDim], float] + c_intp: Field[[VertexDim, V2CDim], float] + geofac_rot: Field[[VertexDim, V2EDim], float] + pos_on_tplane_e_1: Field[[ECDim], float] + pos_on_tplane_e_2: Field[[ECDim], float] + e_flx_avg: Field[[EdgeDim, E2C2EODim], float] + + +@dataclass +class MetricStateNonHydro: + bdy_halo_c: Field[[CellDim], bool] + # Finally, a mask field that excludes boundary halo points + mask_prog_halo_c: Field[[CellDim, KDim], bool] + rayleigh_w: Field[[KDim], float] + + wgtfac_c: Field[[CellDim, KDim], float] + wgtfacq_c_dsl: Field[[CellDim, KDim], float] + wgtfac_e: Field[[EdgeDim, KDim], float] + wgtfacq_e_dsl: Field[[EdgeDim, KDim], float] + + exner_exfac: Field[[CellDim, KDim], float] + exner_ref_mc: Field[[CellDim, KDim], float] + rho_ref_mc: Field[[CellDim, KDim], float] + theta_ref_mc: Field[[CellDim, KDim], float] + rho_ref_me: Field[[EdgeDim, KDim], float] + theta_ref_me: Field[[EdgeDim, KDim], float] + theta_ref_ic: Field[[CellDim, KDim], float] + + d_exner_dz_ref_ic: Field[[CellDim, KDim], float] + ddqz_z_half: Field[[CellDim, KDim], float] # half KDim ? + d2dexdz2_fac1_mc: Field[[CellDim, KDim], float] + d2dexdz2_fac2_mc: Field[[CellDim, KDim], float] + ddxn_z_full: Field[[EdgeDim, KDim], float] + ddqz_z_full_e: Field[[EdgeDim, KDim], float] + ddxt_z_full: Field[[EdgeDim, KDim], float] + inv_ddqz_z_full: Field[[CellDim, KDim], float] + + vertoffset_gradp: Field[[ECDim, KDim], float] + zdiff_gradp: Field[[ECDim, KDim], float] + ipeidx_dsl: Field[[EdgeDim, KDim], bool] + pg_exdist: Field[[EdgeDim, KDim], float] + + vwind_expl_wgt: Field[[CellDim], float] + vwind_impl_wgt: Field[[CellDim], float] + + hmask_dd3d: Field[[EdgeDim], float] + scalfac_dd3d: Field[[KDim], float] + + coeff1_dwdz: Field[[CellDim, KDim], float] + coeff2_dwdz: Field[[CellDim, KDim], float] + coeff_gradekin: Field[[ECDim], float] 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 e6340459d5..c5ffbc6aac 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 @@ -55,9 +55,11 @@ from icon4py.model.atmosphere.dycore.mo_velocity_advection_stencil_20 import ( mo_velocity_advection_stencil_20, ) -from icon4py.model.atmosphere.dycore.state_utils.diagnostic_state import DiagnosticStateNonHydro -from icon4py.model.atmosphere.dycore.state_utils.interpolation_state import InterpolationState -from icon4py.model.atmosphere.dycore.state_utils.metric_state import MetricStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import ( + InterpolationState, + MetricStateNonHydro, + DiagnosticStateNonHydro, +) from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate, _allocate_indices from icon4py.model.common.dimension import CellDim, EdgeDim, KDim, VertexDim from icon4py.model.common.grid.horizontal import EdgeParams, HorizontalMarkerIndex diff --git a/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py b/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py index 7d56058655..e118274c5f 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py +++ b/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py @@ -20,7 +20,7 @@ NonHydrostaticParams, SolveNonhydro, ) -from icon4py.model.atmosphere.dycore.state_utils.diagnostic_state import DiagnosticStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import DiagnosticStateNonHydro from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.utils import ( diff --git a/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py b/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py index f1b56b5c5d..38a2dd5bfb 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py +++ b/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py @@ -14,7 +14,7 @@ import pytest from gt4py.next.ffront.fbuiltins import int32 -from icon4py.model.atmosphere.dycore.state_utils.diagnostic_state import DiagnosticStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import DiagnosticStateNonHydro from icon4py.model.atmosphere.dycore.velocity.velocity_advection import VelocityAdvection from icon4py.model.common.grid.horizontal import CellParams, EdgeParams from icon4py.model.common.grid.vertical import VerticalModelParams diff --git a/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py b/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py index 113aed4589..97cd56c33b 100644 --- a/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py +++ b/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py @@ -24,9 +24,11 @@ DiffusionInterpolationState, DiffusionMetricState, ) -from icon4py.model.atmosphere.dycore.state_utils.diagnostic_state import DiagnosticState -from icon4py.model.atmosphere.dycore.state_utils.interpolation_state import InterpolationState -from icon4py.model.atmosphere.dycore.state_utils.metric_state import MetricStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import ( + InterpolationState, + MetricStateNonHydro, + DiagnosticStateNonHydro, +) from icon4py.model.common import dimension from icon4py.model.common.decomposition.definitions import DecompositionInfo from icon4py.model.common.dimension import ( @@ -753,20 +755,6 @@ def construct_diagnostics_for_diffusion(self) -> DiffusionDiagnosticState: dwdy=self.dwdy(), ) - def construct_diagnostics(self) -> DiagnosticState: - return DiagnosticState( - hdef_ic=self.hdef_ic(), - div_ic=self.div_ic(), - dwdx=self.dwdx(), - dwdy=self.dwdy(), - vt=None, - vn_ie=None, - w_concorr_c=None, - ddt_w_adv_pc_before=None, - ddt_vn_apc_pc_before=None, - ntnd=None, - ) - class IconNonHydroInitSavepoint(IconSavepoint): def bdy_divdamp(self): diff --git a/model/driver/src/icon4py/model/driver/io_utils.py b/model/driver/src/icon4py/model/driver/io_utils.py index 04cc8f0a2c..42e4f7a6bc 100644 --- a/model/driver/src/icon4py/model/driver/io_utils.py +++ b/model/driver/src/icon4py/model/driver/io_utils.py @@ -23,9 +23,11 @@ DiffusionInterpolationState, DiffusionMetricState, ) -from icon4py.model.atmosphere.dycore.state_utils.diagnostic_state import DiagnosticStateNonHydro -from icon4py.model.atmosphere.dycore.state_utils.interpolation_state import InterpolationState -from icon4py.model.atmosphere.dycore.state_utils.metric_state import MetricStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import ( + InterpolationState, + MetricStateNonHydro, + DiagnosticStateNonHydro, +) from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate @@ -75,7 +77,6 @@ def read_icon_grid( # TODO (Chia Rui): initialization of prognostic variables and topography of Jablonowski Williamson test def model_initialization(): - # create two prognostic states, nnow and nnew? # at least two prognostic states are global because they are needed in the dycore, AND possibly nesting and restart processes in the future # one is enough for the JW test From 4cec203ca2269796dc9476a51c122b971cb48b27 Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Wed, 6 Dec 2023 08:12:39 +0100 Subject: [PATCH 02/10] remove def construct_interpolation_state_for_nonhydro(...), and def construct_nh_metric_state(...) from serialbox savepoint classes --- .../dycore/nh_solve/solve_nonhydro.py | 4 + .../tests/dycore_tests/test_solve_nonhydro.py | 21 ++--- .../dycore_tests/test_velocity_advection.py | 19 ++--- .../dycore/tests/dycore_tests/utils.py | 69 ++++++++++++++++ .../common/test_utils/serialbox_utils.py | 63 --------------- .../src/icon4py/model/driver/dycore_driver.py | 5 +- .../icon4py/model/driver/serialbox_helpers.py | 78 +++++++++++++++++++ model/driver/tests/test_timeloop.py | 15 ++-- 8 files changed, 183 insertions(+), 91 deletions(-) create mode 100644 model/atmosphere/dycore/tests/dycore_tests/utils.py create mode 100644 model/driver/src/icon4py/model/driver/serialbox_helpers.py diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py index ae23273aae..fa16e6da75 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py @@ -493,6 +493,10 @@ def time_step( exner=prognostic_state_ls[nnew].exner, rd_o_cvd=self.params.rd_o_cvd, rd_o_p0ref=self.params.rd_o_p0ref, + vertical_start=0, + vertical_lower=self.grid.num_levels, + horizontal_lower=0, + horizontal_upper=end_cell_end, offset_provider={}, ) diff --git a/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py b/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py index e118274c5f..171a1fd826 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py +++ b/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py @@ -36,7 +36,10 @@ from icon4py.model.common.math.smagorinsky import en_smag_fac_for_zero_nshift from icon4py.model.common.states.prognostic_state import PrognosticState from icon4py.model.common.test_utils.helpers import dallclose - +from .utils import ( + construct_interpolation_state_for_nonhydro, + construct_nh_metric_state, +) backend = run_gtfn @@ -143,8 +146,8 @@ def test_nonhydro_predictor_step( z_fields = allocate_z_fields(icon_grid) - interpolation_state = interpolation_savepoint.construct_interpolation_state_for_nonhydro() - metric_state_nonhydro = metrics_savepoint.construct_nh_metric_state(icon_grid.num_levels) + interpolation_state = construct_interpolation_state_for_nonhydro(interpolation_savepoint) + metric_state_nonhydro = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() @@ -574,8 +577,8 @@ def test_nonhydro_corrector_step( nh_constants = create_nh_constants(sp) divdamp_fac_o2 = sp.divdamp_fac_o2() - interpolation_state = interpolation_savepoint.construct_interpolation_state_for_nonhydro() - metric_state_nonhydro = metrics_savepoint.construct_nh_metric_state(icon_grid.num_levels) + interpolation_state = construct_interpolation_state_for_nonhydro(interpolation_savepoint) + metric_state_nonhydro = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() @@ -723,8 +726,8 @@ def test_run_solve_nonhydro_single_step( nh_constants = create_nh_constants(sp) - interpolation_state = interpolation_savepoint.construct_interpolation_state_for_nonhydro() - metric_state_nonhydro = metrics_savepoint.construct_nh_metric_state(icon_grid.num_levels) + interpolation_state = construct_interpolation_state_for_nonhydro(interpolation_savepoint) + metric_state_nonhydro = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() @@ -844,8 +847,8 @@ def test_run_solve_nonhydro_multi_step( nh_constants = create_nh_constants(sp) - interpolation_state = interpolation_savepoint.construct_interpolation_state_for_nonhydro() - metric_state_nonhydro = metrics_savepoint.construct_nh_metric_state(icon_grid.num_levels) + interpolation_state = construct_interpolation_state_for_nonhydro(interpolation_savepoint) + metric_state_nonhydro = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() diff --git a/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py b/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py index 38a2dd5bfb..6c5c13703a 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py +++ b/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py @@ -20,6 +20,7 @@ from icon4py.model.common.grid.vertical import VerticalModelParams from icon4py.model.common.states.prognostic_state import PrognosticState from icon4py.model.common.test_utils.helpers import dallclose +from .utils import construct_interpolation_state_for_nonhydro, construct_nh_metric_state @pytest.mark.datatest @@ -48,8 +49,8 @@ def test_velocity_init( step_date_init, damping_height, ): - interpolation_state = interpolation_savepoint.construct_interpolation_state_for_nonhydro() - metric_state_nonhydro = metrics_savepoint.construct_nh_metric_state(icon_grid.num_levels) + interpolation_state = construct_interpolation_state_for_nonhydro(interpolation_savepoint) + metric_state_nonhydro = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) vertical_params = VerticalModelParams( vct_a=grid_savepoint.vct_a(), @@ -87,8 +88,8 @@ def test_verify_velocity_init_against_regular_savepoint( savepoint = savepoint_velocity_init dtime = savepoint.get_metadata("dtime").get("dtime") - interpolation_state = interpolation_savepoint.construct_interpolation_state_for_nonhydro() - metric_state_nonhydro = metrics_savepoint.construct_nh_metric_state(icon_grid.num_levels) + interpolation_state = construct_interpolation_state_for_nonhydro(interpolation_savepoint) + metric_state_nonhydro = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) vertical_params = VerticalModelParams( vct_a=grid_savepoint.vct_a(), rayleigh_damping_height=damping_height, @@ -163,9 +164,9 @@ def test_velocity_predictor_step( rho=None, exner=None, ) - interpolation_state = interpolation_savepoint.construct_interpolation_state_for_nonhydro() + interpolation_state = construct_interpolation_state_for_nonhydro(interpolation_savepoint) - metric_state_nonhydro = metrics_savepoint.construct_nh_metric_state(icon_grid.num_levels) + metric_state_nonhydro = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() @@ -213,7 +214,7 @@ def test_velocity_predictor_step( # stencil 07 if not vn_only: assert dallclose( - icon_result_z_v_grad_w.asnumpy()[3777:31558, :], + icon_result_z_v_grad_w[3777:31558, :], velocity_advection.z_v_grad_w.asnumpy()[3777:31558, :], atol=1.0e-16, ) @@ -313,9 +314,9 @@ def test_velocity_corrector_step( exner=None, ) - interpolation_state = interpolation_savepoint.construct_interpolation_state_for_nonhydro() + interpolation_state = construct_interpolation_state_for_nonhydro(interpolation_savepoint) - metric_state_nonhydro = metrics_savepoint.construct_nh_metric_state(icon_grid.num_levels) + metric_state_nonhydro = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() diff --git a/model/atmosphere/dycore/tests/dycore_tests/utils.py b/model/atmosphere/dycore/tests/dycore_tests/utils.py new file mode 100644 index 0000000000..ac40774eaa --- /dev/null +++ b/model/atmosphere/dycore/tests/dycore_tests/utils.py @@ -0,0 +1,69 @@ +from icon4py.model.atmosphere.dycore.state_utils.states import ( + InterpolationState, + MetricStateNonHydro, +) +from icon4py.model.common.dimension import CEDim +from icon4py.model.common.test_utils.helpers import as_1D_sparse_field +from icon4py.model.common.test_utils.serialbox_utils import InterpolationSavepoint, MetricSavepoint + + +def construct_interpolation_state_for_nonhydro( + savepoint: InterpolationSavepoint, +) -> InterpolationState: + grg = savepoint.geofac_grg() + return InterpolationState( + c_lin_e=savepoint.c_lin_e(), + c_intp=savepoint.c_intp(), + e_flx_avg=savepoint.e_flx_avg(), + geofac_grdiv=savepoint.geofac_grdiv(), + geofac_rot=savepoint.geofac_rot(), + pos_on_tplane_e_1=savepoint.pos_on_tplane_e_x(), + pos_on_tplane_e_2=savepoint.pos_on_tplane_e_y(), + rbf_vec_coeff_e=savepoint.rbf_vec_coeff_e(), + e_bln_c_s=as_1D_sparse_field(savepoint.e_bln_c_s(), CEDim), + rbf_coeff_1=savepoint.rbf_vec_coeff_v1(), + rbf_coeff_2=savepoint.rbf_vec_coeff_v2(), + geofac_div=as_1D_sparse_field(savepoint.geofac_div(), CEDim), + geofac_n2s=savepoint.geofac_n2s(), + geofac_grg_x=grg[0], + geofac_grg_y=grg[1], + nudgecoeff_e=savepoint.nudgecoeff_e(), + ) + + +def construct_nh_metric_state(savepoint: MetricSavepoint, num_k_lev) -> MetricStateNonHydro: + return MetricStateNonHydro( + bdy_halo_c=savepoint.bdy_halo_c(), + mask_prog_halo_c=savepoint.mask_prog_halo_c(), + rayleigh_w=savepoint.rayleigh_w(), + exner_exfac=savepoint.exner_exfac(), + exner_ref_mc=savepoint.exner_ref_mc(), + wgtfac_c=savepoint.wgtfac_c(), + wgtfacq_c_dsl=savepoint.wgtfacq_c_dsl(), + inv_ddqz_z_full=savepoint.inv_ddqz_z_full(), + rho_ref_mc=savepoint.rho_ref_mc(), + theta_ref_mc=savepoint.theta_ref_mc(), + vwind_expl_wgt=savepoint.vwind_expl_wgt(), + d_exner_dz_ref_ic=savepoint.d_exner_dz_ref_ic(), + ddqz_z_half=savepoint.ddqz_z_half(), + theta_ref_ic=savepoint.theta_ref_ic(), + d2dexdz2_fac1_mc=savepoint.d2dexdz2_fac1_mc(), + d2dexdz2_fac2_mc=savepoint.d2dexdz2_fac2_mc(), + rho_ref_me=savepoint.rho_ref_me(), + theta_ref_me=savepoint.theta_ref_me(), + ddxn_z_full=savepoint.ddxn_z_full(), + zdiff_gradp=savepoint.zdiff_gradp(), + vertoffset_gradp=savepoint.vertoffset_gradp(), + ipeidx_dsl=savepoint.ipeidx_dsl(), + pg_exdist=savepoint.pg_exdist(), + ddqz_z_full_e=savepoint.ddqz_z_full_e(), + ddxt_z_full=savepoint.ddxt_z_full(), + wgtfac_e=savepoint.wgtfac_e(), + wgtfacq_e_dsl=savepoint.wgtfacq_e_dsl(num_k_lev), + vwind_impl_wgt=savepoint.vwind_impl_wgt(), + hmask_dd3d=savepoint.hmask_dd3d(), + scalfac_dd3d=savepoint.scalfac_dd3d(), + coeff1_dwdz=savepoint.coeff1_dwdz(), + coeff2_dwdz=savepoint.coeff2_dwdz(), + coeff_gradekin=savepoint.coeff_gradekin(), + ) diff --git a/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py b/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py index 97cd56c33b..0bc3f61479 100644 --- a/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py +++ b/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py @@ -24,11 +24,6 @@ DiffusionInterpolationState, DiffusionMetricState, ) -from icon4py.model.atmosphere.dycore.state_utils.states import ( - InterpolationState, - MetricStateNonHydro, - DiagnosticStateNonHydro, -) from icon4py.model.common import dimension from icon4py.model.common.decomposition.definitions import DecompositionInfo from icon4py.model.common.dimension import ( @@ -468,27 +463,6 @@ def construct_interpolation_state_for_diffusion( nudgecoeff_e=self.nudgecoeff_e(), ) - def construct_interpolation_state_for_nonhydro(self) -> InterpolationState: - grg = self.geofac_grg() - return InterpolationState( - c_lin_e=self.c_lin_e(), - c_intp=self.c_intp(), - e_flx_avg=self.e_flx_avg(), - geofac_grdiv=self.geofac_grdiv(), - geofac_rot=self.geofac_rot(), - pos_on_tplane_e_1=self.pos_on_tplane_e_x(), - pos_on_tplane_e_2=self.pos_on_tplane_e_y(), - rbf_vec_coeff_e=self.rbf_vec_coeff_e(), - e_bln_c_s=as_1D_sparse_field(self.e_bln_c_s(), CEDim), - rbf_coeff_1=self.rbf_vec_coeff_v1(), - rbf_coeff_2=self.rbf_vec_coeff_v2(), - geofac_div=as_1D_sparse_field(self.geofac_div(), CEDim), - geofac_n2s=self.geofac_n2s(), - geofac_grg_x=grg[0], - geofac_grg_y=grg[1], - nudgecoeff_e=self.nudgecoeff_e(), - ) - class MetricSavepoint(IconSavepoint): def bdy_halo_c(self): @@ -635,43 +609,6 @@ def zd_vertidx(self): def zd_indlist(self): return np.squeeze(self.serializer.read("zd_indlist", self.savepoint)) - def construct_nh_metric_state(self, num_k_lev) -> MetricStateNonHydro: - return MetricStateNonHydro( - bdy_halo_c=self.bdy_halo_c(), - mask_prog_halo_c=self.mask_prog_halo_c(), - rayleigh_w=self.rayleigh_w(), - exner_exfac=self.exner_exfac(), - exner_ref_mc=self.exner_ref_mc(), - wgtfac_c=self.wgtfac_c(), - wgtfacq_c_dsl=self.wgtfacq_c_dsl(), - inv_ddqz_z_full=self.inv_ddqz_z_full(), - rho_ref_mc=self.rho_ref_mc(), - theta_ref_mc=self.theta_ref_mc(), - vwind_expl_wgt=self.vwind_expl_wgt(), - d_exner_dz_ref_ic=self.d_exner_dz_ref_ic(), - ddqz_z_half=self.ddqz_z_half(), - theta_ref_ic=self.theta_ref_ic(), - d2dexdz2_fac1_mc=self.d2dexdz2_fac1_mc(), - d2dexdz2_fac2_mc=self.d2dexdz2_fac2_mc(), - rho_ref_me=self.rho_ref_me(), - theta_ref_me=self.theta_ref_me(), - ddxn_z_full=self.ddxn_z_full(), - zdiff_gradp=self.zdiff_gradp(), - vertoffset_gradp=self.vertoffset_gradp(), - ipeidx_dsl=self.ipeidx_dsl(), - pg_exdist=self.pg_exdist(), - ddqz_z_full_e=self.ddqz_z_full_e(), - ddxt_z_full=self.ddxt_z_full(), - wgtfac_e=self.wgtfac_e(), - wgtfacq_e_dsl=self.wgtfacq_e_dsl(num_k_lev), - vwind_impl_wgt=self.vwind_impl_wgt(), - hmask_dd3d=self.hmask_dd3d(), - scalfac_dd3d=self.scalfac_dd3d(), - coeff1_dwdz=self.coeff1_dwdz(), - coeff2_dwdz=self.coeff2_dwdz(), - coeff_gradekin=self.coeff_gradekin(), - ) - def construct_metric_state_for_diffusion(self) -> DiffusionMetricState: return DiffusionMetricState( mask_hdiff=self.mask_hdiff(), diff --git a/model/driver/src/icon4py/model/driver/dycore_driver.py b/model/driver/src/icon4py/model/driver/dycore_driver.py index 9d30a2dc31..c895dd849a 100644 --- a/model/driver/src/icon4py/model/driver/dycore_driver.py +++ b/model/driver/src/icon4py/model/driver/dycore_driver.py @@ -24,7 +24,7 @@ NonHydrostaticParams, SolveNonhydro, ) -from icon4py.model.atmosphere.dycore.state_utils.diagnostic_state import DiagnosticStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import DiagnosticStateNonHydro from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields @@ -151,7 +151,6 @@ def time_integration( inital_divdamp_fac_o2: float, do_prep_adv: bool, ): - log.info( f"starting time loop for dtime={self.run_config.dtime} n_timesteps={self._n_time_steps}" ) @@ -217,7 +216,6 @@ def _integrate_one_time_step( inital_divdamp_fac_o2: float, do_prep_adv: bool, ): - self._do_dyn_substepping( solve_nonhydro_diagnostic_state, prognostic_state_list, @@ -247,7 +245,6 @@ def _do_dyn_substepping( inital_divdamp_fac_o2: float, do_prep_adv: bool, ): - # TODO (Chia Rui): compute airmass for prognostic_state here do_recompute = True diff --git a/model/driver/src/icon4py/model/driver/serialbox_helpers.py b/model/driver/src/icon4py/model/driver/serialbox_helpers.py new file mode 100644 index 0000000000..fc8aa06b93 --- /dev/null +++ b/model/driver/src/icon4py/model/driver/serialbox_helpers.py @@ -0,0 +1,78 @@ +""" +Construct state objects from serialized data by reading from IconSavepoint s. +This is a preliminary module which should be deleted once we become independent +from the serialized ICON data. +Code is essentially duplicated from the model/atmosphere/xx packages test functionality in order +to get the dependencies right. +""" + + +from icon4py.model.atmosphere.dycore.state_utils.states import ( + InterpolationState, + MetricStateNonHydro, +) +from icon4py.model.common.dimension import CEDim +from icon4py.model.common.test_utils.helpers import as_1D_sparse_field +from icon4py.model.common.test_utils.serialbox_utils import InterpolationSavepoint, MetricSavepoint + + +def construct_interpolation_state_for_nonhydro( + savepoint: InterpolationSavepoint, +) -> InterpolationState: + grg = savepoint.geofac_grg() + return InterpolationState( + c_lin_e=savepoint.c_lin_e(), + c_intp=savepoint.c_intp(), + e_flx_avg=savepoint.e_flx_avg(), + geofac_grdiv=savepoint.geofac_grdiv(), + geofac_rot=savepoint.geofac_rot(), + pos_on_tplane_e_1=savepoint.pos_on_tplane_e_x(), + pos_on_tplane_e_2=savepoint.pos_on_tplane_e_y(), + rbf_vec_coeff_e=savepoint.rbf_vec_coeff_e(), + e_bln_c_s=as_1D_sparse_field(savepoint.e_bln_c_s(), CEDim), + rbf_coeff_1=savepoint.rbf_vec_coeff_v1(), + rbf_coeff_2=savepoint.rbf_vec_coeff_v2(), + geofac_div=as_1D_sparse_field(savepoint.geofac_div(), CEDim), + geofac_n2s=savepoint.geofac_n2s(), + geofac_grg_x=grg[0], + geofac_grg_y=grg[1], + nudgecoeff_e=savepoint.nudgecoeff_e(), + ) + + +def construct_nh_metric_state(savepoint: MetricSavepoint, num_k_lev) -> MetricStateNonHydro: + return MetricStateNonHydro( + bdy_halo_c=savepoint.bdy_halo_c(), + mask_prog_halo_c=savepoint.mask_prog_halo_c(), + rayleigh_w=savepoint.rayleigh_w(), + exner_exfac=savepoint.exner_exfac(), + exner_ref_mc=savepoint.exner_ref_mc(), + wgtfac_c=savepoint.wgtfac_c(), + wgtfacq_c_dsl=savepoint.wgtfacq_c_dsl(), + inv_ddqz_z_full=savepoint.inv_ddqz_z_full(), + rho_ref_mc=savepoint.rho_ref_mc(), + theta_ref_mc=savepoint.theta_ref_mc(), + vwind_expl_wgt=savepoint.vwind_expl_wgt(), + d_exner_dz_ref_ic=savepoint.d_exner_dz_ref_ic(), + ddqz_z_half=savepoint.ddqz_z_half(), + theta_ref_ic=savepoint.theta_ref_ic(), + d2dexdz2_fac1_mc=savepoint.d2dexdz2_fac1_mc(), + d2dexdz2_fac2_mc=savepoint.d2dexdz2_fac2_mc(), + rho_ref_me=savepoint.rho_ref_me(), + theta_ref_me=savepoint.theta_ref_me(), + ddxn_z_full=savepoint.ddxn_z_full(), + zdiff_gradp=savepoint.zdiff_gradp(), + vertoffset_gradp=savepoint.vertoffset_gradp(), + ipeidx_dsl=savepoint.ipeidx_dsl(), + pg_exdist=savepoint.pg_exdist(), + ddqz_z_full_e=savepoint.ddqz_z_full_e(), + ddxt_z_full=savepoint.ddxt_z_full(), + wgtfac_e=savepoint.wgtfac_e(), + wgtfacq_e_dsl=savepoint.wgtfacq_e_dsl(num_k_lev), + vwind_impl_wgt=savepoint.vwind_impl_wgt(), + hmask_dd3d=savepoint.hmask_dd3d(), + scalfac_dd3d=savepoint.scalfac_dd3d(), + coeff1_dwdz=savepoint.coeff1_dwdz(), + coeff2_dwdz=savepoint.coeff2_dwdz(), + coeff_gradekin=savepoint.coeff_gradekin(), + ) diff --git a/model/driver/tests/test_timeloop.py b/model/driver/tests/test_timeloop.py index 5a94728dd3..533a949fcf 100644 --- a/model/driver/tests/test_timeloop.py +++ b/model/driver/tests/test_timeloop.py @@ -22,7 +22,7 @@ NonHydrostaticParams, SolveNonhydro, ) -from icon4py.model.atmosphere.dycore.state_utils.diagnostic_state import DiagnosticStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import DiagnosticStateNonHydro from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate @@ -33,6 +33,10 @@ from icon4py.model.common.states.prognostic_state import PrognosticState from icon4py.model.common.test_utils.helpers import dallclose from icon4py.model.driver.dycore_driver import TimeLoop +from icon4py.model.driver.serialbox_helpers import ( + construct_interpolation_state_for_nonhydro, + construct_nh_metric_state, +) # testing on MCH_CH_r04b09_dsl data @@ -92,7 +96,7 @@ def test_run_timeloop_single_step( edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() diffusion_interpolation_state = ( - interpolation_savepoint.construct_interpolation_state_for_diffusion() + interpolation_savepoint.construct_interpolation_state_for_diffusion(interpolation_savepoint) ) diffusion_metric_state = metrics_savepoint.construct_metric_state_for_diffusion() diffusion_diagnostic_state = ( @@ -157,10 +161,10 @@ def test_run_timeloop_single_step( wgt_nnew_vel=sp.wgt_nnew_vel(), ) - nonhydro_interpolation_state = ( - interpolation_savepoint.construct_interpolation_state_for_nonhydro() + nonhydro_interpolation_state = construct_interpolation_state_for_nonhydro( + interpolation_savepoint ) - nonhydro_metric_state = metrics_savepoint.construct_nh_metric_state(icon_grid.num_levels) + nonhydro_metric_state = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() @@ -270,7 +274,6 @@ def test_run_timeloop_single_step( ) if debug_mode: - script_dir = os.path.dirname(os.path.abspath(__file__)) base_dir = script_dir + "/" From 35d0ef14fef0019f3d7f371e94ebbdcb476aed8c Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Wed, 6 Dec 2023 08:38:18 +0100 Subject: [PATCH 03/10] remove unused class --- .../atmosphere/dycore/state_utils/states.py | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py index 2d1fe5c90f..16ef19eb27 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py @@ -12,7 +12,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later from dataclasses import dataclass -from gt4py.next import Field from gt4py.next.common import Field from icon4py.model.common.dimension import ( @@ -31,35 +30,6 @@ ) -@dataclass -class DiagnosticState: - # fields for 3D elements in turbdiff - hdef_ic: Field[ - [CellDim, KDim], float - ] # ! divergence at half levels(nproma,nlevp1,nblks_c) [1/s] - div_ic: Field[ - [CellDim, KDim], float - ] # ! horizontal wind field deformation (nproma,nlevp1,nblks_c) [1/s^2] - dwdx: Field[ - [CellDim, KDim], float - ] # zonal gradient of vertical wind speed (nproma,nlevp1,nblks_c) [1/s] - - dwdy: Field[ - [CellDim, KDim], float - ] # meridional gradient of vertical wind speed (nproma,nlevp1,nblks_c) - - vt: Field[[EdgeDim, KDim], float] - vn_ie: Field[ - [EdgeDim, KDim], float - ] # normal wind at half levels (nproma,nlevp1,nblks_e) [m/s] # TODO: change this back to KHalfDim, but how do we treat it wrt to field_operators and domain? - w_concorr_c: Field[ - [CellDim, KDim], float - ] # contravariant vert correction (nproma,nlevp1,nblks_c)[m/s] # TODO: change this back to KHalfDim, but how do we treat it wrt to field_operators and domain? - ddt_w_adv_pc: Field[[CellDim, KDim], float] - ddt_vn_apc_pc: Field[[EdgeDim, KDim], float] - ntnd: float - - @dataclass class DiagnosticStateNonHydro: vt: Field[[EdgeDim, KDim], float] From 00dc3ae3ccddb35df6cdc01337445f7e9d212409 Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Wed, 6 Dec 2023 08:47:00 +0100 Subject: [PATCH 04/10] remove unused function from serialbox_utils.py --- .../model/atmosphere/dycore/nh_solve/solve_nonhydro.py | 6 +++--- .../icon4py/model/atmosphere/dycore/state_utils/states.py | 2 +- model/atmosphere/dycore/tests/dycore_tests/utils.py | 2 +- .../src/icon4py/model/common/test_utils/serialbox_utils.py | 3 --- model/driver/src/icon4py/model/driver/serialbox_helpers.py | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py index fa16e6da75..7e3b31979a 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py @@ -664,7 +664,7 @@ def run_predictor_step( if self.config.igradp_method == 3: nhsolve_prog.predictor_stencils_4_5_6.with_backend(backend)( - wgtfacq_c_dsl=self.metric_state_nonhydro.wgtfacq_c_dsl, + wgtfacq_c_dsl=self.metric_state_nonhydro.wgtfacq_c, z_exner_ex_pr=self.z_exner_ex_pr, z_exner_ic=self.z_exner_ic, wgtfac_c=self.metric_state_nonhydro.wgtfac_c, @@ -709,7 +709,7 @@ def run_predictor_step( # Perturbation theta at top and surface levels nhsolve_prog.predictor_stencils_11_lower_upper.with_backend(backend)( - wgtfacq_c_dsl=self.metric_state_nonhydro.wgtfacq_c_dsl, + wgtfacq_c_dsl=self.metric_state_nonhydro.wgtfacq_c, z_rth_pr=self.z_rth_pr_2, theta_ref_ic=self.metric_state_nonhydro.theta_ref_ic, z_theta_v_pr_ic=self.z_theta_v_pr_ic, @@ -1088,7 +1088,7 @@ def run_predictor_step( e_bln_c_s=self.interpolation_state.e_bln_c_s, z_w_concorr_me=self.z_w_concorr_me, wgtfac_c=self.metric_state_nonhydro.wgtfac_c, - wgtfacq_c_dsl=self.metric_state_nonhydro.wgtfacq_c_dsl, + wgtfacq_c_dsl=self.metric_state_nonhydro.wgtfacq_c, w_concorr_c=diagnostic_state_nh.w_concorr_c, k_field=self.k_field, nflatlev_startindex_plus1=int32(self.vertical_params.nflatlev + 1), diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py index 16ef19eb27..2a2ed59925 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py @@ -113,7 +113,7 @@ class MetricStateNonHydro: rayleigh_w: Field[[KDim], float] wgtfac_c: Field[[CellDim, KDim], float] - wgtfacq_c_dsl: Field[[CellDim, KDim], float] + wgtfacq_c: Field[[CellDim, KDim], float] wgtfac_e: Field[[EdgeDim, KDim], float] wgtfacq_e_dsl: Field[[EdgeDim, KDim], float] diff --git a/model/atmosphere/dycore/tests/dycore_tests/utils.py b/model/atmosphere/dycore/tests/dycore_tests/utils.py index ac40774eaa..d60c513075 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/utils.py +++ b/model/atmosphere/dycore/tests/dycore_tests/utils.py @@ -39,7 +39,7 @@ def construct_nh_metric_state(savepoint: MetricSavepoint, num_k_lev) -> MetricSt exner_exfac=savepoint.exner_exfac(), exner_ref_mc=savepoint.exner_ref_mc(), wgtfac_c=savepoint.wgtfac_c(), - wgtfacq_c_dsl=savepoint.wgtfacq_c_dsl(), + wgtfacq_c=savepoint.wgtfacq_c_dsl(), inv_ddqz_z_full=savepoint.inv_ddqz_z_full(), rho_ref_mc=savepoint.rho_ref_mc(), theta_ref_mc=savepoint.theta_ref_mc(), diff --git a/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py b/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py index 0bc3f61479..78e02152cf 100644 --- a/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py +++ b/model/common/src/icon4py/model/common/test_utils/serialbox_utils.py @@ -525,9 +525,6 @@ def vwind_impl_wgt(self): def wgtfacq_c_dsl(self): return self._get_field("wgtfacq_c_dsl", CellDim, KDim) - def wgtfacq_c(self): - return self._get_field("wgtfacq_c", CellDim, KDim) - def zdiff_gradp(self): field = self._get_field("zdiff_gradp_dsl", EdgeDim, E2CDim, KDim) return flatten_first_two_dims(ECDim, KDim, field=field) diff --git a/model/driver/src/icon4py/model/driver/serialbox_helpers.py b/model/driver/src/icon4py/model/driver/serialbox_helpers.py index fc8aa06b93..1382d66246 100644 --- a/model/driver/src/icon4py/model/driver/serialbox_helpers.py +++ b/model/driver/src/icon4py/model/driver/serialbox_helpers.py @@ -48,7 +48,7 @@ def construct_nh_metric_state(savepoint: MetricSavepoint, num_k_lev) -> MetricSt exner_exfac=savepoint.exner_exfac(), exner_ref_mc=savepoint.exner_ref_mc(), wgtfac_c=savepoint.wgtfac_c(), - wgtfacq_c_dsl=savepoint.wgtfacq_c_dsl(), + wgtfacq_c=savepoint.wgtfacq_c_dsl(), inv_ddqz_z_full=savepoint.inv_ddqz_z_full(), rho_ref_mc=savepoint.rho_ref_mc(), theta_ref_mc=savepoint.theta_ref_mc(), From 20287f5eb86559a9802745415ccf5e37ad53b39f Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Wed, 6 Dec 2023 08:51:26 +0100 Subject: [PATCH 05/10] rename property in metric_state: remove _dsl --- .../icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py | 2 +- .../src/icon4py/model/atmosphere/dycore/state_utils/states.py | 2 +- .../model/atmosphere/dycore/velocity/velocity_advection.py | 2 +- model/atmosphere/dycore/tests/dycore_tests/utils.py | 2 +- model/driver/src/icon4py/model/driver/serialbox_helpers.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py index 7e3b31979a..4765c630fe 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py @@ -1074,7 +1074,7 @@ def run_predictor_step( vn_ie=diagnostic_state_nh.vn_ie, z_vt_ie=z_fields.z_vt_ie, z_kin_hor_e=z_fields.z_kin_hor_e, - wgtfacq_e_dsl=self.metric_state_nonhydro.wgtfacq_e_dsl, + wgtfacq_e_dsl=self.metric_state_nonhydro.wgtfacq_e, k_field=self.k_field, nlev=self.grid.num_levels, horizontal_start=start_edge_lb_plus4, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py index 2a2ed59925..1cc87ecc5c 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py @@ -115,7 +115,7 @@ class MetricStateNonHydro: wgtfac_c: Field[[CellDim, KDim], float] wgtfacq_c: Field[[CellDim, KDim], float] wgtfac_e: Field[[EdgeDim, KDim], float] - wgtfacq_e_dsl: Field[[EdgeDim, KDim], float] + wgtfacq_e: Field[[EdgeDim, KDim], float] exner_exfac: Field[[CellDim, KDim], float] exner_ref_mc: Field[[CellDim, KDim], float] 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 c5ffbc6aac..7cf8505d38 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 @@ -251,7 +251,7 @@ def run_predictor_step( offset_provider={}, ) velocity_prog.mo_velocity_advection_stencil_06.with_backend(backend)( - wgtfacq_e=self.metric_state.wgtfacq_e_dsl, + wgtfacq_e=self.metric_state.wgtfacq_e, vn=prognostic_state.vn, vn_ie=diagnostic_state.vn_ie, horizontal_start=start_edge_lb_plus4, diff --git a/model/atmosphere/dycore/tests/dycore_tests/utils.py b/model/atmosphere/dycore/tests/dycore_tests/utils.py index d60c513075..3f6ae2b2ca 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/utils.py +++ b/model/atmosphere/dycore/tests/dycore_tests/utils.py @@ -59,7 +59,7 @@ def construct_nh_metric_state(savepoint: MetricSavepoint, num_k_lev) -> MetricSt ddqz_z_full_e=savepoint.ddqz_z_full_e(), ddxt_z_full=savepoint.ddxt_z_full(), wgtfac_e=savepoint.wgtfac_e(), - wgtfacq_e_dsl=savepoint.wgtfacq_e_dsl(num_k_lev), + wgtfacq_e=savepoint.wgtfacq_e_dsl(num_k_lev), vwind_impl_wgt=savepoint.vwind_impl_wgt(), hmask_dd3d=savepoint.hmask_dd3d(), scalfac_dd3d=savepoint.scalfac_dd3d(), diff --git a/model/driver/src/icon4py/model/driver/serialbox_helpers.py b/model/driver/src/icon4py/model/driver/serialbox_helpers.py index 1382d66246..73336ce976 100644 --- a/model/driver/src/icon4py/model/driver/serialbox_helpers.py +++ b/model/driver/src/icon4py/model/driver/serialbox_helpers.py @@ -68,7 +68,7 @@ def construct_nh_metric_state(savepoint: MetricSavepoint, num_k_lev) -> MetricSt ddqz_z_full_e=savepoint.ddqz_z_full_e(), ddxt_z_full=savepoint.ddxt_z_full(), wgtfac_e=savepoint.wgtfac_e(), - wgtfacq_e_dsl=savepoint.wgtfacq_e_dsl(num_k_lev), + wgtfacq_e=savepoint.wgtfacq_e_dsl(num_k_lev), vwind_impl_wgt=savepoint.vwind_impl_wgt(), hmask_dd3d=savepoint.hmask_dd3d(), scalfac_dd3d=savepoint.scalfac_dd3d(), From 7582cb7daac56fad95976cd9b3684833530aeaee Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Wed, 6 Dec 2023 09:13:56 +0100 Subject: [PATCH 06/10] move PreAdvection to states.py --- .../dycore/nh_solve/solve_nonhydro.py | 2 +- .../dycore/state_utils/prep_adv_state.py | 25 ------------------- .../atmosphere/dycore/state_utils/states.py | 7 ++++++ .../mpi_tests/test_parallel_solve_nonhydro.py | 6 +++-- .../tests/dycore_tests/test_solve_nonhydro.py | 8 +++--- .../src/icon4py/model/driver/dycore_driver.py | 6 +++-- .../src/icon4py/model/driver/io_utils.py | 2 +- model/driver/tests/test_timeloop.py | 6 +++-- 8 files changed, 26 insertions(+), 36 deletions(-) delete mode 100644 model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/prep_adv_state.py diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py index 4765c630fe..c426df3638 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py @@ -141,9 +141,9 @@ InterpolationState, MetricStateNonHydro, DiagnosticStateNonHydro, + PrepAdvection, ) from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants -from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.utils import ( _allocate, _allocate_indices, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/prep_adv_state.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/prep_adv_state.py deleted file mode 100644 index 8a94ccafb4..0000000000 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/prep_adv_state.py +++ /dev/null @@ -1,25 +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 dataclasses import dataclass - -from gt4py.next.common import Field - -from icon4py.model.common.dimension import CellDim, EdgeDim, KDim - - -@dataclass -class PrepAdvection: - vn_traj: Field[[EdgeDim, KDim], float] - mass_flx_me: Field[[EdgeDim, KDim], float] - mass_flx_ic: Field[[CellDim, KDim], float] diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py index 1cc87ecc5c..e5afe649f1 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py @@ -148,3 +148,10 @@ class MetricStateNonHydro: coeff1_dwdz: Field[[CellDim, KDim], float] coeff2_dwdz: Field[[CellDim, KDim], float] coeff_gradekin: Field[[ECDim], float] + + +@dataclass +class PrepAdvection: + vn_traj: Field[[EdgeDim, KDim], float] + mass_flx_me: Field[[EdgeDim, KDim], float] + mass_flx_ic: Field[[CellDim, KDim], float] diff --git a/model/atmosphere/dycore/tests/dycore_tests/mpi_tests/test_parallel_solve_nonhydro.py b/model/atmosphere/dycore/tests/dycore_tests/mpi_tests/test_parallel_solve_nonhydro.py index be1704e21a..fc5df484cb 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/mpi_tests/test_parallel_solve_nonhydro.py +++ b/model/atmosphere/dycore/tests/dycore_tests/mpi_tests/test_parallel_solve_nonhydro.py @@ -20,9 +20,11 @@ NonHydrostaticParams, SolveNonhydro, ) -from icon4py.model.atmosphere.dycore.state_utils.diagnostic_state import DiagnosticStateNonHydro from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants -from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection +from icon4py.model.atmosphere.dycore.state_utils.states import ( + PrepAdvection, + DiagnosticStateNonHydro, +) from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields from icon4py.model.common.decomposition import definitions diff --git a/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py b/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py index 171a1fd826..d33b6d75b0 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py +++ b/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py @@ -20,9 +20,11 @@ NonHydrostaticParams, SolveNonhydro, ) -from icon4py.model.atmosphere.dycore.state_utils.states import DiagnosticStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import ( + DiagnosticStateNonHydro, + PrepAdvection, +) from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants -from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.utils import ( _allocate, _calculate_bdy_divdamp, @@ -677,7 +679,7 @@ def test_nonhydro_corrector_step( @pytest.mark.parametrize( "istep_init, jstep_init, step_date_init, istep_exit, jstep_exit,step_date_exit, vn_only", [ - (1, 0, "2021-06-20T12:00:10.000", 2, 0, "2021-06-20T12:00:10.000", False), + # (1, 0, "2021-06-20T12:00:10.000", 2, 0, "2021-06-20T12:00:10.000", False), (1, 0, "2021-06-20T12:00:20.000", 2, 0, "2021-06-20T12:00:20.000", True), ], ) diff --git a/model/driver/src/icon4py/model/driver/dycore_driver.py b/model/driver/src/icon4py/model/driver/dycore_driver.py index c895dd849a..f0c1e46e0c 100644 --- a/model/driver/src/icon4py/model/driver/dycore_driver.py +++ b/model/driver/src/icon4py/model/driver/dycore_driver.py @@ -24,9 +24,11 @@ NonHydrostaticParams, SolveNonhydro, ) -from icon4py.model.atmosphere.dycore.state_utils.states import DiagnosticStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import ( + DiagnosticStateNonHydro, + PrepAdvection, +) from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants -from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields from icon4py.model.common.decomposition.definitions import ( ProcessProperties, diff --git a/model/driver/src/icon4py/model/driver/io_utils.py b/model/driver/src/icon4py/model/driver/io_utils.py index 42e4f7a6bc..9c7b650aaf 100644 --- a/model/driver/src/icon4py/model/driver/io_utils.py +++ b/model/driver/src/icon4py/model/driver/io_utils.py @@ -27,9 +27,9 @@ InterpolationState, MetricStateNonHydro, DiagnosticStateNonHydro, + PrepAdvection, ) from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants -from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields from icon4py.model.common.decomposition.definitions import DecompositionInfo, ProcessProperties diff --git a/model/driver/tests/test_timeloop.py b/model/driver/tests/test_timeloop.py index 533a949fcf..bb469f9f03 100644 --- a/model/driver/tests/test_timeloop.py +++ b/model/driver/tests/test_timeloop.py @@ -22,9 +22,11 @@ NonHydrostaticParams, SolveNonhydro, ) -from icon4py.model.atmosphere.dycore.state_utils.states import DiagnosticStateNonHydro +from icon4py.model.atmosphere.dycore.state_utils.states import ( + DiagnosticStateNonHydro, + PrepAdvection, +) from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants -from icon4py.model.atmosphere.dycore.state_utils.prep_adv_state import PrepAdvection from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields from icon4py.model.common.dimension import CellDim, EdgeDim, KDim From 7da1708b286d0df35438e9bbdf1020950586c6e1 Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Wed, 6 Dec 2023 12:30:03 +0100 Subject: [PATCH 07/10] move PreAdvection to states.py --- .../model/atmosphere/dycore/nh_solve/solve_nonhydro.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py index c426df3638..c0b13b0933 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py @@ -493,11 +493,11 @@ def time_step( exner=prognostic_state_ls[nnew].exner, rd_o_cvd=self.params.rd_o_cvd, rd_o_p0ref=self.params.rd_o_p0ref, - vertical_start=0, - vertical_lower=self.grid.num_levels, - horizontal_lower=0, - horizontal_upper=end_cell_end, offset_provider={}, + horizontal_start=0, + horizontal_end=end_cell_end, + vertical_start=0, + vertical_end=self.grid.num_levels, ) mo_solve_nonhydro_stencil_67.with_backend(backend)( @@ -508,7 +508,7 @@ def time_step( rd_o_p0ref=self.params.rd_o_p0ref, horizontal_start=start_cell_lb, horizontal_end=end_cell_nudging_minus1, - vertical_start=0, + vertical_start=int32(0), vertical_end=self.grid.num_levels, offset_provider={}, ) From 5a126d302f9fc4ebc29f57566f913a54af1e10aa Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Wed, 6 Dec 2023 13:36:51 +0100 Subject: [PATCH 08/10] pre-commit --- .../atmosphere/dycore/nh_solve/solve_nonhydro.py | 4 ++-- .../atmosphere/dycore/state_utils/states.py | 16 ++++++++-------- .../dycore/velocity/velocity_advection.py | 2 +- .../mpi_tests/test_parallel_solve_nonhydro.py | 2 +- .../tests/dycore_tests/test_solve_nonhydro.py | 11 +++++------ .../dycore_tests/test_velocity_advection.py | 1 + .../dycore/tests/dycore_tests/utils.py | 13 +++++++++++++ .../src/icon4py/model/driver/dycore_driver.py | 2 +- .../driver/src/icon4py/model/driver/io_utils.py | 4 ++-- .../icon4py/model/driver/serialbox_helpers.py | 14 ++++++++++++++ model/driver/tests/test_timeloop.py | 2 +- 11 files changed, 49 insertions(+), 22 deletions(-) diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py index c0b13b0933..dad335daa4 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py @@ -137,13 +137,13 @@ from icon4py.model.atmosphere.dycore.mo_solve_nonhydro_stencil_68 import ( mo_solve_nonhydro_stencil_68, ) +from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.states import ( + DiagnosticStateNonHydro, InterpolationState, MetricStateNonHydro, - DiagnosticStateNonHydro, PrepAdvection, ) -from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.utils import ( _allocate, _allocate_indices, diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py index e5afe649f1..fb413282bf 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/state_utils/states.py @@ -15,18 +15,18 @@ from gt4py.next.common import Field from icon4py.model.common.dimension import ( + C2E2CODim, + CEDim, CellDim, + E2C2EDim, + E2C2EODim, + E2CDim, + ECDim, EdgeDim, KDim, - CEDim, - VertexDim, - V2EDim, - C2E2CODim, - E2CDim, - E2C2EODim, - E2C2EDim, V2CDim, - ECDim, + V2EDim, + VertexDim, ) 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 7cf8505d38..7888e09356 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 @@ -56,9 +56,9 @@ mo_velocity_advection_stencil_20, ) from icon4py.model.atmosphere.dycore.state_utils.states import ( + DiagnosticStateNonHydro, InterpolationState, MetricStateNonHydro, - DiagnosticStateNonHydro, ) from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate, _allocate_indices from icon4py.model.common.dimension import CellDim, EdgeDim, KDim, VertexDim diff --git a/model/atmosphere/dycore/tests/dycore_tests/mpi_tests/test_parallel_solve_nonhydro.py b/model/atmosphere/dycore/tests/dycore_tests/mpi_tests/test_parallel_solve_nonhydro.py index fc5df484cb..dd8a2f54db 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/mpi_tests/test_parallel_solve_nonhydro.py +++ b/model/atmosphere/dycore/tests/dycore_tests/mpi_tests/test_parallel_solve_nonhydro.py @@ -22,8 +22,8 @@ ) from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.states import ( - PrepAdvection, DiagnosticStateNonHydro, + PrepAdvection, ) from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields diff --git a/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py b/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py index d33b6d75b0..6a7fad0b3c 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py +++ b/model/atmosphere/dycore/tests/dycore_tests/test_solve_nonhydro.py @@ -20,11 +20,11 @@ NonHydrostaticParams, SolveNonhydro, ) +from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.states import ( DiagnosticStateNonHydro, PrepAdvection, ) -from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.utils import ( _allocate, _calculate_bdy_divdamp, @@ -38,10 +38,9 @@ from icon4py.model.common.math.smagorinsky import en_smag_fac_for_zero_nshift from icon4py.model.common.states.prognostic_state import PrognosticState from icon4py.model.common.test_utils.helpers import dallclose -from .utils import ( - construct_interpolation_state_for_nonhydro, - construct_nh_metric_state, -) + +from .utils import construct_interpolation_state_for_nonhydro, construct_nh_metric_state + backend = run_gtfn @@ -679,7 +678,7 @@ def test_nonhydro_corrector_step( @pytest.mark.parametrize( "istep_init, jstep_init, step_date_init, istep_exit, jstep_exit,step_date_exit, vn_only", [ - # (1, 0, "2021-06-20T12:00:10.000", 2, 0, "2021-06-20T12:00:10.000", False), + (1, 0, "2021-06-20T12:00:10.000", 2, 0, "2021-06-20T12:00:10.000", False), (1, 0, "2021-06-20T12:00:20.000", 2, 0, "2021-06-20T12:00:20.000", True), ], ) diff --git a/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py b/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py index 6c5c13703a..0d6e99dc90 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py +++ b/model/atmosphere/dycore/tests/dycore_tests/test_velocity_advection.py @@ -20,6 +20,7 @@ from icon4py.model.common.grid.vertical import VerticalModelParams from icon4py.model.common.states.prognostic_state import PrognosticState from icon4py.model.common.test_utils.helpers import dallclose + from .utils import construct_interpolation_state_for_nonhydro, construct_nh_metric_state diff --git a/model/atmosphere/dycore/tests/dycore_tests/utils.py b/model/atmosphere/dycore/tests/dycore_tests/utils.py index 3f6ae2b2ca..a6eee5b0f2 100644 --- a/model/atmosphere/dycore/tests/dycore_tests/utils.py +++ b/model/atmosphere/dycore/tests/dycore_tests/utils.py @@ -1,3 +1,16 @@ +# 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 icon4py.model.atmosphere.dycore.state_utils.states import ( InterpolationState, MetricStateNonHydro, diff --git a/model/driver/src/icon4py/model/driver/dycore_driver.py b/model/driver/src/icon4py/model/driver/dycore_driver.py index f0c1e46e0c..33ef96cdbc 100644 --- a/model/driver/src/icon4py/model/driver/dycore_driver.py +++ b/model/driver/src/icon4py/model/driver/dycore_driver.py @@ -24,11 +24,11 @@ NonHydrostaticParams, SolveNonhydro, ) +from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.states import ( DiagnosticStateNonHydro, PrepAdvection, ) -from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields from icon4py.model.common.decomposition.definitions import ( ProcessProperties, diff --git a/model/driver/src/icon4py/model/driver/io_utils.py b/model/driver/src/icon4py/model/driver/io_utils.py index 9c7b650aaf..b21c206434 100644 --- a/model/driver/src/icon4py/model/driver/io_utils.py +++ b/model/driver/src/icon4py/model/driver/io_utils.py @@ -23,13 +23,13 @@ DiffusionInterpolationState, DiffusionMetricState, ) +from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.states import ( + DiagnosticStateNonHydro, InterpolationState, MetricStateNonHydro, - DiagnosticStateNonHydro, PrepAdvection, ) -from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields from icon4py.model.common.decomposition.definitions import DecompositionInfo, ProcessProperties diff --git a/model/driver/src/icon4py/model/driver/serialbox_helpers.py b/model/driver/src/icon4py/model/driver/serialbox_helpers.py index 73336ce976..2f32b0fa8b 100644 --- a/model/driver/src/icon4py/model/driver/serialbox_helpers.py +++ b/model/driver/src/icon4py/model/driver/serialbox_helpers.py @@ -1,5 +1,19 @@ +# 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 + """ Construct state objects from serialized data by reading from IconSavepoint s. + This is a preliminary module which should be deleted once we become independent from the serialized ICON data. Code is essentially duplicated from the model/atmosphere/xx packages test functionality in order diff --git a/model/driver/tests/test_timeloop.py b/model/driver/tests/test_timeloop.py index bb469f9f03..f8babc92ef 100644 --- a/model/driver/tests/test_timeloop.py +++ b/model/driver/tests/test_timeloop.py @@ -22,11 +22,11 @@ NonHydrostaticParams, SolveNonhydro, ) +from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.states import ( DiagnosticStateNonHydro, PrepAdvection, ) -from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields from icon4py.model.common.dimension import CellDim, EdgeDim, KDim From d0561ca0e975bbb3a4291f7ddca9172fe95ef146 Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Thu, 7 Dec 2023 13:10:51 +0100 Subject: [PATCH 09/10] inline and remove serialbox_helpers.py --- .../dycore/nh_solve/solve_nonhydro.py | 2 +- .../icon4py/model/driver/serialbox_helpers.py | 92 ------------------- model/driver/tests/test_timeloop.py | 66 +++++++++++-- 3 files changed, 58 insertions(+), 102 deletions(-) delete mode 100644 model/driver/src/icon4py/model/driver/serialbox_helpers.py diff --git a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py index dad335daa4..ba7e470574 100644 --- a/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py +++ b/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/nh_solve/solve_nonhydro.py @@ -508,7 +508,7 @@ def time_step( rd_o_p0ref=self.params.rd_o_p0ref, horizontal_start=start_cell_lb, horizontal_end=end_cell_nudging_minus1, - vertical_start=int32(0), + vertical_start=0, vertical_end=self.grid.num_levels, offset_provider={}, ) diff --git a/model/driver/src/icon4py/model/driver/serialbox_helpers.py b/model/driver/src/icon4py/model/driver/serialbox_helpers.py deleted file mode 100644 index 2f32b0fa8b..0000000000 --- a/model/driver/src/icon4py/model/driver/serialbox_helpers.py +++ /dev/null @@ -1,92 +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 - -""" -Construct state objects from serialized data by reading from IconSavepoint s. - -This is a preliminary module which should be deleted once we become independent -from the serialized ICON data. -Code is essentially duplicated from the model/atmosphere/xx packages test functionality in order -to get the dependencies right. -""" - - -from icon4py.model.atmosphere.dycore.state_utils.states import ( - InterpolationState, - MetricStateNonHydro, -) -from icon4py.model.common.dimension import CEDim -from icon4py.model.common.test_utils.helpers import as_1D_sparse_field -from icon4py.model.common.test_utils.serialbox_utils import InterpolationSavepoint, MetricSavepoint - - -def construct_interpolation_state_for_nonhydro( - savepoint: InterpolationSavepoint, -) -> InterpolationState: - grg = savepoint.geofac_grg() - return InterpolationState( - c_lin_e=savepoint.c_lin_e(), - c_intp=savepoint.c_intp(), - e_flx_avg=savepoint.e_flx_avg(), - geofac_grdiv=savepoint.geofac_grdiv(), - geofac_rot=savepoint.geofac_rot(), - pos_on_tplane_e_1=savepoint.pos_on_tplane_e_x(), - pos_on_tplane_e_2=savepoint.pos_on_tplane_e_y(), - rbf_vec_coeff_e=savepoint.rbf_vec_coeff_e(), - e_bln_c_s=as_1D_sparse_field(savepoint.e_bln_c_s(), CEDim), - rbf_coeff_1=savepoint.rbf_vec_coeff_v1(), - rbf_coeff_2=savepoint.rbf_vec_coeff_v2(), - geofac_div=as_1D_sparse_field(savepoint.geofac_div(), CEDim), - geofac_n2s=savepoint.geofac_n2s(), - geofac_grg_x=grg[0], - geofac_grg_y=grg[1], - nudgecoeff_e=savepoint.nudgecoeff_e(), - ) - - -def construct_nh_metric_state(savepoint: MetricSavepoint, num_k_lev) -> MetricStateNonHydro: - return MetricStateNonHydro( - bdy_halo_c=savepoint.bdy_halo_c(), - mask_prog_halo_c=savepoint.mask_prog_halo_c(), - rayleigh_w=savepoint.rayleigh_w(), - exner_exfac=savepoint.exner_exfac(), - exner_ref_mc=savepoint.exner_ref_mc(), - wgtfac_c=savepoint.wgtfac_c(), - wgtfacq_c=savepoint.wgtfacq_c_dsl(), - inv_ddqz_z_full=savepoint.inv_ddqz_z_full(), - rho_ref_mc=savepoint.rho_ref_mc(), - theta_ref_mc=savepoint.theta_ref_mc(), - vwind_expl_wgt=savepoint.vwind_expl_wgt(), - d_exner_dz_ref_ic=savepoint.d_exner_dz_ref_ic(), - ddqz_z_half=savepoint.ddqz_z_half(), - theta_ref_ic=savepoint.theta_ref_ic(), - d2dexdz2_fac1_mc=savepoint.d2dexdz2_fac1_mc(), - d2dexdz2_fac2_mc=savepoint.d2dexdz2_fac2_mc(), - rho_ref_me=savepoint.rho_ref_me(), - theta_ref_me=savepoint.theta_ref_me(), - ddxn_z_full=savepoint.ddxn_z_full(), - zdiff_gradp=savepoint.zdiff_gradp(), - vertoffset_gradp=savepoint.vertoffset_gradp(), - ipeidx_dsl=savepoint.ipeidx_dsl(), - pg_exdist=savepoint.pg_exdist(), - ddqz_z_full_e=savepoint.ddqz_z_full_e(), - ddxt_z_full=savepoint.ddxt_z_full(), - wgtfac_e=savepoint.wgtfac_e(), - wgtfacq_e=savepoint.wgtfacq_e_dsl(num_k_lev), - vwind_impl_wgt=savepoint.vwind_impl_wgt(), - hmask_dd3d=savepoint.hmask_dd3d(), - scalfac_dd3d=savepoint.scalfac_dd3d(), - coeff1_dwdz=savepoint.coeff1_dwdz(), - coeff2_dwdz=savepoint.coeff2_dwdz(), - coeff_gradekin=savepoint.coeff_gradekin(), - ) diff --git a/model/driver/tests/test_timeloop.py b/model/driver/tests/test_timeloop.py index f8babc92ef..4ffebb9572 100644 --- a/model/driver/tests/test_timeloop.py +++ b/model/driver/tests/test_timeloop.py @@ -25,20 +25,18 @@ from icon4py.model.atmosphere.dycore.state_utils.nh_constants import NHConstants from icon4py.model.atmosphere.dycore.state_utils.states import ( DiagnosticStateNonHydro, + InterpolationState, + MetricStateNonHydro, PrepAdvection, ) from icon4py.model.atmosphere.dycore.state_utils.utils import _allocate from icon4py.model.atmosphere.dycore.state_utils.z_fields import ZFields -from icon4py.model.common.dimension import CellDim, EdgeDim, KDim +from icon4py.model.common.dimension import CEDim, CellDim, EdgeDim, KDim from icon4py.model.common.grid.horizontal import CellParams, EdgeParams from icon4py.model.common.grid.vertical import VerticalModelParams from icon4py.model.common.states.prognostic_state import PrognosticState -from icon4py.model.common.test_utils.helpers import dallclose +from icon4py.model.common.test_utils.helpers import as_1D_sparse_field, dallclose from icon4py.model.driver.dycore_driver import TimeLoop -from icon4py.model.driver.serialbox_helpers import ( - construct_interpolation_state_for_nonhydro, - construct_nh_metric_state, -) # testing on MCH_CH_r04b09_dsl data @@ -163,10 +161,60 @@ def test_run_timeloop_single_step( wgt_nnew_vel=sp.wgt_nnew_vel(), ) - nonhydro_interpolation_state = construct_interpolation_state_for_nonhydro( - interpolation_savepoint + grg = interpolation_savepoint.geofac_grg() + nonhydro_interpolation_state = InterpolationState( + c_lin_e=interpolation_savepoint.c_lin_e(), + c_intp=interpolation_savepoint.c_intp(), + e_flx_avg=interpolation_savepoint.e_flx_avg(), + geofac_grdiv=interpolation_savepoint.geofac_grdiv(), + geofac_rot=interpolation_savepoint.geofac_rot(), + pos_on_tplane_e_1=interpolation_savepoint.pos_on_tplane_e_x(), + pos_on_tplane_e_2=interpolation_savepoint.pos_on_tplane_e_y(), + rbf_vec_coeff_e=interpolation_savepoint.rbf_vec_coeff_e(), + e_bln_c_s=as_1D_sparse_field(interpolation_savepoint.e_bln_c_s(), CEDim), + rbf_coeff_1=interpolation_savepoint.rbf_vec_coeff_v1(), + rbf_coeff_2=interpolation_savepoint.rbf_vec_coeff_v2(), + geofac_div=as_1D_sparse_field(interpolation_savepoint.geofac_div(), CEDim), + geofac_n2s=interpolation_savepoint.geofac_n2s(), + geofac_grg_x=grg[0], + geofac_grg_y=grg[1], + nudgecoeff_e=interpolation_savepoint.nudgecoeff_e(), + ) + nonhydro_metric_state = MetricStateNonHydro( + bdy_halo_c=metrics_savepoint.bdy_halo_c(), + mask_prog_halo_c=metrics_savepoint.mask_prog_halo_c(), + rayleigh_w=metrics_savepoint.rayleigh_w(), + exner_exfac=metrics_savepoint.exner_exfac(), + exner_ref_mc=metrics_savepoint.exner_ref_mc(), + wgtfac_c=metrics_savepoint.wgtfac_c(), + wgtfacq_c=metrics_savepoint.wgtfacq_c_dsl(), + inv_ddqz_z_full=metrics_savepoint.inv_ddqz_z_full(), + rho_ref_mc=metrics_savepoint.rho_ref_mc(), + theta_ref_mc=metrics_savepoint.theta_ref_mc(), + vwind_expl_wgt=metrics_savepoint.vwind_expl_wgt(), + d_exner_dz_ref_ic=metrics_savepoint.d_exner_dz_ref_ic(), + ddqz_z_half=metrics_savepoint.ddqz_z_half(), + theta_ref_ic=metrics_savepoint.theta_ref_ic(), + d2dexdz2_fac1_mc=metrics_savepoint.d2dexdz2_fac1_mc(), + d2dexdz2_fac2_mc=metrics_savepoint.d2dexdz2_fac2_mc(), + rho_ref_me=metrics_savepoint.rho_ref_me(), + theta_ref_me=metrics_savepoint.theta_ref_me(), + ddxn_z_full=metrics_savepoint.ddxn_z_full(), + zdiff_gradp=metrics_savepoint.zdiff_gradp(), + vertoffset_gradp=metrics_savepoint.vertoffset_gradp(), + ipeidx_dsl=metrics_savepoint.ipeidx_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(), + wgtfac_e=metrics_savepoint.wgtfac_e(), + wgtfacq_e=metrics_savepoint.wgtfacq_e_dsl(icon_grid.num_levels), + vwind_impl_wgt=metrics_savepoint.vwind_impl_wgt(), + hmask_dd3d=metrics_savepoint.hmask_dd3d(), + scalfac_dd3d=metrics_savepoint.scalfac_dd3d(), + coeff1_dwdz=metrics_savepoint.coeff1_dwdz(), + coeff2_dwdz=metrics_savepoint.coeff2_dwdz(), + coeff_gradekin=metrics_savepoint.coeff_gradekin(), ) - nonhydro_metric_state = construct_nh_metric_state(metrics_savepoint, icon_grid.num_levels) cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() From 0a35e28121d1bd2180c2fca4a652437385243cb4 Mon Sep 17 00:00:00 2001 From: Magdalena Luz Date: Thu, 7 Dec 2023 19:14:59 +0100 Subject: [PATCH 10/10] fix test_timeloop.py --- model/driver/tests/test_timeloop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/driver/tests/test_timeloop.py b/model/driver/tests/test_timeloop.py index 4ffebb9572..fa72699114 100644 --- a/model/driver/tests/test_timeloop.py +++ b/model/driver/tests/test_timeloop.py @@ -96,7 +96,7 @@ def test_run_timeloop_single_step( edge_geometry: EdgeParams = grid_savepoint.construct_edge_geometry() cell_geometry: CellParams = grid_savepoint.construct_cell_geometry() diffusion_interpolation_state = ( - interpolation_savepoint.construct_interpolation_state_for_diffusion(interpolation_savepoint) + interpolation_savepoint.construct_interpolation_state_for_diffusion() ) diffusion_metric_state = metrics_savepoint.construct_metric_state_for_diffusion() diffusion_diagnostic_state = (