-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial condition for jw test #446
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
49e165a
Pull changes for initial conditions from Jablonowski_Williamson_test …
OngChia 7c20ea6
Changes function names testcase_functions.py for better readability.
OngChia 6e02762
Added initial conditions for JW.
OngChia 7a900f7
Add back io_utils which later will become initialization_utils.py
OngChia 8242587
remove existing initialization
OngChia 4951b81
rename io_utils.py as initialization_utils.py
OngChia 17e1d51
Add JW initial conditions in initialization_utils.py. Move non-compul…
OngChia 8be6e12
Removed unecessary savepoints.
OngChia 92c3db0
clean up. Remove unecessary codes that were used to output data for C…
OngChia 994b32e
precommit
OngChia 33abcd2
Merge branch 'main' into initial_condition_for_JW_test
OngChia 37725c1
merge main
OngChia 9445dd5
Remove dummy log file that was accidentally added
OngChia 9ac856c
Removed unwanted diagnostic metric state variables that were used to …
OngChia ebd03db
merge main
OngChia 617b312
add docstring to variables in horizontal.py
OngChia b092957
move referecen solution to second argument in allclose.
OngChia ccc4b05
create diagnostic_stencils and their tests
OngChia b44895d
merge main
OngChia b9a3061
Finalizing all stencil and data tests for diagnostic state variables,…
OngChia 3342960
Removed init_exner_pr and temporary printing statement in test_diagno…
OngChia b557e1c
remove comment
OngChia 21eb5a0
remove unsued rbf numpy stencil in testcase_functions.py
OngChia 53a0d6c
remove bug in pressure stencil test
OngChia 00ce346
Resolved pressure problem
OngChia 4d16b5d
changes according to review
OngChia 9fdc961
remove the pytest skip mark for test_jabw_initial_condition because j…
OngChia d3e1d7a
merge main
OngChia 1908c52
skip test_diagnose_pressure when roundtrip backend
OngChia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
13 changes: 13 additions & 0 deletions
13
model/common/src/icon4py/model/common/diagnostic_calculations/stencils/__init__.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,13 @@ | ||
# 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 | ||
|
73 changes: 73 additions & 0 deletions
73
model/common/src/icon4py/model/common/diagnostic_calculations/stencils/diagnose_pressure.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,73 @@ | ||
# 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, scan_operator | ||
from gt4py.next.ffront.fbuiltins import Field, exp, int32, sqrt | ||
|
||
from icon4py.model.common.dimension import CellDim, KDim | ||
from icon4py.model.common.settings import backend | ||
from icon4py.model.common.type_alias import vpfloat, wpfloat | ||
|
||
|
||
@scan_operator(axis=KDim, forward=False, init=(0.0, 0.0, True)) | ||
def _scan_pressure( | ||
state: tuple[vpfloat, vpfloat, bool], | ||
ddqz_z_full: vpfloat, | ||
temperature: vpfloat, | ||
pressure_sfc: vpfloat, | ||
grav_o_rd: wpfloat, | ||
): | ||
pressure_interface = ( | ||
pressure_sfc * exp(-grav_o_rd * ddqz_z_full / temperature) | ||
if state[2] | ||
else state[1] * exp(-grav_o_rd * ddqz_z_full / temperature) | ||
) | ||
pressure = ( | ||
sqrt(pressure_sfc * pressure_interface) if state[2] else sqrt(state[1] * pressure_interface) | ||
) | ||
return pressure, pressure_interface, False | ||
|
||
|
||
@field_operator | ||
def _diagnose_pressure( | ||
ddqz_z_full: Field[[CellDim, KDim], wpfloat], | ||
temperature: Field[[CellDim, KDim], vpfloat], | ||
pressure_sfc: Field[[CellDim], vpfloat], | ||
grav_o_rd: wpfloat, | ||
) -> tuple[Field[[CellDim, KDim], vpfloat], Field[[CellDim, KDim], vpfloat]]: | ||
pressure, pressure_ifc, _ = _scan_pressure(ddqz_z_full, temperature, pressure_sfc, grav_o_rd) | ||
return pressure, pressure_ifc | ||
|
||
|
||
@program(grid_type=GridType.UNSTRUCTURED, backend=backend) | ||
def diagnose_pressure( | ||
ddqz_z_full: Field[[CellDim, KDim], wpfloat], | ||
temperature: Field[[CellDim, KDim], vpfloat], | ||
pressure_sfc: Field[[CellDim], vpfloat], | ||
pressure: Field[[CellDim, KDim], vpfloat], | ||
pressure_ifc: Field[[CellDim, KDim], vpfloat], | ||
grav_o_rd: wpfloat, | ||
horizontal_start: int32, | ||
horizontal_end: int32, | ||
vertical_start: int32, | ||
vertical_end: int32, | ||
): | ||
_diagnose_pressure( | ||
ddqz_z_full, | ||
temperature, | ||
pressure_sfc, | ||
grav_o_rd, | ||
out=(pressure, pressure_ifc), | ||
domain={CellDim: (horizontal_start, horizontal_end), KDim: (vertical_start, vertical_end)}, | ||
) |
70 changes: 70 additions & 0 deletions
70
...on/src/icon4py/model/common/diagnostic_calculations/stencils/diagnose_surface_pressure.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,70 @@ | ||
# 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, exp, int32, log | ||
|
||
from icon4py.model.common.dimension import CellDim, KDim, Koff | ||
from icon4py.model.common.settings import backend | ||
from icon4py.model.common.type_alias import vpfloat, wpfloat | ||
|
||
|
||
@field_operator | ||
def _diagnose_surface_pressure( | ||
exner: Field[[CellDim, KDim], vpfloat], | ||
temperature: Field[[CellDim, KDim], vpfloat], | ||
ddqz_z_full: Field[[CellDim, KDim], wpfloat], | ||
cpd_o_rd: wpfloat, | ||
p0ref: wpfloat, | ||
grav_o_rd: wpfloat, | ||
) -> Field[[CellDim, KDim], vpfloat]: | ||
pressure_sfc = p0ref * exp( | ||
cpd_o_rd * log(exner(Koff[-3])) | ||
+ grav_o_rd | ||
* ( | ||
ddqz_z_full(Koff[-1]) / temperature(Koff[-1]) | ||
+ ddqz_z_full(Koff[-2]) / temperature(Koff[-2]) | ||
+ 0.5 * ddqz_z_full(Koff[-3]) / temperature(Koff[-3]) | ||
) | ||
) | ||
return pressure_sfc | ||
|
||
|
||
@program(grid_type=GridType.UNSTRUCTURED, backend=backend) | ||
def diagnose_surface_pressure( | ||
exner: Field[[CellDim, KDim], vpfloat], | ||
temperature: Field[[CellDim, KDim], vpfloat], | ||
ddqz_z_full: Field[[CellDim, KDim], wpfloat], | ||
pressure_sfc: Field[[CellDim, KDim], vpfloat], | ||
cpd_o_rd: wpfloat, | ||
p0ref: wpfloat, | ||
grav_o_rd: wpfloat, | ||
horizontal_start: int32, | ||
horizontal_end: int32, | ||
vertical_start: int32, | ||
vertical_end: int32, | ||
): | ||
_diagnose_surface_pressure( | ||
exner, | ||
temperature, | ||
ddqz_z_full, | ||
cpd_o_rd, | ||
p0ref, | ||
grav_o_rd, | ||
out=pressure_sfc, | ||
domain={ | ||
CellDim: (horizontal_start, horizontal_end), | ||
KDim: (vertical_start, vertical_end), | ||
}, | ||
) |
50 changes: 50 additions & 0 deletions
50
.../common/src/icon4py/model/common/diagnostic_calculations/stencils/diagnose_temperature.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 _diagnose_temperature( | ||
theta_v: Field[[CellDim, KDim], vpfloat], | ||
exner: Field[[CellDim, KDim], vpfloat], | ||
) -> Field[[CellDim, KDim], vpfloat]: | ||
temperature = theta_v * exner | ||
return temperature | ||
|
||
|
||
@program(grid_type=GridType.UNSTRUCTURED, backend=backend) | ||
def diagnose_temperature( | ||
theta_v: Field[[CellDim, KDim], vpfloat], | ||
exner: Field[[CellDim, KDim], vpfloat], | ||
temperature: Field[[CellDim, KDim], vpfloat], | ||
horizontal_start: int32, | ||
horizontal_end: int32, | ||
vertical_start: int32, | ||
vertical_end: int32, | ||
): | ||
_diagnose_temperature( | ||
theta_v, | ||
exner, | ||
out=(temperature), | ||
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you return here two fields one with shape (cell, num_lev) and one with shape (cell, num_lev + 1) interesting for the horizontal stencils we sometimes had problems with that due to the bounds. But lets keep it that way as long as it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know that. Probably, in this case, because the diagnose_pressure stencil should be called with bounds (:, 0:nlev), gt4py did not complain anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stencil does not compile when backend is roundtrip. I added a few lines in
test_diagnose_pressure.py
to skip it for roundtrip backend.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a
is_roundtrip
function for that just in case.