Mimi Framework

Line numbers in `run_timestep`

I’ve noticed that after Mimi changed to move run_timestep to within the component definition, I only rarely get line numbers for errors. Is there anything that can be done about that?

Hi James, do you mean when there are errors within the run_timestep function you don’t get line numbers for those errors? I previously noticed that due to macro expansion the line numbers were not helpful, which lead to this PR: https://github.com/mimiframework/Mimi.jl/pull/404 … but hadn’t noticed line numbers for errors not showing up at all. Do you have an example by any chance?

I haven’t put together a minimal case, but here’s an example of the errors that I get:

ERROR: LoadError: ArgumentError: invalid index: FixedTimestep{24106,6,24112}(1) of type FixedTimestep{24106,6,24112}
Stacktrace:
 [1] to_index(::FixedTimestep{24106,6,24112}) at ./indices.jl:266
 [2] to_index(::Array{Union{Missing, Float64},3}, ::FixedTimestep{24106,6,24112}) at ./indices.jl:247
 [3] to_indices at ./indices.jl:294 [inlined]
 [4] to_indices at ./multidimensional.jl:581 [inlined] (repeats 2 times)
 [5] to_indices at ./indices.jl:290 [inlined]
 [6] view(::Array{Union{Missing, Float64},3}, ::Function, ::Function, ::FixedTimestep{24106,6,24112}) at ./subarray.jl:146
 [7] maybeview(::Array{Union{Missing, Float64},3}, ::Function, ::Vararg{Any,N} where N) at ./views.jl:124
 [8] dotview(::Array{Union{Missing, Float64},3}, ::Function, ::Function, ::Vararg{Any,N} where N) at ./broadcast.jl:1074
 [9] dotview(::Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},3,3}, ::Function, ::Function, ::Vararg{Any,N} where N) at /Users/jrising/.julia/dev/Mimi/src/core/time.jl:403
 [10] run_timestep_UnivariateAgriculture(::Mimi.ComponentInstanceParameters{NamedTuple{(:totalareas, :yield, :irrigation_rate),Tuple{Array{Float64,3},Array{Float64,4},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Float64,4,4}}}}, ::Mimi.ComponentInstanceVariables{NamedTuple{(:totalareas2, :allagarea, :totalirrigation, :yield2, :production, :opcost, :unicultivationcost, :production_sumregion, :area_sumregion),Tuple{Array{Float64,3},Array{Float64,2},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},3,3},Array{Float64,4},Array{Float64,4},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},3,3},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},3,3},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},3,3},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},2,2}}}}, ::Mimi.DimDict, ::FixedTimestep{24106,6,24112}) at /Users/jrising/.julia/dev/Mimi/src/core/defcomp.jl:0
 [11] run_timestep(::Mimi.ComponentInstance{Mimi.ComponentInstanceVariables{NamedTuple{(:totalareas2, :allagarea, :totalirrigation, :yield2, :production, :opcost, :unicultivationcost, :production_sumregion, :area_sumregion),Tuple{Array{Float64,3},Array{Float64,2},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},3,3},Array{Float64,4},Array{Float64,4},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},3,3},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},3,3},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},3,3},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Union{Missing, Float64},2,2}}}},Mimi.ComponentInstanceParameters{NamedTuple{(:totalareas, :yield, :irrigation_rate),Tuple{Array{Float64,3},Array{Float64,4},Mimi.TimestepArray{FixedTimestep{24106,6,LAST} where LAST,Float64,4,4}}}}}, ::Mimi.Clock{FixedTimestep}) at /Users/jrising/.julia/dev/Mimi/src/core/instances.jl:264
 [12] _run_components(::ModelInstance, ::Mimi.Clock{FixedTimestep}, ::Array{Int64,1}, ::Array{Int64,1}, ::Array{Mimi.Clock{FixedTimestep},1}) at /Users/jrising/.julia/dev/Mimi/src/core/instances.jl:277
 [13] run(::ModelInstance, ::Int64, ::Nothing) at /Users/jrising/.julia/dev/Mimi/src/core/instances.jl:313
 [14] #run#114(::Int64, ::Nothing, ::Function, ::Model) at /Users/jrising/.julia/dev/Mimi/src/core/model.jl:399
 [15] run(::Model) at /Users/jrising/.julia/dev/Mimi/src/core/model.jl:390
 [16] top-level scope at util.jl:156
 [17] include at ./boot.jl:317 [inlined]
 [18] include_relative(::Module, ::String) at ./loading.jl:1044
 [19] include(::Module, ::String) at ./sysimg.jl:29
 [20] include(::String) at ./client.jl:392
 [21] top-level scope at none:0
in expression starting at /Users/jrising/research/water/awash/test/test_simulate.jl:14

The line number reference is to defcomp.jl, line 0. [Don’t worry about the particular error-- it happens with lots of errors, but I’m not sure what kinds.]

Note that this is on the time branch, into which I’ve merged the most recent changes on master.