1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259
|
SUBROUTINE PSLASCAL( TYPE, M, N, ALPHA, A, IA, JA, DESCA )
*
* -- PBLAS test routine (version 2.0) --
* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
* and University of California, Berkeley.
* April 1, 1998
*
* .. Scalar Arguments ..
CHARACTER*1 TYPE
INTEGER IA, JA, M, N
REAL ALPHA
* ..
* .. Array Arguments ..
INTEGER DESCA( * )
REAL A( * )
* ..
*
* Purpose
* =======
*
* PSLASCAL scales the m by n submatrix A(IA:IA+M-1,JA:JA+N-1) denoted
* by sub( A ) by the scalar alpha. TYPE specifies if sub( A ) is full,
* upper triangular, lower triangular or upper Hessenberg.
*
* Notes
* =====
*
* A description vector is associated with each 2D block-cyclicly dis-
* tributed matrix. This vector stores the information required to
* establish the mapping between a matrix entry and its corresponding
* process and memory location.
*
* In the following comments, the character _ should be read as
* "of the distributed matrix". Let A be a generic term for any 2D
* block cyclicly distributed matrix. Its description vector is DESCA:
*
* NOTATION STORED IN EXPLANATION
* ---------------- --------------- ------------------------------------
* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
* the NPROW x NPCOL BLACS process grid
* A is distributed over. The context
* itself is global, but the handle
* (the integer value) may vary.
* M_A (global) DESCA( M_ ) The number of rows in the distribu-
* ted matrix A, M_A >= 0.
* N_A (global) DESCA( N_ ) The number of columns in the distri-
* buted matrix A, N_A >= 0.
* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
* block of the matrix A, IMB_A > 0.
* INB_A (global) DESCA( INB_ ) The number of columns of the upper
* left block of the matrix A,
* INB_A > 0.
* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
* bute the last M_A-IMB_A rows of A,
* MB_A > 0.
* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
* bute the last N_A-INB_A columns of
* A, NB_A > 0.
* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
* row of the matrix A is distributed,
* NPROW > RSRC_A >= 0.
* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
* first column of A is distributed.
* NPCOL > CSRC_A >= 0.
* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
* array storing the local blocks of
* the distributed matrix A,
* IF( Lc( 1, N_A ) > 0 )
* LLD_A >= MAX( 1, Lr( 1, M_A ) )
* ELSE
* LLD_A >= 1.
*
* Let K be the number of rows of a matrix A starting at the global in-
* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
* receive if these K rows were distributed over NPROW processes. If K
* is the number of columns of a matrix A starting at the global index
* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
* these K columns were distributed over NPCOL processes.
*
* The values of Lr() and Lc() may be determined via a call to the func-
* tion PB_NUMROC:
* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
*
* Arguments
* =========
*
* TYPE (global input) CHARACTER*1
* On entry, TYPE specifies the type of the input submatrix as
* follows:
* = 'L' or 'l': sub( A ) is a lower triangular matrix,
* = 'U' or 'u': sub( A ) is an upper triangular matrix,
* = 'H' or 'h': sub( A ) is an upper Hessenberg matrix,
* otherwise sub( A ) is a full matrix.
*
* M (global input) INTEGER
* On entry, M specifies the number of rows of the submatrix
* sub( A ). M must be at least zero.
*
* N (global input) INTEGER
* On entry, N specifies the number of columns of the submatrix
* sub( A ). N must be at least zero.
*
* ALPHA (global input) REAL
* On entry, ALPHA specifies the scalar alpha.
*
* A (local input/local output) REAL array
* On entry, A is an array of dimension (LLD_A, Ka), where Ka is
* at least Lc( 1, JA+N-1 ). Before entry, this array contains
* the local entries of the matrix A.
* On exit, the local entries of this array corresponding to the
* to the entries of the submatrix sub( A ) are overwritten by
* the local entries of the m by n scaled submatrix.
*
* IA (global input) INTEGER
* On entry, IA specifies A's global row index, which points to
* the beginning of the submatrix sub( A ).
*
* JA (global input) INTEGER
* On entry, JA specifies A's global column index, which points
* to the beginning of the submatrix sub( A ).
*
* DESCA (global and local input) INTEGER array
* On entry, DESCA is an integer array of dimension DLEN_. This
* is the array descriptor for the matrix A.
*
* -- Written on April 1, 1998 by
* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
*
* =====================================================================
*
* .. Parameters ..
INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
$ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
$ RSRC_
PARAMETER ( BLOCK_CYCLIC_2D_INB = 2, DLEN_ = 11,
$ DTYPE_ = 1, CTXT_ = 2, M_ = 3, N_ = 4,
$ IMB_ = 5, INB_ = 6, MB_ = 7, NB_ = 8,
$ RSRC_ = 9, CSRC_ = 10, LLD_ = 11 )
* ..
* .. Local Scalars ..
CHARACTER*1 UPLO
LOGICAL GODOWN, GOLEFT, LOWER, UPPER
INTEGER IACOL, IAROW, ICTXT, IIA, IIMAX, ILOW, IMB1,
$ IMBLOC, INB1, INBLOC, IOFFA, IOFFD, ITYPE,
$ IUPP, JJA, JJMAX, JOFFA, JOFFD, LCMT, LCMT00,
$ LDA, LMBLOC, LNBLOC, LOW, M1, MB, MBLKD, MBLKS,
$ MBLOC, MP, MRCOL, MRROW, MYCOL, MYROW, N1, NB,
$ NBLKD, NBLKS, NBLOC, NPCOL, NPROW, NQ, PMB,
$ QNB, TMP1, UPP
* ..
* .. Local Arrays ..
INTEGER DESCA2( DLEN_ )
* ..
* .. External Subroutines ..
EXTERNAL BLACS_GRIDINFO, PB_AINFOG2L, PB_BINFO,
$ PB_DESCTRANS, PB_INFOG2L, PB_SLASCAL
* ..
* .. External Functions ..
LOGICAL LSAME
INTEGER PB_NUMROC
EXTERNAL LSAME, PB_NUMROC
* ..
* .. Intrinsic Functions ..
INTRINSIC MIN
* ..
* .. Executable Statements ..
*
* Convert descriptor
*
CALL PB_DESCTRANS( DESCA, DESCA2 )
*
* Get grid parameters
*
ICTXT = DESCA2( CTXT_ )
CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )
*
* Quick return if possible
*
IF( M.EQ.0 .OR. N.EQ.0 )
$ RETURN
*
IF( LSAME( TYPE, 'L' ) ) THEN
ITYPE = 1
UPLO = TYPE
UPPER = .FALSE.
LOWER = .TRUE.
IOFFD = 0
ELSE IF( LSAME( TYPE, 'U' ) ) THEN
ITYPE = 2
UPLO = TYPE
UPPER = .TRUE.
LOWER = .FALSE.
IOFFD = 0
ELSE IF( LSAME( TYPE, 'H' ) ) THEN
ITYPE = 3
UPLO = 'U'
UPPER = .TRUE.
LOWER = .FALSE.
IOFFD = 1
ELSE
ITYPE = 0
UPLO = 'A'
UPPER = .TRUE.
LOWER = .TRUE.
IOFFD = 0
END IF
*
* Compute local indexes
*
IF( ITYPE.EQ.0 ) THEN
*
* Full matrix
*
CALL PB_INFOG2L( IA, JA, DESCA2, NPROW, NPCOL, MYROW, MYCOL,
$ IIA, JJA, IAROW, IACOL )
MP = PB_NUMROC( M, IA, DESCA2( IMB_ ), DESCA2( MB_ ), MYROW,
$ DESCA2( RSRC_ ), NPROW )
NQ = PB_NUMROC( N, JA, DESCA2( INB_ ), DESCA2( NB_ ), MYCOL,
$ DESCA2( CSRC_ ), NPCOL )
*
IF( MP.LE.0 .OR. NQ.LE.0 )
$ RETURN
*
LDA = DESCA2( LLD_ )
IOFFA = IIA + ( JJA - 1 ) * LDA
*
CALL PB_SLASCAL( 'All', MP, NQ, 0, ALPHA, A( IOFFA ), LDA )
*
ELSE
*
* Trapezoidal matrix
*
CALL PB_AINFOG2L( M, N, IA, JA, DESCA2, NPROW, NPCOL, MYROW,
$ MYCOL, IMB1, INB1, MP, NQ, IIA, JJA, IAROW,
$ IACOL, MRROW, MRCOL )
*
IF( MP.LE.0 .OR. NQ.LE.0 )
$ RETURN
*
* Initialize LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC, LMBLOC,
* LNBLOC, ILOW, LOW, IUPP, and UPP.
*
MB = DESCA2( MB_ )
NB = DESCA2( NB_ )
LDA = DESCA2( LLD_ )
*
CALL PB_BINFO( IOFFD, MP, NQ, IMB1, INB1, MB, NB, MRROW,
$ MRCOL, LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC,
$ LMBLOC, LNBLOC, ILOW, LOW, IUPP, UPP )
*
M1 = MP
N1 = NQ
IOFFA = IIA - 1
JOFFA = JJA - 1
IIMAX = IOFFA + MP
JJMAX = JOFFA + NQ
*
IF( DESCA2( RSRC_ ).LT.0 ) THEN
PMB = MB
ELSE
PMB = NPROW * MB
END IF
IF( DESCA2( CSRC_ ).LT.0 ) THEN
QNB = NB
ELSE
QNB = NPCOL * NB
END IF
*
* Handle the first block of rows or columns separately, and
* update LCMT00, MBLKS and NBLKS.
*
GODOWN = ( LCMT00.GT.IUPP )
GOLEFT = ( LCMT00.LT.ILOW )
*
IF( .NOT.GODOWN .AND. .NOT.GOLEFT ) THEN
*
* LCMT00 >= ILOW && LCMT00 <= IUPP
*
GOLEFT = ( ( LCMT00 - ( IUPP - UPP + PMB ) ).LT.ILOW )
GODOWN = .NOT.GOLEFT
*
CALL PB_SLASCAL( UPLO, IMBLOC, INBLOC, LCMT00, ALPHA,
$ A( IIA+JOFFA*LDA ), LDA )
IF( GODOWN ) THEN
IF( UPPER .AND. NQ.GT.INBLOC )
$ CALL PB_SLASCAL( 'All', IMBLOC, NQ-INBLOC, 0, ALPHA,
$ A( IIA+(JOFFA+INBLOC)*LDA ), LDA )
IIA = IIA + IMBLOC
M1 = M1 - IMBLOC
ELSE
IF( LOWER .AND. MP.GT.IMBLOC )
$ CALL PB_SLASCAL( 'All', MP-IMBLOC, INBLOC, 0, ALPHA,
$ A( IIA+IMBLOC+JOFFA*LDA ), LDA )
JJA = JJA + INBLOC
N1 = N1 - INBLOC
END IF
*
END IF
*
IF( GODOWN ) THEN
*
LCMT00 = LCMT00 - ( IUPP - UPP + PMB )
MBLKS = MBLKS - 1
IOFFA = IOFFA + IMBLOC
*
10 CONTINUE
IF( MBLKS.GT.0 .AND. LCMT00.GT.UPP ) THEN
LCMT00 = LCMT00 - PMB
MBLKS = MBLKS - 1
IOFFA = IOFFA + MB
GO TO 10
END IF
*
TMP1 = MIN( IOFFA, IIMAX ) - IIA + 1
IF( UPPER .AND. TMP1.GT.0 ) THEN
CALL PB_SLASCAL( 'All', TMP1, N1, 0, ALPHA,
$ A( IIA+JOFFA*LDA ), LDA )
IIA = IIA + TMP1
M1 = M1 - TMP1
END IF
*
IF( MBLKS.LE.0 )
$ RETURN
*
LCMT = LCMT00
MBLKD = MBLKS
IOFFD = IOFFA
*
MBLOC = MB
20 CONTINUE
IF( MBLKD.GT.0 .AND. LCMT.GE.ILOW ) THEN
IF( MBLKD.EQ.1 )
$ MBLOC = LMBLOC
CALL PB_SLASCAL( UPLO, MBLOC, INBLOC, LCMT, ALPHA,
$ A( IOFFD+1+JOFFA*LDA ), LDA )
LCMT00 = LCMT
LCMT = LCMT - PMB
MBLKS = MBLKD
MBLKD = MBLKD - 1
IOFFA = IOFFD
IOFFD = IOFFD + MBLOC
GO TO 20
END IF
*
TMP1 = M1 - IOFFD + IIA - 1
IF( LOWER .AND. TMP1.GT.0 )
$ CALL PB_SLASCAL( 'All', TMP1, INBLOC, 0, ALPHA,
$ A( IOFFD+1+JOFFA*LDA ), LDA )
*
TMP1 = IOFFA - IIA + 1
M1 = M1 - TMP1
N1 = N1 - INBLOC
LCMT00 = LCMT00 + LOW - ILOW + QNB
NBLKS = NBLKS - 1
JOFFA = JOFFA + INBLOC
*
IF( UPPER .AND. TMP1.GT.0 .AND. N1.GT.0 )
$ CALL PB_SLASCAL( 'All', TMP1, N1, 0, ALPHA,
$ A( IIA+JOFFA*LDA ), LDA )
*
IIA = IOFFA + 1
JJA = JOFFA + 1
*
ELSE IF( GOLEFT ) THEN
*
LCMT00 = LCMT00 + LOW - ILOW + QNB
NBLKS = NBLKS - 1
JOFFA = JOFFA + INBLOC
*
30 CONTINUE
IF( NBLKS.GT.0 .AND. LCMT00.LT.LOW ) THEN
LCMT00 = LCMT00 + QNB
NBLKS = NBLKS - 1
JOFFA = JOFFA + NB
GO TO 30
END IF
*
TMP1 = MIN( JOFFA, JJMAX ) - JJA + 1
IF( LOWER .AND. TMP1.GT.0 ) THEN
CALL PB_SLASCAL( 'All', M1, TMP1, 0, ALPHA,
$ A( IIA+(JJA-1)*LDA ), LDA )
JJA = JJA + TMP1
N1 = N1 - TMP1
END IF
*
IF( NBLKS.LE.0 )
$ RETURN
*
LCMT = LCMT00
NBLKD = NBLKS
JOFFD = JOFFA
*
NBLOC = NB
40 CONTINUE
IF( NBLKD.GT.0 .AND. LCMT.LE.IUPP ) THEN
IF( NBLKD.EQ.1 )
$ NBLOC = LNBLOC
CALL PB_SLASCAL( UPLO, IMBLOC, NBLOC, LCMT, ALPHA,
$ A( IIA+JOFFD*LDA ), LDA )
LCMT00 = LCMT
LCMT = LCMT + QNB
NBLKS = NBLKD
NBLKD = NBLKD - 1
JOFFA = JOFFD
JOFFD = JOFFD + NBLOC
GO TO 40
END IF
*
TMP1 = N1 - JOFFD + JJA - 1
IF( UPPER .AND. TMP1.GT.0 )
$ CALL PB_SLASCAL( 'All', IMBLOC, TMP1, 0, ALPHA,
$ A( IIA+JOFFD*LDA ), LDA )
*
TMP1 = JOFFA - JJA + 1
M1 = M1 - IMBLOC
N1 = N1 - TMP1
LCMT00 = LCMT00 - ( IUPP - UPP + PMB )
MBLKS = MBLKS - 1
IOFFA = IOFFA + IMBLOC
*
IF( LOWER .AND. M1.GT.0 .AND. TMP1.GT.0 )
$ CALL PB_SLASCAL( 'All', M1, TMP1, 0, ALPHA,
$ A( IOFFA+1+(JJA-1)*LDA ), LDA )
*
IIA = IOFFA + 1
JJA = JOFFA + 1
*
END IF
*
NBLOC = NB
50 CONTINUE
IF( NBLKS.GT.0 ) THEN
IF( NBLKS.EQ.1 )
$ NBLOC = LNBLOC
60 CONTINUE
IF( MBLKS.GT.0 .AND. LCMT00.GT.UPP ) THEN
LCMT00 = LCMT00 - PMB
MBLKS = MBLKS - 1
IOFFA = IOFFA + MB
GO TO 60
END IF
*
TMP1 = MIN( IOFFA, IIMAX ) - IIA + 1
IF( UPPER .AND. TMP1.GT.0 ) THEN
CALL PB_SLASCAL( 'All', TMP1, N1, 0, ALPHA,
$ A( IIA+JOFFA*LDA ), LDA )
IIA = IIA + TMP1
M1 = M1 - TMP1
END IF
*
IF( MBLKS.LE.0 )
$ RETURN
*
LCMT = LCMT00
MBLKD = MBLKS
IOFFD = IOFFA
*
MBLOC = MB
70 CONTINUE
IF( MBLKD.GT.0 .AND. LCMT.GE.LOW ) THEN
IF( MBLKD.EQ.1 )
$ MBLOC = LMBLOC
CALL PB_SLASCAL( UPLO, MBLOC, NBLOC, LCMT, ALPHA,
$ A( IOFFD+1+JOFFA*LDA ), LDA )
LCMT00 = LCMT
LCMT = LCMT - PMB
MBLKS = MBLKD
MBLKD = MBLKD - 1
IOFFA = IOFFD
IOFFD = IOFFD + MBLOC
GO TO 70
END IF
*
TMP1 = M1 - IOFFD + IIA - 1
IF( LOWER .AND. TMP1.GT.0 )
$ CALL PB_SLASCAL( 'All', TMP1, NBLOC, 0, ALPHA,
$ A( IOFFD+1+JOFFA*LDA ), LDA )
*
TMP1 = MIN( IOFFA, IIMAX ) - IIA + 1
M1 = M1 - TMP1
N1 = N1 - NBLOC
LCMT00 = LCMT00 + QNB
NBLKS = NBLKS - 1
JOFFA = JOFFA + NBLOC
*
IF( UPPER .AND. TMP1.GT.0 .AND. N1.GT.0 )
$ CALL PB_SLASCAL( 'All', TMP1, N1, 0, ALPHA,
$ A( IIA+JOFFA*LDA ), LDA )
*
IIA = IOFFA + 1
JJA = JOFFA + 1
*
GO TO 50
*
END IF
*
END IF
*
RETURN
*
* End of PSLASCAL
*
END
SUBROUTINE PSLAGEN( INPLACE, AFORM, DIAG, OFFA, M, N, IA, JA,
$ DESCA, IASEED, A, LDA )
*
* -- PBLAS test routine (version 2.0) --
* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
* and University of California, Berkeley.
* April 1, 1998
*
* .. Scalar Arguments ..
LOGICAL INPLACE
CHARACTER*1 AFORM, DIAG
INTEGER IA, IASEED, JA, LDA, M, N, OFFA
* ..
* .. Array Arguments ..
INTEGER DESCA( * )
REAL A( LDA, * )
* ..
*
* Purpose
* =======
*
* PSLAGEN generates (or regenerates) a submatrix sub( A ) denoting
* A(IA:IA+M-1,JA:JA+N-1).
*
* Notes
* =====
*
* A description vector is associated with each 2D block-cyclicly dis-
* tributed matrix. This vector stores the information required to
* establish the mapping between a matrix entry and its corresponding
* process and memory location.
*
* In the following comments, the character _ should be read as
* "of the distributed matrix". Let A be a generic term for any 2D
* block cyclicly distributed matrix. Its description vector is DESCA:
*
* NOTATION STORED IN EXPLANATION
* ---------------- --------------- ------------------------------------
* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
* the NPROW x NPCOL BLACS process grid
* A is distributed over. The context
* itself is global, but the handle
* (the integer value) may vary.
* M_A (global) DESCA( M_ ) The number of rows in the distribu-
* ted matrix A, M_A >= 0.
* N_A (global) DESCA( N_ ) The number of columns in the distri-
* buted matrix A, N_A >= 0.
* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
* block of the matrix A, IMB_A > 0.
* INB_A (global) DESCA( INB_ ) The number of columns of the upper
* left block of the matrix A,
* INB_A > 0.
* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
* bute the last M_A-IMB_A rows of A,
* MB_A > 0.
* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
* bute the last N_A-INB_A columns of
* A, NB_A > 0.
* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
* row of the matrix A is distributed,
* NPROW > RSRC_A >= 0.
* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
* first column of A is distributed.
* NPCOL > CSRC_A >= 0.
* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
* array storing the local blocks of
* the distributed matrix A,
* IF( Lc( 1, N_A ) > 0 )
* LLD_A >= MAX( 1, Lr( 1, M_A ) )
* ELSE
* LLD_A >= 1.
*
* Let K be the number of rows of a matrix A starting at the global in-
* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
* receive if these K rows were distributed over NPROW processes. If K
* is the number of columns of a matrix A starting at the global index
* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
* these K columns were distributed over NPCOL processes.
*
* The values of Lr() and Lc() may be determined via a call to the func-
* tion PB_NUMROC:
* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
*
* Arguments
* =========
*
* INPLACE (global input) LOGICAL
* On entry, INPLACE specifies if the matrix should be generated
* in place or not. If INPLACE is .TRUE., the local random array
* to be generated will start in memory at the local memory lo-
* cation A( 1, 1 ), otherwise it will start at the local posi-
* tion induced by IA and JA.
*
* AFORM (global input) CHARACTER*1
* On entry, AFORM specifies the type of submatrix to be genera-
* ted as follows:
* AFORM = 'S', sub( A ) is a symmetric matrix,
* AFORM = 'H', sub( A ) is a Hermitian matrix,
* AFORM = 'T', sub( A ) is overrwritten with the transpose
* of what would normally be generated,
* AFORM = 'C', sub( A ) is overwritten with the conjugate
* transpose of what would normally be genera-
* ted.
* AFORM = 'N', a random submatrix is generated.
*
* DIAG (global input) CHARACTER*1
* On entry, DIAG specifies if the generated submatrix is diago-
* nally dominant or not as follows:
* DIAG = 'D' : sub( A ) is diagonally dominant,
* DIAG = 'N' : sub( A ) is not diagonally dominant.
*
* OFFA (global input) INTEGER
* On entry, OFFA specifies the offdiagonal of the underlying
* matrix A(1:DESCA(M_),1:DESCA(N_)) of interest when the subma-
* trix is symmetric, Hermitian or diagonally dominant. OFFA = 0
* specifies the main diagonal, OFFA > 0 specifies a subdiago-
* nal, and OFFA < 0 specifies a superdiagonal (see further de-
* tails).
*
* M (global input) INTEGER
* On entry, M specifies the global number of matrix rows of the
* submatrix sub( A ) to be generated. M must be at least zero.
*
* N (global input) INTEGER
* On entry, N specifies the global number of matrix columns of
* the submatrix sub( A ) to be generated. N must be at least
* zero.
*
* IA (global input) INTEGER
* On entry, IA specifies A's global row index, which points to
* the beginning of the submatrix sub( A ).
*
* JA (global input) INTEGER
* On entry, JA specifies A's global column index, which points
* to the beginning of the submatrix sub( A ).
*
* DESCA (global and local input) INTEGER array
* On entry, DESCA is an integer array of dimension DLEN_. This
* is the array descriptor for the matrix A.
*
* IASEED (global input) INTEGER
* On entry, IASEED specifies the seed number to generate the
* matrix A. IASEED must be at least zero.
*
* A (local output) REAL array
* On entry, A is an array of dimension (LLD_A, Ka), where Ka is
* at least Lc( 1, JA+N-1 ). On exit, this array contains the
* local entries of the randomly generated submatrix sub( A ).
*
* LDA (local input) INTEGER
* On entry, LDA specifies the local leading dimension of the
* array A. When INPLACE is .FALSE., LDA is usually DESCA(LLD_).
* This restriction is however not enforced, and this subroutine
* requires only that LDA >= MAX( 1, Mp ) where
*
* Mp = PB_NUMROC( M, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW ).
*
* PB_NUMROC is a ScaLAPACK tool function; MYROW, MYCOL, NPROW
* and NPCOL can be determined by calling the BLACS subroutine
* BLACS_GRIDINFO.
*
* Further Details
* ===============
*
* OFFD is tied to the matrix described by DESCA, as opposed to the
* piece that is currently (re)generated. This is a global information
* independent from the distribution parameters. Below are examples of
* the meaning of OFFD for a global 7 by 5 matrix:
*
* ---------------------------------------------------------------------
* OFFD | 0 -1 -2 -3 -4 0 -1 -2 -3 -4 0 -1 -2 -3 -4
* -------|-------------------------------------------------------------
* | | OFFD=-1 | OFFD=0 OFFD=2
* | V V
* 0 | . d . . . -> d . . . . . . . . .
* 1 | . . d . . . d . . . . . . . .
* 2 | . . . d . . . d . . -> d . . . .
* 3 | . . . . d . . . d . . d . . .
* 4 | . . . . . . . . . d . . d . .
* 5 | . . . . . . . . . . . . . d .
* 6 | . . . . . . . . . . . . . . d
* ---------------------------------------------------------------------
*
* -- Written on April 1, 1998 by
* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
*
* =====================================================================
*
* .. Parameters ..
INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
$ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
$ RSRC_
PARAMETER ( BLOCK_CYCLIC_2D_INB = 2, DLEN_ = 11,
$ DTYPE_ = 1, CTXT_ = 2, M_ = 3, N_ = 4,
$ IMB_ = 5, INB_ = 6, MB_ = 7, NB_ = 8,
$ RSRC_ = 9, CSRC_ = 10, LLD_ = 11 )
INTEGER JMP_1, JMP_COL, JMP_IMBV, JMP_INBV, JMP_LEN,
$ JMP_MB, JMP_NB, JMP_NPIMBLOC, JMP_NPMB,
$ JMP_NQINBLOC, JMP_NQNB, JMP_ROW
PARAMETER ( JMP_1 = 1, JMP_ROW = 2, JMP_COL = 3,
$ JMP_MB = 4, JMP_IMBV = 5, JMP_NPMB = 6,
$ JMP_NPIMBLOC = 7, JMP_NB = 8, JMP_INBV = 9,
$ JMP_NQNB = 10, JMP_NQINBLOC = 11,
$ JMP_LEN = 11 )
* ..
* .. Local Scalars ..
LOGICAL DIAGDO, SYMM, HERM, NOTRAN
INTEGER CSRC, I, IACOL, IAROW, ICTXT, IIA, ILOCBLK,
$ ILOCOFF, ILOW, IMB, IMB1, IMBLOC, IMBVIR, INB,
$ INB1, INBLOC, INBVIR, INFO, IOFFDA, ITMP, IUPP,
$ IVIR, JJA, JLOCBLK, JLOCOFF, JVIR, LCMT00,
$ LMBLOC, LNBLOC, LOW, MAXMN, MB, MBLKS, MP,
$ MRCOL, MRROW, MYCDIST, MYCOL, MYRDIST, MYROW,
$ NB, NBLKS, NPCOL, NPROW, NQ, NVIR, RSRC, UPP
REAL ALPHA
* ..
* .. Local Arrays ..
INTEGER DESCA2( DLEN_ ), IMULADD( 4, JMP_LEN ),
$ IRAN( 2 ), JMP( JMP_LEN ), MULADD0( 4 )
* ..
* .. External Subroutines ..
EXTERNAL BLACS_GRIDINFO, PB_AINFOG2L, PB_BINFO,
$ PB_CHKMAT, PB_DESCTRANS, PB_INITJMP,
$ PB_INITMULADD, PB_JUMP, PB_JUMPIT, PB_LOCINFO,
$ PB_SETLOCRAN, PB_SETRAN, PB_SLAGEN, PSLADOM,
$ PXERBLA
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN, REAL
* ..
* .. Data Statements ..
DATA ( MULADD0( I ), I = 1, 4 ) / 20077, 16838,
$ 12345, 0 /
* ..
* .. Executable Statements ..
*
* Convert descriptor
*
CALL PB_DESCTRANS( DESCA, DESCA2 )
*
* Test the input arguments
*
ICTXT = DESCA2( CTXT_ )
CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )
*
* Test the input parameters
*
INFO = 0
IF( NPROW.EQ.-1 ) THEN
INFO = -( 1000 + CTXT_ )
ELSE
SYMM = LSAME( AFORM, 'S' )
HERM = LSAME( AFORM, 'H' )
NOTRAN = LSAME( AFORM, 'N' )
DIAGDO = LSAME( DIAG, 'D' )
IF( .NOT.( SYMM.OR.HERM.OR.NOTRAN ) .AND.
$ .NOT.( LSAME( AFORM, 'T' ) ) .AND.
$ .NOT.( LSAME( AFORM, 'C' ) ) ) THEN
INFO = -2
ELSE IF( ( .NOT.DIAGDO ) .AND.
$ ( .NOT.LSAME( DIAG, 'N' ) ) ) THEN
INFO = -3
END IF
CALL PB_CHKMAT( ICTXT, M, 5, N, 6, IA, JA, DESCA2, 10, INFO )
END IF
*
IF( INFO.NE.0 ) THEN
CALL PXERBLA( ICTXT, 'PSLAGEN', -INFO )
RETURN
END IF
*
* Quick return if possible
*
IF( ( M.LE.0 ).OR.( N.LE.0 ) )
$ RETURN
*
* Start the operations
*
MB = DESCA2( MB_ )
NB = DESCA2( NB_ )
IMB = DESCA2( IMB_ )
INB = DESCA2( INB_ )
RSRC = DESCA2( RSRC_ )
CSRC = DESCA2( CSRC_ )
*
* Figure out local information about the distributed matrix operand
*
CALL PB_AINFOG2L( M, N, IA, JA, DESCA2, NPROW, NPCOL, MYROW,
$ MYCOL, IMB1, INB1, MP, NQ, IIA, JJA, IAROW,
$ IACOL, MRROW, MRCOL )
*
* Decide where the entries shall be stored in memory
*
IF( INPLACE ) THEN
IIA = 1
JJA = 1
END IF
*
* Initialize LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC, LMBLOC, LNBLOC,
* ILOW, LOW, IUPP, and UPP.
*
IOFFDA = JA + OFFA - IA
CALL PB_BINFO( IOFFDA, MP, NQ, IMB1, INB1, MB, NB, MRROW,
$ MRCOL, LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC,
$ LMBLOC, LNBLOC, ILOW, LOW, IUPP, UPP )
*
* Initialize ILOCBLK, ILOCOFF, MYRDIST, JLOCBLK, JLOCOFF, MYCDIST
* This values correspond to the square virtual underlying matrix
* of size MAX( M_ + MAX( 0, -OFFA ), N_ + MAX( 0, OFFA ) ) used
* to set up the random sequence. For practical purposes, the size
* of this virtual matrix is upper bounded by M_ + N_ - 1.
*
ITMP = MAX( 0, -OFFA )
IVIR = IA + ITMP
IMBVIR = IMB + ITMP
NVIR = DESCA2( M_ ) + ITMP
*
CALL PB_LOCINFO( IVIR, IMBVIR, MB, MYROW, RSRC, NPROW, ILOCBLK,
$ ILOCOFF, MYRDIST )
*
ITMP = MAX( 0, OFFA )
JVIR = JA + ITMP
INBVIR = INB + ITMP
NVIR = MAX( MAX( NVIR, DESCA2( N_ ) + ITMP ),
$ DESCA2( M_ ) + DESCA2( N_ ) - 1 )
*
CALL PB_LOCINFO( JVIR, INBVIR, NB, MYCOL, CSRC, NPCOL, JLOCBLK,
$ JLOCOFF, MYCDIST )
*
IF( SYMM .OR. HERM .OR. NOTRAN ) THEN
*
CALL PB_INITJMP( .TRUE., NVIR, IMBVIR, INBVIR, IMBLOC, INBLOC,
$ MB, NB, RSRC, CSRC, NPROW, NPCOL, 1, JMP )
*
* Compute constants to jump JMP( * ) numbers in the sequence
*
CALL PB_INITMULADD( MULADD0, JMP, IMULADD )
*
* Compute and set the random value corresponding to A( IA, JA )
*
CALL PB_SETLOCRAN( IASEED, ILOCBLK, JLOCBLK, ILOCOFF, JLOCOFF,
$ MYRDIST, MYCDIST, NPROW, NPCOL, JMP,
$ IMULADD, IRAN )
*
CALL PB_SLAGEN( 'Lower', AFORM, A( IIA, JJA ), LDA, LCMT00,
$ IRAN, MBLKS, IMBLOC, MB, LMBLOC, NBLKS, INBLOC,
$ NB, LNBLOC, JMP, IMULADD )
*
END IF
*
IF( SYMM .OR. HERM .OR. ( .NOT. NOTRAN ) ) THEN
*
CALL PB_INITJMP( .FALSE., NVIR, IMBVIR, INBVIR, IMBLOC, INBLOC,
$ MB, NB, RSRC, CSRC, NPROW, NPCOL, 1, JMP )
*
* Compute constants to jump JMP( * ) numbers in the sequence
*
CALL PB_INITMULADD( MULADD0, JMP, IMULADD )
*
* Compute and set the random value corresponding to A( IA, JA )
*
CALL PB_SETLOCRAN( IASEED, ILOCBLK, JLOCBLK, ILOCOFF, JLOCOFF,
$ MYRDIST, MYCDIST, NPROW, NPCOL, JMP,
$ IMULADD, IRAN )
*
CALL PB_SLAGEN( 'Upper', AFORM, A( IIA, JJA ), LDA, LCMT00,
$ IRAN, MBLKS, IMBLOC, MB, LMBLOC, NBLKS, INBLOC,
$ NB, LNBLOC, JMP, IMULADD )
*
END IF
*
IF( DIAGDO ) THEN
*
MAXMN = MAX( DESCA2( M_ ), DESCA2( N_ ) )
ALPHA = REAL( MAXMN )
*
IF( IOFFDA.GE.0 ) THEN
CALL PSLADOM( INPLACE, MIN( MAX( 0, M-IOFFDA ), N ), ALPHA,
$ A, MIN( IA+IOFFDA, IA+M-1 ), JA, DESCA )
ELSE
CALL PSLADOM( INPLACE, MIN( M, MAX( 0, N+IOFFDA ) ), ALPHA,
$ A, IA, MIN( JA-IOFFDA, JA+N-1 ), DESCA )
END IF
*
END IF
*
RETURN
*
* End of PSLAGEN
*
END
SUBROUTINE PSLADOM( INPLACE, N, ALPHA, A, IA, JA, DESCA )
*
* -- PBLAS test routine (version 2.0) --
* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
* and University of California, Berkeley.
* April 1, 1998
*
* .. Scalar Arguments ..
LOGICAL INPLACE
INTEGER IA, JA, N
REAL ALPHA
* ..
* .. Array Arguments ..
INTEGER DESCA( * )
REAL A( * )
* ..
*
* Purpose
* =======
*
* PSLADOM adds alpha to the diagonal entries of an n by n submatrix
* sub( A ) denoting A( IA:IA+N-1, JA:JA+N-1 ).
*
* Notes
* =====
*
* A description vector is associated with each 2D block-cyclicly dis-
* tributed matrix. This vector stores the information required to
* establish the mapping between a matrix entry and its corresponding
* process and memory location.
*
* In the following comments, the character _ should be read as
* "of the distributed matrix". Let A be a generic term for any 2D
* block cyclicly distributed matrix. Its description vector is DESCA:
*
* NOTATION STORED IN EXPLANATION
* ---------------- --------------- ------------------------------------
* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
* the NPROW x NPCOL BLACS process grid
* A is distributed over. The context
* itself is global, but the handle
* (the integer value) may vary.
* M_A (global) DESCA( M_ ) The number of rows in the distribu-
* ted matrix A, M_A >= 0.
* N_A (global) DESCA( N_ ) The number of columns in the distri-
* buted matrix A, N_A >= 0.
* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
* block of the matrix A, IMB_A > 0.
* INB_A (global) DESCA( INB_ ) The number of columns of the upper
* left block of the matrix A,
* INB_A > 0.
* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
* bute the last M_A-IMB_A rows of A,
* MB_A > 0.
* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
* bute the last N_A-INB_A columns of
* A, NB_A > 0.
* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
* row of the matrix A is distributed,
* NPROW > RSRC_A >= 0.
* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
* first column of A is distributed.
* NPCOL > CSRC_A >= 0.
* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
* array storing the local blocks of
* the distributed matrix A,
* IF( Lc( 1, N_A ) > 0 )
* LLD_A >= MAX( 1, Lr( 1, M_A ) )
* ELSE
* LLD_A >= 1.
*
* Let K be the number of rows of a matrix A starting at the global in-
* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
* receive if these K rows were distributed over NPROW processes. If K
* is the number of columns of a matrix A starting at the global index
* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
* these K columns were distributed over NPCOL processes.
*
* The values of Lr() and Lc() may be determined via a call to the func-
* tion PB_NUMROC:
* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
*
* Arguments
* =========
*
* INPLACE (global input) LOGICAL
* On entry, INPLACE specifies if the matrix should be generated
* in place or not. If INPLACE is .TRUE., the local random array
* to be generated will start in memory at the local memory lo-
* cation A( 1, 1 ), otherwise it will start at the local posi-
* tion induced by IA and JA.
*
* N (global input) INTEGER
* On entry, N specifies the global order of the submatrix
* sub( A ) to be modified. N must be at least zero.
*
* ALPHA (global input) REAL
* On entry, ALPHA specifies the scalar alpha.
*
* A (local input/local output) REAL array
* On entry, A is an array of dimension (LLD_A, Ka), where Ka is
* at least Lc( 1, JA+N-1 ). Before entry, this array contains
* the local entries of the matrix A. On exit, the local entries
* of this array corresponding to the main diagonal of sub( A )
* have been updated.
*
* IA (global input) INTEGER
* On entry, IA specifies A's global row index, which points to
* the beginning of the submatrix sub( A ).
*
* JA (global input) INTEGER
* On entry, JA specifies A's global column index, which points
* to the beginning of the submatrix sub( A ).
*
* DESCA (global and local input) INTEGER array
* On entry, DESCA is an integer array of dimension DLEN_. This
* is the array descriptor for the matrix A.
*
* -- Written on April 1, 1998 by
* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
*
* =====================================================================
*
* .. Parameters ..
INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
$ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
$ RSRC_
PARAMETER ( BLOCK_CYCLIC_2D_INB = 2, DLEN_ = 11,
$ DTYPE_ = 1, CTXT_ = 2, M_ = 3, N_ = 4,
$ IMB_ = 5, INB_ = 6, MB_ = 7, NB_ = 8,
$ RSRC_ = 9, CSRC_ = 10, LLD_ = 11 )
* ..
* .. Local Scalars ..
LOGICAL GODOWN, GOLEFT
INTEGER I, IACOL, IAROW, ICTXT, IIA, IJOFFA, ILOW,
$ IMB1, IMBLOC, INB1, INBLOC, IOFFA, IOFFD, IUPP,
$ JJA, JOFFA, JOFFD, LCMT, LCMT00, LDA, LDAP1,
$ LMBLOC, LNBLOC, LOW, MB, MBLKD, MBLKS, MBLOC,
$ MRCOL, MRROW, MYCOL, MYROW, NB, NBLKD, NBLKS,
$ NBLOC, NP, NPCOL, NPROW, NQ, PMB, QNB, UPP
REAL ATMP
* ..
* .. Local Scalars ..
INTEGER DESCA2( DLEN_ )
* ..
* .. External Subroutines ..
EXTERNAL BLACS_GRIDINFO, PB_AINFOG2L, PB_BINFO,
$ PB_DESCTRANS
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, MAX, MIN
* ..
* .. Executable Statements ..
*
* Convert descriptor
*
CALL PB_DESCTRANS( DESCA, DESCA2 )
*
* Get grid parameters
*
ICTXT = DESCA2( CTXT_ )
CALL BLACS_GRIDINFO( ICTXT, NPROW, NPCOL, MYROW, MYCOL )
*
IF( N.EQ.0 )
$ RETURN
*
CALL PB_AINFOG2L( N, N, IA, JA, DESCA2, NPROW, NPCOL, MYROW,
$ MYCOL, IMB1, INB1, NP, NQ, IIA, JJA, IAROW,
$ IACOL, MRROW, MRCOL )
*
* Decide where the entries shall be stored in memory
*
IF( INPLACE ) THEN
IIA = 1
JJA = 1
END IF
*
* Initialize LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC, LMBLOC, LNBLOC,
* ILOW, LOW, IUPP, and UPP.
*
MB = DESCA2( MB_ )
NB = DESCA2( NB_ )
*
CALL PB_BINFO( 0, NP, NQ, IMB1, INB1, MB, NB, MRROW, MRCOL,
$ LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC, LMBLOC,
$ LNBLOC, ILOW, LOW, IUPP, UPP )
*
IOFFA = IIA - 1
JOFFA = JJA - 1
LDA = DESCA2( LLD_ )
LDAP1 = LDA + 1
*
IF( DESCA2( RSRC_ ).LT.0 ) THEN
PMB = MB
ELSE
PMB = NPROW * MB
END IF
IF( DESCA2( CSRC_ ).LT.0 ) THEN
QNB = NB
ELSE
QNB = NPCOL * NB
END IF
*
* Handle the first block of rows or columns separately, and update
* LCMT00, MBLKS and NBLKS.
*
GODOWN = ( LCMT00.GT.IUPP )
GOLEFT = ( LCMT00.LT.ILOW )
*
IF( .NOT.GODOWN .AND. .NOT.GOLEFT ) THEN
*
* LCMT00 >= ILOW && LCMT00 <= IUPP
*
IF( LCMT00.GE.0 ) THEN
IJOFFA = IOFFA+LCMT00 + ( JOFFA - 1 ) * LDA
DO 10 I = 1, MIN( INBLOC, MAX( 0, IMBLOC - LCMT00 ) )
ATMP = A( IJOFFA + I*LDAP1 )
A( IJOFFA + I*LDAP1 ) = ABS( ATMP ) + ALPHA
10 CONTINUE
ELSE
IJOFFA = IOFFA + ( JOFFA - LCMT00 - 1 ) * LDA
DO 20 I = 1, MIN( IMBLOC, MAX( 0, INBLOC + LCMT00 ) )
ATMP = A( IJOFFA + I*LDAP1 )
A( IJOFFA + I*LDAP1 ) = ABS( ATMP ) + ALPHA
20 CONTINUE
END IF
GOLEFT = ( ( LCMT00 - ( IUPP - UPP + PMB ) ).LT.ILOW )
GODOWN = .NOT.GOLEFT
*
END IF
*
IF( GODOWN ) THEN
*
LCMT00 = LCMT00 - ( IUPP - UPP + PMB )
MBLKS = MBLKS - 1
IOFFA = IOFFA + IMBLOC
*
30 CONTINUE
IF( MBLKS.GT.0 .AND. LCMT00.GT.UPP ) THEN
LCMT00 = LCMT00 - PMB
MBLKS = MBLKS - 1
IOFFA = IOFFA + MB
GO TO 30
END IF
*
LCMT = LCMT00
MBLKD = MBLKS
IOFFD = IOFFA
*
MBLOC = MB
40 CONTINUE
IF( MBLKD.GT.0 .AND. LCMT.GE.ILOW ) THEN
IF( MBLKD.EQ.1 )
$ MBLOC = LMBLOC
IF( LCMT.GE.0 ) THEN
IJOFFA = IOFFD + LCMT + ( JOFFA - 1 ) * LDA
DO 50 I = 1, MIN( INBLOC, MAX( 0, MBLOC - LCMT ) )
ATMP = A( IJOFFA + I*LDAP1 )
A( IJOFFA + I*LDAP1 ) = ABS( ATMP ) + ALPHA
50 CONTINUE
ELSE
IJOFFA = IOFFD + ( JOFFA - LCMT - 1 ) * LDA
DO 60 I = 1, MIN( MBLOC, MAX( 0, INBLOC + LCMT ) )
ATMP = A( IJOFFA + I*LDAP1 )
A( IJOFFA + I*LDAP1 ) = ABS( ATMP ) + ALPHA
60 CONTINUE
END IF
LCMT00 = LCMT
LCMT = LCMT - PMB
MBLKS = MBLKD
MBLKD = MBLKD - 1
IOFFA = IOFFD
IOFFD = IOFFD + MBLOC
GO TO 40
END IF
*
LCMT00 = LCMT00 + LOW - ILOW + QNB
NBLKS = NBLKS - 1
JOFFA = JOFFA + INBLOC
*
ELSE IF( GOLEFT ) THEN
*
LCMT00 = LCMT00 + LOW - ILOW + QNB
NBLKS = NBLKS - 1
JOFFA = JOFFA + INBLOC
*
70 CONTINUE
IF( NBLKS.GT.0 .AND. LCMT00.LT.LOW ) THEN
LCMT00 = LCMT00 + QNB
NBLKS = NBLKS - 1
JOFFA = JOFFA + NB
GO TO 70
END IF
*
LCMT = LCMT00
NBLKD = NBLKS
JOFFD = JOFFA
*
NBLOC = NB
80 CONTINUE
IF( NBLKD.GT.0 .AND. LCMT.LE.IUPP ) THEN
IF( NBLKD.EQ.1 )
$ NBLOC = LNBLOC
IF( LCMT.GE.0 ) THEN
IJOFFA = IOFFA + LCMT + ( JOFFD - 1 ) * LDA
DO 90 I = 1, MIN( NBLOC, MAX( 0, IMBLOC - LCMT ) )
ATMP = A( IJOFFA + I*LDAP1 )
A( IJOFFA + I*LDAP1 ) = ABS( ATMP ) + ALPHA
90 CONTINUE
ELSE
IJOFFA = IOFFA + ( JOFFD - LCMT - 1 ) * LDA
DO 100 I = 1, MIN( IMBLOC, MAX( 0, NBLOC + LCMT ) )
ATMP = A( IJOFFA + I*LDAP1 )
A( IJOFFA + I*LDAP1 ) = ABS( ATMP ) + ALPHA
100 CONTINUE
END IF
LCMT00 = LCMT
LCMT = LCMT + QNB
NBLKS = NBLKD
NBLKD = NBLKD - 1
JOFFA = JOFFD
JOFFD = JOFFD + NBLOC
GO TO 80
END IF
*
LCMT00 = LCMT00 - ( IUPP - UPP + PMB )
MBLKS = MBLKS - 1
IOFFA = IOFFA + IMBLOC
*
END IF
*
NBLOC = NB
110 CONTINUE
IF( NBLKS.GT.0 ) THEN
IF( NBLKS.EQ.1 )
$ NBLOC = LNBLOC
120 CONTINUE
IF( MBLKS.GT.0 .AND. LCMT00.GT.UPP ) THEN
LCMT00 = LCMT00 - PMB
MBLKS = MBLKS - 1
IOFFA = IOFFA + MB
GO TO 120
END IF
*
LCMT = LCMT00
MBLKD = MBLKS
IOFFD = IOFFA
*
MBLOC = MB
130 CONTINUE
IF( MBLKD.GT.0 .AND. LCMT.GE.LOW ) THEN
IF( MBLKD.EQ.1 )
$ MBLOC = LMBLOC
IF( LCMT.GE.0 ) THEN
IJOFFA = IOFFD + LCMT + ( JOFFA - 1 ) * LDA
DO 140 I = 1, MIN( NBLOC, MAX( 0, MBLOC - LCMT ) )
ATMP = A( IJOFFA + I*LDAP1 )
A( IJOFFA + I*LDAP1 ) = ABS( ATMP ) + ALPHA
140 CONTINUE
ELSE
IJOFFA = IOFFD + ( JOFFA - LCMT - 1 ) * LDA
DO 150 I = 1, MIN( MBLOC, MAX( 0, NBLOC + LCMT ) )
ATMP = A( IJOFFA + I*LDAP1 )
A( IJOFFA + I*LDAP1 ) = ABS( ATMP ) + ALPHA
150 CONTINUE
END IF
LCMT00 = LCMT
LCMT = LCMT - PMB
MBLKS = MBLKD
MBLKD = MBLKD - 1
IOFFA = IOFFD
IOFFD = IOFFD + MBLOC
GO TO 130
END IF
*
LCMT00 = LCMT00 + QNB
NBLKS = NBLKS - 1
JOFFA = JOFFA + NBLOC
GO TO 110
*
END IF
*
RETURN
*
* End of PSLADOM
*
END
SUBROUTINE PB_SLASCAL( UPLO, M, N, IOFFD, ALPHA, A, LDA )
*
* -- PBLAS test routine (version 2.0) --
* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
* and University of California, Berkeley.
* April 1, 1998
*
* .. Scalar Arguments ..
CHARACTER*1 UPLO
INTEGER IOFFD, LDA, M, N
REAL ALPHA
* ..
* .. Array Arguments ..
REAL A( LDA, * )
* ..
*
* Purpose
* =======
*
* PB_SLASCAL scales a two-dimensional array A by the scalar alpha.
*
* Arguments
* =========
*
* UPLO (input) CHARACTER*1
* On entry, UPLO specifies which trapezoidal part of the ar-
* ray A is to be scaled as follows:
* = 'L' or 'l': the lower trapezoid of A is scaled,
* = 'U' or 'u': the upper trapezoid of A is scaled,
* = 'D' or 'd': diagonal specified by IOFFD is scaled,
* Otherwise: all of the array A is scaled.
*
* M (input) INTEGER
* On entry, M specifies the number of rows of the array A. M
* must be at least zero.
*
* N (input) INTEGER
* On entry, N specifies the number of columns of the array A.
* N must be at least zero.
*
* IOFFD (input) INTEGER
* On entry, IOFFD specifies the position of the offdiagonal de-
* limiting the upper and lower trapezoidal part of A as follows
* (see the notes below):
*
* IOFFD = 0 specifies the main diagonal A( i, i ),
* with i = 1 ... MIN( M, N ),
* IOFFD > 0 specifies the subdiagonal A( i+IOFFD, i ),
* with i = 1 ... MIN( M-IOFFD, N ),
* IOFFD < 0 specifies the superdiagonal A( i, i-IOFFD ),
* with i = 1 ... MIN( M, N+IOFFD ).
*
* ALPHA (input) REAL
* On entry, ALPHA specifies the scalar alpha.
*
* A (input/output) REAL array
* On entry, A is an array of dimension (LDA,N). Before entry
* with UPLO = 'U' or 'u', the leading m by n part of the array
* A must contain the upper trapezoidal part of the matrix as
* specified by IOFFD to be scaled, and the strictly lower tra-
* pezoidal part of A is not referenced; When UPLO = 'L' or 'l',
* the leading m by n part of the array A must contain the lower
* trapezoidal part of the matrix as specified by IOFFD to be
* scaled, and the strictly upper trapezoidal part of A is not
* referenced. On exit, the entries of the trapezoid part of A
* determined by UPLO and IOFFD are scaled.
*
* LDA (input) INTEGER
* On entry, LDA specifies the leading dimension of the array A.
* LDA must be at least max( 1, M ).
*
* Notes
* =====
* N N
* ---------------------------- -----------
* | d | | |
* M | d 'U' | | 'U' |
* | 'L' 'D' | |d |
* | d | M | d |
* ---------------------------- | 'D' |
* | d |
* IOFFD < 0 | 'L' d |
* | d|
* N | |
* ----------- -----------
* | d 'U'|
* | d | IOFFD > 0
* M | 'D' |
* | d| N
* | 'L' | ----------------------------
* | | | 'U' |
* | | |d |
* | | | 'D' |
* | | | d |
* | | |'L' d |
* ----------- ----------------------------
*
* -- Written on April 1, 1998 by
* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
*
* =====================================================================
*
* .. Local Scalars ..
INTEGER I, J, JTMP, MN
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN
* ..
* .. Executable Statements ..
*
* Quick return if possible
*
IF( M.LE.0 .OR. N.LE.0 )
$ RETURN
*
* Start the operations
*
IF( LSAME( UPLO, 'L' ) ) THEN
*
* Scales the lower triangular part of the array by ALPHA.
*
MN = MAX( 0, -IOFFD )
DO 20 J = 1, MIN( MN, N )
DO 10 I = 1, M
A( I, J ) = ALPHA * A( I, J )
10 CONTINUE
20 CONTINUE
DO 40 J = MN + 1, MIN( M - IOFFD, N )
DO 30 I = J + IOFFD, M
A( I, J ) = ALPHA * A( I, J )
30 CONTINUE
40 CONTINUE
*
ELSE IF( LSAME( UPLO, 'U' ) ) THEN
*
* Scales the upper triangular part of the array by ALPHA.
*
MN = MIN( M - IOFFD, N )
DO 60 J = MAX( 0, -IOFFD ) + 1, MN
DO 50 I = 1, J + IOFFD
A( I, J ) = ALPHA * A( I, J )
50 CONTINUE
60 CONTINUE
DO 80 J = MAX( 0, MN ) + 1, N
DO 70 I = 1, M
A( I, J ) = ALPHA * A( I, J )
70 CONTINUE
80 CONTINUE
*
ELSE IF( LSAME( UPLO, 'D' ) ) THEN
*
* Scales the diagonal entries by ALPHA.
*
DO 90 J = MAX( 0, -IOFFD ) + 1, MIN( M - IOFFD, N )
JTMP = J + IOFFD
A( JTMP, J ) = ALPHA * A( JTMP, J )
90 CONTINUE
*
ELSE
*
* Scales the entire array by ALPHA.
*
DO 110 J = 1, N
DO 100 I = 1, M
A( I, J ) = ALPHA * A( I, J )
100 CONTINUE
110 CONTINUE
*
END IF
*
RETURN
*
* End of PB_SLASCAL
*
END
SUBROUTINE PB_SLAGEN( UPLO, AFORM, A, LDA, LCMT00, IRAN, MBLKS,
$ IMBLOC, MB, LMBLOC, NBLKS, INBLOC, NB,
$ LNBLOC, JMP, IMULADD )
*
* -- PBLAS test routine (version 2.0) --
* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
* and University of California, Berkeley.
* April 1, 1998
*
* .. Scalar Arguments ..
CHARACTER*1 UPLO, AFORM
INTEGER IMBLOC, INBLOC, LCMT00, LDA, LMBLOC, LNBLOC,
$ MB, MBLKS, NB, NBLKS
* ..
* .. Array Arguments ..
INTEGER IMULADD( 4, * ), IRAN( * ), JMP( * )
REAL A( LDA, * )
* ..
*
* Purpose
* =======
*
* PB_SLAGEN locally initializes an array A.
*
* Arguments
* =========
*
* UPLO (global input) CHARACTER*1
* On entry, UPLO specifies whether the lower (UPLO='L') trape-
* zoidal part or the upper (UPLO='U') trapezoidal part is to be
* generated when the matrix to be generated is symmetric or
* Hermitian. For all the other values of AFORM, the value of
* this input argument is ignored.
*
* AFORM (global input) CHARACTER*1
* On entry, AFORM specifies the type of submatrix to be genera-
* ted as follows:
* AFORM = 'S', sub( A ) is a symmetric matrix,
* AFORM = 'H', sub( A ) is a Hermitian matrix,
* AFORM = 'T', sub( A ) is overrwritten with the transpose
* of what would normally be generated,
* AFORM = 'C', sub( A ) is overwritten with the conjugate
* transpose of what would normally be genera-
* ted.
* AFORM = 'N', a random submatrix is generated.
*
* A (local output) REAL array
* On entry, A is an array of dimension (LLD_A, *). On exit,
* this array contains the local entries of the randomly genera-
* ted submatrix sub( A ).
*
* LDA (local input) INTEGER
* On entry, LDA specifies the local leading dimension of the
* array A. LDA must be at least one.
*
* LCMT00 (global input) INTEGER
* On entry, LCMT00 is the LCM value specifying the off-diagonal
* of the underlying matrix of interest. LCMT00=0 specifies the
* main diagonal, LCMT00 > 0 specifies a subdiagonal, LCMT00 < 0
* specifies superdiagonals.
*
* IRAN (local input) INTEGER array
* On entry, IRAN is an array of dimension 2 containing respec-
* tively the 16-lower and 16-higher bits of the encoding of the
* entry of the random sequence corresponding locally to the
* first local array entry to generate. Usually, this array is
* computed by PB_SETLOCRAN.
*
* MBLKS (local input) INTEGER
* On entry, MBLKS specifies the local number of blocks of rows.
* MBLKS is at least zero.
*
* IMBLOC (local input) INTEGER
* On entry, IMBLOC specifies the number of rows (size) of the
* local uppest blocks. IMBLOC is at least zero.
*
* MB (global input) INTEGER
* On entry, MB specifies the blocking factor used to partition
* the rows of the matrix. MB must be at least one.
*
* LMBLOC (local input) INTEGER
* On entry, LMBLOC specifies the number of rows (size) of the
* local lowest blocks. LMBLOC is at least zero.
*
* NBLKS (local input) INTEGER
* On entry, NBLKS specifies the local number of blocks of co-
* lumns. NBLKS is at least zero.
*
* INBLOC (local input) INTEGER
* On entry, INBLOC specifies the number of columns (size) of
* the local leftmost blocks. INBLOC is at least zero.
*
* NB (global input) INTEGER
* On entry, NB specifies the blocking factor used to partition
* the the columns of the matrix. NB must be at least one.
*
* LNBLOC (local input) INTEGER
* On entry, LNBLOC specifies the number of columns (size) of
* the local rightmost blocks. LNBLOC is at least zero.
*
* JMP (local input) INTEGER array
* On entry, JMP is an array of dimension JMP_LEN containing the
* different jump values used by the random matrix generator.
*
* IMULADD (local input) INTEGER array
* On entry, IMULADD is an array of dimension (4, JMP_LEN). The
* jth column of this array contains the encoded initial cons-
* tants a_j and c_j to jump from X( n ) to X( n + JMP( j ) )
* (= a_j * X( n ) + c_j) in the random sequence. IMULADD(1:2,j)
* contains respectively the 16-lower and 16-higher bits of the
* constant a_j, and IMULADD(3:4,j) contains the 16-lower and
* 16-higher bits of the constant c_j.
*
* -- Written on April 1, 1998 by
* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
*
* =====================================================================
*
* .. Parameters ..
INTEGER JMP_1, JMP_COL, JMP_IMBV, JMP_INBV, JMP_LEN,
$ JMP_MB, JMP_NB, JMP_NPIMBLOC, JMP_NPMB,
$ JMP_NQINBLOC, JMP_NQNB, JMP_ROW
PARAMETER ( JMP_1 = 1, JMP_ROW = 2, JMP_COL = 3,
$ JMP_MB = 4, JMP_IMBV = 5, JMP_NPMB = 6,
$ JMP_NPIMBLOC = 7, JMP_NB = 8, JMP_INBV = 9,
$ JMP_NQNB = 10, JMP_NQINBLOC = 11,
$ JMP_LEN = 11 )
* ..
* .. Local Scalars ..
INTEGER I, IB, IBLK, II, IK, ITMP, JB, JBLK, JJ, JK,
$ JTMP, LCMTC, LCMTR, LOW, MNB, UPP
REAL DUMMY
* ..
* .. Local Arrays ..
INTEGER IB0( 2 ), IB1( 2 ), IB2( 2 ), IB3( 2 )
* ..
* .. External Subroutines ..
EXTERNAL PB_JUMPIT
* ..
* .. External Functions ..
LOGICAL LSAME
REAL PB_SRAND
EXTERNAL LSAME, PB_SRAND
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN
* ..
* .. Executable Statements ..
*
DO 10 I = 1, 2
IB1( I ) = IRAN( I )
IB2( I ) = IRAN( I )
IB3( I ) = IRAN( I )
10 CONTINUE
*
IF( LSAME( AFORM, 'N' ) ) THEN
*
* Generate random matrix
*
JJ = 1
*
DO 50 JBLK = 1, NBLKS
*
IF( JBLK.EQ.1 ) THEN
JB = INBLOC
ELSE IF( JBLK.EQ.NBLKS ) THEN
JB = LNBLOC
ELSE
JB = NB
END IF
*
DO 40 JK = JJ, JJ + JB - 1
*
II = 1
*
DO 30 IBLK = 1, MBLKS
*
IF( IBLK.EQ.1 ) THEN
IB = IMBLOC
ELSE IF( IBLK.EQ.MBLKS ) THEN
IB = LMBLOC
ELSE
IB = MB
END IF
*
* Blocks are IB by JB
*
DO 20 IK = II, II + IB - 1
A( IK, JK ) = PB_SRAND( 0 )
20 CONTINUE
*
II = II + IB
*
IF( IBLK.EQ.1 ) THEN
*
* Jump IMBLOC + ( NPROW - 1 ) * MB rows
*
CALL PB_JUMPIT( IMULADD( 1, JMP_NPIMBLOC ), IB1,
$ IB0 )
*
ELSE
*
* Jump NPROW * MB rows
*
CALL PB_JUMPIT( IMULADD( 1, JMP_NPMB ), IB1, IB0 )
*
END IF
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
*
30 CONTINUE
*
* Jump one column
*
CALL PB_JUMPIT( IMULADD( 1, JMP_COL ), IB2, IB0 )
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
IB2( 1 ) = IB0( 1 )
IB2( 2 ) = IB0( 2 )
*
40 CONTINUE
*
JJ = JJ + JB
*
IF( JBLK.EQ.1 ) THEN
*
* Jump INBLOC + ( NPCOL - 1 ) * NB columns
*
CALL PB_JUMPIT( IMULADD( 1, JMP_NQINBLOC ), IB3, IB0 )
*
ELSE
*
* Jump NPCOL * NB columns
*
CALL PB_JUMPIT( IMULADD( 1, JMP_NQNB ), IB3, IB0 )
*
END IF
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
IB2( 1 ) = IB0( 1 )
IB2( 2 ) = IB0( 2 )
IB3( 1 ) = IB0( 1 )
IB3( 2 ) = IB0( 2 )
*
50 CONTINUE
*
ELSE IF( LSAME( AFORM, 'T' ) .OR. LSAME( AFORM, 'C' ) ) THEN
*
* Generate the transpose of the matrix that would be normally
* generated.
*
II = 1
*
DO 90 IBLK = 1, MBLKS
*
IF( IBLK.EQ.1 ) THEN
IB = IMBLOC
ELSE IF( IBLK.EQ.MBLKS ) THEN
IB = LMBLOC
ELSE
IB = MB
END IF
*
DO 80 IK = II, II + IB - 1
*
JJ = 1
*
DO 70 JBLK = 1, NBLKS
*
IF( JBLK.EQ.1 ) THEN
JB = INBLOC
ELSE IF( JBLK.EQ.NBLKS ) THEN
JB = LNBLOC
ELSE
JB = NB
END IF
*
* Blocks are IB by JB
*
DO 60 JK = JJ, JJ + JB - 1
A( IK, JK ) = PB_SRAND( 0 )
60 CONTINUE
*
JJ = JJ + JB
*
IF( JBLK.EQ.1 ) THEN
*
* Jump INBLOC + ( NPCOL - 1 ) * NB columns
*
CALL PB_JUMPIT( IMULADD( 1, JMP_NQINBLOC ), IB1,
$ IB0 )
*
ELSE
*
* Jump NPCOL * NB columns
*
CALL PB_JUMPIT( IMULADD( 1, JMP_NQNB ), IB1, IB0 )
*
END IF
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
*
70 CONTINUE
*
* Jump one row
*
CALL PB_JUMPIT( IMULADD( 1, JMP_ROW ), IB2, IB0 )
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
IB2( 1 ) = IB0( 1 )
IB2( 2 ) = IB0( 2 )
*
80 CONTINUE
*
II = II + IB
*
IF( IBLK.EQ.1 ) THEN
*
* Jump IMBLOC + ( NPROW - 1 ) * MB rows
*
CALL PB_JUMPIT( IMULADD( 1, JMP_NPIMBLOC ), IB3, IB0 )
*
ELSE
*
* Jump NPROW * MB rows
*
CALL PB_JUMPIT( IMULADD( 1, JMP_NPMB ), IB3, IB0 )
*
END IF
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
IB2( 1 ) = IB0( 1 )
IB2( 2 ) = IB0( 2 )
IB3( 1 ) = IB0( 1 )
IB3( 2 ) = IB0( 2 )
*
90 CONTINUE
*
ELSE IF( ( LSAME( AFORM, 'S' ) ).OR.( LSAME( AFORM, 'H' ) ) ) THEN
*
* Generate a symmetric matrix
*
IF( LSAME( UPLO, 'L' ) ) THEN
*
* generate lower trapezoidal part
*
JJ = 1
LCMTC = LCMT00
*
DO 170 JBLK = 1, NBLKS
*
IF( JBLK.EQ.1 ) THEN
JB = INBLOC
LOW = 1 - INBLOC
ELSE IF( JBLK.EQ.NBLKS ) THEN
JB = LNBLOC
LOW = 1 - NB
ELSE
JB = NB
LOW = 1 - NB
END IF
*
DO 160 JK = JJ, JJ + JB - 1
*
II = 1
LCMTR = LCMTC
*
DO 150 IBLK = 1, MBLKS
*
IF( IBLK.EQ.1 ) THEN
IB = IMBLOC
UPP = IMBLOC - 1
ELSE IF( IBLK.EQ.MBLKS ) THEN
IB = LMBLOC
UPP = MB - 1
ELSE
IB = MB
UPP = MB - 1
END IF
*
* Blocks are IB by JB
*
IF( LCMTR.GT.UPP ) THEN
*
DO 100 IK = II, II + IB - 1
DUMMY = PB_SRAND( 0 )
100 CONTINUE
*
ELSE IF( LCMTR.GE.LOW ) THEN
*
JTMP = JK - JJ + 1
MNB = MAX( 0, -LCMTR )
*
IF( JTMP.LE.MIN( MNB, JB ) ) THEN
*
DO 110 IK = II, II + IB - 1
A( IK, JK ) = PB_SRAND( 0 )
110 CONTINUE
*
ELSE IF( ( JTMP.GE.( MNB + 1 ) ) .AND.
$ ( JTMP.LE.MIN( IB-LCMTR, JB ) ) ) THEN
*
ITMP = II + JTMP + LCMTR - 1
*
DO 120 IK = II, ITMP - 1
DUMMY = PB_SRAND( 0 )
120 CONTINUE
*
DO 130 IK = ITMP, II + IB - 1
A( IK, JK ) = PB_SRAND( 0 )
130 CONTINUE
*
END IF
*
ELSE
*
DO 140 IK = II, II + IB - 1
A( IK, JK ) = PB_SRAND( 0 )
140 CONTINUE
*
END IF
*
II = II + IB
*
IF( IBLK.EQ.1 ) THEN
*
* Jump IMBLOC + ( NPROW - 1 ) * MB rows
*
LCMTR = LCMTR - JMP( JMP_NPIMBLOC )
CALL PB_JUMPIT( IMULADD( 1, JMP_NPIMBLOC ), IB1,
$ IB0 )
*
ELSE
*
* Jump NPROW * MB rows
*
LCMTR = LCMTR - JMP( JMP_NPMB )
CALL PB_JUMPIT( IMULADD( 1, JMP_NPMB ), IB1,
$ IB0 )
*
END IF
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
*
150 CONTINUE
*
* Jump one column
*
CALL PB_JUMPIT( IMULADD( 1, JMP_COL ), IB2, IB0 )
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
IB2( 1 ) = IB0( 1 )
IB2( 2 ) = IB0( 2 )
*
160 CONTINUE
*
JJ = JJ + JB
*
IF( JBLK.EQ.1 ) THEN
*
* Jump INBLOC + ( NPCOL - 1 ) * NB columns
*
LCMTC = LCMTC + JMP( JMP_NQINBLOC )
CALL PB_JUMPIT( IMULADD( 1, JMP_NQINBLOC ), IB3, IB0 )
*
ELSE
*
* Jump NPCOL * NB columns
*
LCMTC = LCMTC + JMP( JMP_NQNB )
CALL PB_JUMPIT( IMULADD( 1, JMP_NQNB ), IB3, IB0 )
*
END IF
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
IB2( 1 ) = IB0( 1 )
IB2( 2 ) = IB0( 2 )
IB3( 1 ) = IB0( 1 )
IB3( 2 ) = IB0( 2 )
*
170 CONTINUE
*
ELSE
*
* generate upper trapezoidal part
*
II = 1
LCMTR = LCMT00
*
DO 250 IBLK = 1, MBLKS
*
IF( IBLK.EQ.1 ) THEN
IB = IMBLOC
UPP = IMBLOC - 1
ELSE IF( IBLK.EQ.MBLKS ) THEN
IB = LMBLOC
UPP = MB - 1
ELSE
IB = MB
UPP = MB - 1
END IF
*
DO 240 IK = II, II + IB - 1
*
JJ = 1
LCMTC = LCMTR
*
DO 230 JBLK = 1, NBLKS
*
IF( JBLK.EQ.1 ) THEN
JB = INBLOC
LOW = 1 - INBLOC
ELSE IF( JBLK.EQ.NBLKS ) THEN
JB = LNBLOC
LOW = 1 - NB
ELSE
JB = NB
LOW = 1 - NB
END IF
*
* Blocks are IB by JB
*
IF( LCMTC.LT.LOW ) THEN
*
DO 180 JK = JJ, JJ + JB - 1
DUMMY = PB_SRAND( 0 )
180 CONTINUE
*
ELSE IF( LCMTC.LE.UPP ) THEN
*
ITMP = IK - II + 1
MNB = MAX( 0, LCMTC )
*
IF( ITMP.LE.MIN( MNB, IB ) ) THEN
*
DO 190 JK = JJ, JJ + JB - 1
A( IK, JK ) = PB_SRAND( 0 )
190 CONTINUE
*
ELSE IF( ( ITMP.GE.( MNB + 1 ) ) .AND.
$ ( ITMP.LE.MIN( JB+LCMTC, IB ) ) ) THEN
*
JTMP = JJ + ITMP - LCMTC - 1
*
DO 200 JK = JJ, JTMP - 1
DUMMY = PB_SRAND( 0 )
200 CONTINUE
*
DO 210 JK = JTMP, JJ + JB - 1
A( IK, JK ) = PB_SRAND( 0 )
210 CONTINUE
*
END IF
*
ELSE
*
DO 220 JK = JJ, JJ + JB - 1
A( IK, JK ) = PB_SRAND( 0 )
220 CONTINUE
*
END IF
*
JJ = JJ + JB
*
IF( JBLK.EQ.1 ) THEN
*
* Jump INBLOC + ( NPCOL - 1 ) * NB columns
*
LCMTC = LCMTC + JMP( JMP_NQINBLOC )
CALL PB_JUMPIT( IMULADD( 1, JMP_NQINBLOC ), IB1,
$ IB0 )
*
ELSE
*
* Jump NPCOL * NB columns
*
LCMTC = LCMTC + JMP( JMP_NQNB )
CALL PB_JUMPIT( IMULADD( 1, JMP_NQNB ), IB1,
$ IB0 )
*
END IF
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
*
230 CONTINUE
*
* Jump one row
*
CALL PB_JUMPIT( IMULADD( 1, JMP_ROW ), IB2, IB0 )
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
IB2( 1 ) = IB0( 1 )
IB2( 2 ) = IB0( 2 )
*
240 CONTINUE
*
II = II + IB
*
IF( IBLK.EQ.1 ) THEN
*
* Jump IMBLOC + ( NPROW - 1 ) * MB rows
*
LCMTR = LCMTR - JMP( JMP_NPIMBLOC )
CALL PB_JUMPIT( IMULADD( 1, JMP_NPIMBLOC ), IB3, IB0 )
*
ELSE
*
* Jump NPROW * MB rows
*
LCMTR = LCMTR - JMP( JMP_NPMB )
CALL PB_JUMPIT( IMULADD( 1, JMP_NPMB ), IB3, IB0 )
*
END IF
*
IB1( 1 ) = IB0( 1 )
IB1( 2 ) = IB0( 2 )
IB2( 1 ) = IB0( 1 )
IB2( 2 ) = IB0( 2 )
IB3( 1 ) = IB0( 1 )
IB3( 2 ) = IB0( 2 )
*
250 CONTINUE
*
END IF
*
END IF
*
RETURN
*
* End of PB_SLAGEN
*
END
REAL FUNCTION PB_SRAND( IDUMM )
*
* -- PBLAS test routine (version 2.0) --
* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
* and University of California, Berkeley.
* April 1, 1998
*
* .. Scalar Arguments ..
INTEGER IDUMM
* ..
*
* Purpose
* =======
*
* PB_SRAND generates the next number in the random sequence. This func-
* tion ensures that this number will be in the interval ( -1.0, 1.0 ).
*
* Arguments
* =========
*
* IDUMM (local input) INTEGER
* This argument is ignored, but necessary to a FORTRAN 77 func-
* tion.
*
* Further Details
* ===============
*
* On entry, the array IRAND stored in the common block RANCOM contains
* the information (2 integers) required to generate the next number in
* the sequence X( n ). This number is computed as
*
* X( n ) = ( 2^16 * IRAND( 2 ) + IRAND( 1 ) ) / d,
*
* where the constant d is the largest 32 bit positive integer. The
* array IRAND is then updated for the generation of the next number
* X( n+1 ) in the random sequence as follows X( n+1 ) = a * X( n ) + c.
* The constants a and c should have been preliminarily stored in the
* array IACS as 2 pairs of integers. The initial set up of IRAND and
* IACS is performed by the routine PB_SETRAN.
*
* -- Written on April 1, 1998 by
* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
*
* =====================================================================
*
* .. Parameters ..
REAL ONE, TWO
PARAMETER ( ONE = 1.0E+0, TWO = 2.0E+0 )
* ..
* .. External Functions ..
REAL PB_SRAN
EXTERNAL PB_SRAN
* ..
* .. Executable Statements ..
*
PB_SRAND = ONE - TWO * PB_SRAN( IDUMM )
*
RETURN
*
* End of PB_SRAND
*
END
REAL FUNCTION PB_SRAN( IDUMM )
*
* -- PBLAS test routine (version 2.0) --
* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
* and University of California, Berkeley.
* April 1, 1998
*
* .. Scalar Arguments ..
INTEGER IDUMM
* ..
*
* Purpose
* =======
*
* PB_SRAN generates the next number in the random sequence.
*
* Arguments
* =========
*
* IDUMM (local input) INTEGER
* This argument is ignored, but necessary to a FORTRAN 77 func-
* tion.
*
* Further Details
* ===============
*
* On entry, the array IRAND stored in the common block RANCOM contains
* the information (2 integers) required to generate the next number in
* the sequence X( n ). This number is computed as
*
* X( n ) = ( 2^16 * IRAND( 2 ) + IRAND( 1 ) ) / d,
*
* where the constant d is the largest 32 bit positive integer. The
* array IRAND is then updated for the generation of the next number
* X( n+1 ) in the random sequence as follows X( n+1 ) = a * X( n ) + c.
* The constants a and c should have been preliminarily stored in the
* array IACS as 2 pairs of integers. The initial set up of IRAND and
* IACS is performed by the routine PB_SETRAN.
*
* -- Written on April 1, 1998 by
* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
*
* =====================================================================
*
* .. Parameters ..
REAL DIVFAC, POW16
PARAMETER ( DIVFAC = 2.147483648E+9,
$ POW16 = 6.5536E+4 )
* ..
* .. Local Arrays ..
INTEGER J( 2 )
* ..
* .. External Subroutines ..
EXTERNAL PB_LADD, PB_LMUL
* ..
* .. Intrinsic Functions ..
INTRINSIC REAL
* ..
* .. Common Blocks ..
INTEGER IACS( 4 ), IRAND( 2 )
COMMON /RANCOM/ IRAND, IACS
* ..
* .. Save Statements ..
SAVE /RANCOM/
* ..
* .. Executable Statements ..
*
PB_SRAN = ( REAL( IRAND( 1 ) ) + POW16 * REAL( IRAND( 2 ) ) ) /
$ DIVFAC
*
CALL PB_LMUL( IRAND, IACS, J )
CALL PB_LADD( J, IACS( 3 ), IRAND )
*
RETURN
*
* End of PB_SRAN
*
END
|