1 SUBROUTINE pzrow2col( 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 COMPLEX*16 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, zgesd2d, zgerv2d, zlacpy
105 EXTERNAL ilcm, numroc
111 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
116 IF( nprow .NE. npcol )
THEN
117 lcm = ilcm( nprow, npcol )
118 rblkskip = lcm / npcol
119 cblkskip = lcm / nprow
123 IF( myrow.EQ.rsrc )
THEN
130 mydist = mod( npcol+mycol-csrc, npcol )
131 mq = numroc( m, nb, mycol, csrc, npcol )
132 irdest = mod( rdest+mydist, nprow )
136 DO 20 k = 1, rblkskip
141 IF( (myrow.NE.irdest).OR.(mycol.NE.cdest) )
THEN
145 DO 10 ii = istart, mq, nb*rblkskip
146 jb =
min( nb, mq-ii+1 )
147 CALL zlacpy(
'G', jb, n, vs(ii,1), ldvs,
157 $
CALL zgesd2d( ictxt, jj, 1, work, jj, irdest,
168 irdest = mod( irdest+npcol, nprow )
174 IF( mycol.EQ.cdest )
THEN
181 mydist = mod( nprow+myrow-rdest, nprow )
182 mp = numroc( m, nb, myrow, rdest, nprow )
183 icsrc = mod( csrc+mydist, npcol )
187 DO 50 k = 1, cblkskip
191 IF( (myrow.NE.rsrc).OR.(mycol.NE.icsrc) )
THEN
196 nblocks = (mp - istart + nb) / nb
197 jj = ((nblocks+cblkskip-1) / cblkskip)*nb
199 $
CALL zgerv2d( ictxt, jj, n, work, jj, rsrc, icsrc )
204 DO 30 ii = istart, mp, nb*cblkskip
205 jb =
min( nb, mp-ii+1 )
206 CALL zlacpy(
'G', jb, n, work(jj), jb, vd(ii,1),
215 DO 40 ii = istart, mp, nb*cblkskip
216 jb =
min( nb, mp-ii+1 )
217 CALL zlacpy(
'G', jb, n, vs(jj,1), ldvs, vd(ii,1),
219 jj = jj + nb*rblkskip
223 icsrc = mod( icsrc+nprow, npcol )
232 IF( myrow.EQ.rsrc )
THEN
237 mydist = mod( npcol+mycol-csrc, npcol )
238 mq = numroc( m, nb, mycol, csrc, npcol )
239 irdest = mod( rdest+mydist, nprow )
240 IF( (myrow.NE.irdest).OR.(mycol.NE.cdest) )
THEN
241 CALL zgesd2d( ictxt, mq, n, vs, ldvs, irdest, cdest )
243 CALL zlacpy(
'G', mq, n, vs, ldvs, vd, ldvd )
246 IF( mycol.EQ.cdest )
THEN
251 mydist = mod( nprow+myrow-rdest, nprow )
252 mp = numroc( m, nb, myrow, rdest, nprow )
253 icsrc = mod( csrc+mydist, npcol )
254 IF( (mycol.NE.icsrc).OR.(myrow.NE. rsrc) )
255 $
CALL zgerv2d( ictxt, mp, n, vd, ldvd, rsrc, icsrc )