XL Fortran for AIX 8.1

Language Reference


Explicit-Shape Arrays

Explicit-shape arrays are arrays where the bounds are explicitly specified for each dimension.

Explicit_shape_spec_list
   .-,-------------------------------.
   V                                 |
>>---+----------------+--upper_bound-+-------------------------><
     '-lower_bound--:-'
 
 

lower_bound, upper_bound
are specification expressions

If any bound is not constant, the array must be declared inside a subprogram and the nonconstant bounds are determined on entry to the subprogram. If a lower bound is omitted, its default value is one.

The rank is the number of specified upper bounds. The shape of an explicit-shape dummy argument can differ from that of the corresponding actual argument.

The size is determined by the specified bounds.

Examples of Explicit-Shape Arrays

INTEGER A,B,C(1:10,-5:5)  ! All bounds are constant
A=8; B=3
CALL SUB1(A,B,C)
END
SUBROUTINE SUB1(X,Y,Z)
  INTEGER X,Y,Z(X,Y)      ! Some bounds are not constant
END SUBROUTINE

Automatic Arrays

An automatic array is an explicit-shape array that is declared in a subprogram, is not a dummy argument or pointee array, and has at least one bound that is a nonconstant specification expression. The bounds are evaluated on entry to the subprogram and remain unchanged during execution of the subprogram.

INTEGER X
COMMON X
X = 10
CALL SUB1(5)
END
 
SUBROUTINE SUB1(Y)
  INTEGER X
  COMMON X
  INTEGER Y
  REAL Z (X:20, 1:Y)         ! Automatic array.  Here the bounds are made available
                             ! through dummy arguments and common blocks, although
                             ! Z itself is not a dummy argument.
END SUBROUTINE

Related Information

For general information about automatic data objects, see Automatic Objects and Storage Classes for Variables.

Adjustable Arrays

An adjustable array is an explicit-shape array that is declared in a subprogram and has at least one bound that is a nonconstant specification expression. An adjustable array must be a dummy argument.

SUBROUTINE SUB1(X, Y)
INTEGER X, Y(X*3)  ! Adjustable array.  Here the bounds depend on a
                   ! dummy argument, and the array name is also passed in.
END SUBROUTINE

+-------------------------------IBM Extension--------------------------------+

Pointee Arrays

Pointee arrays are explicit-shape or assumed-size arrays that are declared in integer POINTER statements or other specification statements.

The declarator for a pointee array may only contain variables if the array is declared inside a subprogram, and any such variables must be dummy arguments, members of a common block, or use or host associated. The sizes of the dimensions are evaluated upon entry to the subprogram and remain constant during execution of the subprogram.

With the -qddim compiler option, explained in "-qddim Option" in the User's Guide, the restrictions on which variables may appear in the array declarator are lifted, declarators in the main program may contain variable names, and any specified nonconstant bounds are re-evaluated each time the array is referenced, so that you can change the properties of the pointee array by simply changing the values of the variables used in the bounds expressions:

@PROCESS DDIM
INTEGER PTE, N, ARRAY(10)
POINTER (P, PTE(N))
N = 5
P = LOC(ARRAY(2))  !
PRINT *, PTE       ! Print elements 2 through 6 of ARRAY
N = 7              ! Increase the size
PRINT *, PTE       ! Print elements 2 through 8 of ARRAY
END

Related Information:

POINTER (integer)

+----------------------------End of IBM Extension----------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]