Skip to content
Draft
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
9 changes: 5 additions & 4 deletions tools/src/icon4py/tools/py2fgen/wrappers/diffusion_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ def diffusion_init(
}
xp = wgtfac_c.array_ns
if mask_hdiff is None:
mask_hdiff = gtx.zeros(cell_k_domain, dtype=xp.bool_)
mask_hdiff = gtx.zeros(cell_k_domain, dtype=xp.bool_, allocator=model_backends.get_allocator(actual_backend))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically Fortran said the array is not associated therefore we dummy allocate. Previously, we allocated for numpy which will give an error because even if the field is not used (actively) in the program it is passed over the interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hit this in the uncoupled r2b10 setup, which is a bit weird, because the fields should actually not be None. Maybe there is a rank where the mask is all False and the field does not get allocated on the Fortran side.

if zd_diffcoef is None:
zd_diffcoef = gtx.zeros(cell_k_domain, dtype=theta_ref_mc.dtype)
zd_diffcoef = gtx.zeros(cell_k_domain, dtype=theta_ref_mc.dtype, allocator=model_backends.get_allocator(actual_backend))
if zd_intcoef is None:
zd_intcoef = gtx.zeros(cell_c2e2c_k_domain, dtype=wgtfac_c.dtype)
zd_intcoef = gtx.zeros(cell_c2e2c_k_domain, dtype=wgtfac_c.dtype, allocator=model_backends.get_allocator(actual_backend))
if zd_vertoffset is None:
zd_vertoffset = gtx.zeros(cell_c2e2c_k_domain, dtype=xp.int32)
zd_vertoffset = gtx.zeros(cell_c2e2c_k_domain, dtype=xp.int32, allocator=model_backends.get_allocator(actual_backend))
# Metric state
metric_state = DiffusionMetricState(
mask_hdiff=mask_hdiff,
Expand Down Expand Up @@ -178,6 +178,7 @@ def diffusion_init(
model_backends.get_allocator(actual_backend)
),
)
gtx.wait_for_compilation()


@icon4py_export.export
Expand Down
1 change: 1 addition & 0 deletions tools/src/icon4py/tools/py2fgen/wrappers/dycore_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def solve_nh_init(
model_backends.get_allocator(actual_backend)
),
)
gtx.wait_for_compilation()


NumpyFloatArray1D: TypeAlias = Annotated[
Expand Down