-
Notifications
You must be signed in to change notification settings - Fork 24
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
Prognostic and DiagnosticVariables array-agnostic #525
base: main
Are you sure you want to change the base?
Conversation
Problem, while this works (LowerTriangularMatrix on layer 1, time step 1) julia> progn.vor[:,1,1]
65×64 LowerTriangularMatrix{ComplexF32}:
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im … this doesn't julia> progn.vor[:,end,1]
ERROR: BoundsError: attempt to access 2144×2×2 Array{ComplexF32, 3} at index [1:2144, 64, 1] the |
This is a consequence of the LTA/LTM being a subtype of AbstractArray{T,4} in this case. What we did with the two ways of indexing is a of a hack to be fair, the LTA can't be a 3-dim and 4-dim at the same time that easily. As far as I know we could maybe redefine the behaviour of |
Does this actually appear in the dynamical core? Because the 3d indexing with leading colon does cause allocations, so it should be avoided anyway, or we can introduce a non-allocating view variarant. That's possible as well. In the end, I think we can just avoid using the |
Another alternative would be to do something a bit similar to EndpointRanges.jl and define a custom |
Okay that's interesting, thanks for looking into it. No we wouldn't really need to use I am generally not super sure about the whole two ways of indexing
I obviously don't want to keep changing things but I see somewhat an appeal to make our life easier with 2-4. But I'm wondering whether in the end we should first reimplement the gradients and transforms for |
Let's not overthink it, I would say. We defined Additionally we defined several functions so that the flat indexing with The alternative would be to swap the behaviour by making it a subtype of And so far, the only limitation that I can think of are those connected with Edit: Another way to look at is also that the way we have it currently implemented we gives us the matrix style indexing and some support for flat indexing. At the same time though we can also always directly index the |
As far as I can see it, EndpointRanges does even directly allow to define those as subtypes of their types. It's a pretty small package, so it wouldn't be too bad to depend on it. I could have a look at it some day. |
Sounds good, I could do a code review next week. I think the |
A draft superceding #493 to restructure the prognostic variables.
Includes
device
andArrayType
inSpectralGrid
the variables 3D/4D are now directly in prognostic variables, not nested in
.layers[1].timesteps[1]
or.surface
the type signature for
PrognosticVariables
however got a bit more complicated, maybe there's ways to simplify that