generic interface real function vs real
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
generic interface real function vs real         


Author: mabrowning
Date: Apr 16, 2008 15:13

I am trying to create a subroutine that can either take a time
dependent function, or a constant.

It compiles and runs perfectly with GNU Fortran (GCC) 4.2.3, but ifort
(IFORT) 10.0 20070426 complains:

fortcom: Warning: generic.f90, line 13: The type/rank/keyword
signature for this specific procedure matches another specific
procedure that shares the same generic-name. [FOO_SCALAR]
SUBROUTINE foo_scalar(A)
-------------------^

It looks like the function signature and the scalar signature are the
same? This doesn't seem to make sense!

---------------------------------------------------------------------------
example:
Show full article (1.10Kb)
13 Comments
Re: generic interface real function vs real         


Author: jamesgiles
Date: Apr 16, 2008 15:30

On Apr 16, 4:13 pm, mabrowning gmail.com> wrote:
> I am trying to create a subroutine that can either take a time
> dependent function, or a constant.
...

Unfortunately, the resolution of which specific to call is
based entirely and only on four criteria: 1) number of arguments,
and for each of those arguments 2) type, 3) KIND, and 4) rank.
In your example, both your functions accept only one argument,
and that argument is REAL, default KIND, and rank zero (scalar).
So, for the purposes of Fortran procedure overloading, those
functions are not usefully different.

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
no comments
Re: generic interface real function vs real         


Author: FX
Date: Apr 16, 2008 15:32

> It compiles and runs perfectly with GNU Fortran (GCC) 4.2.3, but ifort
> (IFORT) 10.0 20070426 complains

I was going to say that this is an Intel bug, because it looked OK to me
and other compilers certainly did accept it (Sun, gfortran, IBM) but
Lahey also complains. So, I looked into the F2003 standard and I think
that's what the last example (INTERFACE BAD9) of C.11.2 says: it is
unambiguous, but still invalid, because: "the rules do not distinguish on
the basis of any properties other than type, kind type parameters, and
rank".

Anyone willing to confirm/infirm this?

PS: the root cause for that might be the will to have some simpler rules,
but it is a bit sad if the example showed by the poster is invalid
(moreover, these rules *are* complex anyway).

--
FX
no comments
Re: generic interface real function vs real         


Author: nospam
Date: Apr 16, 2008 15:59

FX alussinan.org> wrote:
> "the rules do not distinguish on
> the basis of any properties other than type, kind type parameters, and
> rank".
>
> Anyone willing to confirm/infirm this?

That's correct. Thus the common abbreviation TKR (for type,kind, and
rank). That combination comes up enough to merit an abbreviation.
> PS: the root cause for that might be the will to have some simpler rules,
> but it is a bit sad if the example showed by the poster is invalid
> (moreover, these rules *are* complex anyway).

Indeed the rules are complex in that area. And there must be about a
dozen different proposals for enhancing the rules, including some
proposals that are directly incompatible with each other. That is
definitely an area where "this enhancement would be nifty" is nowhere
near a good enough selling point. It takes a lot of looking at the
cost/benefit, including the impact on other potential enhancements.
Show full article (1.13Kb)
no comments
Re: generic interface real function vs real         


Author: Steve Lionel
Date: Apr 16, 2008 17:52

Richard Maine wrote:
> FX alussinan.org> wrote:
>
>> "the rules do not distinguish on
>> the basis of any properties other than type, kind type parameters, and
>> rank".
>>
>> Anyone willing to confirm/infirm this?
>
> That's correct. Thus the common abbreviation TKR (for type,kind, and
> rank). That combination comes up enough to merit an abbreviation.
Show full article (0.97Kb)
no comments
Re: generic interface real function vs real         


Author: Herman D. Knoble
Date: Apr 17, 2008 05:37

Have you tried overloading (on arg type) ?

Skip Knoble

On Wed, 16 Apr 2008 15:13:54 -0700 (PDT), mabrowning gmail.com> wrote:

-|I am trying to create a subroutine that can either take a time
-|dependent function, or a constant.
-|
-|It compiles and runs perfectly with GNU Fortran (GCC) 4.2.3, but ifort
-|(IFORT) 10.0 20070426...
Show full article (1.35Kb)
no comments
Re: generic interface real function vs real         


Author: Gerry Ford
Date: Apr 17, 2008 21:43

"FX" alussinan.org> wrote in message
news:fu5up8$15hd$1@nef.ens.fr...
>> It compiles and runs perfectly with GNU Fortran (GCC) 4.2.3, but ifort
>> (IFORT) 10.0 20070426 complains
>
> I was going to say that this is an Intel bug, because it looked OK to me
> and other compilers certainly did accept it (Sun, gfortran, IBM) but
> Lahey also complains. So, I looked into the F2003 standard and I think
> that's what the last example (INTERFACE BAD9) of C.11.2 says: it is
> unambiguous, but still invalid, because: "the rules do not distinguish on
> the basis of any properties other than type, kind type parameters, and
> rank".

I think that TKR is the expression I've been reaching for when I wondered
what "type" the implementation gives. This from g95 had kind where it
should have type:

KIND types available in the g95 compiler (at the time of writing quad
precisison is not yet available).

+------------------+----------+------------------+--------------------------+--------------------------+ | Kind | Memory | Precision | Smallest value, TINY()| Largest value, HUGE...
Show full article (2.79Kb)
no comments
Re: generic interface real function vs real         


Author: FX
Date: Apr 18, 2008 01:00

[AS: Gerry, you might want to check on your newsreader settings; yours
posts often appear to me lacking newline characters, which makes them
quite hard to read. Also, it's easier if you use quoting the same as
others here, by prefixing each line you quote with a ">".]
>> Anyone willing to confirm/infirm this?
>
> You'll find that "infirm" in common parlance is an adjective

Indeed; I apologise. I was mislead by french where "infirm", in addition
to meaning ailing or disable, is also a verb that means something like
"contradict with a greater authority" (an appeal court would use it to
overrule the judgment of a lower court).

--
FX
no comments
Re: generic interface real function vs real         


Author: Craig Dedo
Date: Apr 18, 2008 05:07

"Steve Lionel" wrote in message
news:YaxNj.16048$vz2.11366@trndny05...
> Richard Maine wrote:
>> FX alussinan.org> wrote:
>>
>>> "the rules do not distinguish on
>>> the basis of any properties other than type, kind type parameters, and
>>> rank".
>>>
>>> Anyone willing to confirm/infirm this?
>>
>> That's correct. Thus the common abbreviation TKR (for type,kind, and
>> rank). That combination comes up enough to merit an abbreviation.
>
> Right. I recall this issue very well and wrote up the problem report, since
> earlier versions of ifort did allow this. The key, as Richard says, is that
> "procedureness" (my word) is not a distinguishing factor for generic
> resolution.
> --
> Steve Lionel ...
Show full article (1.51Kb)
no comments
Re: generic interface real function vs real         


Author: Craig Dedo
Date: Apr 18, 2008 05:31

"Craig Dedo" wi.rr.com> wrote in message
news:48088ef1$0$5719$4c368faf@roadrunner.com...
> "Steve Lionel" wrote in message
> news:YaxNj.16048$vz2.11366@trndny05...
>> Richard Maine wrote:
>>> FX alussinan.org> wrote:
>>>
>>>> "the rules do not distinguish on
>>>> the basis of any properties other than type, kind type parameters, and
>>>> rank".
>>>>
>>>> Anyone willing to confirm/infirm this?
>>>
>>> That's correct. Thus the common abbreviation TKR (for type,kind, and
>>> rank). That combination comes up enough to merit an abbreviation.
>>
>> Right. I recall this issue very well and wrote up the problem report, since
>> earlier versions of ifort did allow this. The key, as Richard says, is that
>> "procedureness" (my word) is not a distinguishing factor for generic
>> resolution. ...
Show full article (1.98Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
Hypergeometric functions and beta functionssci.math ·
1 2