Dear all,
I stumbled upon a compiler-error (or is it a restriction in the standard?) with passing optional arrays in mixed assumed- and explicit shape.
module m implicit none contains ! explicit shape optional subroutine take_optional(arg) integer, dimension(1), optional :: arg print *, present(arg) ! output is "F" end subroutine ! assumed shape optional subroutine pass_optional(arg) integer, dimension(:), optional :: arg call take_optional(arg) ! expects explicit shape end subroutine end module program p use m implicit none integer, dimension(1) :: arg arg = [1] call pass_optional(arg) end program
The assumed-shape array is passed to a second subroutine which expects explicit shape. It is however not present any more, and any attempt to access it will cause a runtime error. Compiler is ifort 14.0.1, all default options.
Your comments are appreciated.
With regards
Ferdinand