I wish automatic arrays whose shapes are the same as that of a procedure argument could be declared more concisely. If x is a 3-D procedure argument you can write
real :: y(size(x,1), size(x, 2), size(x, 3))
but it is verbose, and it’s possible to slip and unintentionally write
real :: y(size(x,1), size(x, 2), size(x, 2))
More concise and less error-prone would be
real :: y(shape(x))
This would be allowed if the rank of x is known at compile time, as it usually is. Another possible syntax is
real, mold(x) :: y
I know you can make y a local allocatable array and write
I should really read the F2023 draft when I get the chance. This is the second time in a week I am caught off guard about a new feature of Fortran, the first one was split.
While this is now valid, I’m still hesitant to recommend its use in declaring dummy arguments. Nothing verifies that the actual argument is the same shape. It can lead to weird bugs for multi-dimensional arrays, or flat out memory corruption in any case.