- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Both ifort and ifx don't accept using a parameter integer declared within the module to be used in function declarations.
This is the minimized reproducer:
module aaa
implicit none
integer, parameter :: dp = selected_real_kind(15)
interface
real(dp) module function foo(x)
real(dp) :: x
end function foo
end interface
end module aaa
submodule(aaa) bbb
implicit none
contains
real(dp) module function foo(x)
real(dp) :: x
foo = x
end function foo
end submodule bbb
$ ifx -c sub.f90
sub.f90(5): error #6683: A kind type parameter must be a compile-time constant. [DP]
real(dp) module function foo(x)
---------^
sub.f90(11): error #8765: Error in opening the compiled ancestor module file. [AAA]
submodule(aaa) bbb
----------^
sub.f90(14): error #6683: A kind type parameter must be a compile-time constant. [DP]
real(dp) module function foo(x)
-------^
sub.f90(14): error #6115: A separate interface body must have been declared in the program unit or an ancestor of the program unit for the separate module procedure. [FOO]
real(dp) module function foo(x)
---------------------------^
sub.f90(15): error #6683: A kind type parameter must be a compile-time constant. [DP]
real(dp) :: x
---------^
compilation aborted for sub.f90 (code 1)
$ ifort -c sub.f90
sub.f90(5): error #6683: A kind type parameter must be a compile-time constant. [DP]
real(dp) module function foo(x)
---------^
sub.f90(11): error #8765: Error in opening the compiled ancestor module file. [AAA]
submodule(aaa) bbb
----------^
sub.f90(14): error #6683: A kind type parameter must be a compile-time constant. [DP]
real(dp) module function foo(x)
-------^
sub.f90(14): error #6115: A separate interface body must have been declared in the program unit or an ancestor of the program unit for the separate module procedure. [FOO]
real(dp) module function foo(x)
---------------------------^
sub.f90(15): error #6683: A kind type parameter must be a compile-time constant. [DP]
real(dp) :: x
---------^
compilation aborted for sub.f90 (code 1)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please submit a support request toward bug resolution at Intel OSC if you have support subscription:
https://supporttickets.intel.com/servicecenter?lang=en-US
In the meantime, please consider using the RESULT clause as shown below as a workaround (by the way, please seek employing dummy argument INTENT in your actual codes in case you don't have them):
module aaa
implicit none
integer, parameter :: dp = selected_real_kind(15)
interface
module function foo(x) result(r)
real(dp), intent(in) :: x
real(dp) :: r
end function foo
end interface
end module aaa
submodule(aaa) bbb
implicit none
contains
module function foo(x) result(r)
real(dp), intent(in) :: x
real(dp) :: r
r = x
end function foo
end submodule bbb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I wouldn't post here if I have support subscription.
Thanks for the proposed workaround.
I always use intent(in), intent(out), pure, elemental...etc in my program But since It's just a minimal example I didn't bother adding those attributes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your code is lacking an import statement:
module aaa
implicit none
integer, parameter :: dp = selected_real_kind(15)
interface
real(dp) module function foo(x)
import :: dp !<== need to import the parameter explicitly
real(dp) :: x
end function foo
end interface
end module aaa
submodule(aaa) bbb
implicit none
contains
real(dp) module function foo(x)
real(dp) :: x
foo = x
end function foo
end submodule bbb
With this Intel Fortran does accept the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The gfortran compiler accepts the original code, but it seems to me that this is inconsistent with other interface declarations, where you do need to import a symbol like dp. I do not know which one is right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your posts here perhaps reveal the root cause of the issue with Intel Fortran compiler i.e., the compiler developer(s) too have not looked adequately into the standard even though the change has only been in effect for over a dozen years now!
The key aspect to notice in the reproducer in the original post is the MODULE clause with the function `foo`. This is part of the functionality introduced way back in Fortran 2008 to support SUBMODULEs. With such MODULE subprograms, the scoping rules are different and the IMPORT statement is not needed. You could have realized this also from the workaround I posted upthread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hm, I overlooked your workaround. So, the analysis of the code for submodules is only partially wrong. Still a bug though ;).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I filed a bug report, CMPLRLLVM-36605, for you.
And, yes, you see the same messages with ifort and ifx since they share the same front-end.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I compiled with ifx and ifort that were released last week with 2024.1. Those erroneous error messages are gone.
Please try the new compilers.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page