> There are enough such situations that the compiler writers should be motivated > to find a way to optimize them e.g. > > MAXLOC(ABS(X(1:n))) > > isn't too slow on the SGI 7.2 compiler, although it is dead slow on some > others. Supposing that such expressions expand initially into a sequence of > DO loops, a decent optimizer should be able to fuse them and come up with > reasonable results. It was for exactly this reason that I proposed a MAXABSLOC intrinsic. MAXABSLOC is what one uses to determine the pivot when solving a linear system. To avoid the "dead slow" or a temp array or both, I have taken to using: k = MAXLOC(a(i,:)) small_k = MINLOC(a(i,:)) if ( -a(i,small_k) > a(i,k) ) k = small_k This sometimes has worse performance than MAXLOC(ABS(a(i,:))) but is never as bad as the worst implementation of MAXLOC(ABS(a(i,:))). It seems never to make a temp. Van Snyder %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%