next up previous contents
Next: Array Element Ordering Up: Arrays Previous: Declarations

 

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. (Note that 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,

  figure7310
Figure 9: 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.

Now try this question gif

Return to corresponding overview page gif


next up previous contents
Next: Array Element Ordering Up: Arrays Previous: Declarations

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.