Variable Templates

Types

ClimateMachine.VariableTemplates.GradType
Grad{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.

source

Index methods

ClimateMachine.VariableTemplates.@varsMacro
@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}}
source
ClimateMachine.VariableTemplates.varsindicesFunction
varsindices(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)
source
ClimateMachine.VariableTemplates.varsindexFunction
varsindex(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
source