Description
In stencils, any unknown variable is automatically assumed to be a temporary. In the context of NWP codes with cryptic argument names, it can easily happen that an "output argument" is misspelled. In that case, the variable is a temporary. In this case, we get faulty behavior and potentially needlessly allocated memory. We could detect scenarios where temporaries are written and not read afterwards. Such cases could be flagged and reported (as warnings/errors) to users of GT4Py.
The current behavior is that this kind of situation is undetected at the GT4Py level. Once code is generated, the underlying compiler of the target language of the backend might or might not raise warnings.
Example
Notice how qcu_s, qlu_s, qiu_s, xc_s, cin_s, cinlcl_s, cbmf_s, and qc_s are allocated as temporaries in the following stencil.
def adjust_implicit_CIN_inputs2(
condensation: BoolFieldIJ,
umf_s: FloatField,
umf_zint: FloatField,
dcm: FloatField,
qrten: FloatField,
qsten: FloatField,
cush: FloatFieldIJ,
cufrc: FloatField,
slflx_s: FloatField,
slflx: FloatField,
qtflx_s: FloatField,
qtflx: FloatField,
uflx_s: FloatField,
uflx: FloatField,
vflx_s: FloatField,
vflx: FloatField,
qcu: FloatField,
qlu: FloatField,
qiu: FloatField,
fer: FloatField,
fdr: FloatField,
xco: FloatField,
cin_IJ: FloatFieldIJ,
cinlcl_IJ: FloatFieldIJ,
cbmf: FloatField,
qc: FloatField,
qlten_det: FloatField,
qiten_det: FloatField,
qlten_sink: FloatField,
qiten_sink: FloatField,
ufrc_s: FloatField,
ufrc: FloatField,
dcm_s: FloatField,
qrten_s: FloatField,
qsten_s: FloatField,
qldet_s: FloatField,
qidet_s: FloatField,
qlsub_s: FloatField,
qisub_s: FloatField,
cush_s: FloatField,
cufrc_s: FloatField,
fer_s: FloatField,
fdr_s: FloatField,
iteration: int32,
):
"""
Part II of Adjust Implicit CIN Inputs
"""
with computation(FORWARD), interval(...):
if not condensation:
umf_s = umf_zint
umf_s[0, 0, 1] = umf_zint[0, 0, 1]
dcm_s = dcm
qrten_s = qrten
qsten_s = qsten
cush_s = cush
cufrc_s = cufrc
slflx_s = slflx
qtflx_s = qtflx
uflx_s = uflx
vflx_s = vflx
slflx_s[0, 0, 1] = slflx[0, 0, 1]
qtflx_s[0, 0, 1] = qtflx[0, 0, 1]
uflx_s[0, 0, 1] = uflx[0, 0, 1]
vflx_s[0, 0, 1] = vflx[0, 0, 1]
qcu_s = qcu
qlu_s = qlu
qiu_s = qiu
fer_s = fer
fdr_s = fdr
xc_s = xco
cin_s = cin_IJ
cinlcl_s = cinlcl_IJ
cbmf_s = cbmf
qc_s = qc
qldet_s = qlten_det
qidet_s = qiten_det
qlsub_s = qlten_sink
qisub_s = qiten_sink
ufrc_s = ufrc
ufrc_s[0, 0, 1] = ufrc[0, 0, 1]
Description
In stencils, any unknown variable is automatically assumed to be a temporary. In the context of NWP codes with cryptic argument names, it can easily happen that an "output argument" is misspelled. In that case, the variable is a temporary. In this case, we get faulty behavior and potentially needlessly allocated memory. We could detect scenarios where temporaries are written and not read afterwards. Such cases could be flagged and reported (as warnings/errors) to users of GT4Py.
The current behavior is that this kind of situation is undetected at the GT4Py level. Once code is generated, the underlying compiler of the target language of the backend might or might not raise warnings.
Example
Notice how
qcu_s,qlu_s,qiu_s,xc_s,cin_s,cinlcl_s,cbmf_s, andqc_sare allocated as temporaries in the following stencil.