This program below with a cascaded optional array, which is assumed-rank in the last called routine, works fine with gfortran, but fails on execution with any version of ifort/ifx.
module foo
implicit none
contains
subroutine foo1(a)
real, intent(in), optional :: a(:)
call foo2(a)
end subroutine
subroutine foo2(a)
real, intent(in), optional :: a(..)
if (present(a)) then
print*, rank(a)
else
print*, "a not present"
end if
end subroutine
end module
program bar
use foo
implicit none
call foo1()
end
Different compilers have different ways to do a lot of things. You can try to write a 2D array say of random numbers with an implied do loop using the intel compiler and then see the result with gfortran !
FWIW, I think the program is standards conforming. However, when I turn on the stack trace (i.e. -g -traceback) I see the segfault coming from the beginning of foo1.