1 SUBROUTINE picol2row( ICTXT, M, N, NB, VS, LDVS, VD, LDVD, RSRC,
2 $ CSRC, RDEST, CDEST, WORK)
10 INTEGER CDEST, CSRC, ICTXT, LDVD, LDVS, M, N, NB,
14 INTEGER VD( LDVD, * ), VS( LDVS, * ), WORK( * )
97 INTEGER CBLKSKIP, ICPY, ICDEST, II, IRSRC, ISTART, JB,
98 $ jj, k, lcm, mp, mq, mycol, mydist, myrow,
99 $ nblocks, npcol, nprow, rblkskip
102 EXTERNAL blacs_gridinfo, igesd2d, igerv2d,
ilacpy
106 EXTERNAL ilcm, numroc
116 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
121 IF( nprow.NE.npcol )
THEN
122 lcm = ilcm( nprow, npcol )
123 rblkskip = lcm / npcol
124 cblkskip = lcm / nprow
128 IF( mycol.EQ.csrc )
THEN
135 mydist = mod( nprow+myrow-rsrc, nprow )
136 mp = numroc( m, nb, myrow, rsrc, nprow )
137 icdest = mod( cdest+mydist, npcol )
141 DO 20 k = 1, cblkskip
146 IF( (mycol.NE.icdest).OR.(myrow.NE.rdest) )
THEN
150 DO 10 ii = istart, mp, nb*cblkskip
151 jb =
min(nb, mp-ii+1)
152 CALL ilacpy(
'G', jb, n, vs(ii,1), ldvs,
162 $
CALL igesd2d( ictxt, jj, 1, work, jj, rdest,
174 icdest = mod(icdest+nprow, npcol)
180 IF( myrow.EQ.rdest )
THEN
187 mydist = mod( npcol+mycol-cdest, npcol )
188 mq = numroc( m, nb, mycol, cdest, npcol )
189 irsrc = mod( rsrc+mydist, nprow )
190 DO 50 k = 1, rblkskip
194 IF( (mycol.NE.csrc).OR.(myrow.NE.irsrc) )
THEN
199 nblocks = (mq - istart + nb) / nb
200 jj = ((nblocks+rblkskip-1) / rblkskip)*nb
202 $
CALL igerv2d( ictxt, jj, n, work, jj, irsrc, csrc )
207 DO 30 ii = istart, mq, nb*rblkskip
208 jb =
min( nb, mq-ii+1 )
209 CALL ilacpy(
'G', jb, n, work(jj), jb,
218 DO 40 ii = istart, mq, nb*rblkskip
219 jb =
min( nb, mq-ii+1 )
220 CALL ilacpy(
'G', jb, n, vs(jj,1), ldvs,
222 jj = jj + nb*cblkskip
226 irsrc = mod( irsrc+npcol, nprow )
235 IF( mycol.EQ.csrc )
THEN
240 mydist = mod( nprow+myrow-rsrc, nprow )
241 mp = numroc( m, nb, myrow, rsrc, nprow )
242 icdest = mod( cdest+mydist, npcol )
244 IF( (mycol.NE.icdest).OR.(myrow.NE.rdest) )
THEN
245 CALL igesd2d( ictxt, mp, n, vs, ldvs, rdest, icdest )
247 CALL ilacpy(
'G', mp, n, vs, ldvs, vd, ldvd )
251 IF( myrow.EQ.rdest )
THEN
256 mydist = mod( npcol+mycol-cdest, npcol )
257 mq = numroc( m, nb, mycol, cdest, npcol )
258 irsrc = mod( rsrc+mydist, nprow )
260 IF( (myrow.NE.irsrc).OR.(mycol.NE.csrc) )
261 $
CALL igerv2d( ictxt, mq, n, vd, ldvd, irsrc, csrc )