1 SUBROUTINE pcunglq( M, N, K, A, IA, JA, DESCA, TAU, WORK, LWORK,
10 INTEGER IA, INFO, JA, K, LWORK, M, N
14 COMPLEX 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, 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
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 ) =
cmplx( 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,
'PCUNGLQ', -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 pclaset(
'All', ia+m-il, il-ia, zero, zero, a, il, ja,
259 CALL pcungl2( 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 pclarft(
'Forward',
'Rowwise', n-i+ia, ib, a, i, j,
278 $ desca, tau, work, work( ipw ) )
282 CALL pclarfb(
'Right',
'Conjugate transpose',
'Forward',
283 $
'Rowwise', m-i-ib+ia, n-i+ia, ib, a, i, j,
284 $ desca, work, a, i+ib, j, desca,
290 CALL pcungl2( ib, n-i+ia, ib, a, i, j, desca, tau, work,
295 CALL pclaset(
'All', ib, i-ia, zero, zero, a, i, ja, desca )
309 CALL pclarft(
'Forward',
'Rowwise', n, ib, a, ia, ja, desca,
310 $ tau, work, work( ipw ) )
314 CALL pclarfb(
'Right',
'Conjugate transpose',
'Forward',
315 $
'Rowwise', m-ib, n, ib, a, ia, ja, desca, work,
316 $ a, ia+ib, ja, desca, work( ipw ) )
320 CALL pcungl2( ib, n, ib, a, ia, ja, desca, tau, work, lwork,
325 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
326 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
328 work( 1 ) =
cmplx( real( lwmin ) )