1 SUBROUTINE psorglq( 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( zero = 0.0e+0 )
167 CHARACTER COLBTOP, ROWBTOP
168 INTEGER I, IACOL, IAROW, IB, ICTXT, IINFO, IL, IN, IPW,
169 $ j, lwmin, mpa0, mycol, myrow, npcol, nprow,
173 INTEGER IDUM1( 2 ), IDUM2( 2 )
181 INTEGER ICEIL, INDXG2P, NUMROC
182 EXTERNAL iceil, indxg2p, numroc
185 INTRINSIC max,
min, mod, real
191 ictxt = desca( ctxt_ )
192 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
197 IF( nprow.EQ.-1 )
THEN
200 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 7, info )
202 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
204 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
206 mpa0 = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
207 $ myrow, iarow, nprow )
208 nqa0 = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
209 $ mycol, iacol, npcol )
210 lwmin = desca( mb_ ) * ( mpa0 + nqa0 + desca( mb_ ) )
212 work( 1 ) = real( lwmin )
213 lquery = ( lwork.EQ.-1 )
216 ELSE IF( k.LT.0 .OR. k.GT.m )
THEN
218 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
224 IF( lwork.EQ.-1 )
THEN
230 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 7, 2, idum1, idum2,
235 CALL pxerbla( ictxt,
'PSORGLQ', -info )
237 ELSE IF( lquery )
THEN
246 ipw = desca( mb_ ) * desca( mb_ ) + 1
247 in =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+k-1 )
248 il =
max( ( (ia+k-2) / desca( mb_ ) ) * desca( mb_ ) + 1, ia )
249 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
250 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
251 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
' ' )
252 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'D-ring' )
254 CALL pslaset(
'All', ia+m-il, il-ia, zero, zero, a, il, ja,
259 CALL psorgl2( ia+m-il, n-il+ia, ia+k-il, a, il, ja+il-ia, desca,
260 $ tau, work, lwork, iinfo )
264 IF( il.GT.in+1 )
THEN
268 DO 10 i = il-desca( mb_ ), in+1, -desca( mb_ )
269 ib =
min( desca( mb_ ), ia+m-i )
272 IF( i+ib.LE.ia+m-1 )
THEN
277 CALL pslarft(
'Forward',
'Rowwise', n-i+ia, ib, a, i, j,
278 $ desca, tau, work, work( ipw ) )
282 CALL pslarfb(
'Right',
'Transpose',
'Forward',
'Rowwise',
283 $ m-i-ib+ia, n-i+ia, ib, a, i, j, desca,
284 $ work, a, i+ib, j, desca, work( ipw ) )
289 CALL psorgl2( ib, n-i+ia, ib, a, i, j, desca, tau, work,
294 CALL pslaset(
'All', ib, i-ia, zero, zero, a, i, ja, desca )
308 CALL pslarft(
'Forward',
'Rowwise', n, ib, a, ia, ja, desca,
309 $ tau, work, work( ipw ) )
313 CALL pslarfb(
'Right',
'Transpose',
'Forward',
'Rowwise', m-ib,
314 $ n, ib, a, ia, ja, desca, work, a, ia+ib, ja,
315 $ desca, work( ipw ) )
319 CALL psorgl2( ib, n, ib, a, ia, ja, desca, tau, work, lwork,
324 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
325 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
327 work( 1 ) = real( lwmin )