Variable Templates
Types
ClimateMachine.VariableTemplates.Grad — TypeGrad{S,A,offset}(array::A)Defines property overloading along slices of the second dimension of array using the type S as a template. offset is used to shift the starting element of the array.
ClimateMachine.VariableTemplates.Vars — TypeVars{S,A,offset}(array::A)Defines property overloading for array using the type S as a template. offset is used to shift the starting element of the array.
Index methods
ClimateMachine.VariableTemplates.@vars — Macro@vars(var1::Type1, var2::Type2)A convenient syntax for describing a NamedTuple type.
Example
julia> @vars(a::Float64, b::Float64)
NamedTuple{(:a, :b),Tuple{Float64,Float64}}ClimateMachine.VariableTemplates.vuntuple — Functionvuntuple(f::F, N::Int)Val-Unroll ntuple: wrap ntuple arguments in Val for unrolling.
ClimateMachine.VariableTemplates.unroll_map — Function@unroll_map(f::F, N::Int, args...) where {F}
unroll_map(f::F, N::Int, args...) where {F}Unroll N-expressions and wrap arguments in Val.
ClimateMachine.VariableTemplates.flattened_tup_chain — Functionflattened_tup_chain(::Type{T}) where {T <: Union{NamedTuple,NTuple}}An array of tuples, containing symbols and integers for every combination of each field in the Vars array.
ClimateMachine.VariableTemplates.varsize — Functionvarsize(S)The number of elements specified by the template type S.
ClimateMachine.VariableTemplates.varsindices — Functionvarsindices(S, ps::Tuple)
varsindices(S, ps...)Return a tuple of indices corresponding to the properties specified by ps based on the template type S. Properties can be specified using either symbols or strings.
Examples
julia> S = @vars(x::Float64, y::Float64, z::Float64)
julia> varsindices(S, (:x, :z))
(1, 3)
julia> S = @vars(x::Float64, y::@vars(α::Float64, β::SVector{3, Float64}))
julia> varsindices(S, "x", "y.β")
(1, 3, 4, 5)ClimateMachine.VariableTemplates.varsindex — Functionvarsindex(S, p::Symbol, [sp::Symbol...])Return a range of indices corresponding to the property p and (optionally) its subproperties sp based on the template type S.
Examples
julia> S = @vars(x::Float64, y::Float64)
julia> varsindex(S, :y)
2:2
julia> S = @vars(x::Float64, y::@vars(α::Float64, β::SVector{3, Float64}))
julia> varsindex(S, :y, :β)
3:5