Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions bindings/src/icon4py/bindings/diffusion_wrapper.py
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, as agreed upon.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Diffusion,
DiffusionConfig,
DiffusionParams,
ForcingType,
TurbulenceShearForcingType,
)
from icon4py.model.atmosphere.diffusion.diffusion_states import (
Expand Down Expand Up @@ -84,11 +85,20 @@ def diffusion_init(
hdiff_efdt_ratio: gtx.float64,
hdiff_w_efdt_ratio: gtx.float64,
smagorinski_scaling_factor: gtx.float64,
smagorinski_scaling_factor2: gtx.float64,
smagorinski_scaling_factor3: gtx.float64,
smagorinski_scaling_factor4: gtx.float64,
smagorinski_scaling_height: gtx.float64,
smagorinski_scaling_height2: gtx.float64,
smagorinski_scaling_height3: gtx.float64,
smagorinski_scaling_height4: gtx.float64,
hdiff_temp: bool,
denom_diffu_v: float,
nudge_max_coeff: float, # note: this is the scaled ICON value, i.e. not the namelist value
itype_sher: gtx.int32,
ltkeshs: bool,
iforcing: gtx.int32,
a_hshr: gtx.float64,
loutshs: bool,
backend: gtx.int32,
):
if grid_wrapper.grid_state is None:
Expand Down Expand Up @@ -117,12 +127,21 @@ def diffusion_init(
hdiff_efdt_ratio=hdiff_efdt_ratio,
hdiff_w_efdt_ratio=hdiff_w_efdt_ratio,
smagorinski_scaling_factor=smagorinski_scaling_factor,
smagorinski_scaling_factor2=smagorinski_scaling_factor2,
smagorinski_scaling_factor3=smagorinski_scaling_factor3,
smagorinski_scaling_factor4=smagorinski_scaling_factor4,
smagorinski_scaling_height=smagorinski_scaling_height,
smagorinski_scaling_height2=smagorinski_scaling_height2,
smagorinski_scaling_height3=smagorinski_scaling_height3,
smagorinski_scaling_height4=smagorinski_scaling_height4,
hdiff_temp=hdiff_temp,
n_substeps=ndyn_substeps,
velocity_boundary_diffusion_denom=denom_diffu_v,
max_nudging_coefficient=nudge_max_coeff,
shear_type=TurbulenceShearForcingType(itype_sher),
ltkeshs=ltkeshs,
iforcing=ForcingType(iforcing),
a_hshr=a_hshr,
loutshs=loutshs,
)

diffusion_params = DiffusionParams(config)
Expand Down Expand Up @@ -281,13 +300,9 @@ def diffusion_run(
dwdy=dwdy,
)

if linit:
granule.diffusion.initial_run(
diagnostic_state,
prognostic_state,
dtime,
)
else:
granule.diffusion.run(
prognostic_state=prognostic_state, diagnostic_state=diagnostic_state, dtime=dtime
)
granule.diffusion.run(
diagnostic_state=diagnostic_state,
prognostic_state=prognostic_state,
dtime=dtime,
initial_run=linit,
)
2 changes: 2 additions & 0 deletions bindings/src/icon4py/bindings/dycore_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def solve_nh_init(
l_vert_nested: bool,
ldeepatmo: bool,
iau_init: bool,
extra_diffu: bool,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand, I set the default of extra_diffu to True in `solve_nh_init. Can you check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I do not understand, I set the default of extra_diffu to True in `solve_nh_init. Can you check?

rhotheta_offctr: gtx.float64,
veladv_offctr: gtx.float64,
nudge_max_coeff: gtx.float64, # note: this is the scaled ICON value, i.e. not the namelist value
Expand Down Expand Up @@ -164,6 +165,7 @@ def solve_nh_init(
l_vert_nested=l_vert_nested,
deepatmos_mode=ldeepatmo,
iau_init=iau_init,
extra_diffu=extra_diffu,
rhotheta_offctr=rhotheta_offctr,
veladv_offctr=veladv_offctr,
max_nudging_coefficient=nudge_max_coeff,
Expand Down
73 changes: 68 additions & 5 deletions bindings/tests/bindings/references/diffusion/diffusion.f90
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with diffusion_wrapper.py

Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,20 @@ function diffusion_init_wrapper(theta_ref_mc, &
hdiff_efdt_ratio, &
hdiff_w_efdt_ratio, &
smagorinski_scaling_factor, &
smagorinski_scaling_factor2, &
smagorinski_scaling_factor3, &
smagorinski_scaling_factor4, &
smagorinski_scaling_height, &
smagorinski_scaling_height2, &
smagorinski_scaling_height3, &
smagorinski_scaling_height4, &
hdiff_temp, &
denom_diffu_v, &
nudge_max_coeff, &
itype_sher, &
ltkeshs, &
iforcing, &
a_hshr, &
loutshs, &
backend, &
on_gpu) bind(c, name="diffusion_init_wrapper") result(rc)
import :: c_int, c_double, c_bool, c_ptr
Expand Down Expand Up @@ -260,6 +269,20 @@ function diffusion_init_wrapper(theta_ref_mc, &

real(c_double), value, target :: smagorinski_scaling_factor

real(c_double), value, target :: smagorinski_scaling_factor2

real(c_double), value, target :: smagorinski_scaling_factor3

real(c_double), value, target :: smagorinski_scaling_factor4

real(c_double), value, target :: smagorinski_scaling_height

real(c_double), value, target :: smagorinski_scaling_height2

real(c_double), value, target :: smagorinski_scaling_height3

real(c_double), value, target :: smagorinski_scaling_height4

logical(c_int), value, target :: hdiff_temp

real(c_double), value, target :: denom_diffu_v
Expand All @@ -268,7 +291,11 @@ function diffusion_init_wrapper(theta_ref_mc, &

integer(c_int), value, target :: itype_sher

logical(c_int), value, target :: ltkeshs
integer(c_int), value, target :: iforcing

real(c_double), value, target :: a_hshr

logical(c_int), value, target :: loutshs

integer(c_int), value, target :: backend

Expand Down Expand Up @@ -493,11 +520,20 @@ subroutine diffusion_init(theta_ref_mc, &
hdiff_efdt_ratio, &
hdiff_w_efdt_ratio, &
smagorinski_scaling_factor, &
smagorinski_scaling_factor2, &
smagorinski_scaling_factor3, &
smagorinski_scaling_factor4, &
smagorinski_scaling_height, &
smagorinski_scaling_height2, &
smagorinski_scaling_height3, &
smagorinski_scaling_height4, &
hdiff_temp, &
denom_diffu_v, &
nudge_max_coeff, &
itype_sher, &
ltkeshs, &
iforcing, &
a_hshr, &
loutshs, &
backend, &
rc)
use, intrinsic :: iso_c_binding
Expand Down Expand Up @@ -550,6 +586,20 @@ subroutine diffusion_init(theta_ref_mc, &

real(c_double), value, target :: smagorinski_scaling_factor

real(c_double), value, target :: smagorinski_scaling_factor2

real(c_double), value, target :: smagorinski_scaling_factor3

real(c_double), value, target :: smagorinski_scaling_factor4

real(c_double), value, target :: smagorinski_scaling_height

real(c_double), value, target :: smagorinski_scaling_height2

real(c_double), value, target :: smagorinski_scaling_height3

real(c_double), value, target :: smagorinski_scaling_height4

logical(c_int), value, target :: hdiff_temp

real(c_double), value, target :: denom_diffu_v
Expand All @@ -558,7 +608,11 @@ subroutine diffusion_init(theta_ref_mc, &

integer(c_int), value, target :: itype_sher

logical(c_int), value, target :: ltkeshs
integer(c_int), value, target :: iforcing

real(c_double), value, target :: a_hshr

logical(c_int), value, target :: loutshs

integer(c_int), value, target :: backend

Expand Down Expand Up @@ -752,11 +806,20 @@ subroutine diffusion_init(theta_ref_mc, &
hdiff_efdt_ratio=hdiff_efdt_ratio, &
hdiff_w_efdt_ratio=hdiff_w_efdt_ratio, &
smagorinski_scaling_factor=smagorinski_scaling_factor, &
smagorinski_scaling_factor2=smagorinski_scaling_factor2, &
smagorinski_scaling_factor3=smagorinski_scaling_factor3, &
smagorinski_scaling_factor4=smagorinski_scaling_factor4, &
smagorinski_scaling_height=smagorinski_scaling_height, &
smagorinski_scaling_height2=smagorinski_scaling_height2, &
smagorinski_scaling_height3=smagorinski_scaling_height3, &
smagorinski_scaling_height4=smagorinski_scaling_height4, &
hdiff_temp=hdiff_temp, &
denom_diffu_v=denom_diffu_v, &
nudge_max_coeff=nudge_max_coeff, &
itype_sher=itype_sher, &
ltkeshs=ltkeshs, &
iforcing=iforcing, &
a_hshr=a_hshr, &
loutshs=loutshs, &
backend=backend, &
on_gpu=on_gpu)
!$acc end host_data
Expand Down
8 changes: 6 additions & 2 deletions bindings/tests/bindings/references/diffusion/diffusion.h
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with diffusion_wrapper.py

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ extern int diffusion_init_wrapper(
int ndyn_substeps, int diffusion_type, int hdiff_w, int hdiff_vn,
int hdiff_smag_w, int zdiffu_t, int type_t_diffu, int type_vn_diffu,
double hdiff_efdt_ratio, double hdiff_w_efdt_ratio,
double smagorinski_scaling_factor, int hdiff_temp, double denom_diffu_v,
double nudge_max_coeff, int itype_sher, int ltkeshs, int backend,
double smagorinski_scaling_factor, double smagorinski_scaling_factor2,
double smagorinski_scaling_factor3, double smagorinski_scaling_factor4,
double smagorinski_scaling_height, double smagorinski_scaling_height2,
double smagorinski_scaling_height3, double smagorinski_scaling_height4,
int hdiff_temp, double denom_diffu_v, double nudge_max_coeff,
int itype_sher, int iforcing, double a_hshr, int loutshs, int backend,
int on_gpu);
22 changes: 20 additions & 2 deletions bindings/tests/bindings/references/diffusion/diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,20 @@ def diffusion_init_wrapper(
hdiff_efdt_ratio,
hdiff_w_efdt_ratio,
smagorinski_scaling_factor,
smagorinski_scaling_factor2,
smagorinski_scaling_factor3,
smagorinski_scaling_factor4,
smagorinski_scaling_height,
smagorinski_scaling_height2,
smagorinski_scaling_height3,
smagorinski_scaling_height4,
hdiff_temp,
denom_diffu_v,
nudge_max_coeff,
itype_sher,
ltkeshs,
iforcing,
a_hshr,
loutshs,
backend,
on_gpu,
):
Expand Down Expand Up @@ -566,11 +575,20 @@ def diffusion_init_wrapper(
hdiff_efdt_ratio=hdiff_efdt_ratio,
hdiff_w_efdt_ratio=hdiff_w_efdt_ratio,
smagorinski_scaling_factor=smagorinski_scaling_factor,
smagorinski_scaling_factor2=smagorinski_scaling_factor2,
smagorinski_scaling_factor3=smagorinski_scaling_factor3,
smagorinski_scaling_factor4=smagorinski_scaling_factor4,
smagorinski_scaling_height=smagorinski_scaling_height,
smagorinski_scaling_height2=smagorinski_scaling_height2,
smagorinski_scaling_height3=smagorinski_scaling_height3,
smagorinski_scaling_height4=smagorinski_scaling_height4,
hdiff_temp=hdiff_temp,
denom_diffu_v=denom_diffu_v,
nudge_max_coeff=nudge_max_coeff,
itype_sher=itype_sher,
ltkeshs=ltkeshs,
iforcing=iforcing,
a_hshr=a_hshr,
loutshs=loutshs,
backend=backend,
)

Expand Down
7 changes: 7 additions & 0 deletions bindings/tests/bindings/references/dycore/dycore.f90
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ function solve_nh_init_wrapper(c_lin_e, &
l_vert_nested, &
ldeepatmo, &
iau_init, &
extra_diffu, &
rhotheta_offctr, &
veladv_offctr, &
nudge_max_coeff, &
Expand Down Expand Up @@ -822,6 +823,8 @@ function solve_nh_init_wrapper(c_lin_e, &

logical(c_int), value, target :: iau_init

logical(c_int), value, target :: extra_diffu

real(c_double), value, target :: rhotheta_offctr

real(c_double), value, target :: veladv_offctr
Expand Down Expand Up @@ -1519,6 +1522,7 @@ subroutine solve_nh_init(c_lin_e, &
l_vert_nested, &
ldeepatmo, &
iau_init, &
extra_diffu, &
rhotheta_offctr, &
veladv_offctr, &
nudge_max_coeff, &
Expand Down Expand Up @@ -1651,6 +1655,8 @@ subroutine solve_nh_init(c_lin_e, &

logical(c_int), value, target :: iau_init

logical(c_int), value, target :: extra_diffu

real(c_double), value, target :: rhotheta_offctr

real(c_double), value, target :: veladv_offctr
Expand Down Expand Up @@ -2226,6 +2232,7 @@ subroutine solve_nh_init(c_lin_e, &
l_vert_nested=l_vert_nested, &
ldeepatmo=ldeepatmo, &
iau_init=iau_init, &
extra_diffu=extra_diffu, &
rhotheta_offctr=rhotheta_offctr, &
veladv_offctr=veladv_offctr, &
nudge_max_coeff=nudge_max_coeff, &
Expand Down
2 changes: 1 addition & 1 deletion bindings/tests/bindings/references/dycore/dycore.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ extern int solve_nh_init_wrapper(
int coeff_gradekin_size_1, int *c_owner_mask, int c_owner_mask_size_0,
int itime_scheme, int iadv_rhotheta, int igradp_method, int rayleigh_type,
int divdamp_order, int divdamp_type, int l_vert_nested, int ldeepatmo,
int iau_init, double rhotheta_offctr, double veladv_offctr,
int iau_init, int extra_diffu, double rhotheta_offctr, double veladv_offctr,
double nudge_max_coeff, double divdamp_fac, double divdamp_fac2,
double divdamp_fac3, double divdamp_fac4, double divdamp_z,
double divdamp_z2, double divdamp_z3, double divdamp_z4, int nflat_gradp,
Expand Down
2 changes: 2 additions & 0 deletions bindings/tests/bindings/references/dycore/dycore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,7 @@ def solve_nh_init_wrapper(
l_vert_nested,
ldeepatmo,
iau_init,
extra_diffu,
rhotheta_offctr,
veladv_offctr,
nudge_max_coeff,
Expand Down Expand Up @@ -1828,6 +1829,7 @@ def solve_nh_init_wrapper(
l_vert_nested=l_vert_nested,
ldeepatmo=ldeepatmo,
iau_init=iau_init,
extra_diffu=extra_diffu,
rhotheta_offctr=rhotheta_offctr,
veladv_offctr=veladv_offctr,
nudge_max_coeff=nudge_max_coeff,
Expand Down
Loading
Loading