- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Within a scoping unit, two procedures that have the same generic name must both be subroutines (or both be functions). One of the procedures must have a nonoptional dummy argument that is one of the following:
- Not present by position or argument keyword in the other argument list
- Is present, but has different type and kind parameters, or rank
Within a scoping unit, two procedures that have the same generic operator must both have the same number of arguments or both define assignment. One of the procedures must have a dummy argument that corresponds by position in the argument list to a dummy argument of the other procedure that has a different type and kind parameters, or rank."
implicit none
private :: mod_big_int,mod_int_big,mod_big_big
integer(kind=4), parameter, public :: nr_of_decimal_digits = 100
logical(kind=1), parameter, private :: t=.true.,f=.false.
real, parameter, private :: log_base_10_of_radix = 0.30103
integer(kind=4), parameter, private :: &
d = digits(0)-1 , &
r = radix(0), &
base = r ** d, &
half_base = base/2
integer(kind=4), parame ter, public :: &
nr_of_digits = nr_of_decimal_digits / (log_base_10_of_radix * d) + 1
integer(kind=4),parameter,private, dimension(9):: tien=((/10,100,1000,10000,100000,1000000,10000000,100000000,1000000000/))
type, public :: big_integer
integer (kind=4), dimension(0 : nr_of_digits) :: digit
logical (kind=1) :: neg !** true means negative
logical (kind=1) :: zero !** true means number is zero
logical (kind=1) :: inf !** true means abs. value larger than huge
logical (kind=1) :: nan !** true means not a number (e.g. by illegal input)
end type big_integer
Big_Zero = big_integer((/ (0, n = 0, nr_of_digits) /),f,t,f,f )
module procedure mod_big_int, mod_int_big, mod_big_big
end interface
type(big_integer),intent(in)::b
type(big_integer):: q,br
integer(kind=4),intent(in)::i
integer(kind=4)::r
r=0
end function mod_big_int
type(big_integer), intent(in)::b
integer(kind=4), intent(in)::i
type(big_integer)::q,r
r=big_zero
end function mod_int_big
type(big_integer), intent(in)::x,y
type(big_integer)::q,r
r=big_zero
end function mod_big_big
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
module testI'll submit a Premier support issue (If I still recall my password :-D ).
implicit none
interface mood
module procedure mod_big_int
module procedure mod_int_big
end interface
contains
subroutine mod_big_int(b,i)
real,intent(in)::b
integer(kind=4),intent(in)::i
end subroutine mod_big_int
subroutine mod_int_big(i,b)
integer(kind=4), intent(in)::i
real, intent(in)::b
end subroutine mod_int_big
end module test
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
program main
use test
real b
integer i
call mood (b=b, i=i)
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Steve,
I apologize for being away and replying late, but we had a bereavement in the family.
I am a bit confused about the discussion that followed the problem I presented. My problem is, that the module cannot be compiled. So trying your test program is of no avail. Perhaps I missed an essential point in your and Jugoslav's replies.
Yours sincerely,
Niels H. Veldhuijzen
Cito, Arnhem, The Netherlands
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, sorry for your loss.
The bottom line is: your code is potentially ambiguous indeed, because both dummy arguments are named b and i in both routines. However, you can resolve the ambiguity by simply renaming at least one of them.
Regards,
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Jugoslav,
Thank you for your advice: my module can be compiled now.
I still think the problem is a (bit of a) bug. One of the great things in Fortran is that program units are independent of each other. So why should the compiler muse about argument names in different program units? The help file is not very helpful in this respect, I think.
Best wishes, Niels
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note that the compiler does not actually complain about the routines themselves it complains about correctness of the INTERFACE block, and if you'd take it out you'd get a compilable code. MODULE PROCEDURE keyword "imports" the declarations of routines, including argument names. This is somewhat akin to using same names for entities of different scoping units -- you may define a subrotine Foo in module M1 and module M2, but you can't use symbol Foo if you USE both M1 and M2 in the same unit. In this case, argument names and types (and I initially forgot about the former) are considered a part of routine signature, which must be unique within same generic interface block.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Jugoslav (and Steve),
OK, I rest my case. It IS a subtle matter, isn't it?
Thanks, and best wishes, Niels
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page