1 SUBROUTINE pcgetrrv( M, N, A, IA, JA, DESCA, IPIV, WORK )
12 INTEGER DESCA( * ), IPIV( * )
13 COMPLEX A( * ), WORK( * )
144 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
145 $ LLD_, MB_, M_, NB_, N_, RSRC_
146 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
147 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
148 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
150 parameter( one = 1.0e+0, zero = 0.0e+0 )
153 CHARACTER COLBTOP, ROWBTOP
154 INTEGER IACOL, IAROW, ICTXT, IL, IPL, IPU, IROFF, J,
155 $ JB, JL, JN, MN, MP, MYCOL, MYROW, NPCOL, NPROW
157 INTEGER DESCIP( DLEN_ ), DESCL( DLEN_ ),
158 $ DESCU( DLEN_ ), IDUM( 1 )
165 INTEGER ICEIL, INDXG2P, NUMROC
166 EXTERNAL iceil, indxg2p, numroc
175 ictxt = desca( ctxt_ )
176 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
178 iroff = mod( ia-1, desca( mb_ ) )
179 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ), nprow )
180 mp = numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
182 ipu = ipl + mp * desca( nb_ )
183 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
184 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
185 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'S-ring' )
186 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
191 il =
max( ( ( ia+mn-2 ) / desca( mb_ ) ) * desca( mb_ ) + 1, ia )
192 jl =
max( ( ( ja+mn-2 ) / desca( nb_ ) ) * desca( nb_ ) + 1, ja )
193 jn =
min( iceil( ja, desca( nb_ ) )*desca( nb_ ), ja+mn-1 )
194 iarow = indxg2p( il, desca( mb_ ), myrow, desca( rsrc_ ), nprow )
195 iacol = indxg2p( jl, desca( nb_ ), mycol, desca( csrc_ ), npcol )
197 CALL descset( descl, ia+m-il, desca( nb_ ), desca( mb_ ),
198 $ desca( nb_ ), iarow, iacol, ictxt,
max( 1, mp ) )
200 CALL descset( descu, desca( mb_ ), ja+n-jl, desca( mb_ ),
201 $ desca( nb_ ), iarow, iacol, ictxt, desca( mb_ ) )
203 CALL descset( descip, desca( m_ ) + desca( mb_ )*nprow, 1,
204 $ desca( mb_ ), 1, desca( rsrc_ ), mycol, ictxt,
205 $ numroc( desca( m_ ), desca( mb_ ), myrow,
206 $ desca( rsrc_ ), nprow ) + desca( mb_ ) )
209 DO 10 j = jl, jn+1, -desca( nb_ )
211 jb =
min( ja+mn-j, desca( nb_ ) )
215 CALL pclacpy(
'Lower', m-il+ia, jb, a, il, j, desca,
216 $ work( ipl ), 1, 1, descl )
217 CALL pclaset(
'Upper', m-il+ia, jb, zero, one, work( ipl ),
222 CALL pclacpy(
'Upper', jb, ja+n-j, a, il, j, desca,
223 $ work( ipu ), 1, 1, descu )
224 CALL pclaset(
'Lower', jb-1, ja+n-j, zero, zero,
225 $ work( ipu ), 2, 1, descu )
229 CALL pclaset(
'Lower', ia+m-il-1, jb, zero, zero, a, il+1, j,
234 CALL pclaset(
'Upper', jb, ja+n-j, zero, zero, a, il, j,
239 CALL pcgemm(
'No transpose',
'No transpose', ia+m-il,
240 $ ja+n-j, jb, one, work( ipl ), 1, 1, descl,
241 $ work( ipu ), 1, 1, descu, one, a, il, j, desca )
243 il = il - desca( mb_ )
244 descl( m_ ) = descl( m_ ) + descl( mb_ )
245 descl( rsrc_ ) = mod( descl( rsrc_ ) + nprow - 1, nprow )
246 descl( csrc_ ) = mod( descl( csrc_ ) + npcol - 1, npcol )
247 descu( n_ ) = descu( n_ ) + descu( nb_ )
248 descu( rsrc_ ) = descl( rsrc_ )
249 descu( csrc_ ) = descl( csrc_ )
255 jb =
min( jn-ja+1, desca( nb_ ) )
259 CALL pclacpy(
'Lower', m, jb, a, ia, ja, desca, work( ipl ),
261 CALL pclaset(
'Upper', m, jb, zero, one, work( ipl ), 1, 1,
266 CALL pclacpy(
'Upper', jb, n, a, ia, ja, desca, work( ipu ), 1,
268 CALL pclaset(
'Lower', jb-1, n, zero, zero, work( ipu ), 2, 1,
273 CALL pclaset(
'Lower', m-1, jb, zero, zero, a, ia+1, ja, desca )
277 CALL pclaset(
'Upper', jb, n, zero, zero, a, ia, ja, desca )
281 CALL pcgemm(
'No transpose',
'No transpose', m, n, jb, one,
282 $ work( ipl ), 1, 1, descl, work( ipu ), 1, 1,
283 $ descu, one, a, ia, ja, desca )
287 CALL pclapiv(
'Backward',
'Row',
'Col',
min( m, n ), n, a, ia, ja,
288 $ desca, ipiv, ia, 1, descip, idum )
290 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
291 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )