Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Understanding do loops in Fortran

mechprog
초급자
1,883 조회수
Hi all,
I want to fully understand the do loop process behind the following code:
[fxfortran]      do kdim = 1, ndim   
         do jdim = 1, ndim
               ULOCAL(kdim) = ULOCAL(kdim)-ALOCAL(jdim,kdim)*UTEMP(jdim)
         enddo
      enddo[/fxfortran]
Does this start from the first do loop (kdim) at 1, then start the second do loop (jdim) at 1, then conduct the calculation ULOCAL(kdim) at 1. Take the value at ULOCAL(1) and minus ALOCAL(1,1)*UTEMP(1). Where 1 is the array reference?
I have been going through books in fortran but, I thought it might help to talk the problem through too to improve my understanding.
Thanks
0 포인트
1 응답
TimP
명예로운 기여자 III
1,883 조회수
Conceptually, your understanding is correct. The compiler can choose another order of evaluation only if analysis indicates the result will be the same, except for changes in roundoff error. Ideally, the compiler could optimize this the same as a MATMUL, possibly involving unroll-and-jam (grouping outer loop iterations) as well as scalar replacement (inner loop treated as dot_product).
0 포인트
응답