The following code does not compile (whichever the compiler):
program foobar
implicit none
integer :: x(100)
x = 1
call foo(x)
contains
subroutine foo(x)
integer, contiguous :: x(:)
call bar(x(10)) ! error here
end subroutine
subroutine bar(x)
integer :: x(*)
print*, x(1)
end subroutine
end
Error message:
If the actual argument is scalar, the dummy argument shall be scalar unless the actual argument is of type character or is an element of an array that is not assumed shape, pointer, or polymorphic.
I can see the reason for the “not assumed shape” restriction: if the dummy argument of foo
is assumed shape, then it can be discontiguous. bar
is expecting a contiguous array, which means that copy-in/copy-out should occur, but what should be copied is possibly ambiguous to the compiler.
However, the dummy argument of foo
is specified as contiguous
here, so that no copy-in/copy-out is required anyway.
Isn’t it a too strong restriction?