1 SUBROUTINE pclaschk( SYMM, DIAG, N, NRHS, X, IX, JX, DESCX,
2 $ IASEED, IA, JA, DESCA, IBSEED, ANORM, RESID,
12 INTEGER IA, IASEED, IBSEED, IX, JA, JX, N, NRHS
16 INTEGER DESCA( * ), DESCX( * )
17 COMPLEX WORK( * ), X( * )
149 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
150 $ LLD_, MB_, M_, NB_, N_, RSRC_
151 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
152 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
153 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
155 PARAMETER ( ONE = ( 1.0e+0, 0.0e+0 ),
156 $ zero = ( 0.0e+0, 0.0e+0 ) )
159 INTEGER IACOL, IAROW, IB, ICOFF, ICTXT, ICURCOL, IDUMM,
160 $ II, IIA, IIX, IOFFX, IPA, IPB, IPW, IPX, IROFF,
161 $ ixcol, ixrow, j, jbrhs, jj, jja, jjx, ldx,
162 $ mycol, myrow, np, npcol, nprow, nq
163 REAL DIVISOR, EPS, RESID1
167 EXTERNAL blacs_gridinfo, cgamx2d, cgemm, cgsum2d,
169 $ sgebs2d, sgerv2d, sgesd2d
172 INTEGER ICAMAX, NUMROC
174 EXTERNAL icamax, numroc, pslamch
177 INTRINSIC abs,
max,
min, mod, real
183 ictxt = desca( ctxt_ )
184 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
186 eps = pslamch( ictxt,
'eps' )
188 divisor = anorm * eps * real( n )
190 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
192 CALL infog2l( ix, jx, descx, nprow, npcol, myrow, mycol, iix, jjx,
194 iroff = mod( ia-1, desca( mb_ ) )
195 icoff = mod( ja-1, desca( nb_ ) )
196 np = numroc( n+iroff, desca( mb_ ), myrow, iarow, nprow )
197 nq = numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
201 ipx = ipb + np * descx( nb_ )
202 ipa = ipx + nq * descx( nb_ )
213 DO 40 j = 1, nrhs, descx( nb_ )
214 jbrhs =
min( descx( nb_ ), nrhs-j+1 )
218 ioffx = iix + ( jjx - 1 ) * descx( lld_ )
219 CALL pbctran( ictxt,
'Column',
'Transpose', n, jbrhs,
220 $ descx( mb_ ), x( ioffx ), descx( lld_ ), zero,
221 $ work( ipx ), jbrhs, ixrow, icurcol, -1, iacol,
226 IF( mycol.EQ.icurcol )
THEN
227 CALL pcmatgen( ictxt,
'N',
'N', descx( m_ ), descx( n_ ),
228 $ descx( mb_ ), descx( nb_ ), work( ipb ), ldx,
229 $ ixrow, ixcol, ibseed, iix-1, np, jjx-1,
230 $ jbrhs, myrow, mycol, nprow, npcol )
237 DO 10 ii = iia, iia+np-1, desca( mb_ )
238 ib =
min( desca( mb_ ), iia+np-ii )
242 CALL pcmatgen( ictxt, symm, diag, desca( m_ ),
243 $ desca( n_ ), desca( mb_ ), desca( nb_ ),
244 $ work( ipa ), ib, desca( rsrc_ ),
245 $ desca( csrc_ ), iaseed, ii-1, ib,
246 $ jja-1, nq, myrow, mycol, nprow, npcol )
250 CALL cgemm(
'No transpose',
'Transpose', ib, jbrhs, nq,
251 $ -one, work( ipa ), ib, work( ipx ), jbrhs,
252 $ beta, work( ipb+ii-iia ), ldx )
256 ELSE IF( mycol.NE.icurcol )
THEN
258 CALL claset(
'All', np, jbrhs, zero, zero, work( ipb ),
265 CALL cgsum2d( ictxt,
'Row',
' ', np, jbrhs, work( ipb ), ldx,
268 IF( mycol.EQ.icurcol )
THEN
273 DO 20 jj = 0, jbrhs - 1
275 ii = icamax( np, work( ipb+jj*ldx ), 1 )
276 work( ipa+jj ) = abs( work( ipb+ii-1+jj*ldx ) )
277 work( ipw+jj ) = abs( x( ioffx + icamax( np,
278 $ x( ioffx + jj*descx( lld_ ) ), 1 )-1+jj*
281 work( ipa+jj ) = zero
282 work( ipw+jj ) = zero
290 CALL cgamx2d( ictxt,
'Column',
' ', 1, 2*jbrhs,
291 $ work( ipa ), 1, idumm, idumm, -1, 0, icurcol )
295 IF( myrow.EQ.0 )
THEN
296 DO 30 jj = 0, jbrhs - 1
297 resid1 = real( work( ipa+jj ) ) /
298 $ ( real( work( ipw+jj ) )*divisor )
299 IF( resid.LT.resid1 )
303 $
CALL sgesd2d( ictxt, 1, 1, resid, 1, 0, 0 )
306 ELSE IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
308 CALL sgerv2d( ictxt, 1, 1, resid1, 1, 0, icurcol )
309 IF( resid.LT.resid1 )
314 IF( mycol.EQ.icurcol )
316 icurcol = mod( icurcol+1, npcol )
320 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
321 CALL sgebs2d( ictxt,
'All',
' ', 1, 1, resid, 1 )
323 CALL sgebr2d( ictxt,
'All',
' ', 1, 1, resid, 1, 0, 0 )