Yeh, do the work inside the "do ii=1,i-lb+ub" loop. Well, when you start doing complicated stuff, you do work all over the place :) There isn't a need to do the k=1 iteration... you are always putting inc(1)=lb(1) anyway. Stu. On 23/06/2005, at 10:55, Aleksandar Donev wrote: > Stuart Midgley wrote: > > >> inc = lb1 >> >> do while (ii <= imax) >> > > ! Do the actual work in here > > >> do k = 2, ndims >> inc(k) = inc(k) + 1 >> if (inc(k) <= ub2(k)) exit >> inc(k) = lb1(k) >> end do >> end do >> > > >> end do >> > > This is the same basic trick that Yasuki Arasaki sent (you use > k=2,ndims instead of k=1,ndims?). I am guessing it an idiom known > to compiler folks who need to flatten out loop nests? It seems too > cute to be a coincidence you both offered the same solution... > Thanks, > Aleksandar > > -- Dr Stuart Midgley Industry Uptake Program Leader iVEC, 'The hub of advanced computing in Western Australia' 26 Dick Perry Avenue, Technology Park Kensington WA 6151 Australia Phone: +61 8 6436 8545 Fax: +61 8 6436 8555 Email: [log in to unmask] WWW: http://www.ivec.org