Bring back to life Julia 0.4 code

I am trying to port an older Julia 0.4 code that uses ODE.jl and I find it stumbles on this line

tout, aout = ode45((t,a)->F(t,a, N,p,q,m₀,n₀,J,σ,Ω,κ,f), a₀, [0., 10])

The code is a single, small file. The error I get is:

ERROR: LoadError: MethodError: no method matching Array(::Type{ComplexF64}, ::Int64)

Closest candidates are:
  Array(::LinearAlgebra.UniformScaling, ::Integer, ::Integer)
   @ LinearAlgebra ~/.julia/juliaup/

  [1] F(t::Float64, a::Vector{ComplexF64}, N::Int64, p::Int64, q::Int64, m₀::Int64, n₀::Int64, J::Float64, σ::Float64, Ω::Float64, κ::Float64, f::Vector{Float64})
    @ Main ~/Development/topo-condensate/runge-kutta.jl:27
  [2] (::var"#3#4")(t::Float64, a::Vector{ComplexF64})
    @ Main ~/Development/topo-condensate/runge-kutta.jl:110
  [3] hinit(F::var"#3#4", x0::Vector{ComplexF64}, t0::Float64, tend::Float64, p::Int64, reltol::Float64, abstol::Float64)
    @ ODE ~/.julia/packages/ODE/N5yvz/src/ODE.jl:91
  [4] oderk_adapt(fn::var"#3#4", y0::Vector{ComplexF64}, tspan::Vector{Float64}, btab_::ODE.TableauRKExplicit{:dopri, 7, Rational{Int64}}; reltol::Float64, abstol::Float64, norm::Function, minstep::Float64, maxstep::Float64, initstep::Int64, points::Symbol, alias_u0::Bool)
    @ ODE ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:292
  [5] oderk_adapt(fn::Function, y0::Vector{ComplexF64}, tspan::Vector{Float64}, btab_::ODE.TableauRKExplicit{:dopri, 7, Rational{Int64}})
    @ ODE ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:232
  [6] #ode45_dp#10
    @ ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:221 [inlined]
  [7] ode45_dp
    @ ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:221 [inlined]
  [8] #ode45#11
    @ ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:223 [inlined]
  [9] ode45(fn::Function, y0::Vector{ComplexF64}, tspan::Vector{Float64})
    @ ODE ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:223
 [10] top-level scope
    @ ~/Development/topo-condensate/runge-kutta.jl:110
in expression starting at /Users/berceanu/Development/topo-condensate/runge-kutta.jl:110

Any ideas on how to get this working with the current version of ODE.jl and Julia 1.9?

Cross posting: Backwards compatibility · Issue #180 · SciML/ODE.jl · GitHub

1 Like

The problem is in F. What happens when you call F separately from the ode solve?

The usual recommendation if your code works with Julia 0.4 is to try it with Julia 0.5. If you get deprecation warnings, fix those. Then step up through 0.6, 0.7, 1.0 and fix any warnings you get along they way. Juliaup makes it easy to install the historical versions.


Thanks, I did a few other changes in my file and now everything works on 1.9 :sunny: