Re: Derived type argument to subroutine
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Wed, 16 Apr 2008 20:18:22 -0700
Gib Bogle <g.bogle@xxxxxxxxxxxxxxxxxxxxxx> wrote:
My question is motivated by concern about performance. I assume that
when I pass a variable that is a derived type as an argument to a
subroutine, is it passed by reference, just as fundamental types are.
1. The standard does not specify that *ANYTHING* is passed by reference.
In practice, they often, but not always are. It is just plain incorrect
to say that "fundamental types are passed by reference". While they
sometimes are, they sometimes aren't. There are even some cases where
they pretty much cannot be.
2. However, that being said, it is just as likely that a derived type
object will be passed by reference. For the most part, the issues simply
don't have much to do with type. It is things orthogonal to type that
are much more important to the question of how arguments are passed. If
anything, to the extent that type matters, I would say that it is the
fundamental types that have greater odds of being passed by something
other than reference.
3. But as you say that your question is motivated by performance issues,
I'd say that you have expressed it in terms that don't really capture
that. Presumably, you don't really care so much about whether it is
passed by reference as whether it has performance comparable to that
expected of pass-by-reference. The answer to that is basically yes.
4. But to reiterate a point made above - a really, really important
point worthy of reiteration - type is *NOT* the most important factor
here. You can get copy-in/copy-out argument passing that can (in some
cases) cause really horrid performance. But the things that typically
trigger that have nothing to do with type. They have much more to do
with array issues and apply to all types.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: Derived type argument to subroutine
- From: Arno
- Re: Derived type argument to subroutine
- From: Gib Bogle
- Re: Derived type argument to subroutine
- References:
- Derived type argument to subroutine
- From: Gib Bogle
- Derived type argument to subroutine
- Prev by Date: Re: Sun Fortran on DVD
- Next by Date: Re: Derived type argument to subroutine
- Previous by thread: Derived type argument to subroutine
- Next by thread: Re: Derived type argument to subroutine
- Index(es):
Relevant Pages
|