next up previous contents index
Next: Implicit Storage for Parallel Up: Declarations Previous: Declaring Degenerate Dimensions

Rank Defined Arrays

   

At the global scope, parallel variables must be declared using regions, as shown above. However, parallel variables that are local to a procedure can be defined using only their rank. This gives the procedure the flexibility to accept parallel parameters of any region of the appropriate rank. Below, the procedures Double and Swap are defined for two-dimensional parallel arrays, as indicated by the two empty sets of regions bounds that are separated by a comma.

    procedure Double (X : [,] float) : [,] float;
    begin
        return X * 2;
    end;

    procedure Swap (var X,Y : [,] float);
    var Temp : [,] float;
    begin
        Temp := X;
        X    := Y;
        Y    := Temp;
    end;
    . . .

[east of R] Double(A);
[west of R] Double(A);
[R]         Swap (A, B);
Note that there are two concepts at work here. First, a parameter that is rank-defined can take any variable of the same rank as its actual parameters. Second, return values and local parallel arrays assume the size of the region scope that is specified at the call site.



Kay Nettle
Fri Feb 21 21:14:29 CST 1997