1 SUBROUTINE pspocon( UPLO, N, A, IA, JA, DESCA, ANORM, RCOND, WORK,
2 $ LWORK, IWORK, LIWORK, INFO )
11 INTEGER IA, INFO, JA, LIWORK, LWORK, N
15 INTEGER DESCA( * ), IWORK( * )
16 REAL A( * ), WORK( * )
169 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
170 $ lld_, mb_, m_, nb_, n_, rsrc_
171 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
172 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
173 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
175 parameter( one = 1.0e+0, zero = 0.0e+0 )
178 LOGICAL LQUERY, UPPER
179 CHARACTER CBTOP, COLCTOP, NORMIN, ROWCTOP
180 INTEGER IACOL, IAROW, ICOFF, ICTXT, IIA, IPNL, IPNU,
181 $ ipv, ipw, ipx, iroff, iv, ix, ixx, jja, jv,
182 $ jx, kase, liwmin, lwmin, mycol, myrow, np,
183 $ npcol, nprow, npmod, nq, nqmod
184 REAL AINVNM, SCALE, SL, SU, SMLNUM
188 INTEGER DESCV( DLEN_ ), DESCX( DLEN_ ), IDUM1( 3 ),
199 INTEGER ICEIL, INDXG2P, NUMROC
201 EXTERNAL iceil, indxg2p, lsame, numroc, pslamch
204 INTRINSIC abs, ichar,
max, mod, real
210 ictxt = desca( ctxt_ )
211 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
216 IF( nprow.EQ.-1 )
THEN
219 CALL chk1mat( n, 2, n, 2, ia, ja, desca, 6, info )
221 upper = lsame( uplo,
'U' )
222 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
224 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
226 npmod = numroc( n + mod( ia-1, desca( mb_ ) ), desca( mb_ ),
227 $ myrow, iarow, nprow )
228 nqmod = numroc( n + mod( ja-1, desca( nb_ ) ), desca( nb_ ),
229 $ mycol, iacol, npcol )
230 lwmin = 2*npmod + 2*nqmod +
231 $
max( 2,
max( desca( nb_ )*
232 $
max( 1, iceil( nprow-1, npcol ) ), nqmod +
234 $
max( 1, iceil( npcol-1, nprow ) ) ) )
235 work( 1 ) = real( lwmin )
238 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 )
240 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
242 ELSE IF( anorm.LT.zero )
THEN
244 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
246 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery )
THEN
253 idum1( 1 ) = ichar(
'U' )
255 idum1( 1 ) = ichar(
'L' )
258 IF( lwork.EQ.-1 )
THEN
264 IF( liwork.EQ.-1 )
THEN
270 CALL pchk1mat( n, 2, n, 2, ia, ja, desca, 6, 3, idum1, idum2,
275 CALL pxerbla( ictxt,
'PSPOCON', -info )
277 ELSE IF( lquery )
THEN
287 ELSE IF( anorm.EQ.zero )
THEN
289 ELSE IF( n.EQ.1 )
THEN
294 CALL pb_topget( ictxt,
'Combine',
'Columnwise', colctop )
295 CALL pb_topget( ictxt,
'Combine',
'Rowwise', rowctop )
296 CALL pb_topset( ictxt,
'Combine',
'Columnwise',
'1-tree' )
297 CALL pb_topset( ictxt,
'Combine',
'Rowwise',
'1-tree' )
299 smlnum = pslamch( ictxt,
'Safe minimum' )
300 iroff = mod( ia-1, desca( mb_ ) )
301 icoff = mod( ja-1, desca( nb_ ) )
302 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
304 np = numroc( n+iroff, desca( mb_ ), myrow, iarow, nprow )
305 nq = numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
317 CALL descset( descv, n+iroff, 1, desca( mb_ ), 1, iarow, mycol,
318 $ ictxt,
max( 1, np ) )
319 CALL descset( descx, n+iroff, 1, desca( mb_ ), 1, iarow, mycol,
320 $ ictxt,
max( 1, np ) )
329 CALL pslacon( n, work( ipv ), iv, jv, descv, work( ipx ), ix, jx,
330 $ descx, iwork, ainvnm, kase )
336 descx( csrc_ ) = iacol
337 CALL pslatrs(
'Upper',
'Transpose',
'Non-unit', normin,
338 $ n, a, ia, ja, desca, work( ipx ), ix, jx,
339 $ descx, sl, work( ipnl ), work( ipw ) )
340 descx( csrc_ ) = mycol
345 descx( csrc_ ) = iacol
346 CALL pslatrs(
'Upper',
'No transpose',
'Non-unit', normin,
347 $ n, a, ia, ja, desca, work( ipx ), ix, jx,
348 $ descx, su, work( ipnu ), work( ipw ) )
349 descx( csrc_ ) = mycol
354 descx( csrc_ ) = iacol
355 CALL pslatrs(
'Lower',
'No transpose',
'Non-unit', normin,
356 $ n, a, ia, ja, desca, work( ipx ), ix, jx,
357 $ descx, sl, work( ipnl ), work( ipw ) )
358 descx( csrc_ ) = mycol
363 descx( csrc_ ) = iacol
364 CALL pslatrs(
'Lower',
'Transpose',
'Non-unit', normin,
365 $ n, a, ia, ja, desca, work( ipx ), ix, jx,
366 $ descx, su, work( ipnu ), work( ipw ) )
367 descx( csrc_ ) = mycol
373 IF( scale.NE.one )
THEN
374 CALL psamax( n, wmax, ixx, work( ipx ), ix, jx, descx, 1 )
375 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
376 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', cbtop )
377 IF( myrow.EQ.iarow )
THEN
378 CALL sgebs2d( ictxt,
'Column', cbtop, 1, 1, wmax, 1 )
380 CALL sgebr2d( ictxt,
'Column', cbtop, 1, 1, wmax, 1,
384 IF( scale.LT.abs( wmax )*smlnum .OR. scale.EQ.zero )
386 CALL psrscl( n, scale, work( ipx ), ix, jx, descx, 1 )
394 $ rcond = ( one / ainvnm ) / anorm
398 CALL pb_topset( ictxt,
'Combine',
'Columnwise', colctop )
399 CALL pb_topset( ictxt,
'Combine',
'Rowwise', rowctop )