(/A+1.3/)is an array constructor of one million elements, each having a value of 1.3 more than the corresponding element value of . The elements of 1.3 are placed in the array constructor in the familiar Fortran ``column-major" order, that is column by column by running down the first dimension and then the second. Thus (/ A+1.3 /) is equivalent to
(/((A(j,k)+1.3,j=1,1000),k=1,1000)/)Implied-do constructs may be used for a different order. For example, if a row by row vector of elements of 1.3 is desired, rather than column by column, the following array constructor would do the job:
(/((A(j,k)+1.3,k=1,1000),j=1,1000)/)
Finally, a simple form of the RESHAPE intrinsic function can be used to reshape the (one-dimensional) result of an array constructor into the desired shape. The form that this takes is
RESHAPE (array-constructor, shape-vector)where the shape-vector has one element for each dimension of the desired array shape, and the value of each shape-vector element is the number of elements in that dimension in the target array. For example, a 10001000 identity matrix of type real can be specified as the constant named Ident_1000 by the declaration
real, parameter :: Ident_1000 = & RESHAPE((/(1.0,(0.0,k=1,1000),j=1,999),1.0/),(/1000,1000/))
Thus the array constructor, coupled with the RESHAPE intrinsic, is an extremely powerful tool for constructing array values, including array constants.