CliMA / CliMA/ClimaCore.jl

Add support for lazy and eager broadcast expressions

Open
#1,605 5 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Julia
Stars
117
Forks
19
Avg merge
3d 4h
Merged PRs (30d)
41

Description

A common pattern that is seen in the ClimaAtmos diagnostics, and a desirable capability for unit tests and performance, is something this:
```julia
if isnothing(out)
return TD.dry_pottemp.(thermo_params, cache.precomputed.ᶜts)
else
out .= TD.dry_pottemp.(thermo_params, cache.precomputed.ᶜts)
end
```
What we are trying to do is this: when `out` is `nothing`, we want to allocate a new `Field` and return it. When `out` is a preallocated `Field`, we just want to use it. It would be really nice for ClimaCore to support this in a single `out .= something` expression.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the ClimaAtmos diagnostic pattern shown in the issue, especially the `out .= TD.dry_pottemp.(...)` expression and its `out === nothing` alternative. Determine how ClimaCore's broadcast expressions currently handle allocation and preallocated `Field` outputs. Done means one `out .= something` form supports both lazy allocation and eager reuse, with behavior suitable for unit tests and performance.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.