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 1671 of file pblastst.f.

1673*
1674* -- PBLAS test routine (version 2.0) --
1675* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
1676* and University of California, Berkeley.
1677* April 1, 1998
1678*
1679* .. Scalar Arguments ..
1680 INTEGER I, II, J, JJ, MYCOL, MYROW, NPCOL, NPROW, PCOL,
1681 $ PROW
1682* ..
1683* .. Array Arguments ..
1684 INTEGER DESC( * )
1685* ..
1686*
1687* Purpose
1688* =======
1689*
1690* PB_INFOG2L computes the starting local index II, JJ corresponding to
1691* the submatrix starting globally at the entry pointed by I, J. This
1692* routine returns the coordinates in the grid of the process owning the
1693* matrix entry of global indexes I, J, namely PROW and PCOL.
1694*
1695* Notes
1696* =====
1697*
1698* A description vector is associated with each 2D block-cyclicly dis-
1699* tributed matrix. This vector stores the information required to
1700* establish the mapping between a matrix entry and its corresponding
1701* process and memory location.
1702*
1703* In the following comments, the character _ should be read as
1704* "of the distributed matrix". Let A be a generic term for any 2D
1705* block cyclicly distributed matrix. Its description vector is DESCA:
1706*
1707* NOTATION STORED IN EXPLANATION
1708* ---------------- --------------- ------------------------------------
1709* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
1710* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
1711* the NPROW x NPCOL BLACS process grid
1712* A is distributed over. The context
1713* itself is global, but the handle
1714* (the integer value) may vary.
1715* M_A (global) DESCA( M_ ) The number of rows in the distribu-
1716* ted matrix A, M_A >= 0.
1717* N_A (global) DESCA( N_ ) The number of columns in the distri-
1718* buted matrix A, N_A >= 0.
1719* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
1720* block of the matrix A, IMB_A > 0.
1721* INB_A (global) DESCA( INB_ ) The number of columns of the upper
1722* left block of the matrix A,
1723* INB_A > 0.
1724* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
1725* bute the last M_A-IMB_A rows of A,
1726* MB_A > 0.
1727* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
1728* bute the last N_A-INB_A columns of
1729* A, NB_A > 0.
1730* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
1731* row of the matrix A is distributed,
1732* NPROW > RSRC_A >= 0.
1733* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
1734* first column of A is distributed.
1735* NPCOL > CSRC_A >= 0.
1736* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
1737* array storing the local blocks of
1738* the distributed matrix A,
1739* IF( Lc( 1, N_A ) > 0 )
1740* LLD_A >= MAX( 1, Lr( 1, M_A ) )
1741* ELSE
1742* LLD_A >= 1.
1743*
1744* Let K be the number of rows of a matrix A starting at the global in-
1745* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
1746* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
1747* receive if these K rows were distributed over NPROW processes. If K
1748* is the number of columns of a matrix A starting at the global index
1749* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
1750* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
1751* these K columns were distributed over NPCOL processes.
1752*
1753* The values of Lr() and Lc() may be determined via a call to the func-
1754* tion PB_NUMROC:
1755* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
1756* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
1757*
1758* Arguments
1759* =========
1760*
1761* I (global input) INTEGER
1762* On entry, I specifies the global starting row index of the
1763* submatrix. I must at least one.
1764*
1765* J (global input) INTEGER
1766* On entry, J specifies the global starting column index of
1767* the submatrix. J must at least one.
1768*
1769* DESC (global and local input) INTEGER array
1770* On entry, DESC is an integer array of dimension DLEN_. This
1771* is the array descriptor of the underlying matrix.
1772*
1773* NPROW (global input) INTEGER
1774* On entry, NPROW specifies the total number of process rows
1775* over which the matrix is distributed. NPROW must be at least
1776* one.
1777*
1778* NPCOL (global input) INTEGER
1779* On entry, NPCOL specifies the total number of process columns
1780* over which the matrix is distributed. NPCOL must be at least
1781* one.
1782*
1783* MYROW (local input) INTEGER
1784* On entry, MYROW specifies the row coordinate of the process
1785* whose local index II is determined. MYROW must be at least
1786* zero and strictly less than NPROW.
1787*
1788* MYCOL (local input) INTEGER
1789* On entry, MYCOL specifies the column coordinate of the pro-
1790* cess whose local index JJ is determined. MYCOL must be at
1791* least zero and strictly less than NPCOL.
1792*
1793* II (local output) INTEGER
1794* On exit, II specifies the local starting row index of the
1795* submatrix. On exit, II is at least one.
1796*
1797* JJ (local output) INTEGER
1798* On exit, JJ specifies the local starting column index of the
1799* submatrix. On exit, JJ is at least one.
1800*
1801* PROW (global output) INTEGER
1802* On exit, PROW specifies the row coordinate of the process
1803* that possesses the first row of the submatrix. On exit, PROW
1804* is -1 if DESC( RSRC_ ) is -1 on input, and, at least zero
1805* and strictly less than NPROW otherwise.
1806*
1807* PCOL (global output) INTEGER
1808* On exit, PCOL specifies the column coordinate of the process
1809* that possesses the first column of the submatrix. On exit,
1810* PCOL is -1 if DESC( CSRC_ ) is -1 on input, and, at least
1811* zero and strictly less than NPCOL otherwise.
1812*
1813* -- Written on April 1, 1998 by
1814* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
1815*
1816* =====================================================================
1817*
1818* .. Parameters ..
1819 INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
1820 $ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
1821 $ RSRC_
1822 parameter( block_cyclic_2d_inb = 2, dlen_ = 11,
1823 $ dtype_ = 1, ctxt_ = 2, m_ = 3, n_ = 4,
1824 $ imb_ = 5, inb_ = 6, mb_ = 7, nb_ = 8,
1825 $ rsrc_ = 9, csrc_ = 10, lld_ = 11 )
1826* ..
1827* .. Local Scalars ..
1828 INTEGER CSRC, I1, ILOCBLK, IMB, INB, J1, MB, MYDIST,
1829 $ NB, NBLOCKS, RSRC
1830* ..
1831* .. Local Arrays ..
1832 INTEGER DESC2( DLEN_ )
1833* ..
1834* .. External Subroutines ..
1835 EXTERNAL pb_desctrans
1836* ..
1837* .. Executable Statements ..
1838*
1839* Convert descriptor
1840*
1841 CALL pb_desctrans( desc, desc2 )
1842*
1843 imb = desc2( imb_ )
1844 prow = desc2( rsrc_ )
1845*
1846* Has every process row I ?
1847*
1848 IF( ( prow.EQ.-1 ).OR.( nprow.EQ.1 ) ) THEN
1849*
1850 ii = i
1851*
1852 ELSE IF( i.LE.imb ) THEN
1853*
1854* I is in range of first block
1855*
1856 IF( myrow.EQ.prow ) THEN
1857 ii = i
1858 ELSE
1859 ii = 1
1860 END IF
1861*
1862 ELSE
1863*
1864* I is not in first block of matrix, figure out who has it.
1865*
1866 rsrc = prow
1867 mb = desc2( mb_ )
1868*
1869 IF( myrow.EQ.rsrc ) THEN
1870*
1871 nblocks = ( i - imb - 1 ) / mb + 1
1872 prow = prow + nblocks
1873 prow = prow - ( prow / nprow ) * nprow
1874*
1875 ilocblk = nblocks / nprow
1876*
1877 IF( ilocblk.GT.0 ) THEN
1878 IF( ( ilocblk*nprow ).GE.nblocks ) THEN
1879 IF( myrow.EQ.prow ) THEN
1880 ii = i + ( ilocblk - nblocks ) * mb
1881 ELSE
1882 ii = imb + ( ilocblk - 1 ) * mb + 1
1883 END IF
1884 ELSE
1885 ii = imb + ilocblk * mb + 1
1886 END IF
1887 ELSE
1888 ii = imb + 1
1889 END IF
1890*
1891 ELSE
1892*
1893 i1 = i - imb
1894 nblocks = ( i1 - 1 ) / mb + 1
1895 prow = prow + nblocks
1896 prow = prow - ( prow / nprow ) * nprow
1897*
1898 mydist = myrow - rsrc
1899 IF( mydist.LT.0 )
1900 $ mydist = mydist + nprow
1901*
1902 ilocblk = nblocks / nprow
1903*
1904 IF( ilocblk.GT.0 ) THEN
1905 mydist = mydist - nblocks + ilocblk * nprow
1906 IF( mydist.LT.0 ) THEN
1907 ii = mb + ilocblk * mb + 1
1908 ELSE
1909 IF( myrow.EQ.prow ) THEN
1910 ii = i1 + ( ilocblk - nblocks + 1 ) * mb
1911 ELSE
1912 ii = ilocblk * mb + 1
1913 END IF
1914 END IF
1915 ELSE
1916 mydist = mydist - nblocks
1917 IF( mydist.LT.0 ) THEN
1918 ii = mb + 1
1919 ELSE IF( myrow.EQ.prow ) THEN
1920 ii = i1 + ( 1 - nblocks ) * mb
1921 ELSE
1922 ii = 1
1923 END IF
1924 END IF
1925 END IF
1926*
1927 END IF
1928*
1929 inb = desc2( inb_ )
1930 pcol = desc2( csrc_ )
1931*
1932* Has every process column J ?
1933*
1934 IF( ( pcol.EQ.-1 ).OR.( npcol.EQ.1 ) ) THEN
1935*
1936 jj = j
1937*
1938 ELSE IF( j.LE.inb ) THEN
1939*
1940* J is in range of first block
1941*
1942 IF( mycol.EQ.pcol ) THEN
1943 jj = j
1944 ELSE
1945 jj = 1
1946 END IF
1947*
1948 ELSE
1949*
1950* J is not in first block of matrix, figure out who has it.
1951*
1952 csrc = pcol
1953 nb = desc2( nb_ )
1954*
1955 IF( mycol.EQ.csrc ) THEN
1956*
1957 nblocks = ( j - inb - 1 ) / nb + 1
1958 pcol = pcol + nblocks
1959 pcol = pcol - ( pcol / npcol ) * npcol
1960*
1961 ilocblk = nblocks / npcol
1962*
1963 IF( ilocblk.GT.0 ) THEN
1964 IF( ( ilocblk*npcol ).GE.nblocks ) THEN
1965 IF( mycol.EQ.pcol ) THEN
1966 jj = j + ( ilocblk - nblocks ) * nb
1967 ELSE
1968 jj = inb + ( ilocblk - 1 ) * nb + 1
1969 END IF
1970 ELSE
1971 jj = inb + ilocblk * nb + 1
1972 END IF
1973 ELSE
1974 jj = inb + 1
1975 END IF
1976*
1977 ELSE
1978*
1979 j1 = j - inb
1980 nblocks = ( j1 - 1 ) / nb + 1
1981 pcol = pcol + nblocks
1982 pcol = pcol - ( pcol / npcol ) * npcol
1983*
1984 mydist = mycol - csrc
1985 IF( mydist.LT.0 )
1986 $ mydist = mydist + npcol
1987*
1988 ilocblk = nblocks / npcol
1989*
1990 IF( ilocblk.GT.0 ) THEN
1991 mydist = mydist - nblocks + ilocblk * npcol
1992 IF( mydist.LT.0 ) THEN
1993 jj = nb + ilocblk * nb + 1
1994 ELSE
1995 IF( mycol.EQ.pcol ) THEN
1996 jj = j1 + ( ilocblk - nblocks + 1 ) * nb
1997 ELSE
1998 jj = ilocblk * nb + 1
1999 END IF
2000 END IF
2001 ELSE
2002 mydist = mydist - nblocks
2003 IF( mydist.LT.0 ) THEN
2004 jj = nb + 1
2005 ELSE IF( mycol.EQ.pcol ) THEN
2006 jj = j1 + ( 1 - nblocks ) * nb
2007 ELSE
2008 jj = 1
2009 END IF
2010 END IF
2011 END IF
2012*
2013 END IF
2014*
2015 RETURN
2016*
2017* End of PB_INFOG2L
2018*
subroutine pb_desctrans(descin, descout)
Definition pblastst.f:2964
Here is the caller graph for this function: