Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

What is the maximum array rank?

Arm_N_
Beginner
5,804 Views

Hi,

I ran the program on intel visual fortran compiler,using Fortran 2003, and got this error message:

error #6204: There are too many dimensions; the maximum rank is 7.

I remembered that in the user manual the inter visual fortran compiler can handle up to the maximum rank of 15.

Could anyone please suggest this? I appreciate all answers.  Thank you very much.

0 Kudos
22 Replies
JVanB
Valued Contributor II
606 Views

mecej4 indeed saw what was in the blind spot of others. The point I was trying to make with the code of Quote #7 was that it is possible to create a data object that is effectively an array with as many dimensions as you want provided that there is a break in the stream of indices at certain points to dereference a structure member. It turns out that gfortran still only goes up to 7 dimensions, so we have to get there in baby steps:

program P
   use ISO_FORTRAN_ENV
   implicit none
   type T
   end type T
   type U
      type(T) M(2,2,2,2,2,2,2)
   end type U
   type V
      type(U) M(2,2,2,2,2,2,2)
   end type V
   type W
      type(V) M(2,2,2,2,2,2,2)
   end type W
   type X
      type(W) M(2,2,2,2,2,2,2)
   end type X
   type(X) B(2,2,2,2,2,2,2)
   B = X(W(V(U(T()))))
   write(*,*) size(B,kind=INT64)* &
      size(B(1,1,1,1,1,1,1)%M,kind=INT64)* &
      size(B(1,1,1,1,1,1,1)%M(1,1,1,1,1,1,1)%M,kind=INT64)* &
      size(B(1,1,1,1,1,1,1)%M(1,1,1,1,1,1,1)%M(1,1,1,1,1,1,1) &
         %M,kind=INT64)* &
      size(B(1,1,1,1,1,1,1)%M(1,1,1,1,1,1,1)%M(1,1,1,1,1,1,1) &
         %M(1,1,1,1,1,1,1)%M,kind=INT64), sizeof(B)
end program P

And gfortran prints out 2**35 = 34359738368 and 0, while ifort still gets a borderline ICE as before. It's kind of strange that ifort has this problem because eventually it will be necessary to multiply the effective array size by the storage size of a single element to get the storage size of the array. Maybe it's just computing the overall size starting from left to right and checking as it goes so that there won't be any issues with overflow at some intermediate point in the calculation.

Outlandish arrays of zero size are more the norm that the exception in specification variables, but since these are automatic data objects they can't have the SAVE attribute so this erroneous check won't be directly applied to them. Specification expressions that are complicated enough to make specification variables necessary or desirable generally ICE the compiler anyway, so an erroneous check that may knock out valid code in such a case likely is just saving the compiler from a full ICE a step or two later.

 

0 Kudos
Steven_L_Intel1
Employee
606 Views

That's not in any way an ICE and I don't consider it a problem.

0 Kudos
Reply