This is where the Fortran Standard Library (https://stdlib.fortran-lang.org/) could be hugely useful.
For example, matrix multiplication could be called as:
call stdlib_matmul(A=A, B=B, C=C)
call stdlib_matmul(OpA='T', A=A, B=B, C=C)
call stdlib_matmul(A=A, B=B, C=A) ! for in-place multiplication
call stdlib_matmul(alpha=alpha, beta=beta, A=A, B=B, C=C)
It would even handle the case given by @RonShepard with
call stdlib_matmul(A=A(i,j,:,:), B=B(k,l,:,:), C=C)
A matrix type could be defined which has all the information about the arrays such as type, dimension, sparcity etc. For example
A%n=100
A%m=100
A%field='complex'
A%precision='double'
A%structure='hermitian'
A%packed=.true.
A%upper='true'
The types and interfaces would be easily extendible without breaking backward compatibility.
Most of the work done by the Fortran Standard Library would be to provide a smart interface to BLAS. This seems to be ideally suited to Fortran with its optional arguments and meta-data passed when calling subroutines with explicit interfaces.
But why stop there? How about a smart interface to LAPACK, FFTW or the GSL?
For example again:
call stdlib_fft(a_in=z, direction='forward')
For an in-place, complex FFT. All the relevant information such as dimensions is passed by the interface. Or how about
call stdlib_fft(a_in=z, a_out=r, direction='backward', scale=.false.)
… for an out-of-place, complex to real FFT without scaling.
Eigenvalues and eigenvectors are another good example:
call stdlib_eigen(a=a, v=v, w=w, range=[0.d0,100.d0]).
call stdlib_eigen(a=a, w=w, num_threads=32)
call stdlib_eigen(a=a, w=w, target_device='GPU')
I think this is a much better way of adding truly useful functionality to Fortran without overburdening the compiler writers and ending up with ambiguous and tangled syntax.
(Just to be clear, the examples above are pure speculation as to how an stdlib interface might look)