1 SUBROUTINE pzlapv2( DIREC, ROWCOL, M, N, A, IA, JA, DESCA, IPIV,
10 CHARACTER DIREC, ROWCOL
11 INTEGER IA, IP, JA, JP, M, N
14 INTEGER DESCA( * ), DESCIP( * ), IPIV( * )
146 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
147 $ lld_, mb_, m_, nb_, n_, rsrc_
148 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
149 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
150 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
153 LOGICAL FORWRD, ROWPVT
154 INTEGER I, IB, ICTXT, ICURCOL, ICURROW, IIP, IP1, ITMP,
155 $ ipvwrk, j, jb, jjp, jp1, k, ma, mba, mycol,
156 $ myrow, nba, npcol, nprow
159 EXTERNAL blacs_gridinfo, igebs2d, igebr2d,
infog2l,
164 INTEGER ICEIL, NUMROC
165 EXTERNAL iceil, lsame, numroc
172 rowpvt = lsame( rowcol,
'R' )
174 IF( m.LE.1 .OR. n.LT.1 )
177 IF( m.LT.1 .OR. n.LE.1 )
180 forwrd = lsame( direc,
'F' )
188 ictxt = desca( ctxt_ )
189 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
195 CALL infog2l( ip, jp, descip, nprow, npcol, myrow, mycol,
196 $ iip, jjp, icurrow, icurcol )
201 ipvwrk = numroc( descip( m_ ), descip( mb_ ), myrow,
202 $ descip( rsrc_ ), nprow ) + 1 -
208 ib =
min( m, iceil( ia, mba ) * mba - ia + 1 )
214 IF( myrow.EQ.icurrow )
THEN
215 CALL igebs2d( ictxt,
'Columnwise',
' ', ib, 1,
221 CALL igebr2d( ictxt,
'Columnwise',
' ', ib, 1,
222 $ ipiv( itmp ), ib, icurrow, mycol )
228 ip1 = ipiv( itmp ) - ip + ia
230 $
CALL pzswap( n, a, k, ja, desca, ma, a, ip1, ja,
238 icurrow = mod( icurrow+1, nprow )
240 ib =
min( mba, m-i+ia )
241 IF( ib .GT. 0 )
GOTO 10
246 ipvwrk = numroc( descip( n_ ), descip( nb_ ), mycol,
247 $ descip( csrc_ ), npcol ) + 1 -
253 jb =
min( n, iceil( ja, nba ) * nba - ja + 1 )
259 IF( mycol.EQ.icurcol )
THEN
260 CALL igebs2d( ictxt,
'Rowwise',
' ', jb, 1,
266 CALL igebr2d( ictxt,
'Rowwise',
' ', jb, 1,
267 $ ipiv( itmp ), jb, myrow, icurcol )
273 jp1 = ipiv( itmp ) - jp + ja
275 $
CALL pzswap( m, a, ia, k, desca, 1, a, ia, jp1,
283 icurcol = mod( icurcol+1, npcol )
285 jb =
min( nba, n-j+ja )
286 IF( jb .GT. 0 )
GOTO 30
298 CALL infog2l( ip+m-1, jp, descip, nprow, npcol, myrow,
299 $ mycol, iip, jjp, icurrow, icurcol )
301 ipvwrk = numroc( descip( m_ ), descip( mb_ ), myrow,
302 $ descip( rsrc_ ), nprow ) + 1 -
309 IF( myrow.NE.icurrow ) iip = iip - 1
315 IF( ib .EQ. 0 ) ib = mba
322 IF( myrow.EQ.icurrow )
THEN
325 CALL igebs2d( ictxt,
'Columnwise',
' ', ib, 1,
326 $ ipiv( iip+1 ), ib )
328 CALL igebr2d( ictxt,
'Columnwise',
' ', ib, 1,
329 $ ipiv( ipvwrk ), ib, icurrow, mycol )
330 itmp = ipvwrk + ib - 1
335 DO 60 k = i, i-ib+1, -1
336 ip1 = ipiv( itmp ) - ip + ia
338 $
CALL pzswap( n, a, k, ja, desca, ma, a, ip1, ja,
346 icurrow = mod( nprow+icurrow-1, nprow )
348 ib =
min( mba, i-ia+1 )
349 IF( ib .GT. 0 )
GOTO 50
354 CALL infog2l( ip, jp+n-1, descip, nprow, npcol, myrow,
355 $ mycol, iip, jjp, icurrow, icurcol )
356 ipvwrk = numroc( descip( n_ ), descip( nb_ ), mycol,
357 $ descip( csrc_ ), npcol ) + 1 -
364 IF( mycol.NE.icurcol ) jjp = jjp - 1
370 IF( jb .EQ. 0 ) jb = nba
377 IF( mycol.EQ.icurcol )
THEN
380 CALL igebs2d( ictxt,
'Rowwise',
' ', jb, 1,
381 $ ipiv( jjp+1 ), jb )
383 CALL igebr2d( ictxt,
'Rowwise',
' ', jb, 1,
384 $ ipiv( ipvwrk ), jb, myrow, icurcol )
385 itmp = ipvwrk + jb - 1
390 DO 80 k = j, j-jb+1, -1
391 jp1 = ipiv( itmp ) - jp + ja
393 $
CALL pzswap( m, a, ia, k, desca, 1, a, ia, jp1,
401 icurcol = mod( npcol+icurcol-1, npcol )
403 jb =
min( nba, j-ja+1 )
404 IF( jb .GT. 0 )
GOTO 70