next up previous contents
Next: Array Sections Up: Arrays Previous: Whole Array Expressions

 

Array Conformance

If an object or sub-object is used directly in an expression then it must conform with all other objects in that expression. As mentioned in the last section, a scalar conforms to any array with the same value for every element; for two array references to conform both objects must be the same shape.

Using the declarations from before:

    C = D                   ! is valid
    A = B                   ! is not valid

Visualisation,

  figure6952
Figure 3: Visualisation of conforming Arrays

A and B have the same size (15 elements) but have different shapes so cannot be directly equated. To force conformance the array must be used as an argument to a transformational intrinsic to change its shape, for example,

    B = RESHAPE(A,(/5,3/))  ! is, see later
    A = PACK(B,.TRUE.)      ! is, see later
    A = RESHAPE(B,(/10,8/)) ! is, see later 
    B = PACK(A,.TRUE.)      ! is, see later

Arrays can have their shapes changed by using transformational intrinsics including, MERGE, PACK, SPREAD, UNPACK and RESHAPE.

Two arrays of different types conform and if used in the same expression will have the relevant type coercion performed just like scalars.


next up previous contents
Next: Array Sections Up: Arrays Previous: Whole Array Expressions

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 15:03:35 GMT 1996
Not for commercial use.