SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
All Classes Files Functions Variables Typedefs Macros

◆ pb_ainfog2l()

subroutine pb_ainfog2l ( integer  m,
integer  n,
integer  i,
integer  j,
integer, dimension( * )  desc,
integer  nprow,
integer  npcol,
integer  myrow,
integer  mycol,
integer  imb1,
integer  inb1,
integer  mp,
integer  nq,
integer  ii,
integer  jj,
integer  prow,
integer  pcol,
integer  rprow,
integer  rpcol 
)

Definition at line 2020 of file pblastst.f.

2023*
2024* -- PBLAS test routine (version 2.0) --
2025* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
2026* and University of California, Berkeley.
2027* April 1, 1998
2028*
2029* .. Scalar Arguments ..
2030 INTEGER I, II, IMB1, INB1, J, JJ, M, MP, MYCOL, MYROW,
2031 $ N, NPCOL, NPROW, NQ, PCOL, PROW, RPCOL, RPROW
2032* ..
2033* .. Array Arguments ..
2034 INTEGER DESC( * )
2035* ..
2036*
2037* Purpose
2038* =======
2039*
2040* PB_AINFOG2L computes the starting local row and column indexes II,
2041* JJ corresponding to the submatrix starting globally at the entry
2042* pointed by I, J. This routine returns the coordinates in the grid of
2043* the process owning the matrix entry of global indexes I, J, namely
2044* PROW and PCOL. In addition, this routine computes the quantities MP
2045* and NQ, which are respectively the local number of rows and columns
2046* owned by the process of coordinate MYROW, MYCOL corresponding to the
2047* global submatrix A(I:I+M-1,J:J+N-1). Finally, the size of the first
2048* partial block and the relative process coordinates are also returned
2049* respectively in IMB, INB and RPROW, RPCOL.
2050*
2051* Notes
2052* =====
2053*
2054* A description vector is associated with each 2D block-cyclicly dis-
2055* tributed matrix. This vector stores the information required to
2056* establish the mapping between a matrix entry and its corresponding
2057* process and memory location.
2058*
2059* In the following comments, the character _ should be read as
2060* "of the distributed matrix". Let A be a generic term for any 2D
2061* block cyclicly distributed matrix. Its description vector is DESCA:
2062*
2063* NOTATION STORED IN EXPLANATION
2064* ---------------- --------------- ------------------------------------
2065* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
2066* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
2067* the NPROW x NPCOL BLACS process grid
2068* A is distributed over. The context
2069* itself is global, but the handle
2070* (the integer value) may vary.
2071* M_A (global) DESCA( M_ ) The number of rows in the distribu-
2072* ted matrix A, M_A >= 0.
2073* N_A (global) DESCA( N_ ) The number of columns in the distri-
2074* buted matrix A, N_A >= 0.
2075* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
2076* block of the matrix A, IMB_A > 0.
2077* INB_A (global) DESCA( INB_ ) The number of columns of the upper
2078* left block of the matrix A,
2079* INB_A > 0.
2080* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
2081* bute the last M_A-IMB_A rows of A,
2082* MB_A > 0.
2083* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
2084* bute the last N_A-INB_A columns of
2085* A, NB_A > 0.
2086* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
2087* row of the matrix A is distributed,
2088* NPROW > RSRC_A >= 0.
2089* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
2090* first column of A is distributed.
2091* NPCOL > CSRC_A >= 0.
2092* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
2093* array storing the local blocks of
2094* the distributed matrix A,
2095* IF( Lc( 1, N_A ) > 0 )
2096* LLD_A >= MAX( 1, Lr( 1, M_A ) )
2097* ELSE
2098* LLD_A >= 1.
2099*
2100* Let K be the number of rows of a matrix A starting at the global in-
2101* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
2102* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
2103* receive if these K rows were distributed over NPROW processes. If K
2104* is the number of columns of a matrix A starting at the global index
2105* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
2106* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
2107* these K columns were distributed over NPCOL processes.
2108*
2109* The values of Lr() and Lc() may be determined via a call to the func-
2110* tion PB_NUMROC:
2111* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
2112* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
2113*
2114* Arguments
2115* =========
2116*
2117* M (global input) INTEGER
2118* On entry, M specifies the global number of rows of the subma-
2119* trix. M must be at least zero.
2120*
2121* N (global input) INTEGER
2122* On entry, N specifies the global number of columns of the
2123* submatrix. N must be at least zero.
2124*
2125* I (global input) INTEGER
2126* On entry, I specifies the global starting row index of the
2127* submatrix. I must at least one.
2128*
2129* J (global input) INTEGER
2130* On entry, J specifies the global starting column index of
2131* the submatrix. J must at least one.
2132*
2133* DESC (global and local input) INTEGER array
2134* On entry, DESC is an integer array of dimension DLEN_. This
2135* is the array descriptor of the underlying matrix.
2136*
2137* NPROW (global input) INTEGER
2138* On entry, NPROW specifies the total number of process rows
2139* over which the matrix is distributed. NPROW must be at least
2140* one.
2141*
2142* NPCOL (global input) INTEGER
2143* On entry, NPCOL specifies the total number of process columns
2144* over which the matrix is distributed. NPCOL must be at least
2145* one.
2146*
2147* MYROW (local input) INTEGER
2148* On entry, MYROW specifies the row coordinate of the process
2149* whose local index II is determined. MYROW must be at least
2150* zero and strictly less than NPROW.
2151*
2152* MYCOL (local input) INTEGER
2153* On entry, MYCOL specifies the column coordinate of the pro-
2154* cess whose local index JJ is determined. MYCOL must be at
2155* least zero and strictly less than NPCOL.
2156*
2157* IMB1 (global output) INTEGER
2158* On exit, IMB1 specifies the number of rows of the upper left
2159* block of the submatrix. On exit, IMB1 is less or equal than
2160* M and greater or equal than MIN( 1, M ).
2161*
2162* INB1 (global output) INTEGER
2163* On exit, INB1 specifies the number of columns of the upper
2164* left block of the submatrix. On exit, INB1 is less or equal
2165* than N and greater or equal than MIN( 1, N ).
2166*
2167* MP (local output) INTEGER
2168* On exit, MP specifies the local number of rows of the subma-
2169* trix, that the processes of row coordinate MYROW own. MP is
2170* at least zero.
2171*
2172* NQ (local output) INTEGER
2173* On exit, NQ specifies the local number of columns of the
2174* submatrix, that the processes of column coordinate MYCOL
2175* own. NQ is at least zero.
2176*
2177* II (local output) INTEGER
2178* On exit, II specifies the local starting row index of the
2179* submatrix. On exit, II is at least one.
2180*
2181* JJ (local output) INTEGER
2182* On exit, JJ specifies the local starting column index of
2183* the submatrix. On exit, II is at least one.
2184*
2185* PROW (global output) INTEGER
2186* On exit, PROW specifies the row coordinate of the process
2187* that possesses the first row of the submatrix. On exit, PROW
2188* is -1 if DESC(RSRC_) is -1 on input, and, at least zero and
2189* strictly less than NPROW otherwise.
2190*
2191* PCOL (global output) INTEGER
2192* On exit, PCOL specifies the column coordinate of the process
2193* that possesses the first column of the submatrix. On exit,
2194* PCOL is -1 if DESC(CSRC_) is -1 on input, and, at least zero
2195* and strictly less than NPCOL otherwise.
2196*
2197* RPROW (global output) INTEGER
2198* On exit, RPROW specifies the relative row coordinate of the
2199* process that possesses the first row I of the submatrix. On
2200* exit, RPROW is -1 if DESC(RSRC_) is -1 on input, and, at
2201* least zero and strictly less than NPROW otherwise.
2202*
2203* RPCOL (global output) INTEGER
2204* On exit, RPCOL specifies the relative column coordinate of
2205* the process that possesses the first column J of the subma-
2206* trix. On exit, RPCOL is -1 if DESC(CSRC_) is -1 on input,
2207* and, at least zero and strictly less than NPCOL otherwise.
2208*
2209* -- Written on April 1, 1998 by
2210* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
2211*
2212* =====================================================================
2213*
2214* .. Parameters ..
2215 INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
2216 $ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
2217 $ RSRC_
2218 parameter( block_cyclic_2d_inb = 2, dlen_ = 11,
2219 $ dtype_ = 1, ctxt_ = 2, m_ = 3, n_ = 4,
2220 $ imb_ = 5, inb_ = 6, mb_ = 7, nb_ = 8,
2221 $ rsrc_ = 9, csrc_ = 10, lld_ = 11 )
2222* ..
2223* .. Local Scalars ..
2224 INTEGER CSRC, I1, ILOCBLK, J1, M1, MB, MYDIST, N1, NB,
2225 $ NBLOCKS, RSRC
2226* ..
2227* .. Local Arrays ..
2228 INTEGER DESC2( DLEN_ )
2229* ..
2230* .. External Subroutines ..
2231 EXTERNAL pb_desctrans
2232* ..
2233* .. Intrinsic Functions ..
2234 INTRINSIC min
2235* ..
2236* .. Executable Statements ..
2237*
2238* Convert descriptor
2239*
2240 CALL pb_desctrans( desc, desc2 )
2241*
2242 mb = desc2( mb_ )
2243 imb1 = desc2( imb_ )
2244 rsrc = desc2( rsrc_ )
2245*
2246 IF( ( rsrc.EQ.-1 ).OR.( nprow.EQ.1 ) ) THEN
2247*
2248 ii = i
2249 imb1 = imb1 - i + 1
2250 IF( imb1.LE.0 )
2251 $ imb1 = ( ( -imb1 ) / mb + 1 ) * mb + imb1
2252 imb1 = min( imb1, m )
2253 mp = m
2254 prow = rsrc
2255 rprow = 0
2256*
2257 ELSE
2258*
2259* Figure out PROW, II and IMB1 first
2260*
2261 IF( i.LE.imb1 ) THEN
2262*
2263 prow = rsrc
2264*
2265 IF( myrow.EQ.prow ) THEN
2266 ii = i
2267 ELSE
2268 ii = 1
2269 END IF
2270*
2271 imb1 = imb1 - i + 1
2272*
2273 ELSE
2274*
2275 i1 = i - imb1 - 1
2276 nblocks = i1 / mb + 1
2277 prow = rsrc + nblocks
2278 prow = prow - ( prow / nprow ) * nprow
2279*
2280 IF( myrow.EQ.rsrc ) THEN
2281*
2282 ilocblk = nblocks / nprow
2283*
2284 IF( ilocblk.GT.0 ) THEN
2285 IF( ( ilocblk*nprow ).GE.nblocks ) THEN
2286 IF( myrow.EQ.prow ) THEN
2287 ii = i + ( ilocblk - nblocks ) * mb
2288 ELSE
2289 ii = imb1 + ( ilocblk - 1 ) * mb + 1
2290 END IF
2291 ELSE
2292 ii = imb1 + ilocblk * mb + 1
2293 END IF
2294 ELSE
2295 ii = imb1 + 1
2296 END IF
2297*
2298 ELSE
2299*
2300 mydist = myrow - rsrc
2301 IF( mydist.LT.0 )
2302 $ mydist = mydist + nprow
2303*
2304 ilocblk = nblocks / nprow
2305*
2306 IF( ilocblk.GT.0 ) THEN
2307 mydist = mydist - nblocks + ilocblk * nprow
2308 IF( mydist.LT.0 ) THEN
2309 ii = ( ilocblk + 1 ) * mb + 1
2310 ELSE IF( myrow.EQ.prow ) THEN
2311 ii = i1 + ( ilocblk - nblocks + 1 ) * mb + 1
2312 ELSE
2313 ii = ilocblk * mb + 1
2314 END IF
2315 ELSE
2316 mydist = mydist - nblocks
2317 IF( mydist.LT.0 ) THEN
2318 ii = mb + 1
2319 ELSE IF( myrow.EQ.prow ) THEN
2320 ii = i1 + ( 1 - nblocks ) * mb + 1
2321 ELSE
2322 ii = 1
2323 END IF
2324 END IF
2325 END IF
2326*
2327 imb1 = nblocks * mb - i1
2328*
2329 END IF
2330*
2331* Figure out MP
2332*
2333 IF( m.LE.imb1 ) THEN
2334*
2335 IF( myrow.EQ.prow ) THEN
2336 mp = m
2337 ELSE
2338 mp = 0
2339 END IF
2340*
2341 ELSE
2342*
2343 m1 = m - imb1
2344 nblocks = m1 / mb + 1
2345*
2346 IF( myrow.EQ.prow ) THEN
2347 ilocblk = nblocks / nprow
2348 IF( ilocblk.GT.0 ) THEN
2349 IF( ( nblocks - ilocblk * nprow ).GT.0 ) THEN
2350 mp = imb1 + ilocblk * mb
2351 ELSE
2352 mp = m + mb * ( ilocblk - nblocks )
2353 END IF
2354 ELSE
2355 mp = imb1
2356 END IF
2357 ELSE
2358 mydist = myrow - prow
2359 IF( mydist.LT.0 )
2360 $ mydist = mydist + nprow
2361 ilocblk = nblocks / nprow
2362 IF( ilocblk.GT.0 ) THEN
2363 mydist = mydist - nblocks + ilocblk * nprow
2364 IF( mydist.LT.0 ) THEN
2365 mp = ( ilocblk + 1 ) * mb
2366 ELSE IF( mydist.GT.0 ) THEN
2367 mp = ilocblk * mb
2368 ELSE
2369 mp = m1 + mb * ( ilocblk - nblocks + 1 )
2370 END IF
2371 ELSE
2372 mydist = mydist - nblocks
2373 IF( mydist.LT.0 ) THEN
2374 mp = mb
2375 ELSE IF( mydist.GT.0 ) THEN
2376 mp = 0
2377 ELSE
2378 mp = m1 + mb * ( 1 - nblocks )
2379 END IF
2380 END IF
2381 END IF
2382*
2383 END IF
2384*
2385 imb1 = min( imb1, m )
2386 rprow = myrow - prow
2387 IF( rprow.LT.0 )
2388 $ rprow = rprow + nprow
2389*
2390 END IF
2391*
2392 nb = desc2( nb_ )
2393 inb1 = desc2( inb_ )
2394 csrc = desc2( csrc_ )
2395*
2396 IF( ( csrc.EQ.-1 ).OR.( npcol.EQ.1 ) ) THEN
2397*
2398 jj = j
2399 inb1 = inb1 - i + 1
2400 IF( inb1.LE.0 )
2401 $ inb1 = ( ( -inb1 ) / nb + 1 ) * nb + inb1
2402 inb1 = min( inb1, n )
2403 nq = n
2404 pcol = csrc
2405 rpcol = 0
2406*
2407 ELSE
2408*
2409* Figure out PCOL, JJ and INB1 first
2410*
2411 IF( j.LE.inb1 ) THEN
2412*
2413 pcol = csrc
2414*
2415 IF( mycol.EQ.pcol ) THEN
2416 jj = j
2417 ELSE
2418 jj = 1
2419 END IF
2420*
2421 inb1 = inb1 - j + 1
2422*
2423 ELSE
2424*
2425 j1 = j - inb1 - 1
2426 nblocks = j1 / nb + 1
2427 pcol = csrc + nblocks
2428 pcol = pcol - ( pcol / npcol ) * npcol
2429*
2430 IF( mycol.EQ.csrc ) THEN
2431*
2432 ilocblk = nblocks / npcol
2433*
2434 IF( ilocblk.GT.0 ) THEN
2435 IF( ( ilocblk*npcol ).GE.nblocks ) THEN
2436 IF( mycol.EQ.pcol ) THEN
2437 jj = j + ( ilocblk - nblocks ) * nb
2438 ELSE
2439 jj = inb1 + ( ilocblk - 1 ) * nb + 1
2440 END IF
2441 ELSE
2442 jj = inb1 + ilocblk * nb + 1
2443 END IF
2444 ELSE
2445 jj = inb1 + 1
2446 END IF
2447*
2448 ELSE
2449*
2450 mydist = mycol - csrc
2451 IF( mydist.LT.0 )
2452 $ mydist = mydist + npcol
2453*
2454 ilocblk = nblocks / npcol
2455*
2456 IF( ilocblk.GT.0 ) THEN
2457 mydist = mydist - nblocks + ilocblk * npcol
2458 IF( mydist.LT.0 ) THEN
2459 jj = ( ilocblk + 1 ) * nb + 1
2460 ELSE IF( mycol.EQ.pcol ) THEN
2461 jj = j1 + ( ilocblk - nblocks + 1 ) * nb + 1
2462 ELSE
2463 jj = ilocblk * nb + 1
2464 END IF
2465 ELSE
2466 mydist = mydist - nblocks
2467 IF( mydist.LT.0 ) THEN
2468 jj = nb + 1
2469 ELSE IF( mycol.EQ.pcol ) THEN
2470 jj = j1 + ( 1 - nblocks ) * nb + 1
2471 ELSE
2472 jj = 1
2473 END IF
2474 END IF
2475 END IF
2476*
2477 inb1 = nblocks * nb - j1
2478*
2479 END IF
2480*
2481* Figure out NQ
2482*
2483 IF( n.LE.inb1 ) THEN
2484*
2485 IF( mycol.EQ.pcol ) THEN
2486 nq = n
2487 ELSE
2488 nq = 0
2489 END IF
2490*
2491 ELSE
2492*
2493 n1 = n - inb1
2494 nblocks = n1 / nb + 1
2495*
2496 IF( mycol.EQ.pcol ) THEN
2497 ilocblk = nblocks / npcol
2498 IF( ilocblk.GT.0 ) THEN
2499 IF( ( nblocks - ilocblk * npcol ).GT.0 ) THEN
2500 nq = inb1 + ilocblk * nb
2501 ELSE
2502 nq = n + nb * ( ilocblk - nblocks )
2503 END IF
2504 ELSE
2505 nq = inb1
2506 END IF
2507 ELSE
2508 mydist = mycol - pcol
2509 IF( mydist.LT.0 )
2510 $ mydist = mydist + npcol
2511 ilocblk = nblocks / npcol
2512 IF( ilocblk.GT.0 ) THEN
2513 mydist = mydist - nblocks + ilocblk * npcol
2514 IF( mydist.LT.0 ) THEN
2515 nq = ( ilocblk + 1 ) * nb
2516 ELSE IF( mydist.GT.0 ) THEN
2517 nq = ilocblk * nb
2518 ELSE
2519 nq = n1 + nb * ( ilocblk - nblocks + 1 )
2520 END IF
2521 ELSE
2522 mydist = mydist - nblocks
2523 IF( mydist.LT.0 ) THEN
2524 nq = nb
2525 ELSE IF( mydist.GT.0 ) THEN
2526 nq = 0
2527 ELSE
2528 nq = n1 + nb * ( 1 - nblocks )
2529 END IF
2530 END IF
2531 END IF
2532*
2533 END IF
2534*
2535 inb1 = min( inb1, n )
2536 rpcol = mycol - pcol
2537 IF( rpcol.LT.0 )
2538 $ rpcol = rpcol + npcol
2539*
2540 END IF
2541*
2542 RETURN
2543*
2544* End of PB_AINFOG2L
2545*
subroutine pb_desctrans(descin, descout)
Definition pblastst.f:2964
#define min(A, B)
Definition pcgemr.c:181
Here is the call graph for this function:
Here is the caller graph for this function: