Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28456 Discussions

problem importing abstract interface

MR
Beginner
335 Views
Hi all,
my impression is that this is a problem with ifort (the code compiles with gfortran).
When compiling the attached code with ifort I get:

import-problem.f90(31): error #6484: Global entities may not be used as IMPORT-name entities [I_F]
import :: i_f
-------------^
import-problem.f90(34): error #8169: The specified interface is not declared. [I_F]
procedure(i_f), pointer, intent(in) :: p
-------------^
compilation aborted for import-problem.f90 (code 1)

ifort -V
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20100414 Package ID: l_cprof_p_11.1.072
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.


module m1
implicit none
abstract interface
function i_f(x) result(y)
real, intent(in) :: x
real :: y
end function i_f
end interface
end module m1

module m2
use m1, only: i_f
implicit none
abstract interface
function i_g(x,p) result(y)
import :: i_f ! does not work
!use m1, only: i_f ! works fine
real, intent(in) :: x
procedure(i_f), pointer, intent(in) :: p
real :: y
end function i_g
end interface
end module m2

0 Kudos
3 Replies
John4
Valued Contributor I
335 Views

Seems like a bug related to the import statement itself ---hopefully, someone from Intel will confirm if it's indeed a compiler's bug.

As a workaround, use IMPORT statement without the import-name-list, e.g.:

[fortran]module m1
    implicit none
    abstract interface
        function i_f(x) result(y)
            real, intent(in) :: x
            real :: y
        end function i_f
    end interface
end module m1

module m2
    use m1, only: i_f
    implicit none
    abstract interface
        function i_g(x,p) result(y)
            import
            real, intent(in) :: x
            procedure(i_f), pointer, intent(in) :: p
            real :: y
        end function i_g
    end interface
end module m2[/fortran]

Funnily, in my case, gfortran is usually the one giving me trouble with abstract interfaces.

0 Kudos
Kevin_D_Intel
Employee
335 Views

I confirmed this is a defect in the current 11.1 release that is corrected in the next major release that will be available later this year.

Sorry for the inconvenience. You will need to employ one of the two noted workarounds for now.

0 Kudos
MR
Beginner
335 Views
John, Kevin, thank you for the comments.

Good to know that there is a fix and that it's coming soon!

Regards,
Marco
0 Kudos
Reply