1 SUBROUTINE pirow2col( ICTXT, M, N, NB, VS, LDVS, VD, LDVD,
2 $ RSRC, CSRC, RDEST, CDEST, WORK)
10 INTEGER CDEST, CSRC, ICTXT, LDVD, LDVS, M, N, NB,
14 INTEGER VD( LDVD, * ), VS( LDVS, * ), WORK( * )
96 INTEGER CBLKSKIP, ICPY, II, ISTART, ICSRC, IRDEST, JB,
97 $ jj, k, lcm, mp, mq, mycol, mydist, myrow,
98 $ nblocks, npcol, nprow, rblkskip
101 EXTERNAL blacs_gridinfo, igesd2d, igerv2d,
ilacpy
105 EXTERNAL ilcm, numroc
114 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
119 IF( nprow .NE. npcol )
THEN
120 lcm = ilcm( nprow, npcol )
121 rblkskip = lcm / npcol
122 cblkskip = lcm / nprow
126 IF( myrow.EQ.rsrc )
THEN
133 mydist = mod( npcol+mycol-csrc, npcol )
134 mq = numroc( m, nb, mycol, csrc, npcol )
135 irdest = mod( rdest+mydist, nprow )
139 DO 20 k = 1, rblkskip
144 IF( (myrow.NE.irdest).OR.(mycol.NE.cdest) )
THEN
148 DO 10 ii = istart, mq, nb*rblkskip
149 jb =
min( nb, mq-ii+1 )
150 CALL ilacpy(
'G', jb, n, vs(ii,1), ldvs,
160 $
CALL igesd2d( ictxt, jj, 1, work, jj, irdest,
171 irdest = mod( irdest+npcol, nprow )
177 IF( mycol.EQ.cdest )
THEN
184 mydist = mod( nprow+myrow-rdest, nprow )
185 mp = numroc( m, nb, myrow, rdest, nprow )
186 icsrc = mod( csrc+mydist, npcol )
190 DO 50 k = 1, cblkskip
194 IF( (myrow.NE.rsrc).OR.(mycol.NE.icsrc) )
THEN
199 nblocks = (mp - istart + nb) / nb
200 jj = ((nblocks+cblkskip-1) / cblkskip)*nb
202 $
CALL igerv2d( ictxt, jj, n, work, jj, rsrc, icsrc )
207 DO 30 ii = istart, mp, nb*cblkskip
208 jb =
min( nb, mp-ii+1 )
209 CALL ilacpy(
'G', jb, n, work(jj), jb, vd(ii,1),
218 DO 40 ii = istart, mp, nb*cblkskip
219 jb =
min( nb, mp-ii+1 )
220 CALL ilacpy(
'G', jb, n, vs(jj,1), ldvs, vd(ii,1),
222 jj = jj + nb*rblkskip
226 icsrc = mod( icsrc+nprow, npcol )
235 IF( myrow.EQ.rsrc )
THEN
240 mydist = mod( npcol+mycol-csrc, npcol )
241 mq = numroc( m, nb, mycol, csrc, npcol )
242 irdest = mod( rdest+mydist, nprow )
243 IF( (myrow.NE.irdest).OR.(mycol.NE.cdest) )
THEN
244 CALL igesd2d( ictxt, mq, n, vs, ldvs, irdest, cdest )
246 CALL ilacpy(
'G', mq, n, vs, ldvs, vd, ldvd )
249 IF( mycol.EQ.cdest )
THEN
254 mydist = mod( nprow+myrow-rdest, nprow )
255 mp = numroc( m, nb, myrow, rdest, nprow )
256 icsrc = mod( csrc+mydist, npcol )
257 IF( (mycol.NE.icsrc).OR.(myrow.NE. rsrc) )
258 $
CALL igerv2d( ictxt, mp, n, vd, ldvd, rsrc, icsrc )