Showing results for 
Search instead for 
Did you mean: 

Q about name conflict with intrinsic function

Hello, What happens when module defines function or interface using the conflicting name of standard Fortran function (say RANDOM_NUMBER): module tm interface random_number module procedure my_random_number( ... ! other overloaded versions here (name the same) end interface contains subroutine my_random_number(dph) double precision,intent(out)::dph ... end subroutine random_number(dph) ... end module tm and then this module is to be used in say main unit: program t use tm double_precision::dprn call random_number(dpm) ... end program t What compiler and linker finally do in this conflicting situation? Are there any standard rules about it? Is there any syntax to avoid the problem (like fully qualified names in Java)? PS. Q is stupid, but this is the real code I have from 3rd party...
0 Kudos
2 Replies

Section of the

Section of the standard covers this. Your code extends the generic interface for the intrinsic. References to generics are resolved in this order:

  1. A non-elemental specific interface defined in the scoping unit or made accessible by USE
  2. An elemental specific interface defined in the scoping unit or made accessible by USE
  3. If the name appears with the INTRINSIC attribute or comes through USE association where it has INTRINSIC, then the intrinsic
  4. If there is a host scoping unit, repeat 1-3 for each host up the line
  5. Otherwise, the intrinsic

You can block the USE-associated generic extension with ONLY or a rename on the USE. To block host-associated extensions, use INTRINSIC.

Retired 12/31/2016
0 Kudos

OK. Thank you Steve for

OK. Thank you Steve for comprehensive info.
0 Kudos