1 SUBROUTINE pclafchk( AFORM, DIAG, M, N, A, IA, JA, DESCA, IASEED,
2 $ ANORM, FRESID, WORK )
11 INTEGER IA, IASEED, JA, M, N
16 COMPLEX A( * ), WORK( * )
148 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
149 $ lld_, mb_, m_, nb_, n_, rsrc_
150 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
151 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
152 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
154 parameter( one = (1.0e+0, 0.0e+0) )
157 INTEGER IACOL, IAROW, ICOFF, ICTXT, ICURCOL, ICURROW,
158 $ ii, iia, ioffa, iroff, jb, jj, jja, jn, kk,
159 $ lda, ldw, ldwp1, mp, mycol, myrow, npcol,
168 INTEGER ICEIL, NUMROC
169 REAL PSLAMCH, PCLANGE
170 EXTERNAL iceil, lsame, numroc, pclange, pslamch
173 INTRINSIC max,
min, mod, real
177 ictxt = desca( ctxt_ )
178 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
179 eps = pslamch( ictxt,
'eps' )
180 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
185 iroff = mod( ia-1, desca( mb_ ) )
186 icoff = mod( ja-1, desca( nb_ ) )
187 mp = numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
188 nq = numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
193 jn =
min( iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
197 ioffa = iia + ( jja - 1 )*lda
199 IF( lsame( aform,
'H' ) )
THEN
208 IF( mycol.EQ.icurcol )
THEN
209 CALL pcmatgen( ictxt, aform, diag, desca( m_ ), desca( n_ ),
210 $ desca( mb_ ), desca( nb_ ), work, ldw,
211 $ desca( rsrc_ ), desca( csrc_ ), iaseed,
212 $ iia-1, mp, jja-1, jb, myrow, mycol, nprow,
214 IF( myrow.EQ.icurrow )
THEN
216 work( ii+kk*ldwp1 ) = real( work( ii+kk*ldwp1 ) )
219 CALL cmatadd( mp, jb, -one, work, ldw, one, a( ioffa ),
222 ioffa = ioffa + jb*lda
225 IF( myrow.EQ.icurrow )
227 icurrow = mod( icurrow+1, nprow )
228 icurcol = mod( icurcol+1, npcol )
230 DO 30, jj = jn+1, ja+n-1, desca( nb_ )
231 jb =
min( ja+n-jj, desca( nb_ ) )
233 IF( mycol.EQ.icurcol )
THEN
234 CALL pcmatgen( ictxt, aform, diag, desca( m_ ),
235 $ desca( n_ ), desca( mb_ ), desca( nb_ ),
236 $ work, ldw, desca( rsrc_ ), desca( csrc_ ),
237 $ iaseed, iia-1, mp, jja-1, jb, myrow,
238 $ mycol, nprow, npcol )
239 IF( myrow.EQ.icurrow )
THEN
241 work( ii+kk*ldwp1 ) = real( work( ii+kk*ldwp1 ) )
244 CALL cmatadd( mp, jb, -one, work, ldw, one, a( ioffa ),
247 ioffa = ioffa + jb*lda
249 IF( myrow.EQ.icurrow )
251 icurrow = mod( icurrow+1, nprow )
252 icurcol = mod( icurcol+1, npcol )
259 IF( mycol.EQ.iacol )
THEN
261 CALL pcmatgen( ictxt, aform, diag, desca( m_ ), desca( n_ ),
262 $ desca( mb_ ), desca( nb_ ), work, ldw,
263 $ desca( rsrc_ ), desca( csrc_ ), iaseed,
264 $ iia-1, mp, jja-1, jb, myrow, mycol, nprow,
266 CALL cmatadd( mp, jb, -one, work, ldw, one, a( ioffa ),
270 ioffa = ioffa + jb * lda
275 DO 40 jj = jja, jja+nq-1, desca( nb_ )
276 jb =
min( desca( nb_ ), jja+nq-jj )
277 ioffa = iia + ( jj - 1 )*lda
278 CALL pcmatgen( ictxt, aform, diag, desca( m_ ), desca( n_ ),
279 $ desca( mb_ ), desca( nb_ ), work, ldw,
280 $ desca( rsrc_ ), desca( csrc_ ), iaseed,
281 $ iia-1, mp, jj-1, jb, myrow, mycol, nprow,
283 CALL cmatadd( mp, jb, -one, work, ldw, one, a( ioffa ),
291 fresid = pclange(
'I', m, n, a, ia, ja, desca, work ) /
292 $ (
max( m, n ) * eps * anorm )