> When it comes to addressing several times a particular component of
> an array or a component of an array of derived type I always feel a
> strong tendency to allocate an additional variable set to this value.
You are performing an optimization known as "common subexpression
elimination". Optimizing compilers do this automatically, but it's possible
that some might not be able to do it with subscripted structure references.
Your doing this explicitly will generally make things easier for the
compiler, which will tend to allocate the "temporary" variable to a
register, if possible. So in my opinion, this is a good thing to do when
reasonable, if for no other reason than it makes the code more readable.
Steve Lionel
Compaq Fortran Engineering
http://www.compaq.com/fortran
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|