14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
70 int GoEast, GoSouth, ilow, imbloc, inbloc, ioff, ioffd, iupp,
71 joff, joffd, lcmt, lcmt00, lmbloc, lnbloc, low, mb, mblkd,
72 mblks, mbloc, nb, nblkd, nblks, nbloc, npq=0, pmb, qnb,
82 if( ( K <= 0 ) || ( mblks == 0 ) || ( nblks == 0 ) )
return;
101 GoSouth = ( lcmt00 > iupp );
102 GoEast = ( lcmt00 < ilow );
106 if( !( GoSouth ) && !( GoEast ) )
113 npq = ( ( tmp2 = ( tmp1 = imbloc - lcmt00 ) > 0 ? tmp1 : 0 ) <
114 inbloc ? tmp2 : inbloc );
119 iupp = ( imbloc -= tmp1 ) - 1;
120 if( mblks == 1 ) lmbloc = imbloc;
122 ilow = 1 - ( inbloc -= K );
123 if( nblks == 1 ) lnbloc = inbloc;
130 npq = ( ( tmp2 = ( tmp1 = inbloc + lcmt00 ) > 0 ? tmp1 : 0 ) >
131 imbloc ? imbloc : tmp2 );
136 ilow = 1 - ( inbloc += tmp1 );
137 if( nblks == 1 ) lnbloc = inbloc;
139 iupp = ( imbloc -= K ) - 1;
140 if( mblks == 1 ) lmbloc = imbloc;
151 GoSouth = !( GoEast = ( ( lcmt00 - ( iupp-upp+pmb ) ) < ilow ) );
155 if( GoSouth ) *II += imbloc;
164 lcmt00 -= iupp - upp + pmb; mblks--; ioff += imbloc;
169 while( mblks && ( lcmt00 > upp ) ) { lcmt00 -= pmb; mblks--; ioff += mb; }
173 if( mblks <= 0 )
goto l_end;
180 lcmt = lcmt00; mblkd = mblks; mbloc = mb; ioffd = ioff;
182 while( mblkd && ( lcmt >= ilow ) )
187 if( mblkd == 1 ) mbloc = lmbloc;
191 npq = ( ( tmp2 = ( tmp1 = mbloc - lcmt ) > 0 ? tmp1 : 0 ) < inbloc ?
197 iupp = ( imbloc = mbloc - tmp1 ) - 1;
198 if( mblks == 1 ) lmbloc = imbloc;
200 ilow = 1 - ( inbloc -= K );
201 if( nblks == 1 ) lnbloc = inbloc;
208 npq = ( ( tmp2 = ( tmp1 = inbloc + lcmt ) > 0 ? tmp1 : 0 ) > mbloc ?
214 ilow = 1 - ( inbloc += tmp1 );
215 if( nblks == 1 ) lnbloc = inbloc;
217 iupp = ( imbloc = mbloc - K ) - 1;
218 if( mblks == 1 ) lmbloc = imbloc;
236 lcmt00 += low - ilow + qnb; nblks--; joff += inbloc;
248 lcmt00 += low - ilow + qnb; nblks--; joff += inbloc;
253 while( nblks && ( lcmt00 < low ) ) { lcmt00 += qnb; nblks--; joff += nb; }
257 if( nblks <= 0 )
goto l_end;
263 lcmt = lcmt00; nblkd = nblks; nbloc = nb; joffd = joff;
265 while( nblkd && ( lcmt <= iupp ) )
270 if( nblkd == 1 ) nbloc = lnbloc;
274 npq = ( ( tmp2 = ( tmp1 = imbloc - lcmt ) > 0 ? tmp1 : 0 ) < nbloc ?
280 iupp = ( imbloc -= tmp1 ) - 1;
281 if( mblks == 1 ) lmbloc = imbloc;
283 ilow = 1 - ( inbloc = nbloc - K );
284 if( nblks == 1 ) lnbloc = inbloc;
291 npq = ( ( tmp2 = ( tmp1 = nbloc + lcmt ) > 0 ? tmp1 : 0 ) > imbloc ?
297 ilow = 1 - ( inbloc = nbloc + tmp1 );
298 if( nblks == 1 ) lnbloc = inbloc;
300 iupp = ( imbloc -= K ) - 1;
301 if( mblks == 1 ) lmbloc = imbloc;
319 lcmt00 -= iupp - upp + pmb; mblks--; ioff += imbloc;
333 if( nblks == 1 ) nbloc = lnbloc;
338 while( mblks && ( lcmt00 > upp ) ) { lcmt00 -= pmb; mblks--; ioff += mb; }
342 if( mblks <= 0 )
goto l_end;
349 lcmt = lcmt00; mblkd = mblks; mbloc = mb; ioffd = ioff;
351 while( mblkd && ( lcmt >= low ) )
356 if( mblkd == 1 ) mbloc = lmbloc;
360 npq = ( ( tmp2 = ( tmp1 = mbloc - lcmt ) > 0 ? tmp1 : 0 ) < nbloc ?
366 iupp = ( imbloc = mbloc - tmp1 ) - 1;
367 if( mblks == 1 ) lmbloc = imbloc;
369 ilow = 1 - ( inbloc = nbloc - K );
370 if( nblks == 1 ) lnbloc = inbloc;
377 npq = ( ( tmp2 = ( tmp1 = nbloc + lcmt ) > 0 ? tmp1 : 0 ) > mbloc ?
383 ilow = 1 - ( inbloc = nbloc + tmp1 );
384 if( nblks == 1 ) lnbloc = inbloc;
386 iupp = ( imbloc = mbloc - K ) - 1;
387 if( mblks == 1 ) lmbloc = imbloc;
406 lcmt00 += qnb; nblks--; joff += nbloc;
419 VM->
mp = ( mblks >= 2 ? imbloc + ( mblks - 2 ) * mb + lmbloc :
420 ( mblks == 1 ? imbloc : 0 ) );
422 VM->
nq = ( nblks >= 2 ? inbloc + ( nblks - 2 ) * nb + lnbloc :
423 ( nblks == 1 ? inbloc : 0 ) );