-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add init_exner_pr stencil and docstring to initialization functions, and some clean up. * remove a bug in solve_nonhydro corrector stencil 41 * add options for grid root and grid level * add C2E2C2EDim size in IconSerialDataProvider * testing * Correct docstring of jabw wind computation and remove c2e2c2e grid size
- Loading branch information
Showing
8 changed files
with
274 additions
and
62 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/init_exner_pr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 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 <https://www.gnu.org/licenses/>. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from gt4py.next.common import GridType | ||
from gt4py.next.ffront.decorator import field_operator, program | ||
from gt4py.next.ffront.fbuiltins import Field, int32 | ||
|
||
from icon4py.model.common.dimension import CellDim, KDim | ||
from icon4py.model.common.settings import backend | ||
from icon4py.model.common.type_alias import vpfloat | ||
|
||
|
||
@field_operator | ||
def _init_exner_pr( | ||
exner: Field[[CellDim, KDim], vpfloat], | ||
exner_ref: Field[[CellDim, KDim], vpfloat], | ||
) -> Field[[CellDim, KDim], vpfloat]: | ||
exner_pr = exner - exner_ref | ||
return exner_pr | ||
|
||
|
||
@program(grid_type=GridType.UNSTRUCTURED, backend=backend) | ||
def init_exner_pr( | ||
exner: Field[[CellDim, KDim], vpfloat], | ||
exner_ref: Field[[CellDim, KDim], vpfloat], | ||
exner_pr: Field[[CellDim, KDim], vpfloat], | ||
horizontal_start: int32, | ||
horizontal_end: int32, | ||
vertical_start: int32, | ||
vertical_end: int32, | ||
): | ||
_init_exner_pr( | ||
exner, | ||
exner_ref, | ||
out=exner_pr, | ||
domain={ | ||
CellDim: (horizontal_start, horizontal_end), | ||
KDim: (vertical_start, vertical_end), | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
model/atmosphere/dycore/tests/dycore_stencil_tests/test_init_exner_pr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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 <https://www.gnu.org/licenses/>. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import numpy as np | ||
import pytest | ||
from gt4py.next.ffront.fbuiltins import int32 | ||
|
||
from icon4py.model.atmosphere.dycore.init_exner_pr import ( | ||
init_exner_pr, | ||
) | ||
from icon4py.model.common.dimension import CellDim, KDim | ||
from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field | ||
from icon4py.model.common.type_alias import vpfloat | ||
|
||
|
||
class TestInitExnerPr(StencilTest): | ||
PROGRAM = init_exner_pr | ||
OUTPUTS = ("exner_pr",) | ||
|
||
@staticmethod | ||
def reference(grid, exner: np.array, exner_ref: np.array, **kwargs) -> dict: | ||
exner_pr = exner - exner_ref | ||
return dict( | ||
exner_pr=exner_pr, | ||
) | ||
|
||
@pytest.fixture | ||
def input_data(self, grid): | ||
exner = random_field(grid, CellDim, KDim, dtype=vpfloat) | ||
exner_ref = random_field(grid, CellDim, KDim, dtype=vpfloat) | ||
exner_pr = zero_field(grid, CellDim, KDim, dtype=vpfloat) | ||
|
||
return dict( | ||
exner=exner, | ||
exner_ref=exner_ref, | ||
exner_pr=exner_pr, | ||
horizontal_start=int32(0), | ||
horizontal_end=int32(grid.num_cells), | ||
vertical_start=int32(0), | ||
vertical_end=int32(grid.num_levels), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.