> 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.
> I then continue using this variable, as in the following example,
>
> ia=sf(isc)%ia
> if (sf(isc)%as(ia:ia) == 'h') ...
>
> instead of writing
>
> if (sf(isc)%as(sf(isc)%ia:sf(isc)%ia) == 'h') ...
> But I also have my doubts if it's resonable, what I'm doing,
> or if it would be better to rely on the cleverness and
> efficiency of the compilers, and not wasting an extra memory
> location.
Surely, a) the memory is negligible and b) a smart compiler would not
actually use it since it's not really needed. The advantage of your
method is clearer code for the reader.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|