| 1 | SUBROUTINE PCTZRZRV( M, N, A, IA, JA, DESCA, TAU, WORK ) |
| 2 | IMPLICIT NONE |
| 3 | * |
| 4 | * -- ScaLAPACK routine (version 1.7) -- |
| 5 | * University of Tennessee, Knoxville, Oak Ridge National Laboratory, |
| 6 | * and University of California, Berkeley. |
| 7 | * May 28, 2001 |
| 8 | * |
| 9 | * .. Scalar Arguments .. |
| 10 | INTEGER IA, JA, M, N |
| 11 | * .. |
| 12 | * .. Array Arguments .. |
| 13 | INTEGER DESCA( * ) |
| 14 | COMPLEX A( * ), TAU( * ), WORK( * ) |
| 15 | * .. |
| 16 | * |
| 17 | * Purpose |
| 18 | * ======= |
| 19 | * |
| 20 | * PCTZRZRV computes sub( A ) = A(IA:IA+M-1,JA:JA+N-1) from T, Z |
| 21 | * computed by PCTZRZF. |
| 22 | * |
| 23 | * Notes |
| 24 | * ===== |
| 25 | * |
| 26 | * Each global data object is described by an associated description |
| 27 | * vector. This vector stores the information required to establish |
| 28 | * the mapping between an object element and its corresponding process |
| 29 | * and memory location. |
| 30 | * |
| 31 | * Let A be a generic term for any 2D block cyclicly distributed array. |
| 32 | * Such a global array has an associated description vector DESCA. |
| 33 | * In the following comments, the character _ should be read as |
| 34 | * "of the global array". |
| 35 | * |
| 36 | * NOTATION STORED IN EXPLANATION |
| 37 | * --------------- -------------- -------------------------------------- |
| 38 | * DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case, |
| 39 | * DTYPE_A = 1. |
| 40 | * CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating |
| 41 | * the BLACS process grid A is distribu- |
| 42 | * ted over. The context itself is glo- |
| 43 | * bal, but the handle (the integer |
| 44 | * value) may vary. |
| 45 | * M_A (global) DESCA( M_ ) The number of rows in the global |
| 46 | * array A. |
| 47 | * N_A (global) DESCA( N_ ) The number of columns in the global |
| 48 | * array A. |
| 49 | * MB_A (global) DESCA( MB_ ) The blocking factor used to distribute |
| 50 | * the rows of the array. |
| 51 | * NB_A (global) DESCA( NB_ ) The blocking factor used to distribute |
| 52 | * the columns of the array. |
| 53 | * RSRC_A (global) DESCA( RSRC_ ) The process row over which the first |
| 54 | * row of the array A is distributed. |
| 55 | * CSRC_A (global) DESCA( CSRC_ ) The process column over which the |
| 56 | * first column of the array A is |
| 57 | * distributed. |
| 58 | * LLD_A (local) DESCA( LLD_ ) The leading dimension of the local |
| 59 | * array. LLD_A >= MAX(1,LOCr(M_A)). |
| 60 | * |
| 61 | * Let K be the number of rows or columns of a distributed matrix, |
| 62 | * and assume that its process grid has dimension p x q. |
| 63 | * LOCr( K ) denotes the number of elements of K that a process |
| 64 | * would receive if K were distributed over the p processes of its |
| 65 | * process column. |
| 66 | * Similarly, LOCc( K ) denotes the number of elements of K that a |
| 67 | * process would receive if K were distributed over the q processes of |
| 68 | * its process row. |
| 69 | * The values of LOCr() and LOCc() may be determined via a call to the |
| 70 | * ScaLAPACK tool function, NUMROC: |
| 71 | * LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ), |
| 72 | * LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ). |
| 73 | * An upper bound for these quantities may be computed by: |
| 74 | * LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A |
| 75 | * LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A |
| 76 | * |
| 77 | * Arguments |
| 78 | * ========= |
| 79 | * |
| 80 | * M (global input) INTEGER |
| 81 | * The number of rows to be operated on, i.e. the number of rows |
| 82 | * of the distributed submatrix sub( A ). M >= 0. |
| 83 | * |
| 84 | * N (global input) INTEGER |
| 85 | * The number of columns to be operated on, i.e. the number of |
| 86 | * columns of the distributed submatrix sub( A ). N >= M >= 0. |
| 87 | * |
| 88 | * A (local input/local output) COMPLEX pointer into the |
| 89 | * local memory to an array of dimension (LLD_A, LOCc(JA+N-1)). |
| 90 | * On entry, sub( A ) contains the the factors T and Z computed |
| 91 | * by PCTZRZF. On exit, the original matrix is restored. |
| 92 | * |
| 93 | * IA (global input) INTEGER |
| 94 | * The row index in the global array A indicating the first |
| 95 | * row of sub( A ). |
| 96 | * |
| 97 | * JA (global input) INTEGER |
| 98 | * The column index in the global array A indicating the |
| 99 | * first column of sub( A ). |
| 100 | * |
| 101 | * DESCA (global and local input) INTEGER array of dimension DLEN_. |
| 102 | * The array descriptor for the distributed matrix A. |
| 103 | * |
| 104 | * TAU (local input) COMPLEX, array, dimension LOCr(M_A). |
| 105 | * This array contains the scalar factors TAU of the elementary |
| 106 | * reflectors computed by PCTZRZF. TAU is tied to the dis- |
| 107 | * tributed matrix A. |
| 108 | * |
| 109 | * WORK (local workspace) COMPLEX array, dimension (LWORK) |
| 110 | * LWORK = MB_A * ( Mp0 + 2*Nq0 + MB_A ), where |
| 111 | * Mp0 = NUMROC( M+IROFF, MB_A, MYROW, IAROW, NPROW ) * NB_A, |
| 112 | * Nq0 = NUMROC( N+ICOFF, NB_A, MYCOL, IACOL, NPCOL ) * MB_A, |
| 113 | * IROFF = MOD( IA-1, MB_A ), ICOFF = MOD( JA-1, NB_A ), |
| 114 | * IAROW = INDXG2P( IA, DESCA( MB_ ), MYROW, DESCA( RSRC_ ), |
| 115 | * NPROW ), |
| 116 | * IACOL = INDXG2P( JA, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ), |
| 117 | * NPCOL ), |
| 118 | * and NUMROC, INDXG2P are ScaLAPACK tool functions. |
| 119 | * |
| 120 | * ===================================================================== |
| 121 | * |
| 122 | * .. Parameters .. |
| 123 | INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_, |
| 124 | $ LLD_, MB_, M_, NB_, N_, RSRC_ |
| 125 | PARAMETER ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1, |
| 126 | $ CTXT_ = 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6, |
| 127 | $ RSRC_ = 7, CSRC_ = 8, LLD_ = 9 ) |
| 128 | COMPLEX ZERO |
| 129 | PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ) ) |
| 130 | * .. |
| 131 | * .. Local Scalars .. |
| 132 | CHARACTER COLBTOP, ROWBTOP |
| 133 | INTEGER I, IACOL, IAROW, IB, ICOFF, ICTXT, IIA, IN, |
| 134 | $ IPT, IPV, IPW, JJA, JM1, JV, L, MYCOL, MYROW, |
| 135 | $ NPCOL, NPROW, NQ |
| 136 | * .. |
| 137 | * .. Local Arrays .. |
| 138 | INTEGER DESCV( DLEN_ ) |
| 139 | * .. |
| 140 | * .. External Subroutines .. |
| 141 | EXTERNAL BLACS_GRIDINFO, DESCSET, INFOG2L, PCLACPY, |
| 142 | $ PCLARZB, PCLARZT, PCLASET, PB_TOPGET, |
| 143 | $ PB_TOPSET |
| 144 | * .. |
| 145 | * .. External Functions .. |
| 146 | INTEGER ICEIL, NUMROC |
| 147 | EXTERNAL ICEIL, NUMROC |
| 148 | * .. |
| 149 | * .. Intrinsic Functions .. |
| 150 | INTRINSIC MAX, MIN, MOD |
| 151 | * .. |
| 152 | * .. Executable Statements .. |
| 153 | * |
| 154 | * Get grid parameters |
| 155 | * |
| 156 | ICTXT = DESCA( CTXT_ ) |
| 157 | CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL ) |
| 158 | * |
| 159 | * Quick return if possible |
| 160 | * |
| 161 | IF( N.LT.M ) |
| 162 | $ RETURN |
| 163 | * |
| 164 | L = N - M |
| 165 | JM1 = JA + MIN( M+1, N ) - 1 |
| 166 | IN = MIN( ICEIL( IA, DESCA( MB_ ) ) * DESCA( MB_ ), IA+M-1 ) |
| 167 | ICOFF = MOD( JA-1, DESCA( NB_ ) ) |
| 168 | CALL INFOG2L( IA, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL, IIA, JJA, |
| 169 | $ IAROW, IACOL ) |
| 170 | NQ = NUMROC( N+ICOFF, DESCA( NB_ ), MYCOL, IACOL, NPCOL ) |
| 171 | IPV = 1 |
| 172 | IPT = IPV + NQ * DESCA( MB_ ) |
| 173 | IPW = IPT + DESCA( MB_ ) * DESCA( MB_ ) |
| 174 | CALL PB_TOPGET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP ) |
| 175 | CALL PB_TOPGET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP ) |
| 176 | CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', ' ' ) |
| 177 | CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', 'I-ring' ) |
| 178 | * |
| 179 | CALL DESCSET( DESCV, DESCA( MB_ ), N + ICOFF, DESCA( MB_ ), |
| 180 | $ DESCA( NB_ ), IAROW, IACOL, ICTXT, DESCA( MB_ ) ) |
| 181 | * |
| 182 | * Handle first block separately |
| 183 | * |
| 184 | IB = IN - IA + 1 |
| 185 | JV = ICOFF + JM1 - JA + 1 |
| 186 | * |
| 187 | * Compute upper triangular matrix T |
| 188 | * |
| 189 | CALL PCLARZT( 'Backward', 'Rowwise', L, IB, A, IA, JM1, DESCA, |
| 190 | $ TAU, WORK( IPT ), WORK( IPW ) ) |
| 191 | * |
| 192 | * Copy Householder vectors into workspace |
| 193 | * |
| 194 | CALL PCLACPY( 'All', IB, L, A, IA, JM1, DESCA, WORK( IPV ), 1, |
| 195 | $ JV, DESCV ) |
| 196 | * |
| 197 | * Save temporarily strict lower part of A(IA:IA+IB-1,JA:JA+IB-1) |
| 198 | * |
| 199 | CALL PCLACPY( 'Lower', IB-1, IB-1, A, IA+1, JA, DESCA, |
| 200 | $ WORK( IPV ), 1, ICOFF+1, DESCV ) |
| 201 | * |
| 202 | * Zeroes the row panel of sub( A ) to get T(IA:IN,JA:JA+N-1) |
| 203 | * |
| 204 | CALL PCLASET( 'All', IB, L, ZERO, ZERO, A, IA, JM1, DESCA ) |
| 205 | CALL PCLASET( 'Lower', IB-1, IB-1, ZERO, ZERO, A, IA+1, JA, |
| 206 | $ DESCA ) |
| 207 | * |
| 208 | * Apply block Householder transformation |
| 209 | * |
| 210 | CALL PCLARZB( 'Right', 'Conjugate transpose', 'Backward', |
| 211 | $ 'Rowwise', IN-IA+1, N, IB, L, WORK( IPV ), 1, JV, |
| 212 | $ DESCV, WORK( IPT ), A, IA, JA, DESCA, WORK( IPW ) ) |
| 213 | * |
| 214 | * Restore strict lower part of A( IA:IA+IB-1, JA:JA+N-1 ) |
| 215 | * |
| 216 | CALL PCLACPY( 'Lower', IB-1, IB-1, WORK( IPV ), 1, ICOFF+1, DESCV, |
| 217 | $ A, IA+1, JA, DESCA ) |
| 218 | * |
| 219 | DESCV( RSRC_ ) = MOD( DESCV( RSRC_ ) + 1, NPROW ) |
| 220 | * |
| 221 | * Loop over the remaining row blocks |
| 222 | * |
| 223 | DO 10 I = IN+1, IA+M-1, DESCA( MB_ ) |
| 224 | IB = MIN( IA+M-I, DESCA( MB_ ) ) |
| 225 | * |
| 226 | * Compute upper triangular matrix T |
| 227 | * |
| 228 | CALL PCLARZT( 'Backward', 'Rowwise', L, IB, A, I, JM1, DESCA, |
| 229 | $ TAU, WORK( IPT ), WORK( IPW ) ) |
| 230 | * |
| 231 | * Copy Householder vectors into workspace |
| 232 | * |
| 233 | CALL PCLACPY( 'All', IB, L, A, I, JM1, DESCA, WORK( IPV ), 1, |
| 234 | $ JV, DESCV ) |
| 235 | * |
| 236 | * Save temporarily strict lower part of A(I:I+IB-1,J:J+IB-1 ) |
| 237 | * |
| 238 | CALL PCLACPY( 'Lower', IB-1, IB-1, A, I+1, JA+I-IA, DESCA, |
| 239 | $ WORK( IPV ), 1, ICOFF+1+I-IA, DESCV ) |
| 240 | * |
| 241 | * Zeoes the row panel of sub( A ) to get T(IA:I-1,JA+I-IA:JA+N-1) |
| 242 | * |
| 243 | CALL PCLASET( 'All', IB, L, ZERO, ZERO, A, I, JM1, DESCA ) |
| 244 | CALL PCLASET( 'Lower', IB-1, IB-1, ZERO, ZERO, A, I+1, JA+I-IA, |
| 245 | $ DESCA ) |
| 246 | * |
| 247 | * Apply block Householder transformation |
| 248 | * |
| 249 | CALL PCLARZB( 'Right', 'Conjugate transpose', 'Backward', |
| 250 | $ 'Rowwise', I+IB-IA, N-I+IA, IB, L, WORK( IPV ), |
| 251 | $ 1, JV, DESCV, WORK( IPT ), A, IA, JA+I-IA, DESCA, |
| 252 | $ WORK( IPW ) ) |
| 253 | * |
| 254 | CALL PCLACPY( 'Lower', IB-1, IB-1, WORK( IPV ), 1, |
| 255 | $ ICOFF+1+I-IA, DESCV, A, I+1, JA+I-IA, DESCA ) |
| 256 | * |
| 257 | DESCV( RSRC_ ) = MOD( DESCV( RSRC_ ) + 1, NPROW ) |
| 258 | * |
| 259 | 10 CONTINUE |
| 260 | * |
| 261 | CALL PB_TOPSET( ICTXT, 'Broadcast', 'Rowwise', ROWBTOP ) |
| 262 | CALL PB_TOPSET( ICTXT, 'Broadcast', 'Columnwise', COLBTOP ) |
| 263 | * |
| 264 | RETURN |
| 265 | * |
| 266 | * End of PCTZRZRV |
| 267 | * |
| 268 | END |