Tracers rework #100
Replies: 5 comments 3 replies
-
Design for Bundling finite elements in and off stencilsWe will run with the Tracers idea here, but this is re-usable for any finite list of items that is mapped on the grid. The dual issueRight now we have @gtscript.stencil(...)
def stencil_operating_on_q(q: FloatField, ...):
with computation(PARALLEL), interval(...):
... # preamble calculation
... q ...
@gtscript.stencil(...)
def stencil_operating_on_ice_and_snow(qsnow: FloatField, qice: FloatField, ...):
with computation(PARALLEL), interval(...):
qsnow = ... qice ...
def solver(tracers: dict):
for tracer in tracers:
stencil_operating_on_q(tracer)
stencil_operating_on_ice_and_snow(tracers["snow"], tracers["ice"] ➕
➖
In physics (PBL, UW, Aerosol Activation, ...) we have a lot of need for in-stencil computation which are done using a 4D array (with data dimensions), e.g.: @gtscript.stencil(...)
def physics_stencil(q: FloatField4D, n_tracers:int, index_for_ice: int ...):
with computation(PARALLEL), interval(...):
... # preamble calculation
while i_tracer < n_tracers:
q[0, 0, 0][i_tracer] = ...
...
q[0, 0, 0][index_for_ice] = ... ➕
➖
Some embryos of solutionsIt seems both are valid use cases. We would need to work torward unifying the frontend for both, which would require First option is to allow in-stencil for looping + name index testing, e.g. @gtscript.stencil(...)
def stencil(tracers: FloatFieldList):
with computation(PARALLEL), interval(...):
for q in tracers:
if q.name == "tke":
q = ...
else:
q = ... Another form of the above, with a more verbose approach that could hide some of the implementing detail a little bit more. Requires element indexing via string in stencil and custom iterators @gtscript.stencil(...)
def stencil(tracers: FloatFieldList):
with computation(PARALLEL), interval(...):
for q in tracers.exclude(["tke"]):
q = ...
tracers["tke"] = ... Both those try to combine pros and leaves cons aside, allowing performance tuning while retaining off-stencil capacity and verbosity. |
Beta Was this translation helpful? Give feedback.
-
Ping @bensonr @fmalatino This the beginning of a larger discussion to be had in the new year to evolve the concepts around list of float fields (like tracers) to match both in and off stencil usage. |
Beta Was this translation helpful? Give feedback.
-
PR for Part 1: NOAA-GFDL/PyFV3#37 |
Beta Was this translation helpful? Give feedback.
-
An issue arise with the If you write for key, value in my_dict.items():
if key in exlude_list:
pass
else:
stencil(value) You get the code that you expect but the The system allows you to specify |
Beta Was this translation helpful? Give feedback.
-
@FlorianDeconinck - I'm late to the discussion as I try to recover my inbox from time off at the end of the year. Knowing we are reading in the tracers as yaml key-value pairs, how are we going to define the tracers that fall into the various classes that have been maintained within the original FV3 - namely hydrometeor tracers (vapor, water, frozen, etc.), chemistry tracers, non-advected (prognostic and diagnostic), as well as number quantities? |
Beta Was this translation helpful? Give feedback.
-
As part of the work to up-skill the dynamics (GEOS-ESM/PyFV3#4) we need to be able to advect N tracers. This echoes a larger issue where the tracers in dynamics have been fixed (with downstream effects on both
pyFV3
andNDSL
) as a dictionary ofquantities
, but physics are currently implementing some as a 4 dimensional array where the tracers are the 4th D.Two goals emerge for the rework
Therefore we propose the following plan:
dynamics
Timeline:
Below we keep notes for the re-design.
Authors: @oelbert @twicki @FlorianDeconinck
Beta Was this translation helpful? Give feedback.
All reactions