SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ pb_infog2l()

subroutine pb_infog2l ( integer  i,
integer  j,
integer, dimension( * )  desc,
integer  nprow,
integer  npcol,
integer  myrow,
integer  mycol,
integer  ii,
integer  jj,
integer  prow,
integer  pcol 
)

Definition at line 1902 of file pblastim.f.

1904*
1905* -- PBLAS test routine (version 2.0) --
1906* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
1907* and University of California, Berkeley.
1908* April 1, 1998
1909*
1910* .. Scalar Arguments ..
1911 INTEGER I, II, J, JJ, MYCOL, MYROW, NPCOL, NPROW, PCOL,
1912 $ PROW
1913* ..
1914* .. Array Arguments ..
1915 INTEGER DESC( * )
1916* ..
1917*
1918* Purpose
1919* =======
1920*
1921* PB_INFOG2L computes the starting local index II, JJ corresponding to
1922* the submatrix starting globally at the entry pointed by I, J. This
1923* routine returns the coordinates in the grid of the process owning the
1924* matrix entry of global indexes I, J, namely PROW and PCOL.
1925*
1926* Notes
1927* =====
1928*
1929* A description vector is associated with each 2D block-cyclicly dis-
1930* tributed matrix. This vector stores the information required to
1931* establish the mapping between a matrix entry and its corresponding
1932* process and memory location.
1933*
1934* In the following comments, the character _ should be read as
1935* "of the distributed matrix". Let A be a generic term for any 2D
1936* block cyclicly distributed matrix. Its description vector is DESCA:
1937*
1938* NOTATION STORED IN EXPLANATION
1939* ---------------- --------------- ------------------------------------
1940* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
1941* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
1942* the NPROW x NPCOL BLACS process grid
1943* A is distributed over. The context
1944* itself is global, but the handle
1945* (the integer value) may vary.
1946* M_A (global) DESCA( M_ ) The number of rows in the distribu-
1947* ted matrix A, M_A >= 0.
1948* N_A (global) DESCA( N_ ) The number of columns in the distri-
1949* buted matrix A, N_A >= 0.
1950* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
1951* block of the matrix A, IMB_A > 0.
1952* INB_A (global) DESCA( INB_ ) The number of columns of the upper
1953* left block of the matrix A,
1954* INB_A > 0.
1955* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
1956* bute the last M_A-IMB_A rows of A,
1957* MB_A > 0.
1958* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
1959* bute the last N_A-INB_A columns of
1960* A, NB_A > 0.
1961* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
1962* row of the matrix A is distributed,
1963* NPROW > RSRC_A >= 0.
1964* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
1965* first column of A is distributed.
1966* NPCOL > CSRC_A >= 0.
1967* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
1968* array storing the local blocks of
1969* the distributed matrix A,
1970* IF( Lc( 1, N_A ) > 0 )
1971* LLD_A >= MAX( 1, Lr( 1, M_A ) )
1972* ELSE
1973* LLD_A >= 1.
1974*
1975* Let K be the number of rows of a matrix A starting at the global in-
1976* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
1977* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
1978* receive if these K rows were distributed over NPROW processes. If K
1979* is the number of columns of a matrix A starting at the global index
1980* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
1981* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
1982* these K columns were distributed over NPCOL processes.
1983*
1984* The values of Lr() and Lc() may be determined via a call to the func-
1985* tion PB_NUMROC:
1986* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
1987* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
1988*
1989* Arguments
1990* =========
1991*
1992* I (global input) INTEGER
1993* On entry, I specifies the global starting row index of the
1994* submatrix. I must at least one.
1995*
1996* J (global input) INTEGER
1997* On entry, J specifies the global starting column index of
1998* the submatrix. J must at least one.
1999*
2000* DESC (global and local input) INTEGER array
2001* On entry, DESC is an integer array of dimension DLEN_. This
2002* is the array descriptor of the underlying matrix.
2003*
2004* NPROW (global input) INTEGER
2005* On entry, NPROW specifies the total number of process rows
2006* over which the matrix is distributed. NPROW must be at least
2007* one.
2008*
2009* NPCOL (global input) INTEGER
2010* On entry, NPCOL specifies the total number of process columns
2011* over which the matrix is distributed. NPCOL must be at least
2012* one.
2013*
2014* MYROW (local input) INTEGER
2015* On entry, MYROW specifies the row coordinate of the process
2016* whose local index II is determined. MYROW must be at least
2017* zero and strictly less than NPROW.
2018*
2019* MYCOL (local input) INTEGER
2020* On entry, MYCOL specifies the column coordinate of the pro-
2021* cess whose local index JJ is determined. MYCOL must be at
2022* least zero and strictly less than NPCOL.
2023*
2024* II (local output) INTEGER
2025* On exit, II specifies the local starting row index of the
2026* submatrix. On exit, II is at least one.
2027*
2028* JJ (local output) INTEGER
2029* On exit, JJ specifies the local starting column index of the
2030* submatrix. On exit, JJ is at least one.
2031*
2032* PROW (global output) INTEGER
2033* On exit, PROW specifies the row coordinate of the process
2034* that possesses the first row of the submatrix. On exit, PROW
2035* is -1 if DESC( RSRC_ ) is -1 on input, and, at least zero
2036* and strictly less than NPROW otherwise.
2037*
2038* PCOL (global output) INTEGER
2039* On exit, PCOL specifies the column coordinate of the process
2040* that possesses the first column of the submatrix. On exit,
2041* PCOL is -1 if DESC( CSRC_ ) is -1 on input, and, at least
2042* zero and strictly less than NPCOL otherwise.
2043*
2044* -- Written on April 1, 1998 by
2045* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
2046*
2047* =====================================================================
2048*
2049* .. Parameters ..
2050 INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
2051 $ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
2052 $ RSRC_
2053 parameter( block_cyclic_2d_inb = 2, dlen_ = 11,
2054 $ dtype_ = 1, ctxt_ = 2, m_ = 3, n_ = 4,
2055 $ imb_ = 5, inb_ = 6, mb_ = 7, nb_ = 8,
2056 $ rsrc_ = 9, csrc_ = 10, lld_ = 11 )
2057* ..
2058* .. Local Scalars ..
2059 INTEGER CSRC, I1, ILOCBLK, IMB, INB, J1, MB, MYDIST,
2060 $ NB, NBLOCKS, RSRC
2061* ..
2062* .. Local Arrays ..
2063 INTEGER DESC2( DLEN_ )
2064* ..
2065* .. External Subroutines ..
2066 EXTERNAL pb_desctrans
2067* ..
2068* .. Executable Statements ..
2069*
2070* Convert descriptor
2071*
2072 CALL pb_desctrans( desc, desc2 )
2073*
2074 imb = desc2( imb_ )
2075 prow = desc2( rsrc_ )
2076*
2077* Has every process row I ?
2078*
2079 IF( ( prow.EQ.-1 ).OR.( nprow.EQ.1 ) ) THEN
2080*
2081 ii = i
2082*
2083 ELSE IF( i.LE.imb ) THEN
2084*
2085* I is in range of first block
2086*
2087 IF( myrow.EQ.prow ) THEN
2088 ii = i
2089 ELSE
2090 ii = 1
2091 END IF
2092*
2093 ELSE
2094*
2095* I is not in first block of matrix, figure out who has it.
2096*
2097 rsrc = prow
2098 mb = desc2( mb_ )
2099*
2100 IF( myrow.EQ.rsrc ) THEN
2101*
2102 nblocks = ( i - imb - 1 ) / mb + 1
2103 prow = prow + nblocks
2104 prow = prow - ( prow / nprow ) * nprow
2105*
2106 ilocblk = nblocks / nprow
2107*
2108 IF( ilocblk.GT.0 ) THEN
2109 IF( ( ilocblk*nprow ).GE.nblocks ) THEN
2110 IF( myrow.EQ.prow ) THEN
2111 ii = i + ( ilocblk - nblocks ) * mb
2112 ELSE
2113 ii = imb + ( ilocblk - 1 ) * mb + 1
2114 END IF
2115 ELSE
2116 ii = imb + ilocblk * mb + 1
2117 END IF
2118 ELSE
2119 ii = imb + 1
2120 END IF
2121*
2122 ELSE
2123*
2124 i1 = i - imb
2125 nblocks = ( i1 - 1 ) / mb + 1
2126 prow = prow + nblocks
2127 prow = prow - ( prow / nprow ) * nprow
2128*
2129 mydist = myrow - rsrc
2130 IF( mydist.LT.0 )
2131 $ mydist = mydist + nprow
2132*
2133 ilocblk = nblocks / nprow
2134*
2135 IF( ilocblk.GT.0 ) THEN
2136 mydist = mydist - nblocks + ilocblk * nprow
2137 IF( mydist.LT.0 ) THEN
2138 ii = mb + ilocblk * mb + 1
2139 ELSE
2140 IF( myrow.EQ.prow ) THEN
2141 ii = i1 + ( ilocblk - nblocks + 1 ) * mb
2142 ELSE
2143 ii = ilocblk * mb + 1
2144 END IF
2145 END IF
2146 ELSE
2147 mydist = mydist - nblocks
2148 IF( mydist.LT.0 ) THEN
2149 ii = mb + 1
2150 ELSE IF( myrow.EQ.prow ) THEN
2151 ii = i1 + ( 1 - nblocks ) * mb
2152 ELSE
2153 ii = 1
2154 END IF
2155 END IF
2156 END IF
2157*
2158 END IF
2159*
2160 inb = desc2( inb_ )
2161 pcol = desc2( csrc_ )
2162*
2163* Has every process column J ?
2164*
2165 IF( ( pcol.EQ.-1 ).OR.( npcol.EQ.1 ) ) THEN
2166*
2167 jj = j
2168*
2169 ELSE IF( j.LE.inb ) THEN
2170*
2171* J is in range of first block
2172*
2173 IF( mycol.EQ.pcol ) THEN
2174 jj = j
2175 ELSE
2176 jj = 1
2177 END IF
2178*
2179 ELSE
2180*
2181* J is not in first block of matrix, figure out who has it.
2182*
2183 csrc = pcol
2184 nb = desc2( nb_ )
2185*
2186 IF( mycol.EQ.csrc ) THEN
2187*
2188 nblocks = ( j - inb - 1 ) / nb + 1
2189 pcol = pcol + nblocks
2190 pcol = pcol - ( pcol / npcol ) * npcol
2191*
2192 ilocblk = nblocks / npcol
2193*
2194 IF( ilocblk.GT.0 ) THEN
2195 IF( ( ilocblk*npcol ).GE.nblocks ) THEN
2196 IF( mycol.EQ.pcol ) THEN
2197 jj = j + ( ilocblk - nblocks ) * nb
2198 ELSE
2199 jj = inb + ( ilocblk - 1 ) * nb + 1
2200 END IF
2201 ELSE
2202 jj = inb + ilocblk * nb + 1
2203 END IF
2204 ELSE
2205 jj = inb + 1
2206 END IF
2207*
2208 ELSE
2209*
2210 j1 = j - inb
2211 nblocks = ( j1 - 1 ) / nb + 1
2212 pcol = pcol + nblocks
2213 pcol = pcol - ( pcol / npcol ) * npcol
2214*
2215 mydist = mycol - csrc
2216 IF( mydist.LT.0 )
2217 $ mydist = mydist + npcol
2218*
2219 ilocblk = nblocks / npcol
2220*
2221 IF( ilocblk.GT.0 ) THEN
2222 mydist = mydist - nblocks + ilocblk * npcol
2223 IF( mydist.LT.0 ) THEN
2224 jj = nb + ilocblk * nb + 1
2225 ELSE
2226 IF( mycol.EQ.pcol ) THEN
2227 jj = j1 + ( ilocblk - nblocks + 1 ) * nb
2228 ELSE
2229 jj = ilocblk * nb + 1
2230 END IF
2231 END IF
2232 ELSE
2233 mydist = mydist - nblocks
2234 IF( mydist.LT.0 ) THEN
2235 jj = nb + 1
2236 ELSE IF( mycol.EQ.pcol ) THEN
2237 jj = j1 + ( 1 - nblocks ) * nb
2238 ELSE
2239 jj = 1
2240 END IF
2241 END IF
2242 END IF
2243*
2244 END IF
2245*
2246 RETURN
2247*
2248* End of PB_INFOG2L
2249*
subroutine pb_desctrans(descin, descout)
Definition pblastst.f:2964