Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
15 Views

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
Highlighted
15 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
Highlighted
Beginner
15 Views

OK. Thank you Steve for comprehensive info.
0 Kudos