Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Internal compiler error

mhermanns
Beginner
854 Views
When I try to compile the following example, which constructs a generic procedure using another generic procedure, the compiler aborts with an internal error. I have tried the same example with the compilers of Compaq on Alpha and Windows and in both cases they give an error message, although its content is not very useful.

!----------------------------------------------------------------!
module Example
implicit none

interface Generic_Sub23
module procedure Sub2
module procedure Sub3
end interface Generic_Sub23

interface Generic_Sub
module procedure Sub1
module procedure Generic_Sub23
end interface Generic_Sub

contains
!------------------------------------!
subroutine Sub1(z)
complex, intent(in) :: z

end subroutine Sub1
!------------------------------------!
subroutine Sub2(x)
real, intent(in) :: x

end subroutine Sub3
!------------------------------------!
end module Example
!----------------------------------------------------------------!
program prueba
use Example
implicit none

integer :: x
real :: y
complex :: z

call Generic_Sub(x)
call Generic_Sub(y)
call Generic_Sub(z)

end program prueba
!----------------------------------------------------------------!
0 Kudos
9 Replies
mhermanns
Beginner
854 Views
Ups, skipped some lines while copying the example file. Here is the correct/complete version:

!----------------------------------------------------------------!
module Example
implicit none

interface Generic_Sub23
module procedure Sub2
module procedure Sub3
end interface Generic_Sub23

interface Generic_Sub
module procedure Sub1
module procedure Generic_Sub23
end interface Generic_Sub

contains
!------------------------------------!
subroutine Sub1(z)
complex, intent(in) :: z

end subroutine Sub1
!------------------------------------!
subroutine Sub2(x)
real, intent(in) :: x

end subroutine Sub2
!------------------------------------!
subroutine Sub3(y)
integer, intent(in) :: y

end subroutine Sub3
!------------------------------------!
end module Example
!----------------------------------------------------------------!
program prueba
use Example
implicit none

integer :: x
real :: y
complex :: z

call Generic_Sub(x)
call Generic_Sub(y)
call Generic_Sub(z)

end program prueba
!----------------------------------------------------------------!
0 Kudos
Steven_L_Intel1
Employee
854 Views
Please report all such issues to Intel Premier Support.
0 Kudos
Steven_L_Intel1
Employee
854 Views
Someone else reported it for you.
This program is illegal - the language does not allow a generic name to appear in a MODULE PROCEDURE declaration. "A module procedure is a procedure that is defined by a module subprogram (R213)." R213 says that a module-subprogram is either a function-subprogram or a subroutine-subprogram.
0 Kudos
mhermanns
Beginner
854 Views
>> Please report all such issues to Intel Premier Support. <<

Took note of that for the next time, thanks :-)

>> "A module procedure is a procedure that is defined by a module subprogram (R213)." <<

Thanks also for pointing me to that. I was looking into the Fortran95 standard without finding a clear answer and so I just tried it out.

Miguel
0 Kudos
forall
Beginner
854 Views
So are you saying you cant overload an overloaded procedure? An indirect way of achieving such a result is to define a procedure procm in module m that calls the overloaded procedure procn. then one can overload procm onto anything else. of course it kind of defeats the purpose since multiple instances of procm may then be needed.
0 Kudos
Steven_L_Intel1
Employee
854 Views
You can extend an existing generic by creating your own generic interface of the same name with an additional module procedure. The compiler will then merge them, assuming all of the specific procedures have unambiguous signatures. You don't do this by giving the generic name as a module procedure.
For example, say you had:
module a
interface foo
module procedure foo_int
end interface foo
contains
subroutine foo_int (arg)
integer arg
...
end subroutine foo_int
end module a
Now you can do this:
module b
use a
interface foo
module procedure foo_real
end interface foo
contains
subroutine foo_real (arg)
real arg
...
Get it?
0 Kudos
mhermanns
Beginner
854 Views
>> You can extend an existing generic by creating your own generic interface of the same name with an additional module procedure. <<

Didn't know that. Very interesting. Is it something defined in the Fortran standard or an enhancement of the intel compiler?

The problem I'm trying to address cannot be solved with the above idea. It solves the example I have used, but not the real case :-(, where I need to not only extend a generic name, but also rename it.

Would it work if the generic interface to be renamed and extended would be in a different module and then rename it through the USE statement? In that case it should work, or?. I will try and let you know.

Miguel
0 Kudos
Steven_L_Intel1
Employee
854 Views
It is a standard feature and it works (or is supposed to work, anyway!) with renaming. This is a part of the language that trips up a lot of compilers, so if you encounter problems, do let us know.
0 Kudos
mhermanns
Beginner
854 Views
I have tried the following example with total success :-):

!-------------------------------------------------------------!
module Original_One
implicit none

interface Original_Generic
module procedure Real_Values
module procedure Complex_Values
end interface

contains
!----------------------------------!
subroutine Real_Values(x)
real, intent(in) :: x

write(*,*) "Real"

end subroutine Real_Values
!----------------------------------!
subroutine Complex_Values(x)
complex, intent(in) :: x

write(*,*) "Complex"

end subroutine Complex_Values
!----------------------------------!
end module Original_One
!-------------------------------------------------------------!
module Extended_One
use Original_One, Extended_Generic => Original_Generic
implicit none

interface Extended_Generic
module procedure Integer_Values
end interface

contains
!----------------------------------!
subroutine Integer_Values(x)
integer, intent(in) :: x

write(*,*) "Integer"

end subroutine Integer_Values
!----------------------------------!
end module Extended_One
!-------------------------------------------------------------!
program Example
use Extended_One
implicit none

integer :: x
real :: y
complex :: z

call Extended_Generic(x)
call Extended_Generic(y)
call Extended_Generic(z)

end program Example
!-------------------------------------------------------------!
0 Kudos
Reply