Richard Maine writes:
> What I meant is exactly what I said - that Fortran does not specify
> pass-by-reference.
My question involves how this affects performance. I have a derived type that
consists of just a single array. With subroutines to define the operations on
the array, I then make an interface to override the arithmetic operators so that
the operations are easier to use in the user's program.
The interfaces are basically one-liners saying to pass the two arrays of the two
derived type arguments to the appropriate subroutine and then return the result.
Timing the operations on two different compilers makes it clear that there is
a performance penalty for using the more convenient derived types. I assume
that is because calling the subroutines directly uses pass-by-reference and
using the derived types does copy-in/copy-out.
Is there anything in the derived type framework that forces copy-in/copy-out, or
might a better optimizer be able to recognize that A = B + C is equivalent here
to a single subroutine call and just do that?
David Smith
[log in to unmask]
|