Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26736 Discussions

efficient way of using large array subsections

Kholikov__Shukur
Beginner
111 Views

Hi all,

 

I need some help to speed up a small portion of my fortran code.

 

Following code is inside several loops.

 

    ix1 and iy1 variables are assigned in outer loops

 

      ij = 0
      do i = 1,4
         ix1pi = ix1+i
         do j = 1,4
            ij = ij+1
            q(ij,:) = dcube(:,ix1pi,iy1+j)
            uxuy(ij,:) = ux(i)*uy(j)
         enddo
      enddo
      sig2 = sum(q*uxuy,dim=1)

 

 

 "dcube" is allocatable array. 

My question is how to avoid copying columns or any other way of speeding this portion of code.

 

Thanks,

Shukur

 

0 Kudos
2 Replies
Steve_Lionel
Black Belt Retired Employee
111 Views

For one, I'd suggest reversing the bounds of q and uxuy (if you can), as the array sections you are assigning to are discontiguous and this is going to require an extra loop.

Kholikov__Shukur
Beginner
111 Views

Thanks Steve!!!  2.3 faster.  I think this is the case because this portion of the code is within 3 outer loops.

 

I am HAPPY.

Shukur

Reply