1 SUBROUTINE pzcol2row( 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 COMPLEX*16 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, zgesd2d, zgerv2d, zlacpy
106 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( mycol.EQ.csrc )
THEN
133 mydist = mod( nprow+myrow-rsrc, nprow )
134 mp = numroc( m, nb, myrow, rsrc, nprow )
135 icdest = mod( cdest+mydist, npcol )
139 DO 20 k = 1, cblkskip
144 IF( (mycol.NE.icdest).OR.(myrow.NE.rdest) )
THEN
148 DO 10 ii = istart, mp, nb*cblkskip
149 jb =
min(nb, mp-ii+1)
150 CALL zlacpy(
'G', jb, n, vs(ii,1), ldvs,
160 $
CALL zgesd2d( ictxt, jj, 1, work, jj, rdest,
172 icdest = mod(icdest+nprow, npcol)
178 IF( myrow.EQ.rdest )
THEN
185 mydist = mod( npcol+mycol-cdest, npcol )
186 mq = numroc( m, nb, mycol, cdest, npcol )
187 irsrc = mod( rsrc+mydist, nprow )
188 DO 50 k = 1, rblkskip
192 IF( (mycol.NE.csrc).OR.(myrow.NE.irsrc) )
THEN
197 nblocks = (mq - istart + nb) / nb
198 jj = ((nblocks+rblkskip-1) / rblkskip)*nb
200 $
CALL zgerv2d( ictxt, jj, n, work, jj, irsrc, csrc )
205 DO 30 ii = istart, mq, nb*rblkskip
206 jb =
min( nb, mq-ii+1 )
207 CALL zlacpy(
'G', jb, n, work(jj), jb,
216 DO 40 ii = istart, mq, nb*rblkskip
217 jb =
min( nb, mq-ii+1 )
218 CALL zlacpy(
'G', jb, n, vs(jj,1), ldvs,
220 jj = jj + nb*cblkskip
224 irsrc = mod( irsrc+npcol, nprow )
233 IF( mycol.EQ.csrc )
THEN
238 mydist = mod( nprow+myrow-rsrc, nprow )
239 mp = numroc( m, nb, myrow, rsrc, nprow )
240 icdest = mod( cdest+mydist, npcol )
242 IF( (mycol.NE.icdest).OR.(myrow.NE.rdest) )
THEN
243 CALL zgesd2d( ictxt, mp, n, vs, ldvs, rdest, icdest )
245 CALL zlacpy(
'G', mp, n, vs, ldvs, vd, ldvd )
249 IF( myrow.EQ.rdest )
THEN
254 mydist = mod( npcol+mycol-cdest, npcol )
255 mq = numroc( m, nb, mycol, cdest, npcol )
256 irsrc = mod( rsrc+mydist, nprow )
258 IF( (myrow.NE.irsrc).OR.(mycol.NE.csrc) )
259 $
CALL zgerv2d( ictxt, mq, n, vd, ldvd, irsrc, csrc )