- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
[fortran]
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
[/fortran]
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just checked it, got "T" for ifort 12.1.2 and 13.0.1, gfortran 4.6.3 and "F" for ifort 14.0.1, all with default options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page