- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- A non-elemental specific interface defined in the scoping unit or made accessible by USE
- An elemental specific interface defined in the scoping unit or made accessible by USE
- If the name appears with the INTRINSIC attribute or comes through USE association where it has INTRINSIC, then the intrinsic
- If there is a host scoping unit, repeat 1-3 for each host up the line
- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK. Thank you Steve for comprehensive info.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page