Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

Still about generic interface from external procedures

$
0
0

I would like to put a question to those that work with the J3 and other committees that determine the standard.

Related to this thread:

https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux...

If I define a generic interface such as below:

module create_gen_int
implicit none
interface fun_gen
   real function fun_int(n)
   integer, intent(in) :: n
   end function fun_int
!***
   real function fun_real(x)
   real, intent(in) :: x
   end function fun_real
end interface fun_gen
end module create_gen_int

The code compiles without any problems.

However, if I move the interfaces to a separate block inside the same module and use "module procedure" in the generic, such as:

module create_gen_int2
implicit none
interface
   real function fun_int(n)
   integer, intent(in) :: n
   end function fun_int
!***
   real function fun_real(x)
   real, intent(in) :: x
   end function fun_real
end interface
!
interface fun_gen
   module procedure fun_int
   module procedure fun_real
end interface fun_gen
end module create_gen_int2

This is not accepted by the standard.  Ifort V. 16.0.3.210 generates the error:

create_gen_int2.f90(4): error #7950: Procedure name in MODULE PROCEDURE statement must be the name of accessible module procedure.   [FUN_INT]
   real function fun_int(n)

Gfortran also complains with an error message.

OTOH, if I move the interfaces to a separate module, such as:

module create_ints
implicit none
interface
   real function fun_int(n)
   integer, intent(in) :: n
   end function fun_int
!***
   real function fun_real(x)
   real, intent(in) :: x
   end function fun_real
end interface
end module create_ints
!*********************************
module create_gen_int3
use create_ints
implicit none
interface fun_gen
   module procedure fun_int
   module procedure fun_real
end interface fun_gen
end module create_gen_int3

This is also not valid according to the standard.  Ifort now issues the error:

create_gen_int3.f90(18): error #7950: Procedure name in MODULE PROCEDURE statement must be the name of accessible module procedure.   [FUN_INT]
   module procedure fun_int

My question is, why don't the standard accept the last two examples?  Since all of them do essentially the same thing?

 


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>