I have been trying to debug an ODE solver code that looks something like this:
u0 = zeros(100)
function f(u, p, t)
a, b, c, d = p
println("t = ", t)
# Applying BC and finding ODE RHS
apply_bc(u, a, b, c, d)
end
tspan = (0.0,500)
param = [A, B, C, D]
prob = ODEProblem(f, u0, tspan, param, saveat=10)
# Solving the ODEs
sol = solve(prob, lsoda()) #alg_hints=[:stiff])
I can run the code as it is, but debugging gives me the error below. I have breakpoints in the function apply_bc()
but it doesn’t even get there, since it doesn’t print the initial time.
ERROR: MethodError: no method matching iterate(::Type{Int32})
Closest candidates are:
iterate(::Union{LinRange, StepRangeLen}) at range.jl:664
iterate(::Union{LinRange, StepRangeLen}, ::Int64) at range.jl:664
iterate(::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} where {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s77"<:Dict} at dict.jl:693
...
Stacktrace:
[1] iterate
@ .\generator.jl:44 [inlined]
[2] collect(itr::Base.Generator{DataType, JuliaInterpreter.var"#56#57"{UnionAll, JuliaInterpreter.FrameData}})
@ Base .\array.jl:678
[3] map(f::Function, A::Type)
@ Base .\abstractarray.jl:2323
[4] evaluate_foreigncall(frame::JuliaInterpreter.Frame, call_expr::Expr)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:162
[5] eval_rhs(recurse::Any, frame::JuliaInterpreter.Frame, node::Expr)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:397
[6] step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, node::Any, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:541
[7] step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:591
[8] finish!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:14
[9] finish_and_return!
@ ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:30 [inlined]
[10] evaluate_call_recurse!(recurse::Any, frame::JuliaInterpreter.Frame, call_expr::Expr; enter_generated::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:240
[11] evaluate_call_recurse!
@ ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:201 [inlined]
[12] eval_rhs(recurse::Any, frame::JuliaInterpreter.Frame, node::Expr)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:395
[13] step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, node::Any, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:454
[14] step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:591
[15] finish!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:14
[16] finish_and_return!
@ ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:30 [inlined]
[17] evaluate_call_recurse!(recurse::Any, frame::JuliaInterpreter.Frame, call_expr::Expr; enter_generated::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:240
[18] evaluate_call_recurse!
@ ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:201 [inlined]
[19] eval_rhs(recurse::Any, frame::JuliaInterpreter.Frame, node::Expr)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:395
[20] step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, node::Any, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:541
--- the last 7 lines are repeated 7 more times ---
[70] step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:591
[71] finish!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:14
[72] finish_and_return!
@ ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:30 [inlined]
[73] evaluate_call_recurse!(recurse::Any, frame::JuliaInterpreter.Frame, call_expr::Expr; enter_generated::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:240
[74] evaluate_call_recurse!
@ ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:201 [inlined]
[75] eval_rhs(recurse::Any, frame::JuliaInterpreter.Frame, node::Expr)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:395
[76] step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, node::Any, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:536
[77] step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\interpret.jl:591
[78] finish!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:14
[79] finish_and_return!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:30
[80] finish_stack!(recurse::Any, frame::JuliaInterpreter.Frame, rootistoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:60
[81] debug_command(recurse::Any, frame::JuliaInterpreter.Frame, cmd::Symbol, rootistoplevel::Bool; line::Nothing)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:474
[82] debug_command(recurse::Any, frame::JuliaInterpreter.Frame, cmd::Symbol, rootistoplevel::Bool)
@ JuliaInterpreter ~\.julia\packages\JuliaInterpreter\6ExCh\src\commands.jl:416
[83] (::Atom.JunoDebugger.var"#54#56"{Bool, Bool, Bool})()
@ Atom.JunoDebugger ~\.julia\packages\Atom\5NgzM\src\debugger\stepper.jl:159
[84] evalscope(f::Atom.JunoDebugger.var"#54#56"{Bool, Bool, Bool})
@ Atom.JunoDebugger ~\.julia\packages\Atom\5NgzM\src\debugger\stepper.jl:392
[85] startdebugging(frame::JuliaInterpreter.Frame, initial_continue::Bool; istoplevel::Bool, toggle_ui::Bool)
@ Atom.JunoDebugger ~\.julia\packages\Atom\5NgzM\src\debugger\stepper.jl:157
[86] #invokelatest#2
@ .\essentials.jl:710 [inlined]
[87] (::Atom.JunoDebugger.var"#48#51"{Module, String, String, Bool, Int64})()
@ Atom.JunoDebugger ~\.julia\packages\Atom\5NgzM\src\debugger\stepper.jl:119
[88] hideprompt(f::Atom.JunoDebugger.var"#48#51"{Module, String, String, Bool, Int64})
@ Atom ~\.julia\packages\Atom\5NgzM\src\repl.jl:127
[89] #47
@ ~\.julia\packages\Atom\5NgzM\src\debugger\stepper.jl:84 [inlined]
[90] task_local_storage(body::Atom.JunoDebugger.var"#47#50"{Module, String, String, Bool, Int64}, key::Symbol, val::String)
@ Base .\task.jl:276
[91] debug_file(mod::String, text::String, path::String, should_step::Bool, line_offset::Int64)
@ Atom.JunoDebugger ~\.julia\packages\Atom\5NgzM\src\debugger\stepper.jl:83
[92] handlemsg(::Dict{String, Any}, ::String, ::Vararg{Any, N} where N)
@ Atom ~\.julia\packages\Atom\5NgzM\src\comm.jl:169
The same error shows up when I use alg_hints=[:stiff]
for the solver algorithm.
Is it, generally, possible to access and debug functions within the ODE solver like I would in MATLAB?
Thanks in advance!