Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: MethodError: no method matching initarray! on Julia v1.8.0-rc1 #2663

Closed
aramirezreyes opened this issue Jul 14, 2022 · 5 comments · Fixed by #2666
Closed

ERROR: MethodError: no method matching initarray! on Julia v1.8.0-rc1 #2663

aramirezreyes opened this issue Jul 14, 2022 · 5 comments · Fixed by #2666

Comments

@aramirezreyes
Copy link
Contributor

aramirezreyes commented Jul 14, 2022

This issue appears on v1.8.0-rc1 so I understand if it is not a priority.
Oceananigans version: So far reproduced in v0.76.6 and v0.76.5
To reproduce, in the REPL:
The error does not prevent the fields from been created but it is a pain to do interactive work with it.

pkg> activate --temp
pkg> add NetCDF_jll@400.802.103, Oceananigans 
#NCDatasets latest release does not work with v1.8.0-rc1
julia> using Oceananigans
julia> grid = RectilinearGrid(CPU(),size = (10, 10),
                                   x = (0, 100), y = (0, 100),
                                   topology = (Periodic, Periodic, Flat), halo = (3, 3))
julia> myfield = CenterField(grid)

Outputs:

Error showing value of type Field{Center, Center, Center, Nothing, RectilinearGrid{Float64, Periodic, Periodic, Flat, Float64, Float64, Float64, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, CPU}, Tuple{Colon, Colon, Colon}, OffsetArrays.OffsetArray{Float64, 3, Array{Float64, 3}}, Float64, FieldBoundaryConditions{BoundaryCondition{Oceananigans.BoundaryConditions.Periodic, Nothing}, BoundaryCondition{Oceananigans.BoundaryConditions.Periodic, Nothing}, BoundaryCondition{Oceananigans.BoundaryConditions.Periodic, Nothing}, BoundaryCondition{Oceananigans.BoundaryConditions.Periodic, Nothing}, Nothing, Nothing, BoundaryCondition{Oceananigans.BoundaryConditions.Flux, Nothing}}, Nothing, Oceananigans.Fields.FieldBoundaryBuffers{Nothing, Nothing, Nothing, Nothing}}:
ERROR: MethodError: no method matching initarray!(::SubArray{Float64, 3, Array{Float64, 3}, Tuple{UnitRange{Int64}, UnitRange{Int64}, UnitRange{Int64}}, false}, ::typeof(Base.add_sum), ::Bool, ::SubArray{Float64, 3, Array{Float64, 3}, Tuple{UnitRange{Int64}, UnitRange{Int64}, UnitRange{Int64}}, false})
Closest candidates are:
  initarray!(::AbstractArray{T}, ::Any, ::typeof(Base.add_sum), ::Bool, ::AbstractArray) where T at reducedim.jl:80
  initarray!(::AbstractArray{T}, ::Any, ::typeof(Base.mul_prod), ::Bool, ::AbstractArray) where T at reducedim.jl:80
  initarray!(::AbstractArray{T}, ::Any, ::Union{typeof(Base._extrema_rf), typeof(max), typeof(min)}, ::Bool, ::AbstractArray) where T at reducedim.jl:84
  ...
Stacktrace:
  [1] initialize_reduced_field!

I'm trying to figure out why would this fail in v1.8.0-rc1 but not on v1.7 but no luck so far.

@simone-silvestri
Copy link
Collaborator

We use that function to initialize a correct array before performing global reductions (i.e. all zeros for sums, all 1s for prods and so on...) which are called when showing a field (if you put a semicolon after myfield = CenterField(grid) the error will disappear) Apparently they have changed the signature of the function in julia-1.8. Adapting Oceananigans to the new initarray! was on the table, I guess it's a good time to fix it

@aramirezreyes
Copy link
Contributor Author

Makes sense. I suppose it would require dropping support for v1.7?

@simone-silvestri
Copy link
Collaborator

simone-silvestri commented Jul 15, 2022

Nono on 1.7 everything works fine, it's 1.8 where they changed initarray!. If possible for the moment you can work with 1.7 or 1.6, I ll fix this issue as soon as possible

@aramirezreyes
Copy link
Contributor Author

Seems to be introduced by JuliaLang/julia#43604

@simone-silvestri
Copy link
Collaborator

Thanks nice observation! that helps! Then we need two initarray! methods to support both julia versions. I ll deal with it tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants