1 SUBROUTINE pcgeequ( M, N, A, IA, JA, DESCA, R, C, ROWCND, COLCND,
10 INTEGER IA, INFO, JA, M, N
11 REAL AMAX, COLCND, ROWCND
158 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
159 $ lld_, mb_, m_, nb_, n_, rsrc_
160 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
161 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
162 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
164 parameter( one = 1.0e+0, zero = 0.0e+0 )
167 CHARACTER COLCTOP, ROWCTOP
168 INTEGER I, IACOL, IAROW, ICOFF, ICTXT, IDUMM, IIA,
169 $ ioffa, iroff, j, jja, lda, mp, mycol, myrow,
171 REAL BIGNUM, RCMAX, RCMIN, SMLNUM
175 INTEGER DESCC( DLEN_ ), DESCR( DLEN_ )
183 INTEGER INDXL2G, NUMROC
185 EXTERNAL indxl2g, numroc, pslamch
188 INTRINSIC abs, aimag,
max,
min, mod, real
194 cabs1( zdum ) = abs( real( zdum ) ) + abs( aimag( zdum ) )
200 ictxt = desca( ctxt_ )
201 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
206 IF( nprow.EQ.-1 )
THEN
209 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
210 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 6, 0, idumm, idumm,
215 CALL pxerbla( ictxt,
'PCGEEQU', -info )
221 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
228 CALL pb_topget( ictxt,
'Combine',
'Rowwise', rowctop )
229 CALL pb_topget( ictxt,
'Combine',
'Columnwise', colctop )
233 smlnum = pslamch( ictxt,
'S' )
234 bignum = one / smlnum
235 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
237 iroff = mod( ia-1, desca( mb_ ) )
238 icoff = mod( ja-1, desca( nb_ ) )
239 mp = numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
240 nq = numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
249 CALL descset( descr, m, 1, desca( mb_ ), 1, 0, 0, ictxt,
251 CALL descset( descc, 1, n, 1, desca( nb_ ), 0, 0, ictxt, 1 )
255 DO 10 i = iia, iia+mp-1
262 DO 30 j = jja, jja+nq-1
263 DO 20 i = iia, iia+mp-1
264 r( i ) =
max( r( i ), cabs1( a( ioffa + i ) ) )
268 CALL sgamx2d( ictxt,
'Rowwise', rowctop, mp, 1, r( iia ),
269 $
max( 1, mp ), idumm, idumm, -1, -1, mycol )
275 DO 40 i = iia, iia+mp-1
276 rcmax =
max( rcmax, r( i ) )
277 rcmin =
min( rcmin, r( i ) )
279 CALL sgamx2d( ictxt,
'Columnwise', colctop, 1, 1, rcmax, 1, idumm,
280 $ idumm, -1, -1, mycol )
281 CALL sgamn2d( ictxt,
'Columnwise', colctop, 1, 1, rcmin, 1, idumm,
282 $ idumm, -1, -1, mycol )
285 IF( rcmin.EQ.zero )
THEN
289 DO 50 i = iia, iia+mp-1
290 IF( r( i ).EQ.zero .AND. info.EQ.0 )
291 $ info = indxl2g( i, desca( mb_ ), myrow, desca( rsrc_ ),
294 CALL igamx2d( ictxt,
'Columnwise', colctop, 1, 1, info, 1,
295 $ idumm, idumm, -1, -1, mycol )
302 DO 60 i = iia, iia+mp-1
303 r( i ) = one /
min(
max( r( i ), smlnum ), bignum )
308 rowcnd =
max( rcmin, smlnum ) /
min( rcmax, bignum )
314 DO 70 j = jja, jja+nq-1
322 DO 90 j = jja, jja+nq-1
323 DO 80 i = iia, iia+mp-1
324 c( j ) =
max( c( j ), cabs1( a( ioffa + i ) )*r( i ) )
328 CALL sgamx2d( ictxt,
'Columnwise', colctop, 1, nq, c( jja ),
329 $ 1, idumm, idumm, -1, -1, mycol )
335 DO 100 j = jja, jja+nq-1
336 rcmin =
min( rcmin, c( j ) )
337 rcmax =
max( rcmax, c( j ) )
339 CALL sgamx2d( ictxt,
'Columnwise', colctop, 1, 1, rcmax, 1, idumm,
340 $ idumm, -1, -1, mycol )
341 CALL sgamn2d( ictxt,
'Columnwise', colctop, 1, 1, rcmin, 1, idumm,
342 $ idumm, -1, -1, mycol )
344 IF( rcmin.EQ.zero )
THEN
348 DO 110 j = jja, jja+nq-1
349 IF( c( j ).EQ.zero .AND. info.EQ.0 )
350 $ info = m + indxl2g( j, desca( nb_ ), mycol,
351 $ desca( csrc_ ), npcol ) - ja + 1
353 CALL igamx2d( ictxt,
'Columnwise', colctop, 1, 1, info, 1,
354 $ idumm, idumm, -1, -1, mycol )
361 DO 120 j = jja, jja+nq-1
362 c( j ) = one /
min(
max( c( j ), smlnum ), bignum )
367 colcnd =
max( rcmin, smlnum ) /
min( rcmax, bignum )