next up previous contents
Next: Visualising Array Sections Up: Arrays Previous: Array Syntax

 

Whole Array Expressions

A whole (or section of an) array can be treated like a single variable in that all intrinsic operators which apply to intrinsic types have their meaning extended to apply to conformable arrays, for example,

    B = C * D - B**2
as long as B, C and D conform then the above assignment is valid. (Recall that the RHS of the ** operator must be scalar.) Note that in the above example, C*D is not matrix multiplication, MATMUL(C,D) should be used if this is the desired operation.

The above assignment is equivalent to:

!PARALLEL
    B(-4,0) = C(1,1)*D(0,0)-B(-4,0)**2 ! in ||
    B(-3,0) = C(2,1)*D(1,0)-B(-3,0)**2 ! in ||
     ...
    B(-4,1) = C(1,2)*D(0,1)-B(-4,1)**2 ! in ||
     ...
    B(0,2)  = C(5,3)*D(4,2)-B(0,2)**2  ! in ||
!END PARALLEL

With array assignment there is no implied order of the individual assignments, they are performed, conceptually, in parallel.

In addition to the above operators, the subset of intrinsic functions termed elemental can also be applied, for example,

    B = SIN(C)+COS(D)
The functions are also applied element by element, thus the above is equivalent to the parallel execution of,
!PARALLEL
    B(-4,0) = SIN(C(1,1))+COS(D(0,0))
     ...
    B(0,2)  = SIN(C(5,3))+COS(D(4,2))
!END PARALLEL

Many of Fortran 90 's intrinsics are elemental including all numeric, mathematical, bit, character and logical intrinsics.

Again it must be stressed that conceptually there is no order implied in the array statement form -- each individual assignment can be thought of as being executed in parallel between corresponding elements of the arrays -- this is very different to the DO-loop.

Return to corresponding overview page gif


next up previous contents
Next: Visualising Array Sections Up: Arrays Previous: Array Syntax

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