I built a new ‘climatedynamics’ component in Jupyter notebook for FUND with a 2-box ocean model adjusted to match climate modes. The component runs without error. The first few lines are;
@defcomp climatedynamics begin
# 2-box climate model
radforc = Parameter(index=[time])
temp = Variable(index=[time])
tempocean = Variable(index=[time])
deeplayer = Parameter()
climatesensitivity = Parameter()
function run_timestep(p, v, d, t)
heatcapdeep = 0.7 * deeplayer * 4180000.0
The next cell is:
replace!(m, :climatedynamics => climatedynamics)
That ran without errors and gave an output of 5760 words!
The next cell is:
set_param!(m, :climatesensitivity, 1.5)
set_param!(m, :deeplayer, 1200)
run(m)
The response was:
UndefVarError: deeplayer not defined
Stacktrace:
[1] run_timestep_Main_climatedynamics(::Mimi.ComponentInstanceParameters{NamedTuple{(:radforc, :deeplayer, :climatesensitivity),Tuple{Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},1,1},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64}}}}, ::Mimi.ComponentInstanceVariables{NamedTuple{(:temp, :tempocean),Tuple{Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},1,1},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},1,1}}}}, ::Mimi.DimValueDict, ::Mimi.FixedTimestep{1950,1,3000}) at C:\Users\Ken.julia\packages\Mimi\mHt54\src\core\defcomp.jl:21
[2] run_timestep(::Mimi.LeafComponentInstance{Mimi.ComponentInstanceVariables{NamedTuple{(:temp, :tempocean),Tuple{Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},1,1},Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},1,1}}}},Mimi.ComponentInstanceParameters{NamedTuple{(:radforc, :deeplayer, :climatesensitivity),Tuple{Mimi.TimestepArray{Mimi.FixedTimestep{1950,1,LAST} where LAST,Union{Missing, Float64},1,1},Mimi.ScalarModelParameter{Float64},Mimi.ScalarModelParameter{Float64}}}}}, ::Mimi.Clock{Mimi.FixedTimestep}, ::Mimi.DimValueDict) at C:\Users\Ken.julia\packages\Mimi\mHt54\src\core\instances.jl:277
[3] run_timestep(::Mimi.ModelInstance, ::Mimi.Clock{Mimi.FixedTimestep}, ::Mimi.DimValueDict) at C:\Users\Ken.julia\packages\Mimi\mHt54\src\core\instances.jl:286
Can you see why this doesn’t work?