1      SUBROUTINE ZRSHFT( M, N, OFFSET, A, LDA )
2*
3*  -- PBLAS auxiliary routine (version 2.0) --
4*     University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5*     and University of California, Berkeley.
6*     April 1, 1998
7*
8*     .. Scalar Arguments ..
9      INTEGER            LDA, M, N, OFFSET
10*     ..
11*     .. Array Arguments ..
12      COMPLEX*16         A( LDA, * )
13*     ..
14*
15*  Purpose
16*  =======
17*
18*  ZRSHFT shifts rows of an m by n array A by OFFSET.
19*
20*  Arguments
21*  =========
22*
23*  M       (local input) INTEGER
24*          On entry, M  specifies the number of rows of A to be shifted.
25*          M must be at least zero.
26*
27*  N       (local input) INTEGER
28*          On entry,  N  specifies the number of columns of A. N must be
29*          at least zero.
30*
31*  OFFSET  (local input) INTEGER
32*          On entry, OFFSET  specifies  the  offset by which the rows of
33*          A should be shifted. OFFSET  can be positive or negative (see
34*          below for further details). When OFFSET is positive, the rows
35*          are shifted to the  bottom. When OFFSET is negative, the rows
36*          of A are shifted to the top.
37*
38*  A       (local input/local output) COMPLEX*16 array
39*          On entry,  A  is an array of dimension ( LDA, N ). On exit, A
40*          contains the shifted array.
41*
42*  LDA     (local input) INTEGER
43*          On entry, LDA specifies the leading dimension of the array A.
44*          LDA must be at least max( 1, M+ABS(OFFSET) ).
45*
46*  Further Details
47*  ===============
48*
49*            N                 N                   N                 N
50*           ---               ---                 ---               ---
51*          | 1 |             | 1 |               | 1 |             | 7 |
52*          | 2 |    M = 3    | 2 |               | 2 |    M = 3    | 8 |
53*          | 3 |             | 3 |               | 3 |             | 9 |
54*          | 4 |             | 4 |               | 4 |             | 4 |
55*          | 5 |   becomes   | 5 |               | 5 |   becomes   | 5 |
56*          | 6 |             | 6 |               | 6 |             | 6 |
57*          | 7 |             | 1 |               | 7 |             | 7 |
58*          | 8 | OFFSET =  6 | 2 |               | 8 | OFFSET = -6 | 8 |
59*          | 9 |             | 3 |               | 9 |             | 9 |
60*           ---               ---                 ---               ---
61*                OFFSET >= 0                           OFFSET <= 0
62*
63*  -- Written on April 1, 1998 by
64*     Antoine Petitet, University  of  Tennessee, Knoxville 37996, USA.
65*
66*  =====================================================================
67*
68*     .. Local Scalars ..
69      INTEGER            I, J
70*     ..
71*     .. Executable Statements ..
72*
73      IF( ( OFFSET.EQ.0 ).OR.( M.LE.0 ).OR.( N.LE.0 ) )
74     $   RETURN
75*
76      IF( OFFSET.GT.0 ) THEN
77         DO 20 J = 1, N
78            DO 10 I = M, 1, -1
79               A( I+OFFSET, J ) = A( I, J )
80   10       CONTINUE
81   20    CONTINUE
82      ELSE
83         DO 40 J = 1, N
84            DO 30 I = 1, M
85               A( I, J ) = A( I-OFFSET, J )
86   30       CONTINUE
87   40    CONTINUE
88      END IF
89*
90      RETURN
91*
92*     End of ZRSHFT
93*
94      END
95