ClimaLand.jl
ClimaLand.jl copied to clipboard
`filter_nt` reallocation
Is your feature request related to a problem? Please describe.
https://github.com/CliMA/ClimaLSM.jl/pull/431 fixed a bug in the state FieldVector structure, but also introduced a function filter_nt
. This function takes in a NamedTuple, and returns a new NamedTuple (reallocating) with all key/value pairs with value nothing
are removed. This is needed because initialize_vars
now maps a model component with no prognostic/auxiliary variables to nothing
. When a CanopyModel
has components that aren't prognostic (e.g. with prognostic hydraulics but not conductance), we need to filter out these components before constructing the FieldVector for Y
, to avoid nothing
s in Y
and maintain compatibility with ClimaTimesteppers.
filter_nt
is used in the CanopyModel
methods of initialize_prognostic
and initialize_auxiliary
, and duplicates the NamedTuples produced by initialize_vars
in these functions. This is not ideal because all of these values are reallocated. We should come up to an alternative solution to CanopyModel components not having prognostic variables that avoids this reallocation.