GridTools/gt4py

Fix Implicit Stencil Arguments

philip-paul-mueller opened this issue · 1 comments

The issue affects an ICON stencil calculate_diagnostics_for_turbulence (model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/stencils/calculate_diagnostics_for_turbulence.py) which look as:

@field_operator
def _calculate_diagnostics_for_turbulence(
    div: Field[[CellDim, KDim], vpfloat],
    kh_c: Field[[CellDim, KDim], vpfloat],
    wgtfac_c: Field[[CellDim, KDim], vpfloat],
) -> tuple[Field[[CellDim, KDim], vpfloat], Field[[CellDim, KDim], vpfloat]]:
    ...
    return astype((div_ic_wp, hdef_ic_wp), vpfloat)


@program(grid_type=GridType.UNSTRUCTURED)
def calculate_diagnostics_for_turbulence(
    div: Field[[CellDim, KDim], vpfloat],
    kh_c: Field[[CellDim, KDim], vpfloat],
    wgtfac_c: Field[[CellDim, KDim], vpfloat],
    div_ic: Field[[CellDim, KDim], vpfloat],
    hdef_ic: Field[[CellDim, KDim], vpfloat],
):
    _calculate_diagnostics_for_turbulence(
    	div, kh_c, wgtfac_c,
    	out=(
    		div_ic[:, 1:],
    		hdef_ic[:, 1:]
    	)
    )

Baseline ITIR to SDFG translator uses itir.params to determine the input arguments.
However, instead of the expected 5 arguments (the fields) there are ten more, i.e. two for every field with the names __${FIELD_NAME}__size_{0, 1}.
I suspect that it is caused by the slicing of the output parameter, but I am not sure.
I looked through the tests and found similar, but they are all in cartesian, at least the only one I found.

Since these arguments are implicitly generated, the current DaCe backend fails to handle them.

These arguments are always added unless there is an explicit domain keyword argument in the field operator call of the program. See here:

if any("domain" not in body_entry.kwargs for body_entry in node.body):

They are used to specify the size of the output domain on itir level. Closing as this is not a GT4Py issue as discussed. Feel free to reopen.