1 SUBROUTINE psgeequ( M, N, A, IA, JA, DESCA, R, C, ROWCND, COLCND,
10 INTEGER IA, INFO, JA, M, N
11 REAL AMAX, COLCND, ROWCND
15 REAL A( * ), C( * ), R( * )
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 )
166 CHARACTER COLCTOP, ROWCTOP
167 INTEGER I, IACOL, IAROW, ICOFF, ICTXT, IDUMM, IIA,
168 $ ioffa, iroff, j, jja, lda, mp, mycol, myrow,
170 REAL BIGNUM, RCMAX, RCMIN, SMLNUM
173 INTEGER DESCC( DLEN_ ), DESCR( DLEN_ )
181 INTEGER INDXL2G, NUMROC
183 EXTERNAL indxl2g, numroc, pslamch
186 INTRINSIC abs,
max,
min, mod
192 ictxt = desca( ctxt_ )
193 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
198 IF( nprow.EQ.-1 )
THEN
201 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
202 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 6, 0, idumm, idumm,
207 CALL pxerbla( ictxt,
'PSGEEQU', -info )
213 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
220 CALL pb_topget( ictxt,
'Combine',
'Rowwise', rowctop )
221 CALL pb_topget( ictxt,
'Combine',
'Columnwise', colctop )
225 smlnum = pslamch( ictxt,
'S' )
226 bignum = one / smlnum
227 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
229 iroff = mod( ia-1, desca( mb_ ) )
230 icoff = mod( ja-1, desca( nb_ ) )
231 mp = numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
232 nq = numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
241 CALL descset( descr, m, 1, desca( mb_ ), 1, 0, 0, ictxt,
243 CALL descset( descc, 1, n, 1, desca( nb_ ), 0, 0, ictxt, 1 )
247 DO 10 i = iia, iia+mp-1
254 DO 30 j = jja, jja+nq-1
255 DO 20 i = iia, iia+mp-1
256 r( i ) =
max( r( i ), abs( a( ioffa + i ) ) )
260 CALL sgamx2d( ictxt,
'Rowwise', rowctop, mp, 1, r( iia ),
261 $
max( 1, mp ), idumm, idumm, -1, -1, mycol )
267 DO 40 i = iia, iia+mp-1
268 rcmax =
max( rcmax, r( i ) )
269 rcmin =
min( rcmin, r( i ) )
271 CALL sgamx2d( ictxt,
'Columnwise', colctop, 1, 1, rcmax, 1, idumm,
272 $ idumm, -1, -1, mycol )
273 CALL sgamn2d( ictxt,
'Columnwise', colctop, 1, 1, rcmin, 1, idumm,
274 $ idumm, -1, -1, mycol )
277 IF( rcmin.EQ.zero )
THEN
281 DO 50 i = iia, iia+mp-1
282 IF( r( i ).EQ.zero .AND. info.EQ.0 )
283 $ info = indxl2g( i, desca( mb_ ), myrow, desca( rsrc_ ),
286 CALL igamx2d( ictxt,
'Columnwise', colctop, 1, 1, info, 1,
287 $ idumm, idumm, -1, -1, mycol )
294 DO 60 i = iia, iia+mp-1
295 r( i ) = one /
min(
max( r( i ), smlnum ), bignum )
300 rowcnd =
max( rcmin, smlnum ) /
min( rcmax, bignum )
306 DO 70 j = jja, jja+nq-1
314 DO 90 j = jja, jja+nq-1
315 DO 80 i = iia, iia+mp-1
316 c( j ) =
max( c( j ), abs( a( ioffa + i ) )*r( i ) )
320 CALL sgamx2d( ictxt,
'Columnwise', colctop, 1, nq, c( jja ),
321 $ 1, idumm, idumm, -1, -1, mycol )
327 DO 100 j = jja, jja+nq-1
328 rcmin =
min( rcmin, c( j ) )
329 rcmax =
max( rcmax, c( j ) )
331 CALL sgamx2d( ictxt,
'Columnwise', colctop, 1, 1, rcmax, 1, idumm,
332 $ idumm, -1, -1, mycol )
333 CALL sgamn2d( ictxt,
'Columnwise', colctop, 1, 1, rcmin, 1, idumm,
334 $ idumm, -1, -1, mycol )
336 IF( rcmin.EQ.zero )
THEN
340 DO 110 j = jja, jja+nq-1
341 IF( c( j ).EQ.zero .AND. info.EQ.0 )
342 $ info = m + indxl2g( j, desca( nb_ ), mycol,
343 $ desca( csrc_ ), npcol ) - ja + 1
345 CALL igamx2d( ictxt,
'Columnwise', colctop, 1, 1, info, 1,
346 $ idumm, idumm, -1, -1, mycol )
353 DO 120 j = jja, jja+nq-1
354 c( j ) = one /
min(
max( c( j ), smlnum ), bignum )
359 colcnd =
max( rcmin, smlnum ) /
min( rcmax, bignum )