At one of the last J3 meetings, the following feature has passed:
The issue has some examples. What other examples would you use this in? I would like to see several diverse examples so that we can write a tutorial on this feature, as well as see if we need to submit some proposals to make this feature more useful.
For example, right now it would allow to write code like this (see the issue for context):
subroutine max_at(x, q1, q2, q3, vec)
real, intent(in) :: x(..)
real, intent(in) :: q1(..)
real, intent(in) :: q2(..)
real, intent(in) :: q3(..)
real, intent(out) :: vec(3)
integer, allocatable :: idx(:)
select rank(x)
rank(2)
idx = maxloc(x)
vec = [q1(@idx), q2(@idx), q3(@idx)]
rank(3)
idx = maxloc(x)
vec = [q1(@idx), q2(@idx), q3(@idx)]
rank(4)
idx = maxloc(x)
vec = [q1(@idx), q2(@idx), q3(@idx)]
end select
end subroutine
Wouldn’t it make sense to submit a proposal to allow writing it like this?
subroutine max_at(x, q1, q2, q3, vec)
real, intent(in) :: x(..)
real, intent(in) :: q1(..)
real, intent(in) :: q2(..)
real, intent(in) :: q3(..)
real, intent(out) :: vec(3)
integer :: idx(rank(x))
idx = maxloc(x)
vec = [q1(@idx), q2(@idx), q3(@idx)]
end subroutine
(No allocatable, thus faster, and no select rank
construct, thus shorter.)