Matrix index-pointer confusion

Thanks for the keyword. Using the J3 interpretation document and reference BLAS I was able to make up a few test codes that worked as expected and got the hang of the notation.

Storage sequence association appears to be in the deprecated features part of Modern Fortran Explained (section A.8). Is there a reason for this? To illustrate the point, one of the test codes I made up was a subroutine to print a matrix. Its declaration looks like:

subroutine print_matrix(A, lda, m, n)
    integer, intent(in) :: lda, m, n
    double precision, intent(in) :: A(lda, *)
    ...
endsubroutine print_matrix

Calling it for say a 3 x 2 submatrix starting at position 3, 4 of the 8 x 8 matrix A would then look like call print_matrix(A(3, 4), 8, 3, 2). If I were to write a more “modern” version of this code, I would write:

subroutine print_matrix(A, m, n)
    integer, intent(in) :: m, n
    double precision, intent(in) :: A(m, n)
    ...
endsubroutine print_matrix

And call this for the same submatrix like call print_matrix(A(3:5, 4:5), 3, 2).

To me the second subroutine seems a lot more wasteful. I could be wrong on this, but since I am calling the second one with a slice, it would first create an array copy and work with that array, and then trash it at the end. The first subroutine would just work with the one array A, and not create or destroy space for it. I know the example isn’t perfect (it could work with just the array A and require 2 starting indices for the print, but I think this gets the point across).

I could be misunderstanding something here, but I feel the storage sequence association method is better than using array slices, and I don’t understand why it is deprecated.