1 SUBROUTINE psmatgen( ICTXT, AFORM, DIAG, M, N, MB, NB, A, LDA,
2 $ IAROW, IACOL, ISEED, IROFF, IRNUM, ICOFF,
3 $ ICNUM, MYROW, MYCOL, NPROW, NPCOL )
11 CHARACTER*1 AFORM, DIAG
12 INTEGER IACOL, IAROW, ICNUM, ICOFF, ICTXT, IRNUM,
13 $ iroff, iseed, lda, m, mb, mycol, myrow, n,
115 INTEGER MULT0, MULT1, IADD0, IADD1
116 PARAMETER ( MULT0=20077, mult1=16838, iadd0=12345,
119 PARAMETER ( ONE = 1.0e+0, two = 2.0e+0 )
122 LOGICAL SYMM, HERM, TRAN
123 INTEGER I, IC, IK, INFO, IOFFC, IOFFR, IR, J, JK,
124 $ jump1, jump2, jump3, jump4, jump5, jump6,
125 $ jump7, maxmn, mend, moff, mp, mrcol, mrrow,
126 $ nend, noff, npmb, nq, nqnb
129 INTEGER IADD(2), IA1(2), IA2(2), IA3(2), IA4(2),
130 $ IA5(2), IB1(2), IB2(2), IB3(2), IC1(2), IC2(2),
131 $ ic3(2), ic4(2), ic5(2), iran1(2), iran2(2),
132 $ iran3(2), iran4(2), itmp1(2), itmp2(2),
133 $ itmp3(2), jseed(2), mult(2)
139 INTRINSIC abs,
max, mod
143 INTEGER ICEIL, NUMROC
145 EXTERNAL iceil, numroc, lsame, psrand
151 mp = numroc( m, mb, myrow, iarow, nprow )
152 nq = numroc( n, nb, mycol, iacol, npcol )
153 symm = lsame( aform,
'S' )
154 herm = lsame( aform,
'H' )
155 tran = lsame( aform,
'T' )
158 IF( .NOT.lsame( diag,
'D' ) .AND.
159 $ .NOT.lsame( diag,
'N' ) )
THEN
161 ELSE IF( symm.OR.herm )
THEN
164 ELSE IF( mb.NE.nb )
THEN
167 ELSE IF( m.LT.0 )
THEN
169 ELSE IF( n.LT.0 )
THEN
171 ELSE IF( mb.LT.1 )
THEN
173 ELSE IF( nb.LT.1 )
THEN
175 ELSE IF( lda.LT.0 )
THEN
177 ELSE IF( ( iarow.LT.0 ).OR.( iarow.GE.nprow ) )
THEN
179 ELSE IF( ( iacol.LT.0 ).OR.( iacol.GE.npcol ) )
THEN
181 ELSE IF( mod(iroff,mb).GT.0 )
THEN
183 ELSE IF( irnum.GT.(mp-iroff) )
THEN
185 ELSE IF( mod(icoff,nb).GT.0 )
THEN
187 ELSE IF( icnum.GT.(nq-icoff) )
THEN
189 ELSE IF( ( myrow.LT.0 ).OR.( myrow.GE.nprow ) )
THEN
191 ELSE IF( ( mycol.LT.0 ).OR.( mycol.GE.npcol ) )
THEN
195 CALL pxerbla( ictxt,
'PSMATGEN', info )
199 mrrow = mod( nprow+myrow-iarow, nprow )
200 mrcol = mod( npcol+mycol-iacol, npcol )
205 mend = iceil(irnum, mb) + moff
206 nend = iceil(icnum, nb) + noff
217 IF( symm.OR.herm )
THEN
229 CALL xjumpm( jump1, mult, iadd, jseed, iran1, ia1, ic1 )
230 CALL xjumpm( jump2, mult, iadd, iran1, itmp1, ia2, ic2 )
231 CALL xjumpm( jump3, mult, iadd, iran1, itmp1, ia3, ic3 )
232 CALL xjumpm( jump4, ia3, ic3, iran1, itmp1, ia4, ic4 )
233 CALL xjumpm( jump5, ia3, ic3, iran1, itmp1, ia5, ic5 )
234 CALL xjumpm( jump6, ia5, ic5, iran1, itmp3, itmp1, itmp2 )
235 CALL xjumpm( jump7, mult, iadd, itmp3, iran1, itmp1, itmp2 )
236 CALL xjumpm( noff, ia4, ic4, iran1, itmp1, itmp2, itmp3 )
237 CALL xjumpm( moff, ia2, ic2, itmp1, iran1, itmp2, itmp3 )
238 CALL setran( iran1, ia1, ic1 )
247 DO 80 ic = noff+1, nend
248 ioffc = ((ic-1)*npcol+mrcol) * nb
250 IF( jk .GT. icnum )
GO TO 90
253 DO 50 ir = moff+1, mend
254 ioffr = ((ir-1)*nprow+mrrow) * mb
256 IF( ioffr .GT. ioffc )
THEN
258 IF( ik .GT. irnum )
GO TO 60
259 a(ik,jk) = one - two*psrand(0)
263 ELSE IF( ioffc .EQ. ioffr )
THEN
265 IF( ik .GT. irnum )
GO TO 60
267 a(ik,jk) = one - two*psrand(0)
269 a(ik,jk) = one - two*psrand(0)
271 IF( ik+j .GT. irnum )
GO TO 60
272 a(ik+j,jk) = one - two*psrand(0)
273 a(ik,jk+j) = a(ik+j,jk)
280 CALL jumpit( ia2, ic2, ib1, iran2 )
287 CALL jumpit( ia3, ic3, ib2, iran3 )
294 CALL jumpit( ia4, ic4, ib3, iran4 )
321 CALL xjumpm( jump1, mult, iadd, jseed, iran1, ia1, ic1 )
322 CALL xjumpm( jump2, mult, iadd, iran1, itmp1, ia2, ic2 )
323 CALL xjumpm( jump3, mult, iadd, iran1, itmp1, ia3, ic3 )
324 CALL xjumpm( jump4, ia3, ic3, iran1, itmp1, ia4, ic4 )
325 CALL xjumpm( jump5, ia3, ic3, iran1, itmp1, ia5, ic5 )
326 CALL xjumpm( jump6, ia5, ic5, iran1, itmp3, itmp1, itmp2 )
327 CALL xjumpm( jump7, mult, iadd, itmp3, iran1, itmp1, itmp2 )
328 CALL xjumpm( moff, ia4, ic4, iran1, itmp1, itmp2, itmp3 )
329 CALL xjumpm( noff, ia2, ic2, itmp1, iran1, itmp2, itmp3 )
330 CALL setran( iran1, ia1, ic1 )
339 DO 150 ir = moff+1, mend
340 ioffr = ((ir-1)*nprow+mrrow) * mb
342 IF( ik .GT. irnum )
GO TO 160
344 DO 120 ic = noff+1, nend
345 ioffc = ((ic-1)*npcol+mrcol) * nb
346 IF( ioffc .GT. ioffr )
THEN
348 IF( jk .GT. icnum )
GO TO 130
349 a(ik,jk) = one - two*psrand(0)
355 CALL jumpit( ia2, ic2, ib1, iran2 )
362 CALL jumpit( ia3, ic3, ib2, iran3 )
369 CALL jumpit( ia4, ic4, ib3, iran4 )
381 ELSE IF( tran .OR. lsame( aform,
'C' ) )
THEN
391 CALL xjumpm( jump1, mult, iadd, jseed, iran1, ia1, ic1 )
392 CALL xjumpm( jump2, mult, iadd, iran1, itmp1, ia2, ic2 )
393 CALL xjumpm( jump3, mult, iadd, iran1, itmp1, ia3, ic3 )
394 CALL xjumpm( jump4, ia3, ic3, iran1, itmp1, ia4, ic4 )
395 CALL xjumpm( jump5, ia3, ic3, iran1, itmp1, ia5, ic5 )
396 CALL xjumpm( jump6, ia5, ic5, iran1, itmp3, itmp1, itmp2 )
397 CALL xjumpm( jump7, mult, iadd, itmp3, iran1, itmp1, itmp2 )
398 CALL xjumpm( moff, ia4, ic4, iran1, itmp1, itmp2, itmp3 )
399 CALL xjumpm( noff, ia2, ic2, itmp1, iran1, itmp2, itmp3 )
400 CALL setran( iran1, ia1, ic1 )
409 DO 220 ir = moff+1, mend
410 ioffr = ((ir-1)*nprow+mrrow) * mb
412 IF( ik .GT. irnum )
GO TO 230
414 DO 190 ic = noff+1, nend
415 ioffc = ((ic-1)*npcol+mrcol) * nb
417 IF( jk .GT. icnum )
GO TO 200
418 a(ik,jk) = one - two*psrand(0)
421 CALL jumpit( ia2, ic2, ib1, iran2 )
428 CALL jumpit( ia3, ic3, ib2, iran3 )
435 CALL jumpit( ia4, ic4, ib3, iran4 )
457 CALL xjumpm( jump1, mult, iadd, jseed, iran1, ia1, ic1 )
458 CALL xjumpm( jump2, mult, iadd, iran1, itmp1, ia2, ic2 )
459 CALL xjumpm( jump3, mult, iadd, iran1, itmp1, ia3, ic3 )
460 CALL xjumpm( jump4, ia3, ic3, iran1, itmp1, ia4, ic4 )
461 CALL xjumpm( jump5, ia3, ic3, iran1, itmp1, ia5, ic5 )
462 CALL xjumpm( jump6, ia5, ic5, iran1, itmp3, itmp1, itmp2 )
463 CALL xjumpm( jump7, mult, iadd, itmp3, iran1, itmp1, itmp2 )
464 CALL xjumpm( noff, ia4, ic4, iran1, itmp1, itmp2, itmp3 )
465 CALL xjumpm( moff, ia2, ic2, itmp1, iran1, itmp2, itmp3 )
466 CALL setran( iran1, ia1, ic1 )
475 DO 290 ic = noff+1, nend
476 ioffc = ((ic-1)*npcol+mrcol) * nb
478 IF( jk .GT. icnum )
GO TO 300
480 DO 260 ir = moff+1, mend
481 ioffr = ((ir-1)*nprow+mrrow) * mb
483 IF( ik .GT. irnum )
GO TO 270
484 a(ik,jk) = one - two*psrand(0)
487 CALL jumpit( ia2, ic2, ib1, iran2 )
494 CALL jumpit( ia3, ic3, ib2, iran3 )
501 CALL jumpit( ia4, ic4, ib3, iran4 )
514 IF( lsame( diag,
'D' ) )
THEN
516 WRITE(*,*)
'Diagonally dominant matrices with rowNB not'//
517 $
' equal colNB is not supported!'
523 DO 340 ic = noff+1, nend
524 ioffc = ((ic-1)*npcol+mrcol) * nb
526 DO 320 ir = moff+1, mend
527 ioffr = ((ir-1)*nprow+mrrow) * mb
528 IF( ioffc.EQ.ioffr )
THEN
530 IF( ik .GT. irnum )
GO TO 330
531 a(ik,jk+j) = abs(a(ik,jk+j)) + maxmn