- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The intel compiler does not accept the following code:
module mod_test
implicit none
public :: f
private
interface f
module procedure ff
end interface
contains
pure function ff(n)
real, allocatable :: ff(:)
integer, intent(in) :: n
allocate( ff(n) )
ff = 1.0
end function ff
end module mod_test
Both ifort (IFORT) 10.0 20070809 and
ifort (IFORT) 9.1 20061101 give
fortcom: Error: mod_test.f90, line 19: This name does not have a type, and must have an explicit type. [FF]
allocate( ff(n) )
------------^
fortcom: Error: mod_test.f90, line 16: This ALLOCATABLE attribute is invalid; the ALLOCATABLE attribute can only be used when declaring array objects. [FF]
real, allocatable :: ff(:)
-----------------------^
fortcom: Error: mod_test.f90, line 15: The array-spec for a function name with no POINTER attribute must be an explicit shape array (R505.9). [FF]
pure function ff(n)
---------------^
fortcom: Warning: mod_test.f90, line 15: The return value of this FUNCTION has not been defined. [FF]
pure function ff(n)
---------------^
fortcom: Error: mod_test.f90, line 15: If a deferred-shape array is intended, then the ALLOCATABLE or POINTER attribute is missing; if an assumed-shape array is intended, the array must be a dummy argument.
pure function ff(n)
---------------^
compilation aborted for mod_test.f90 (code 1)
My system: Gentoo Linux, x86_64 AMD Turion
Notice that the problem disappears if the interface
block is eliminated. I suspect this is a bug in
the compiler, but of course I would appreciate if
you could confirm it (g95 and gfortran accept the code).
Best regards,
Marco Restelli
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following works:
pure function ff(n) result(res)
real, allocatable ::res(:)
integer, intent(in) :: n
allocate(res(n) )
res = 1.0
end function ff
I need to do some more reading to see if the original code is legal, but the fact that the compiler doesn't complain if the generic interface is removed leads me to suspect a compiler bug.
pure function ff(n) result(res)
real, allocatable ::res(:)
integer, intent(in) :: n
allocate(res(n) )
res = 1.0
end function ff
I need to do some more reading to see if the original code is legal, but the fact that the compiler doesn't complain if the generic interface is removed leads me to suspect a compiler bug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe this to be a compiler bug and will let the developers know about it. Thanks.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page