1 SUBROUTINE pscol2row( 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 REAL 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, sgesd2d, sgerv2d, slacpy
106 EXTERNAL ilcm, numroc
117 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
122 IF( nprow.NE.npcol )
THEN
123 lcm = ilcm( nprow, npcol )
124 rblkskip = lcm / npcol
125 cblkskip = lcm / nprow
129 IF( mycol.EQ.csrc )
THEN
136 mydist = mod( nprow+myrow-rsrc, nprow )
137 mp = numroc( m, nb, myrow, rsrc, nprow )
138 icdest = mod( cdest+mydist, npcol )
142 DO 20 k = 1, cblkskip
147 IF( (mycol.NE.icdest).OR.(myrow.NE.rdest) )
THEN
151 DO 10 ii = istart, mp, nb*cblkskip
152 jb =
min(nb, mp-ii+1)
153 CALL slacpy(
'G', jb, n, vs(ii,1), ldvs,
163 $
CALL sgesd2d( ictxt, jj, 1, work, jj, rdest,
175 icdest = mod(icdest+nprow, npcol)
181 IF( myrow.EQ.rdest )
THEN
188 mydist = mod( npcol+mycol-cdest, npcol )
189 mq = numroc( m, nb, mycol, cdest, npcol )
190 irsrc = mod( rsrc+mydist, nprow )
191 DO 50 k = 1, rblkskip
195 IF( (mycol.NE.csrc).OR.(myrow.NE.irsrc) )
THEN
200 nblocks = (mq - istart + nb) / nb
201 jj = ((nblocks+rblkskip-1) / rblkskip)*nb
203 $
CALL sgerv2d( ictxt, jj, n, work, jj, irsrc, csrc )
208 DO 30 ii = istart, mq, nb*rblkskip
209 jb =
min( nb, mq-ii+1 )
210 CALL slacpy(
'G', jb, n, work(jj), jb,
219 DO 40 ii = istart, mq, nb*rblkskip
220 jb =
min( nb, mq-ii+1 )
221 CALL slacpy(
'G', jb, n, vs(jj,1), ldvs,
223 jj = jj + nb*cblkskip
227 irsrc = mod( irsrc+npcol, nprow )
236 IF( mycol.EQ.csrc )
THEN
241 mydist = mod( nprow+myrow-rsrc, nprow )
242 mp = numroc( m, nb, myrow, rsrc, nprow )
243 icdest = mod( cdest+mydist, npcol )
245 IF( (mycol.NE.icdest).OR.(myrow.NE.rdest) )
THEN
246 CALL sgesd2d( ictxt, mp, n, vs, ldvs, rdest, icdest )
248 CALL slacpy(
'G', mp, n, vs, ldvs, vd, ldvd )
252 IF( myrow.EQ.rdest )
THEN
257 mydist = mod( npcol+mycol-cdest, npcol )
258 mq = numroc( m, nb, mycol, cdest, npcol )
259 irsrc = mod( rsrc+mydist, nprow )
261 IF( (myrow.NE.irsrc).OR.(mycol.NE.csrc) )
262 $
CALL sgerv2d( ictxt, mq, n, vd, ldvd, irsrc, csrc )