Hi, I want to ask a question about pass multi dimension array to subroutine.
I know there are three ways to achieve this goal. First is the explicit-shape dummy array
the example code is below:
subroutine foo(data, n, m) integer, intent(in) :: n, m integer,dimension(n,m), intent(in) :: data end subroutine foo
the second is assumed-shape dummy arrays, but this method require the explicit interface of the subroutine
subroutine foo(data) integer,dimension(:,:), intent(in) :: data end subroutine foo
the third is assumed-size dummy arrays, which declare all the dimension of the array except the last dimention.
subroutine foo(data) integer,dimension(5,*), intent(in) :: data end subroutine foo
I have some question:
1. the summarize above was right?
2. In the second method, I think the compiler actually pass the dimension method in the dummy argument, just like the stdcall reference calling convention, am i right?
3. How does the third method achieve the goal? I thought the compiler knew the total size of the array, the last dimension was calculated by division. am i right?
4. if the 3rd is right, how does the compiler know the total size of the array, especially when the subroutine is not explicit.