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

multidimensional array assignments

brad1
Beginner
739 Views

% ifort -v
Version 8.1


sometimes statements like:
X%bin_tot=X%bin

or :
X%bin_tot(X%indx:X%finx,X%indy:X%finy,:,:,:) = X%bin

hang (w/o error) at runtime.

Replacing w/ explicit loops as below runs fine.
do m=1,size(X%bin,5)
do l=1,size(X%bin,4)
do k=1,size(X%bin,3)
do j=X%indy,X%finy
do i=X%indx,X%finx
X%bin_tot(i,j,k,l,m)=X%bin(i,j,k,l,m)
end do
end do
end do
end do
end do

I think this has some dependance on the sparcity of the multidimensionals arrays (ie. intermedial dimensions of length 1).

Optimization flags don't seem to make a difference. Very frustating.
Brad

0 Kudos
2 Replies
Steven_L_Intel1
Employee
739 Views
I doubt it hangs. It just may be taking a long time, especially if the arrays are large and your system is low on physical memory. Your explicit loop code isn't quite the same as Fortran semantics for array assignment which requires that the right side be completely evaluated first. When you're assigning components, the compiler is less able to know whether or not there is overlap and it may be creating temporary copies.
0 Kudos
brad1
Beginner
739 Views
Serious hang actually. No movement for 12+ hours (run before leaving the office for the day) vs. less-than-seconds.

Memory is not a problem as I'm only tieing up a few percent of total available with small test cases.

Specifics: last 3 dimensions of RHS are identical to LHS. Special case is where both sides are of identical size (so I tried the bin_tot=bin line). Even this fails. General case is where several RHS are placed into the LHS to build a total output space.

Things work fine no matter the construct when only first and last dimensions have length and 1,2,5. 1,3,5 fails w/o explicit loop.

I didn't understand some of your comments. Are you refering to loop order?
Cheers-
Brad
0 Kudos
Reply