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

Q about name conflict with intrinsic function

Witold_I_
Beginner
321 Views
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
Steven_L_Intel1
Employee
321 Views

Section 12.5.5.2 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.

0 Kudos
Witold_I_
Beginner
321 Views
OK. Thank you Steve for comprehensive info.
0 Kudos
Reply