I have a question regarding the interface definitions for assumed size.
Assume we have the following function (here just a dummy for what is a supposed to be written in C)
subroutine x(y)
implicit none
integer, dimension(*) :: y
print*, y(1)
end subroutine x
A working solution is
program does_compile1
implicit none
interface
subroutine x(y)
integer, dimension(*) :: y
end subroutine x
end interface
integer, dimension(3) :: a3
integer, dimension(3,3) :: a33
a3 = 3
a33 = 3
call x(a3)
call x(a33)
end program does_compile1
The following code, however, is rejected:
program does_not_compile
implicit none
interface x !< added the name here
subroutine x(y)
integer, dimension(*) :: y
end subroutine x
end interface x
integer, dimension(3,3) :: a33
a33 = 3
call x(a33)
end program does_not_compile
because there is no specific subroutine. I find this strange, because (*)
should match everything.
Interestingly, the following works:
program does_compile2
implicit none
interface x
subroutine x(y)
integer, dimension(*) :: y
end subroutine x
end interface x
integer, dimension(3) :: a3
a3 = 3
call x(a3)
end program does_compile2
This leaves me a little bit puzzled, because I thought that assumed size (*)
does not care about the rank. But here it seems that it implies rank 1.
Tested with ifx 2025.0.4
and gfortran 14.2.1
.