Hi,
If you are going to use the index in a loop and/or in many statements, then
IMHO, use a temp holder to store the index might be more efficient. Although
a good optimizer might do a better job for you, a carefully crafted algorithm
will probably beats most optimizer, or gives a better "hint" of what and how
to optimized.
Shyan Lam
[log in to unmask]
Roland Schilling <[log in to unmask]> wrote:
> 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') ...
>
> (Here sf%ia is an integer and sf%as is a character string.)
> 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. The situation might be a bit different if some
> index arithmetic is required.
>
> I'm curious to see the comments of the compiler experts.
> Thanks in advance,
> Roland
>
>
> +----------------------------------------------------------------------+
> | Roland Schilling Home-Office: +49(89)32929-670 |
> | Max-Planck-Institut fuer Quantenoptik Phone: +49(89)32905-265 |
> | Hans-Kopfermann-Str. 1 Fax: +49(89)32905-200 |
> | D-85748 Garching E-mail: [log in to unmask] |
> | Germany http://www.geo600.uni-hannover.de |
> +----------------------------------------------------------------------+
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|