1 SUBROUTINE psorg2l( M, N, K, A, IA, JA, DESCA, TAU, WORK, LWORK,
10 INTEGER IA, INFO, JA, K, LWORK, M, N
14 REAL A( * ), TAU( * ), WORK( * )
157 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
158 $ lld_, mb_, m_, nb_, n_, rsrc_
159 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
160 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
161 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
163 parameter( one = 1.0e+0, zero = 0.0e+0 )
167 CHARACTER COLBTOP, ROWBTOP
168 INTEGER IACOL, IAROW, ICTXT, J, JJ, LWMIN, MPA0, MYCOL,
169 $ myrow, npcol, nprow, nqa0
178 INTEGER INDXG2L, INDXG2P, NUMROC
179 EXTERNAL indxg2l, indxg2p, numroc
182 INTRINSIC max,
min, mod, real
188 ictxt = desca( ctxt_ )
189 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
194 IF( nprow.EQ.-1 )
THEN
197 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 7, info )
199 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
201 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
203 mpa0 = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
204 $ myrow, iarow, nprow )
205 nqa0 = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
206 $ mycol, iacol, npcol )
207 lwmin = mpa0 +
max( 1, nqa0 )
209 work( 1 ) = real( lwmin )
210 lquery = ( lwork.EQ.-1 )
213 ELSE IF( k.LT.0 .OR. k.GT.n )
THEN
215 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
221 CALL pxerbla( ictxt,
'PSORG2L', -info )
222 CALL blacs_abort( ictxt, 1 )
224 ELSE IF( lquery )
THEN
233 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
234 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
235 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'I-ring' )
236 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
240 CALL pslaset(
'All', m-n, n-k, zero, zero, a, ia, ja, desca )
241 CALL pslaset(
'All', n, n-k, zero, one, a, ia+m-n, ja, desca )
244 nqa0 =
max( 1, numroc( ja+n-1, desca( nb_ ), mycol,
245 $ desca( csrc_ ), npcol ) )
246 DO 10 j = ja+n-k, ja+n-1
250 CALL pselset( a, ia+m-n+j-ja, j, desca, one )
251 CALL pslarf(
'Left', m-n+j-ja+1, j-ja, a, ia, j, desca, 1, tau,
252 $ a, ia, ja, desca, work )
254 jj = indxg2l( j, desca( nb_ ), mycol, desca( csrc_ ), npcol )
255 iacol = indxg2p( j, desca( nb_ ), mycol, desca( csrc_ ),
258 $ tauj = tau(
min( jj, nqa0 ) )
259 CALL psscal( m-n+j-ja, -tauj, a, ia, j, desca, 1 )
260 CALL pselset( a, ia+m-n+j-ja, j, desca, one-tauj )
264 CALL pslaset(
'All', ja+n-1-j, 1, zero, zero, a, ia+m-n+j-ja+1,
269 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
270 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
272 work( 1 ) = real( lwmin )