Sun S3L 3.0 Programming and Reference Guide

Printing S3L Arrays

The Sun S3L utilities S3L_print_array and S3L_print_sub_array can be used to print the values of a distributed S3L array to standard output.

S3L_print_array prints the whole array, while S3L_print_sub_array prints a section of the array that is defined by programmer-specified lower and upper bounds.

The values of array elements will be printed out in column-major order; this is referred to as Fortran ordering, where the leftmost axis index varies fastest.

Each element value is accompanied by the array indices for that value. This is illustrated by the following example.

a is a 4 x 5 x 2 S3L array, which has been initialized to random double-precision values via a call S3L_rand_lcg. A call to S3L_print_array will produce the following output:


Example 2-4

    call s3l_print_array(a)
(1,1,1)    0.000525
(2,1,1)    0.795124
(3,1,1)    0.225717
(4,1,1)    0.371280
(1,2,1)    0.225035
(2,2,1)    0.878745
(3,2,1)    0.047473
(4,2,1)    0.180571
(1,3,1)    0.432766
...

When an S3L array is large, S3L_print_array, it is often a good idea to print only a section of the array, rather than the entire array. This not only reduces the time it takes to retrieve the data, but it can be difficult to locate useful information in displays of large amounts of data. By printing selected sections of a large array can make the task of finding data of interest much easier. This can be done using the function S3L_print_sub_array. The following example shows how to print only the first column of the array shown in the previous example:


Example 2-5

    integer*4 lb(3),ub(3),st(3)

c        specify
the lower and upper bounds
c        along
each axis. Elements whose coordinates
c        are
greater or equal to lb(i) and less or
c        equal
to ub(i) (and with stride st(i)) are
c        printed
to the output
    lb(1) = 1
    ub(1) = 4
    st(1) = 1
    lb(2) = 1
    ub(2) = 1
    st(2) = 1
    lb(3) = 1
    ub(3) = 1
    st(3) = 1
    call s3l_print_sub_array(a,lb,ub,st,ier)

The following output would be produced by this call

(1,1,1)    0.000525
(2,1,1)    0.795124
(3,1,1)    0.225717
(4,1,1)    0.371280

If a stride argument other than 1 is specified, only elements at the specified stride locations will be printed. For example, the following sets the stride for axis 1 to 2

 st(1) = 2

which results in the following output:

(1,1,1)    0.000525 
(3,1,1)    0.225717