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

Array Declaration

Madhubalan_R_
Beginner
696 Views

Hi All, For a Fortran array, Is there any compiler specific parameter to set the array lower bound to zero? Because Linux considers the lower bound as one always.

0 Kudos
2 Replies
TimP
Honored Contributor III
696 Views

I think we need some clarification of what you are asking.

real a(0:n)

declares an array of size n+1 with a lower bound of 0 within the scope of the declaration.  If accessed from outside this scope, with unspecified lower bound, it may appear as a lower bound of 1.

I don't see how this is specific to linux, unless you can clarify, or provide a specific example.

0 Kudos
mecej4
Honored Contributor III
696 Views

It is the Fortran standard that specifies the default lower bound as 1, not Linux.

If you want to use a lower bound of 0 (or anything other than 1), you have to program explicitly for it. It can be troublesome to pass such arrays to standard library routines such as those in BLAS/Lapack.

As far as linear algebra is concerned, for most algorithms a lower bound of zero is not in agreement with standard mathematical conventions. For example, we do not talk of "row number zero of matrix M".

0 Kudos
Reply