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 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929
|
.. _MIGRATING:
New features
============
This document describes the major changes occurring between versions of
Modules. It provides an overview of the new features and changed behaviors
that will be encountered when upgrading.
v5.6
----
This new version is backward-compatible with previous version 5 release. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`5.6 release notes<5.6 release notes>` for a complete
list of the changes between Modules v5.5 and v5.6.
spider sub-command
^^^^^^^^^^^^^^^^^^
Support has been added for the :subcmd:`spider` sub-command introduced by the
`Lmod`_ project. This sub-command lists available modules found in enabled
modulepaths and recursively found in modulepaths enabled by available modules.
.. parsed-literal::
:ps:`$` module avail
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
foo/1 foo/2
:ps:`$` module show foo/1
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1`:
:sgrcm:`conflict` foo
:sgrcm:`module` use /path/to/modulefiles.2
-------------------------------------------------------------------
:ps:`$` module show foo/2
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/2`:
:sgrcm:`conflict` foo
:sgrcm:`append-path` MODULEPATH /path/to/modulefiles.3
-------------------------------------------------------------------
:ps:`$` module spider
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
foo/1 foo/2
-------------- :sgrdi:`/path/to/modulefiles.2` (via foo/1) --------------
bar/1 bar/2 bar/3
-------------- :sgrdi:`/path/to/modulefiles.3` (via foo/2) --------------
bar/3 bar/4
-------------- :sgrdi:`/path/to/modulefiles.3` (via bar/1) --------------
qux/1 qux/2
The :subcmd:`spider` sub-command relies on the :ref:`Extra match search`
mechanism to scan modulefiles and identify the modulepaths they enable. Since
all modulefiles are evaluated during this scan, it is recommended to build
and use a :ref:`Module cache` to improve search performance.
The output of :subcmd:`spider` is similar to that of the :subcmd:`avail`
sub-command and supports the same set of options and queries.
.. parsed-literal::
:ps:`$` module spider -t bar@2:
:sgrdi:`/path/to/modulefiles.2`:
:sgrhi:`bar/2`
bar/3
:sgrdi:`/path/to/modulefiles.3`:
bar/3
bar/4
The :subcmd:`spider` sub-command has its own configuration options to control
the content of its output: :mconfig:`spider_indepth`,
:mconfig:`spider_output`, and :mconfig:`spider_terse_output`.
These settings make it possible to define output for :subcmd:`spider` that
differs from the :subcmd:`avail` sub-command.
.. parsed-literal::
:ps:`$` module config spider_output -modulepath
:ps:`$` module config spider_indepth 0
:ps:`$` module spider
:sgrdi:`bar`/ :sgrdi:`foo`/ :sgrdi:`qux`/
When a modulepath is enabled by a specific module, that modulepath is
considered available *via* that module. When the module is loaded, this *via*
information is stored in the :envvar:`__MODULES_LMUSE` environment variable to
track which modules enable which modulepaths.
By default, the *via* information is included in the standard output of the
:subcmd:`spider` sub-command. Additionally, the JSON output for both the
:subcmd:`avail` and :subcmd:`spider` sub-commands has been updated to include
*via* details for each modulefile.
.. parsed-literal::
:ps:`$` module spider -j bar@2:
{"/path/to/modulefiles.2": {
"bar/2": { "name": "bar/2", "type": "modulefile", "symbols": [], "tags": [], "pathname": "/path/to/modulefiles.2/bar/2", "via": "foo/1"}
"bar/2": { "name": "bar/3", "type": "modulefile", "symbols": [], "tags": [], "pathname": "/path/to/modulefiles.2/bar/3", "via": "foo/1"}
},
"/path/to/modulefiles.3": {
"bar/3": { "name": "bar/3", "type": "modulefile", "symbols": [], "tags": [], "pathname": "/path/to/modulefiles.3/bar/3", "via": "foo/2"},
"bar/4": { "name": "bar/4", "type": "modulefile", "symbols": [], "tags": [], "pathname": "/path/to/modulefiles.3/bar/4", "via": "foo/2"}
}}
.. _Requiring via module:
Requiring *via* module
^^^^^^^^^^^^^^^^^^^^^^
A loaded module that enables a modulepath is considered the *via* module of
other loaded modules whose modulefiles are stored in this modulepath. The
:mconfig:`require_via` configuration option is introduced to consider a *via*
module a requirement for the loaded module stored in the modulepath it
enables.
A *module hierarchy* mechanism, as introduced by the Lmod_ project, is now
supported with this feature. It allows organizing modulefiles through a
primary modulepath, where loading certain modules enables additional
modulepaths. :mconfig:`require_via` maintains a link between modulefiles in
these additional paths and the *via* module that activated them.
The :mconfig:`require_via` setting is disabled by default to maintain
compatibility with previous Modules 5 releases. However, users are encouraged
to enable this feature if they want to use the *module hierarchy* mechanism.
.. parsed-literal::
:ps:`$` module config require_via 1
When unloading a *via* module, all the modules stored in its enabled
modulepath are automatically unloaded thanks to the *Dependent Unload*
mechanism of the :ref:`Automated module handling mode<MODULES_AUTO_HANDLING>`.
.. parsed-literal::
:ps:`$` module load foo/1 bar/2
:ps:`$` module avail
-------------- :sgrdi:`/path/to/modulefiles.2` (via foo/1) --------------
bar/1 :sgrl:`bar/2` bar/3
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
:sgrl:`foo/1` foo/2
Key:
:sgrl:`loaded` :sgrdi:`modulepath`
:ps:`$` module unload foo
Unloading :sgrhi:`foo/1`
:sgrin:`Unloading dependent`: bar/2
When a *via* module is replaced by another, any modulepaths it enabled are
updated accordingly. If the newly enabled modulepath provides alternatives to
modules previously loaded from the original path, those modules are reloaded
from the new location. If no alternatives are found, the dependent modules are
unloaded.
.. parsed-literal::
:ps:`$` module config conflict_unload 1
:ps:`$` module load foo/1 bar/3
:ps:`$` module load foo/2
Loading :sgrhi:`foo/2`
:sgrin:`Unloading dependent`: bar/3
:sgrin:`Unloading conflict`: foo/1
:sgrin:`Reloading dependent`: bar/3
:ps:`$` module avail
-------------- :sgrdi:`/path/to/modulefiles.3` (via foo/2) --------------
:sgrl:`bar/3` bar/4
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
foo/1 :sgrl:`foo/2`
Key:
:sgrl:`loaded` :sgrdi:`modulepath`
Always see hidden modules
^^^^^^^^^^^^^^^^^^^^^^^^^
The ``hidden`` element is a new allowed value for the :mconfig:`avail_output`,
:mconfig:`avail_terse_output`, :mconfig:`list_output`,
:mconfig:`list_terse_output`, :mconfig:`spider_output` and
:mconfig:`spider_terse_output` configuration options. When set into the value
list of these options hidden modules are shown on the output of corresponding
commands (:subcmd:`avail`, :subcmd:`list` and :subcmd:`spider`).
.. parsed-literal::
--------------- :sgrdi:`/path/to/modulefiles` ---------------
bar/1.0
:ps:`$` module config avail_output +hidden
:ps:`$` ml av
--------------- :sgrdi:`/path/to/modulefiles` ---------------
bar/1.0 foo/1.0 <H>
When set, this is equivalent to always adding the :option:`--all` command-line
option.
Issue warning upon module evaluation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The mfcmd:`module-warn` modulefile Tcl command is introduced to define warning
message to print when loading specified modulefiles.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/1.0
#%Module
module-warn --message {Please consider using "bar" module instead} foo
:ps:`$` module load foo
Loading :sgrhi:`foo/1.0`
:sgrwa:`WARNING`: Please consider using "bar" module instead
The warning message is printed when targeted modulefile is evaluated in
*load*, *display*, *help* or *test* mode.
:mfcmd:`module-warn` supports the same kind of options than
:mfcmd:`module-tag` or :mfcmd:`module-hide`: it is possible to specify a list
of affected or unaffected users or groups. Warning may also be only effective
before or after a particular date.
The ``warning`` tag is set on modules targeted by a mfcmd:`module-warn`
command.
Simplified way to define module help message
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Until now module help message was defined through a specific Tcl procedure
that outputs text to *stderr* channel:
.. code-block:: tcl
#%Module
proc ModulesHelp {} {
puts stderr {Module Name: foo, Version: 1.0}
puts stderr {This modulefile does this and that}
}
A new modulefile Tcl command is introduced, :mfcmd:`module-help`, to simplify
a bit the definition of help message:
.. code-block:: tcl
#%Module
module-help {Module Name: foo, Version: 1.0}
module-help {This modulefile does this and that}
With this modulefile command there is no need to define the ``ModulesHelp``
procedure anymore. As :mfcmd:`module-help` is reported on module *display*
evaluation, help message will also be visible there.
Support for newline character in environment variable value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is now possible on *sh*, *bash*, *ksh*, *zsh* and *fish* shells to set
value for environment variable that contains newline character:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/bar/1.0
#%Module
setenv BAR "multi\nline\nvalue"
:ps:`$` module load bar
:ps:`$` echo "$BAR"
multi
line
value
Generated shell code on these shells has been changed to enclose value within
single quotes rather escaping each special characters:
.. parsed-literal::
:ps:`$` module mod-to-sh bash bar/1.0
BAR='multi
line
value'; export BAR;
Declare additional elements provided by a module
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
New :mfcmd:`provide` modulefile command is added to declare additional
elements included in a modulefile. When the modulefile is loaded, each
argument specified in the :mfcmd:`provide` command is registered as an alias
for the module.
.. parsed-literal::
:ps:`$` module show foo
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1`:
:sgrcm:`provide` liba/1.2 libb/2.1
:sgrcm:`conflict` foo
:sgrcm:`conflict` liba libb
-------------------------------------------------------------------
:ps:`$` module load foo
It is advised to define :mfcmd:`conflict` over the name of these additional
elements to ensure only one provider is found loaded in user environment.
.. parsed-literal::
:ps:`$` module show bar/1
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/bar/1`:
:sgrcm:`provide` liba/1.2 libb/2.1
:sgrcm:`conflict` bar
:sgrcm:`conflict` liba libb
-------------------------------------------------------------------
:ps:`$` module load bar
Loading :sgrhi:`bar/1`
:sgrer:`ERROR`: Module cannot be loaded due to a conflict.
HINT: Might try "module unload foo/1" first.
Once a module with a provided alias is loaded, it fulfills any requirements
declared by other modules for that name and version, just like any other type
of module alias.
.. parsed-literal::
:ps:`$` module show qux
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/qux/1`:
:sgrcm:`prereq` liba/1.2
-------------------------------------------------------------------
:ps:`$` module load qux
:ps:`$` module list
Currently Loaded Modulefiles:
1) foo/1 2) qux/1
Module aliases defined via the :mfcmd:`provide` command are not available
during module resolution, as modulefiles are not evaluated in that context.
Therefore, it is recommended to define a global module alias in a ``modulerc``
file using the :mfcmd:`module-alias` command to specify a default target for
the alias.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/.modulerc
#%Module
module-alias liba/1.2 bar/1
:ps:`$` module purge
:ps:`$` module load qux
Loading :sgrhi:`qux/1`
:sgrin:`Loading requirement`: bar/1
The :mfcmd:`provide` modulefile command also serves as an alias for the
:mfcmd:`extensions` command, ensuring compatibility with modulefiles written
for `Lmod`_.
By default an :subcmd:`avail` command includes module aliases defined in
``modulerc`` files. To also get aliases defined within modulefiles with
:mfcmd:`provide` or :mfcmd:`family`, output element ``provided-alias`` has to
be included. It is supported on :mconfig:`avail_output`,
:mconfig:`avail_terse_output`, :mconfig:`spider_output` and
:mconfig:`spider_terse_output` configuration options.
Having ``provided-alias`` included in output triggers :ref:`Extra match
search` mechanism that scans all modulefiles to find these aliases. It is thus
advised to have :ref:`Module cache` built and used to improve search speed.
.. parsed-literal::
:ps:`$` module avail
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1 foo/1 :sgrali:`liba/1.2` qux/1
Key:
:sgrdi:`modulepath` :sgrali:`module-alias`
:ps:`$` module avail -o +provided-alias
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1 foo/1 :sgrali:`liba/1.2` :sgrali:`libb/2.1` qux/1
Key:
:sgrdi:`modulepath` :sgrali:`module-alias`
The ``provided-alias`` :ref:`Extra specifier` is also introduced to find
modules that define such alias with :mfcmd:`provide` or :mfcmd:`family`
modulefile commands.
.. parsed-literal::
:ps:`$` module avail provided-alias:liba/1.2
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1 foo/1
Key:
:sgrdi:`modulepath`
v5.5
----
This new version is backward-compatible with previous version 5 release. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`5.5 release notes<5.5 release notes>` for a complete
list of the changes between Modules v5.4 and v5.5.
.. _Logging activity:
Logging activity
^^^^^^^^^^^^^^^^
The ability to log module command activity is now available out of the box. It
could be enabled on previous versions by using a specific
:file:`siteconfig.tcl` configuration script as described in the
:ref:`log-module-command` cookbook recipe.
Integrated logging feature relies on two configuration options:
* :mconfig:`logger`, the command run to transmit messages to the log system
* :mconfig:`logged_events`, list of module event to log
:mconfig:`logger` option relies on the :command:`logger` command by default,
which is usually available and already installed on most systems.
The :mconfig:`logged_events` option is empty by default, so no content is sent
to logs by default. It recognizes the following events:
* ``requested_cmd``: record module commands typed by users
* ``requested_eval``: record modulefile evaluations requested by users
* ``auto_eval``: record modulefile evaluations automatically triggered
.. parsed-literal::
:ps:`$` module config logged_events +requested_cmd:requested_eval
:ps:`$` ml av
--------------- :sgrdi:`/path/to/modulefiles` ---------------
bar/1.0 foo/1.0 qux/1.0
:ps:`$` module load bar
Loading :sgrhi:`bar/1.0`
:sgrin:`Loading requirement`: qux/1.0
:ps:`$` module purge
In the above example the module command and modulefile evaluations directly
requested by users are sent to the system log:
.. parsed-literal::
:ps:`$` journalctl -q -t modules
Apr 29 07:47:42 hostname modules[3777797]: user="username" command="avail" arguments=""
Apr 29 07:48:10 hostname modules[3777876]: user="username" command="load" arguments="bar"
Apr 29 07:48:10 hostname modules[3777876]: user="username" mode="load" module="bar/1.0" specified="bar" modulefile="/path/to/modulefiles/bar/1.0" requested="1"
Apr 29 07:48:17 hostname modules[3777914]: user="username" command="purge" arguments=""
Apr 29 07:48:17 hostname modules[3777914]: user="username" mode="unload" module="bar/1.0" specified="bar/1.0" modulefile="/path/to/modulefiles/bar/1.0" requested="1"
Some messages can also be sent during modulefile evaluation by using the
``log`` channel of the :mfcmd:`puts` command:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/1.0
#%Module
puts log {some message sent to log}
:ps:`$` ml foo/1.0
:ps:`$` journalctl -q -t modules
Apr 29 07:47:51 hostname modules[3777835]: user="username" command="ml" arguments="foo/1.0"
Apr 29 07:47:51 hostname modules[3777835]: some message sent to log
Apr 29 07:47:51 hostname modules[3777835]: user="username" mode="load" module="foo/1.0" specified="foo/1.0" modulefile="/path/to/modulefiles/foo/1.0" requested="1"
Negating extra match search criteria
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``not:`` prefix string is introduced for extra specifier and variant
criteria. When this prefix is used, the search criteria where it is applied is
negated.
.. parsed-literal::
:ps:`$` module config avail_output +variant
:ps:`$` module config variant_shortcut toolchain=%
:ps:`$` module avail
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1.0{:sgrva:`%x86_64`} foo/2.0{:sgrva:`%x86_64`,\ :sgrva:`arm64`}
bar/2.0{:sgrva:`%x86_64`,\ :sgrva:`arm64`} qux/1.0{:sgrva:`%x86_64`}
foo/1.0{:sgrva:`%x86_64`} qux/2.0{:sgrva:`%x86_64`,\ :sgrva:`arm64`}
:ps:`$` module avail not:envvar:FOO,BAR
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
qux/1.0{:sgrva:`%x86_64`} qux/2.0{:sgrva:`%x86_64`,\ :sgrva:`arm64`}
The above search query returns all modules not defining ``FOO`` and ``BAR``
environment variables.
.. parsed-literal::
:ps:`$` module avail not:envvar:BAR not:%arm64
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
foo/1.0{:sgrva:`%x86_64`} qux/1.0{:sgrva:`%x86_64`}
The above example returns all modules not defining ``BAR`` environment
variable and not defining ``toolchain`` variant or defining this variant
without ``arm64`` among the possible values.
This prefix is recognized on module search context (i.e., :subcmd:`avail`,
:subcmd:`whatis` and :subcmd:`paths` sub-commands).
PowerShell support
^^^^^^^^^^^^^^^^^^
Support for PowerShell (``pwsh``) is added. This shell may be used with
Modules on either Unix or Windows platforms. All main :ref:`kind of
environment changes are supported<Shell support>`.
A ``envmodule`` shell function is configured on PowerShell, as ``module`` is a
reserved keyword on this shell.
The Windows-specific distribution zipball of Modules has been updated to also
contain the required files to setup PowerShell support.
.. _Conflict unload MIGRATING:
Conflict unload
^^^^^^^^^^^^^^^
Automated module handling is enhanced with the addition of a new mechanism:
*Conflict Unload*. When loading a module, this new mechanism automatically
unloads conflicting modules and their dependent.
.. parsed-literal::
:ps:`$` module load foo/1
Loading :sgrhi:`foo/1`:sgrse:`{`:sgrvahi:`-debug`:sgrse:`}`
:sgrin:`Loading requirement`: qux/1 bar/1
:ps:`$` module load foo/2
Loading :sgrhi:`foo/2`
:sgrer:`ERROR`: Module cannot be loaded due to a conflict.
HINT: Might try "module unload foo/1" first.
:ps:`$` module config conflict_unload 1
:ps:`$` module load foo/2
Loading :sgrhi:`foo/2`:sgrse:`{`:sgrvahi:`-debug`:sgrse:`}`
:sgrin:`Unloading conflict`: foo/1\ :sgrse:`{`:sgrva:`-debug`:sgrse:`}`
As seen in the above example, *Conflict Unload* is controlled by the
:mconfig:`conflict_unload` configuration option. It is disabled by default
as it changes behaviors of the :envvar:`automated module handling
mode<MODULES_AUTO_HANDLING>`. But everyone is encouraged to enable this new
option to benefit from an highly automated experience. This option can be
changed at installation time with :instopt:`--enable-conflict-unload`
configure script option.
*Conflict Unload* handles all kind of conflicts: conflicts defined by already
loaded modules, conflict declared by loading module through :mfcmd:`conflict`,
:mfcmd:`family` or :mfcmd:`module unload<module>` commands. It also supports
the unload of a module that is loaded again but with different variant values.
.. parsed-literal::
:ps:`$` module load foo/2 +debug
Loading :sgrhi:`foo/2`:sgrse:`{`:sgrvahi:`+debug`:sgrse:`}`
:sgrin:`Unloading conflict`: foo/2\ :sgrse:`{`:sgrva:`-debug`:sgrse:`}`
Along with *Conflict Unload*, the *Useless Requirement Unload* mechanism is
added to load evaluation. With it, auto loaded requirements of modules
unloaded by *Conflict Unload* mechanism are automatically unloaded.
.. parsed-literal::
:ps:`$` module load foo/3
Loading :sgrhi:`foo/3`:sgrse:`{`:sgrvahi:`-debug`:sgrse:`}`
:sgrin:`Unloading conflict`: foo/2\ :sgrse:`{`:sgrva:`+debug`:sgrse:`}` bar/1
:sgrin:`Loading requirement`: bar/2
:sgrin:`Unloading useless requirement`: qux/1
Dependent modules of *Conflict Unload* modules are considered *Dependent
Reload* modules. They are unloaded prior unloading the *Conflict Unload*
module that depend on them. Reload occurs after loading main module and only
if the loaded environment satisfies the dependencies of the module to reload.
.. parsed-literal::
:ps:`$` module load bar/3
Loading :sgrhi:`bar/3`
:sgrin:`Loading requirement`: qux/2
:ps:`$` module load qux/1
Loading :sgrhi:`qux/1`
:sgrin:`Unloading dependent`: bar/3
:sgrin:`Unloading conflict`: qux/2
:sgrin:`Reloading dependent`: bar/3
Improved automated module handling mechanisms
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Along with the introduction of *Conflict Unload* mechanism, some of the
existing automated module handling mechanisms have been adapted and enhanced.
*Useless Requirement Unload* (UReqUn) mechanism is moved during a
:subcmd:`switch` sub-command from the end of the unload phase to the end of
the load phase. Both *UReqUn* modules coming from unload and load phases are
this way treated jointly. If *UReqUn* modules resulting from the switch unload
phase are detected as conflict to the switched-on module, it is advised to
enable the :mconfig:`conflict_unload` mechanism to automatically handle them.
.. parsed-literal::
:ps:`$` module switch foo/3 foo/4
Loading :sgrhi:`foo/4`
:sgrer:`ERROR`: Module cannot be loaded due to a conflict.
HINT: Might try "module unload bar/2" first.
Switching from :sgrhi:`foo/3`:sgrse:`{`:sgrvahi:`-debug`:sgrse:`}` to :sgrhi:`foo/4`
:sgrer:`ERROR`: Load of switched-on foo/4 failed
:ps:`$` module config conflict_unload 1
:ps:`$` module switch foo/3 foo/4
Switching from :sgrhi:`foo/3`:sgrse:`{`:sgrvahi:`-debug`:sgrse:`}` to :sgrhi:`foo/4`
:sgrin:`Unloading conflict`: bar/2
*Dependent Reload* (DepRe) modules that also are *UReqUn* modules are now
unloaded during the *DepRe* unload phase instead of during the *UReqUn*
process. As a consequence these modules are now unloaded prior main module
action, as they are a dependent of this main module. This kind of *UReqUn*
modules may not be a dependency of a module unloaded in the current
processing.
Modules from *Dependent Unload* (DepUn) and *Dependent Reload* (DepRe)
mechanisms are now mixed together to proceed to their unload. They are this
way unloaded in their reverse loading order. So if a module is part of the
*DepUn* process and one of its requirement is part of the *DepRe* process, the
requirement is now unloaded after its dependent.
Reload of *Dependent Reload* (DepRe) module is now skipped if this module is
not found loadable in environment. Either because its requirements are not
loaded or a conflict is spotted. Such module is considered *Dependent Unload*
rather *Dependent Reload*. If *DepRe* module is sticky, reload is attempted
anyway.
Reload of all *Dependent Reload* (DepRe) modules now occurs after main module
evaluation rather after each sub module evaluation that triggered the
*Dependent Reload* unload phase.
When a loading module requires a *Dependent Unload* (DepUn) module, the unload
of this module was forced when it was triggered by a Conflict Unload or a
switched-off module. The unload of such *DepUn* module is not forced anymore
by default and an error is raised if a loading module requiring the *DepUn*
module is detected.
When unloading *Dependent Reload* modules, do not force by default this unload
unless asked with :option:`--force` option. As a result an error is obtained
when trying to reload Dependent Reload modules that conflict with other loaded
modules. This error may be by-passed with :option:`--force` command-line
option.
.. _Specific modulepath for requirements:
Specific modulepath for requirements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A ``--modulepath`` option is introduced on the :mfcmd:`always-load`,
:mfcmd:`depends-on`, :mfcmd:`prereq`, :mfcmd:`prereq-all` and
:mfcmd:`prereq-any` modulefile commands. This option indicates that
requirement should be specifically searched in the provided list of
modulepaths. Such mechanism helps to ensure loaded requirements are those
expected and they are not coming from an unexpected module tree.
In the following example, ``foo`` module requires ``bar``. It expects the
``bar`` module from the same modulepath than ``foo``. User's environment has
enabled another modulepath that also provides a ``bar`` module. Use of
``--modulepath`` option guides the requirement load mechanism to the expected
module.
.. parsed-literal::
:ps:`$` module avail
--------------------- :sgrdi:`/path/to/othermfiles` ---------------------
bar/1
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1 foo/1 foo/2
:ps:`$` module show foo/1
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1`:
:sgrcm:`prereq` --modulepath .. bar/1
-------------------------------------------------------------------
:ps:`$` module load foo/1
Loading :sgrhi:`foo/1`
:sgrin:`Loading requirement`: bar/1
:ps:`$` echo $_LMFILES_
/path/to/modulefiles/bar/1:/path/to/modulefiles/foo/1
Specific modulepath set may guide to a directory not necessarily enabled
(i.e., not defined in :envvar:`MODULEPATH` environment variable):
.. parsed-literal::
:ps:`$` module show foo/2
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/2`:
:sgrcm:`prereq` --modulepath /path/to/alternatefiles bar/2
-------------------------------------------------------------------
:ps:`$` module load foo/2
Loading :sgrhi:`foo/2`
:sgrin:`Loading requirement`: bar/2
:ps:`$` module list
Currently Loaded Modulefiles:
1) bar/2 2) foo/2
:ps:`$` echo $_LMFILES_
/path/to/alternatefiles/bar/2:/path/to/modulefiles/foo/2
If a required module is already loaded from a modulepath that does not
correspond to the requirement definition, an error is obtained. However if
the *Conflict Unload* mechanism described above is enabled, the conflicting
module will automatically be unloaded.
.. parsed-literal::
:ps:`$` module purge
:ps:`$` module load bar/1
:ps:`$` echo $_LMFILES_
/path/to/othermfiles/bar/1
:ps:`$` module load foo/1
Loading :sgrhi:`bar/1`
:sgrer:`ERROR`: Module already loaded from a different modulepath
Loading :sgrhi:`foo/1`
:sgrer:`ERROR`: Load of requirement bar/1 (specific path) failed
:ps:`$` module config conflict_unload 1
:ps:`$` module load foo/1
Loading :sgrhi:`foo/1`
:sgrin:`Unloading conflict`: bar/1
:sgrin:`Loading requirement`: bar/1
:ps:`$` echo $_LMFILES_
/path/to/modulefiles/bar/1:/path/to/modulefiles/foo/1
v5.4
----
This new version is backward-compatible with previous version 5 release. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`5.4 release notes<5.4 release notes>` for a complete
list of the changes between Modules v5.3 and v5.4.
Enhancing extra specifiers
^^^^^^^^^^^^^^^^^^^^^^^^^^
Extra specifier ``tag`` is introduced to search modules based on tags applied.
It applies to :subcmd:`avail`, :subcmd:`whatis` and :subcmd:`paths`
sub-commands. Tag abbreviation may also be used as extra specifier name.
.. parsed-literal::
:ps:`$` module avail tag:sticky
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
:sgrs:`bar/1`
Multiple names can now be specified on one extra specifier criterion to select
modules matching any of these names.
.. parsed-literal::
:ps:`$` module avail tag:S,F
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
:sgrs:`bar/1` :sgrf:`qux/1`
Multiple values can now be specified on one variant criterion to select
modules providing any of these variant values.
.. parsed-literal::
:ps:`$` module config variant_shortcut toolchain=%
:ps:`$` module avail %a,c
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
baz/1{:sgrvahi:`%c`} foo/1{:sgrvahi:`%a`,\ :sgrva:`b`,\ :sgrvahi:`c`}
:ps:`$` module avail %a,c %b
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
foo/1{:sgrvahi:`%a`,\ :sgrvahi:`b`,\ :sgrvahi:`c`}
Purging sticky modules
^^^^^^^^^^^^^^^^^^^^^^
The :mconfig:`sticky_purge` configuration option is added to define the
behavior of :subcmd:`purge` sub-command when unloading a sticky or
super-sticky module.
By default an ``error`` is raised. :mconfig:`sticky_purge` can be changed to
emit a ``warning`` message instead or to be ``silent``.
.. parsed-literal::
:ps:`$` module purge
Unloading :sgrshi:`foo/1.0`
:sgrer:`ERROR`: Unload of sticky module skipped
:ps:`$` module config sticky_purge warning
:ps:`$` module purge
Unloading :sgrshi:`foo/1.0`
:sgrwa:`WARNING`: Unload of sticky module skipped
:ps:`$` module config sticky_purge silent
:ps:`$` module purge
:ps:`$` module list
Currently Loaded Modulefiles:
1) :sgrs:`foo/1.0`
Key:
:sgrs:`sticky`
Specific modulepath labels
^^^^^^^^^^^^^^^^^^^^^^^^^^
:mfcmd:`modulepath-label` command is introduced to define a label to use to
designate modulepath in module :subcmd:`avail` output. This new command should
be used in global or modulepath-specific rc files.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/.modulerc
#%Module
modulepath-label . Tools
:ps:`$` module avail foo
---------------------- :sgrdi:`Tools` ----------------------
foo/1.0 foo/2.0
Unique module name loaded
^^^^^^^^^^^^^^^^^^^^^^^^^
The configuration option :mconfig:`unique_name_loaded` is introduced to allow
only one module loaded per module name. It is similar to the *One name rule*
feature introduced by the `Lmod`_ project.
When enabled, :mconfig:`unique_name_loaded` produces a conflict definition
at the start of modulefile evaluation for each actual and alternative module
root name. For instance when loading a module named ``foo/sub/1.0`` with a
``qux/1.0`` alias, it produces a conflict against ``foo`` and ``qux``.
When loading a module that shares a name with an already loaded module, an
error is raised due to the conflict definition. This error aborts the module
load evaluation.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/bar/1.0
#%Module
:ps:`$` cat /path/to/modulefiles/bar/2.0
#%Module
:ps:`$` module config unique_name_loaded 1
:ps:`$` module load bar/1.0
:ps:`$` module load bar/2.0
Loading :sgrhi:`bar/2.0`
:sgrer:`ERROR`: Module cannot be loaded due to a conflict.
HINT: Might try "module unload bar" first.
:mconfig:`unique_name_loaded` is disabled by default. It can be changed with
module :subcmd:`config` sub-command or at installation time with
:instopt:`--enable-unique-name-loaded` configure script option.
Cache sourced files
^^^^^^^^^^^^^^^^^^^
You may have gathered common Tcl code files used by all your modulefiles in
Tcl files that are sourced with :manpage:`source(n)` Tcl command. When loading
multiple modulefiles at once, these sourced files may be read for every loaded
modules, which may induce some I/O load.
The configuration option :mconfig:`source_cache` is introduced to cache files
evaluated through ``source`` Tcl command in order to only read them once
during a :file:`modulecmd.tcl` execution. When this option is enabled, sourced
file read also benefits from optimized I/O calls of Modules Tcl extension
library.
In the following example, 20 modules are loaded, each of them sources the same
Tcl file:
.. parsed-literal::
:ps:`$` syscall_list=close,fcntl,ioctl,newfstatat,openat,read,readlink
:ps:`$` strace -f -e $syscall_list -c $MODULES_CMD bash load foo/20
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
31.48 0.000781 1 466 read
28.58 0.000709 5 131 16 openat
14.19 0.000352 2 142 3 newfstatat
9.71 0.000241 1 124 close
8.02 0.000199 0 212 211 readlink
4.55 0.000113 1 67 47 ioctl
3.47 0.000086 1 60 fcntl
------ ----------- ----------- --------- --------- ----------------
100.00 0.002481 2 1202 277 total
When sourced file is cached, it is only read once which saves a substantial
amount of I/O operations:
.. parsed-literal::
:ps:`$` module config source_cache 1
:ps:`$` strace -f -e $syscall_list -c $MODULES_CMD bash load foo/20
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
34.41 0.000523 4 112 16 openat
27.37 0.000416 0 428 read
11.84 0.000180 1 122 3 newfstatat
11.51 0.000175 1 105 close
7.11 0.000108 2 47 27 ioctl
5.99 0.000091 0 92 91 readlink
1.78 0.000027 0 40 fcntl
------ ----------- ----------- --------- --------- ----------------
100.00 0.001520 1 946 137 total
.. _Abort on error:
Abort on error
^^^^^^^^^^^^^^
When an error occurs during the evaluation of a modulefile, several module
sub-commands, like :subcmd:`load` or :subcmd:`unload`, continue their
processing. It means these sub-commands do not stop if they have multiple
modulefiles to evaluate. This is named the *continue on error* behavior.
The :mconfig:`abort_on_error` configuration option is introduced to abort, for
the sub-commands listed in its value, the evaluation of multiple modulefiles
if one fails to evaluate.
The *abort on error* behavior is applied by default on :command:`ml` command,
:subcmd:`reload` sub-command and the unload phase of :subcmd:`switch`
sub-command. This behavior may also be turned on for :subcmd:`load`,
:subcmd:`mod-to-sh`, :subcmd:`purge`, :subcmd:`switch`, :subcmd:`try-load` and
:subcmd:`unload` sub-commands. If a command is removed from
:mconfig:`abort_on_error`'s value, it applies the *continue on error*
behavior.
In the following example, *abort on error* behavior is applied to
:subcmd:`load` sub-command to stop evaluation instead of loading the remaining
modulefile in the sequence if first modulefile fails to evaluate.
.. parsed-literal::
:ps:`$` module load foo bar
Loading :sgrhi:`foo/1`
:sgrer:`ERROR`: Module evaluation aborted
:ps:`$` module list
Currently Loaded Modulefiles:
1) bar/1
:ps:`$` module purge
:ps:`$` module config abort_on_error +load
:ps:`$` module load foo bar
Loading :sgrhi:`foo/1`
:sgrer:`ERROR`: Module evaluation aborted
:ps:`$` module list
No Modulefiles Currently Loaded.
When enabled for :subcmd:`switch` sub-command, whole action aborts if
switched-on modulefile fails to load. By default, :subcmd:`switch` only aborts
if switched-off modulefile fails to unload.
.. parsed-literal::
:ps:`$` module load bar
:ps:`$` module switch bar foo
Loading :sgrhi:`foo/1`
:sgrer:`ERROR`: Module evaluation aborted
Switching from :sgrhi:`bar/1` to :sgrhi:`foo/1`
:sgrwa:`WARNING`: Load of switched-on foo/1 failed
:ps:`$` module list
No Modulefiles Currently Loaded.
:ps:`$` module load bar
:ps:`$` module config abort_on_error +switch
:ps:`$` module switch bar foo
Loading :sgrhi:`foo/1`
:sgrer:`ERROR`: Module evaluation aborted
Switching from :sgrhi:`bar/1` to :sgrhi:`foo/1`
:sgrwa:`WARNING`: Load of switched-on foo/1 failed
:ps:`$` module list
Currently Loaded Modulefiles:
1) bar/1
:mconfig:`abort_on_error` configure option has no impact on :mfcmd:`module`
commands defined in modulefiles. When :option:`--force` option is set,
sub-commands apply the *continue on error* behavior.
When :instopt:`--enable-new-features` installation option is set, the
*abort on error* behavior is also enabled on :subcmd:`load` and
:subcmd:`switch` sub-commands.
Improve error reporting
^^^^^^^^^^^^^^^^^^^^^^^
Module evaluation error reports have been tweaked to appear where these errors
occur rather reporting them on the message block of the main action. Such
change helps to better understand the module evaluation flow.
.. parsed-literal::
:ps:`$` module load baz
Loading :sgrhi:`baz/1`
:sgrin:`Loading requirement`: foo/1
:ps:`$` module switch foo bar
Unloading :sgrhi:`baz/1`
:sgrme:`Module ERROR`: invalid command name "bad_command"
while executing
"bad_command"
(file "/path/to/modulefiles/baz/1" line 4)
Please contact <root@localhost>
Unloading :sgrhi:`foo/1`
:sgrer:`ERROR`: Unload of dependent baz/1 failed
Switching from :sgrhi:`foo/1` to :sgrhi:`bar`
:sgrer:`ERROR`: Unload of switched-off foo/1 failed
:subcmd:`switch` sub-command specific error messages are not reported when
:mfcmd:`module switch<module>` command is run from a modulefile (like *unload
of switched-off module failed*, *load of switched-on module failed* messages
or *Switching* block message). On :subcmd:`switch` sub-command, load failure
of switched-on module is now reported as an error.
.. parsed-literal::
:ps:`$` module load foo
:ps:`$` module switch foo qux
Loading :sgrhi:`qux/1`
:sgrme:`Module ERROR`: invalid command name "bad_command"
while executing
"bad_command"
(file "/path/to/modulefiles/qux/1" line 2)
Please contact <root@localhost>
Switching from :sgrhi:`foo/1` to :sgrhi:`qux/1`
:sgrer:`ERROR`: Load of switched-on qux/1 failed
Conflict error messages now describe the loaded module name and version that
conflicts rather the generic conflict module specification.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/bar/1
#%Module
conflict foo
:ps:`$` module load foo
:ps:`$` module load bar
Loading :sgrhi:`bar/1`
:sgrer:`ERROR`: Module cannot be loaded due to a conflict.
HINT: Might try "module unload foo/1" first.
New options for source-sh modulefile command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Support for new *shell* mode named ``bash-eval`` is added to
:mfcmd:`source-sh` modulefile command. With this new mode, the generated
output of the bash shell script is evaluated to get the environment changes
instead of sourcing this script.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/foo-output.sh
#!/bin/bash
cat <<EOF
export FOO=value;
alias foo_alias='echo foo_alias;'
foo_function() {
echo foo_function;
}
EOF
:ps:`$` cat /path/to/modulefiles/foo/1
#%Module
set foo_script [file dirname $ModulesCurrentModulefile]/foo-output.sh
:sgrhi:`source-sh bash-eval` $foo_script
:ps:`$` module show foo/1
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1`:
:sgrcm:`set-alias` foo_alias {echo foo_alias;}
:sgrcm:`set-function` foo_function {
echo foo_function}
:sgrcm:`setenv` FOO value
-------------------------------------------------------------------
:ps:`$` module load foo/1
:ps:`$` foo_alias
foo_alias
``bash-eval`` *shell* support is also available on :subcmd:`sh-to-mod`
sub-command.
A new option is added to :mfcmd:`source-sh` modulefile command: ``--ignore``.
It filters shell elements changed by script, not to get these changes applied
when loading modulefile. This option accepts a list, separated by colon
character, of shell elements: ``envvar``, ``alias``, ``function``,
``complete`` or ``chdir``.
.. parsed-literal::
:ps:`$` module purge
:ps:`$` cat /path/to/modulefiles/foo/2
#%Module
set foo_script [file dirname $ModulesCurrentModulefile]/foo-output.sh
:sgrhi:`source-sh --ignore alias:function bash-eval` $foo_script
:ps:`$` module show foo/2
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/2`:
:sgrcm:`setenv` FOO value
-------------------------------------------------------------------
:ps:`$` module load foo/2
:ps:`$` foo_alias
bash: foo_alias: command not found
This ``--ignore`` option can be used with any *shell* supported by
:mfcmd:`source-sh`.
v5.3
----
This new version is backward-compatible with previous version 5 release. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`5.3 release notes<5.3 release notes>` for a complete
list of the changes between Modules v5.2 and v5.3.
Module cache
^^^^^^^^^^^^
A module cache file can be created under each modulepath directory with new
:subcmd:`cachebuild` sub-command. Cache file is named :file:`.modulecache` and
contains in one file all modulefiles and modulercs found in modulepath
directory.
When cache file is available, module search mechanism uses this file rather
walking through the content of modulepath directory. I/O operations are saved
this way which reduces search processing time.
When searching for available modules without cache, each file contained
in enabled modulepaths is opened to check if it is a modulefile or not. Such
checks lead to a large number of I/O operations on large module setup like in
the below example where a total of 1051 modulefiles are available:
.. parsed-literal::
:ps:`$` module -o "" avail -t | wc -l
1051
:ps:`$` syscall_list=access,close,getdents64,newfstatat,openat,read
:ps:`$` strace -f -e $syscall_list -c $MODULES_CMD bash avail
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
31.09 0.003776 2 1424 9 openat
28.56 0.003469 2 1649 3 newfstatat
14.08 0.001710 1 1421 close
11.85 0.001439 3 460 getdents64
10.88 0.001321 0 1505 read
3.54 0.000430 4 107 5 access
------ ----------- ----------- --------- --------- ----------------
100.00 0.012145 1 6566 17 total
After building cache file for every enabled modulepaths in this example setup,
a lot of I/O operations are saved when searching for available modules:
.. parsed-literal::
:ps:`$` module cachebuild
Creating :sgrhi:`/path/to/modulefiles/.modulecache`
Creating :sgrhi:`/path/to/modulefiles.2/.modulecache`
Creating :sgrhi:`/path/to/modulefiles.3/.modulecache`
:ps:`$` module config cache_buffer_bytes 1000000
:ps:`$` strace -f -e $syscall_list -c $MODULES_CMD bash avail
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
70.19 0.000544 2 255 read
13.16 0.000102 2 38 9 openat
8.90 0.000069 1 35 close
6.06 0.000047 1 31 2 newfstatat
1.68 0.000013 1 11 2 access
------ ----------- ----------- --------- --------- ----------------
100.00 0.000775 2 370 13 total
A significant execution time drop may be noticed, especially if modulepath
directories are stored on heavily loaded network filesystem.
To further optimize I/O operation count, the :mconfig:`cache_buffer_bytes`
configuration option can be set like in the above example to use fewer number
of ``read`` operation to load cache file content.
To build cache file, user should be granted write access on modulepath
directory. Modulefiles or directories that are not accessible for everyone are
not recorded in cache. An indication is saved instead to test these limited
access elements when cache is loaded to determine if they are available to
currently running user.
Cache file can be ignored with :option:`--ignore-cache` command line switch or
more permanently with :mconfig:`ignore_cache` configuration option.
Cache file is valid indefinitely by default but :mconfig:`cache_expiry_secs`
configuration option can be used to define the number of seconds a cache file
is considered valid after being generated. Expired cache file is ignored.
Cache file of enabled modulepaths can be deleted all at once with
:subcmd:`cacheclear` sub-command.
Querying available module variants
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A new mechanism named :ref:`Extra match search` is introduced to evaluate
modulefiles during a module search to find those matching an extra query on a
variant value, a dependency or an environment variable definition.
During this specific evaluation, modulefiles are interpreted in *scan* mode to
collect the different Tcl modulefile commands they use. Special care should be
given when writing modulefiles to ensure they cope with such evaluation mode.
:ref:`Extra match search` mechanism is available on :subcmd:`avail`,
:subcmd:`whatis` and :subcmd:`paths` sub-commands.
With this new mechanism, it is possible to list all available variant defined
in modulefiles with their associated values:
.. parsed-literal::
:ps:`$` module config avail_output modulepath:alias:dirwsym:sym:tag:key:variant
:ps:`$` module config variant_shortcut toolchain=%
:ps:`$` module avail
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1.0{:sgrva:`%a`,\ :sgrva:`b`} foo/1.0{:sgrvade:`%a`} qux/1.0{:sgrva:`%a`,\ :sgrva:`b`}
bar/2.0{:sgrvade:`%b`} foo/2.0{:sgrva:`%a`,\ :sgrva:`b`,\ :sgrva:`c`} qux/2.0{:sgrva:`%b`,\ :sgrva:`c`}
Key:
:sgrdi:`modulepath` {:sgrva:`%value`}={:sgrva:`toolchain=value`}
:sgrde:`default-version` {:sgrva:`variant=value`}
You can also search for modules defining a specific variant value:
.. parsed-literal::
:ps:`$` module avail %a
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1.0{:sgrvahi:`%a`,\ :sgrva:`b`} foo/1.0{:sgrvadehi:`%a`} foo/2.0{:sgrvahi:`%a`,\ :sgrva:`b`,\ :sgrva:`c`} qux/1.0{:sgrvahi:`%a`,\ :sgrva:`b`}
Key:
:sgrdi:`modulepath` {:sgrva:`%value`}={:sgrva:`toolchain=value`}
:sgrde:`default-version` {:sgrva:`variant=value`}
.. note:: As extra match search implies additional modulefile evaluations, it
is advised to build and use `Module cache`_ to improve search speed.
Two new elements, ``variant`` and ``variantifspec``, are added to the allowed
value list of :mconfig:`avail_output` and :mconfig:`avail_terse_output`
configuration options. The latter is set in the default value list of both
options. When ``variant`` is set, variants and their possible values are
reported along module they are associated to. When ``variantifspec`` is set,
available variants are reported only if a variant is specified in search
query.
.. parsed-literal::
:ps:`$` module config --reset avail_output
:ps:`$` module config avail_output
Modules Release 5.3.0 (2023-05-14)
- :sgrhi:`Config. name` ---------.- :sgrhi:`Value (set by if default overridden)` ---------------
avail_output modulepath:alias:dirwsym:sym:tag:variantifspec:key
:ps:`$` module avail foo
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
:sgrhi:`foo`/1.0 :sgrhi:`foo`/2.0
Key:
:sgrdi:`modulepath`
:ps:`$` module avail foo %a
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
:sgrhi:`foo`/1.0{:sgrvadehi:`%a`} :sgrhi:`foo`/2.0{:sgrvahi:`%a`,\ :sgrva:`b`,\ :sgrva:`c`}
Key:
:sgrdi:`modulepath` {:sgrva:`%value`}={:sgrva:`toolchain=value`}
:sgrde:`default-version` {:sgrva:`variant=value`}
Extra specifiers
^^^^^^^^^^^^^^^^
Extra specifiers are introduced to query content of modulefiles. They can be
specified with *element:name* syntax as part of module specification on module
search commands (:subcmd:`avail`, :subcmd:`paths` and and :subcmd:`whatis`).
Extra specifiers trigger :ref:`Extra match search` mechanism when found in
module specification. Available modulefiles are evaluated in *scan* mode to
collect the different Tcl modulefile commands they use.
.. parsed-literal::
:ps:`$` module avail variant:toolchain
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1.0 bar/2.0 foo/1.0 foo/2.0 qux/1.0 qux/2.0
In the above example, all modulefiles defining a ``toolchain`` variant are
returned.
Most Tcl modulefile commands can be queried with extra specifiers:
``variant``, ``setenv``, ``unsetenv``, ``append-path``, ``prepend-path``,
``remove-path``, ``pushenv``, ``complete``, ``uncomplete``, ``set-alias``,
``unset-alias``, ``set-function``, ``unset-function``, ``chdir``, ``family``,
``prereq``, ``prereq-any``, ``prereq-all``, ``depends-on``, ``always-load``,
``load``, ``load-any``, ``try-load``, ``switch``, ``switch-on``,
``switch-off``, ``conflict`` and ``unload``. Commands that handle environment
variables may be aliased ``envvar``. Commands that define a module requirement
may be aliased ``require`` and those that define a module incompatibility may
be aliased ``incompat``.
When several extra specifiers are set in query, modules returned are those
matching both conditions. In the following example, all modulefiles
interacting with :envvar:`PATH` environment variable and requiring ``foo``
module are returned.
.. parsed-literal::
:ps:`$` module avail envvar:PATH require:foo
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1.0 bar/2.0
Extra specifiers related to module requirement or incompatibility may leverage
the :ref:`Advanced module version specifiers` syntax. On following example,
modulefiles returned are those defining a requirement on ``foo`` module with
version higher or equal to ``1.2`` and variant ``toolchain=a`` selected.
.. parsed-literal::
:ps:`$` module avail "require:foo@1.2: toolchain=a"
--------------------- :sgrdi:`/path/to/modulefiles` ---------------------
bar/1.0
.. note:: Module aliases or symbolic versions used either in modulefile
definitions or as extra specifier values are not resolved.
Append or subtract elements to current option value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For command-line switches and configuration options whose value is a
colon-separated list, it is now possible to append or subtract elements to the
current value. With a ``+`` prefix elements are appended and with a ``-``
prefix elements are subtracted.
This new feature applies to :option:`--output`/:option:`-o` command-line
switches and :mconfig:`avail_output`, :mconfig:`avail_terse_output`,
:mconfig:`list_output`, :mconfig:`list_terse_output`, :mconfig:`colors`,
:mconfig:`protected_envvars`, :mconfig:`shells_with_ksh_fpath`,
:mconfig:`tag_abbrev`, :mconfig:`tag_color_name`, :mconfig:`variant_shortcut`
configuration options.
For instance, to output available *foo* modules without modulepath and tag
information:
.. parsed-literal::
:ps:`$` module -o -modulepath:tag avail foo
:sgrhi:`foo`/1.0 :sgrhi:`foo`/2.0
On following example, terse output mode of *list* sub-command is permanently
updated to report variant information:
.. parsed-literal::
:ps:`$` module config list_terse_output
Modules Release 5.3.0 (2023-05-14)
- :sgrhi:`Config. name` ---------.- :sgrhi:`Value (set by if default overridden)` ---------------
list_terse_output header
:ps:`$` module config list_terse_output +variant
:ps:`$` module config list_terse_output
Modules Release 5.3.0 (2023-05-14)
- :sgrhi:`Config. name` ---------.- :sgrhi:`Value (set by if default overridden)` ---------------
list_terse_output header:variant (env-var)
v5.2
----
This new version is backward-compatible with previous version 5 release. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`5.2 release notes<5.2 release notes>` for a complete
list of the changes between Modules v5.1 and v5.2.
Optional requirements
^^^^^^^^^^^^^^^^^^^^^
The ``--optional`` option has been added to the :mfcmd:`prereq`,
:mfcmd:`prereq-all`, :mfcmd:`depends-on` and :mfcmd:`always-load` modulefile
commands to indicate that specified requirement is optional. An automatic
load attempt is also performed for optional requirements. If requirement is
not found or cannot be loaded, the dependency is yet considered satisfied as
it is optional.
.. parsed-literal::
:ps:`$` module show foo
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo`:
:sgrcm:`prereq` --optional bar
-------------------------------------------------------------------
:ps:`$` module load foo
Loading :sgrhi:`foo`
:sgrin:`Loading requirement`: bar
If the optional requirement is unloaded or loaded afterward, the dependent
module is automatically reloaded thanks to the :mconfig:`auto_handling`
mechanism.
.. parsed-literal::
:ps:`$` module unload bar
Unloading :sgrhi:`bar`
:sgrin:`Unloading dependent`: foo
:sgrin:`Reloading dependent`: foo
:ps:`$` module list
Currently Loaded Modulefiles:
1) foo
:ps:`$` module load bar
Loading :sgrhi:`bar`
:sgrin:`Unloading dependent`: foo
:sgrin:`Reloading dependent`: foo
Modules loaded by other modules with the :mfcmd:`module try-load<module>`
command are now considered optional requirements. Dependent module can be
loaded without the *try-load* modules, but now it gets automatically reloaded
if *try-load* module is loaded afterward, to take it into account.
Linting modulefiles
^^^^^^^^^^^^^^^^^^^
Static analysis of modulefile, modulerc and global/user rc is now possible
with :subcmd:`lint` sub-command. It relies on an external program defined with
:mconfig:`tcl_linter` configuration option. Modules or files specified on the
command-line are resolved then passed to the Tcl linter program.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/1.0
#%Module
if {"str" eq} {
else {
}
:ps:`$` module lint foo/1.0
Linting :sgrhi:`/path/to/modulefiles/foo/1.0`
:sgrer:`ERROR line 2`: Could not complete statement.
One close brace would complete the first line
One close brace would complete at end of line 4.
One close brace would complete the script body at line 5.
Assuming completeness for further processing.
:sgrer:`ERROR line 2`: Bad expression: missing operand at _@_
in expression ""str" eq_@_"
:sgrwa:`WARNING line 3`: Unknown command "else"
:sgrin:`NOTICE line 4`: Close brace not aligned with line 3 (1 0)
`Nagelfar`_ is the Tcl linter recommended for Modules and set by default. This
default can be changed at installation time with :instopt:`--with-tcl-linter`
and :instopt:`--with-tcl-linter-opts` options. It can also be configured later
on through :mconfig:`tcl_linter` config option.
Specific syntax databases and plugins for `Nagelfar`_ are added by Modules to
precisely lint modulefile commands syntax in addition to regular Tcl syntax.
The installation of these specific files is controlled with
:instopt:`--enable-nagelfar-addons` option (enabled by default). Their
location is controlled by the :instopt:`--nagelfardatadir` option.
.. parsed-literal::
:ps:`$` module lint bar@:1 /path/to/modulefiles/.modulerc
Linting :sgrhi:`/path/to/modulefiles/.modulerc`
:sgrer:`ERROR line 35`: Wrong number of arguments (3) to "module-alias"
:sgrer:`ERROR line 41`: Wrong number of arguments (3) to "module-virtual"
Linting :sgrhi:`/path/to/modulefiles/bar/1.2`
:sgrwa:`WARNING line 19`: Unknown command "unk"
:ps:`$` module lint ~/.modulerc
Linting :sgrhi:`/home/user/.modulerc`
:sgrwa:`WARNING line 2`: Command "setenv" should not be be used in global rc file
:subcmd:`lint` sub-command outputs messages returned by the Tcl linter
program. Nagelfar produces NOTICE, WARNING and ERROR messages. If linter does
not report a thing, :subcmd:`lint` sub-command will be silent, unless if the
:option:`--verbose`/:option:`-v` is set.
.. parsed-literal::
:ps:`$` module lint /path/to/modulefiles/bar/.version bar/1.4
:ps:`$` module lint -v /path/to/modulefiles/bar/.version bar/1.4
Linting :sgrhi:`/path/to/modulefiles/bar/.version`
Linting :sgrhi:`/path/to/modulefiles/bar/1.4`
When no file is specified to :subcmd:`lint` sub-command, all the global/user
rc files and all the modulefiles and modulercs from enabled modulepaths are
analyzed. If the :option:`--all`/:option:`-a` option is set, all hidden
modulefiles are also linted.
.. parsed-literal::
:ps:`$` module lint
Linting :sgrhi:`/home/user/.modulerc`
:sgrwa:`WARNING line 2`: Command "setenv" should not be be used in global rc file
Linting :sgrhi:`/path/to/modulefiles/.modulerc`
:sgrer:`ERROR line 35`: Wrong number of arguments (3) to "module-alias"
:sgrer:`ERROR line 41`: Wrong number of arguments (3) to "module-virtual"
Linting :sgrhi:`/path/to/modulefiles/bar/1.2`
:sgrwa:`WARNING line 19`: Unknown command "unk"
...
To use `Nagelfar`_ as Tcl linter for Modules, this open source tool has to be
installed on your system. When installing from tarball distribution, make sure
:command:`nagelfar.tcl` command is found through a :envvar:`PATH` lookup or
that :mconfig:`tcl_linter` option is set to its full path location.
`Nagelfar`_ is also made available as a RPM package in `EPEL and Fedora
repositories`_.
.. _Nagelfar: http://nagelfar.sourceforge.net/
.. _EPEL and Fedora repositories: https://src.fedoraproject.org/rpms/nagelfar
mod-to-sh sub-command
^^^^^^^^^^^^^^^^^^^^^
New sub-command is added to translate modulefile into shell code:
:subcmd:`mod-to-sh`. It evaluates modulefiles passed as argument and produces
code for specified shell.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo
#%Module
setenv FOO value
set-function foo {echo foo}
:ps:`$` module mod-to-sh bash foo
FOO=value; export FOO;
foo () { echo foo; }; export -f foo;
Designated modulefiles are evaluated as if they were loading. But instead of
producing shell code that is evaluated in current shell session,
:command:`module` command outputs this shell code.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/bar
#%Module
setenv BAR othervalue
set-alias bar {echo bar}
:ps:`$` module mod-to-sh fish foo bar
set -xg FOO value;
set -xg BAR othervalue;
alias bar echo\ bar;
function foo; echo foo; end;
:ps:`$` module list
No Modulefiles Currently Loaded.
All shells supported by :file:`modulecmd.tcl` script are supported by
:subcmd:`mod-to-sh`.
.. parsed-literal::
:ps:`$` module mod-to-sh python foo bar
import os
os.environ['FOO'] = 'value'
os.environ['BAR'] = 'othervalue'
.. _Initial environment:
Initial environment
^^^^^^^^^^^^^^^^^^^
When Modules initializes, it evaluates the :file:`initrc` and
:file:`modulespath` configuration files to enable default modulepaths and load
default modules. Initial environment corresponds to the environment state
after this initialization.
Initial environment is now saved in an environment variable
(:envvar:`__MODULES_LMINIT`) in current shell session to remember what are the
initial modulepaths and initial modules with their tags and variants if any.
:subcmd:`reset` sub-command is introduced, in a similar fashion than on
`Lmod`_, to restore the initial environment. Here, :subcmd:`reset` relies on
the :ref:`collection<collections>` mechanism based and the content of
:envvar:`__MODULES_LMINIT`. Currently enabled modulepaths and loaded modules
are respectively unused and unloaded to use the modulepaths and load the
modules with tags and variants as described by initial environment.
.. parsed-literal::
:ps:`$` module list
Currently Loaded Modulefiles:
1) foo/1.0 2) bar/1.0
:ps:`$` module switch bar/1.0 qux/1.0
:ps:`$` module reset
Unloading :sgrhi:`qux/1.0`
Loading :sgrhi:`bar/1.0`
:subcmd:`restore` sub-command has been adapted to reinitialize the environment
to its initial state when no collection name is provided and no *default*
collection exists or if ``__init__`` virtual collection name is provided.
It is possible to view the content of the initial environment with
:subcmd:`saveshow` sub-command. It is displayed when no argument is provided
and no collection exists or if ``__init__`` name is provided.
.. parsed-literal::
:ps:`$` module saveshow __init__
-------------------------------------------------------------------
:sgrhi:`initial environment`:
:sgrcm:`module` use --append /path/to/modulefiles
:sgrcm:`module` load foo/1.0
:sgrcm:`module` load bar/1.0
-------------------------------------------------------------------
Users have the ability to define what is their initial environment state and
thus adapt the behavior of :subcmd:`reset` sub-command with
:mconfig:`reset_target_state` configuration option. Default value is
``__init__`` and it corresponds to the behavior described above. When set to
``__purge__``, a :subcmd:`purge` command is performed when resetting. Any
other value corresponds to the name of a collection to restore.
.. parsed-literal::
:ps:`$` module config reset_target_state __purge__
:ps:`$` module reset
Unloading bar/1.0
Unloading foo/1.0
.. _Stashing environment:
Stashing environment
^^^^^^^^^^^^^^^^^^^^
The ability to stash current environment is added with the introduction of the
:subcmd:`stash` sub-command. When called current environment is saved in a
*stash* collection then initial environment is restored.
.. parsed-literal::
:ps:`$` module list
Currently Loaded Modulefiles:
1) bar/2.0 2) foo/2.0
:ps:`$` module stash
Unloading :sgrhi:`foo/2.0`
Unloading :sgrhi:`bar/2.0`
:ps:`$` module list
No Modulefiles Currently Loaded.
Sub-commands are added to specifically handle stash collections. Their names
are prefixed with *stash*, like :subcmd:`stashlist` to list existing stash
collections or :subcmd:`stashshow` to display their content.
.. parsed-literal::
:ps:`$` module stashlist
Stash collection list:
0) stash-1665377597432 1) stash-1664946764252
:ps:`$` module stashshow
-------------------------------------------------------------------
:sgrhi:`/home/user/.module/stash-1665377597432:`
:sgrcm:`module` use --append /path/to/modulefiles
:sgrcm:`module` load bar
:sgrcm:`module` load foo
-------------------------------------------------------------------
Stash collections can be designated on sub-commands by their collection name
or stash index. Most recent stash collection has index ``0``, the one after is
designated with index ``1``, and so on. When no stash collection is specified,
most recent one is assumed.
.. parsed-literal::
:ps:`$` module stashshow 1
-------------------------------------------------------------------
:sgrhi:`/home/user/.module/stash-1664946764252:`
:sgrcm:`module` use --append /path/to/modulefiles
:sgrcm:`module` load foobar
-------------------------------------------------------------------
Stash collections are restored with the :subcmd:`stashpop` sub-command. It
changes the user environment to match the stash definition, then it deletes
the stash collection file.
.. parsed-literal::
:ps:`$` module stashpop
Loading :sgrhi:`bar/2.0`
Loading :sgrhi:`foo/2.0`
:ps:`$` module stashlist
Stash collection list:
0) stash-1664946764252
Stash collections can be deleted one by one with :subcmd:`stashrm` sub-command
or all together with :subcmd:`stashclear`.
.. parsed-literal::
:ps:`$` module stashrm
:ps:`$` module stashlist
No stash collection.
Siteconfig hook variables
^^^^^^^^^^^^^^^^^^^^^^^^^
Several Tcl variables are introduced for :ref:`Site-specific configuration`
script to define specific commands and variables in the evaluation context of
modulefiles and modulercs. These commands and variables setup in
:file:`siteconfig.tcl` can be used in modulefile or modulerc. Sites can easily
extend modulefile and modulerc syntax with specific elements.
:sitevar:`modulefile_extra_cmds` variable defines a list of commands to expose
in the modulefile evaluation context and the associated procedure to run when
this command is called. This variable has to be defined in
:file:`siteconfig.tcl` located for instance at |file etcdir_siteconfig|.
In the following example :sitevar:`modulefile_extra_cmds` is used to define
the ``sys`` command and bound it to the ``sys`` procedure that is also defined
in :file:`siteconfig.tcl`.
.. code-block:: tcl
proc sys {mode} {
switch -- $mode {
name { return myhost-$::tcl_platform(machine) }
default { error "Unknown mode '$mode'" }
}
}
set modulefile_extra_cmds {sys sys}
Once :file:`siteconfig.tcl` is setup, the ``sys`` command can be called by
modulefiles. In the following example it is used to determine the application
path.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/1.2
#%Module
append-path PATH /path/to/apps/foo-1.2/[sys name]/bin
:ps:`$` module show foo/1.2
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1.2`:
:sgrcm:`append-path` PATH /path/to/apps/foo-1.2/myhost-x86_64/bin
-------------------------------------------------------------------
:sitevar:`modulerc_extra_cmds` follows the same approach than
:sitevar:`modulefile_extra_cmds` and makes specific commands available during
modulerc evaluation.
:sitevar:`modulefile_extra_vars` variable defines a list of variables to
expose in the modulefile evaluation context and their associated value. This
variable has to be defined in :file:`siteconfig.tcl`.
In the following example :sitevar:`modulefile_extra_vars` is used to define
the ``APP_ROOT`` variable with ``/path/to/apps`` as value.
.. code-block:: tcl
set modulefile_extra_vars {APP_ROOT /path/to/apps}
Once :file:`siteconfig.tcl` is setup, the ``APP_ROOT`` variable can be used in
modulefiles.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/bar/2.1
#%Module
append-path PATH $APP_ROOT/bar-2.1/[sys name]/bin
:ps:`$` module show bar/2.1
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/bar/2.1`:
:sgrcm:`append-path` PATH /path/to/apps/bar-2.1/myhost-x86_64/bin
-------------------------------------------------------------------
:sitevar:`modulerc_extra_vars` follows the same approach than
:sitevar:`modulefile_extra_vars` and makes specific variables available during
modulerc evaluation.
v5.1
----
This new version is backward-compatible with previous version 5 release. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`5.1 release notes<5.1 release notes>` for a complete
list of the changes between Modules v5.0 and v5.1.
Control output redirection
^^^^^^^^^^^^^^^^^^^^^^^^^^
Since version 4.0, the :command:`module` function is initialized differently
on *sh*, *bash*, *ksh*, *zsh* and *fish* shells when their session is found
interactive. In such situation :command:`module` redirects its output from
*stderr* to *stdout*. Once initialized the redirection behavior is inherited
in sub-sessions.
The :mconfig:`redirect_output` configuration option is introduced in version
5.1, to supersede the default behavior set at initialization time.
.. parsed-literal::
:ps:`$` module load unknown >/dev/null
:ps:`$` module config redirect_output 0
:ps:`$` module load unknown >/dev/null
:sgrer:`ERROR`: Unable to locate a modulefile for 'unknown'
The :option:`--redirect` and :option:`--no-redirect` command-line switches are
also added to change the output redirection behavior for a single command:
.. parsed-literal::
:ps:`$` module load unknown --redirect >/dev/null
:ps:`$` module load unknown --no-redirect >/dev/null
:sgrer:`ERROR`: Unable to locate a modulefile for 'unknown'
.. _Change modulefile command behavior:
Change modulefile command behavior
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Depending on the evaluation mode of the modulefile (e.g. *load*, *unload*,
*display*, etc) commands have different behavior. Most common example is the
:mfcmd:`setenv` command that sets an environment variable when modulefile is
loaded and unsets it when it is unloaded. A different behavior may be wished
sometimes for commands. This is why options are introduced for some modulefile
commands to control what happens on particular evaluation mode.
The ``--return-value`` option is added to the :mfcmd:`getenv` and
:mfcmd:`getvariant` modulefile commands to ensure that the value of the
designated environment variable or variant is returned even if modulefile is
evaluated in *display* mode:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/1.0
#%Module5.1
if {[getenv --return-value VAR] eq {}} {
setenv VAR value
}
:ps:`$` module display foo/1.0
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1.0`:
:sgrcm:`setenv` VAR value
-------------------------------------------------------------------
``--remove-on-unload``, ``--append-on-unload``, ``--prepend-on-unload`` and
``--noop-on-unload`` options are added to the :mfcmd:`remove-path` and
:mfcmd:`module unuse<module>` modulefile commands to control the behavior
applied when modulefile is unloaded. With these options it is possible for
instance to restore the paths unset at load time or to set other paths:
.. parsed-literal::
:ps:`$` module display bar/1.0
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/bar/1.0`:
:sgrcm:`module` unuse --prepend-on-unload /path/to/dir1
:sgrcm:`module` use /path/to/dir2
-------------------------------------------------------------------
:ps:`$` module use
Search path for module files (in search order):
:sgrmp:`/path/to/dir1`
:sgrmp:`/path/to/modulefiles`
:ps:`$` module bar/1.0
:ps:`$` module use
Search path for module files (in search order):
:sgrmp:`/path/to/dir2`
:sgrmp:`/path/to/modulefiles`
:ps:`$` module unload bar/1.0
:ps:`$` module use
Search path for module files (in search order):
:sgrmp:`/path/to/dir1`
:sgrmp:`/path/to/modulefiles`
Following the same trend, the ``--unset-on-unload`` and ``--noop-on-unload``
options are added to the :mfcmd:`unsetenv` modulefile command to be able to
choose between unsetting variable, setting a value or performing no operation
when modulefile is unloaded.
Reducing number of I/O operations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A new configuration option named :mconfig:`mcookie_check` is introduced to
control the verification made to files to determine if they are modulefiles.
By default this configuration option is set to ``always`` and when searching
for modulefiles within enabled modulepaths each file below these directories
is opened to check if it starts with the Modules magic cookie (i.e.,
``#%Module`` file signature).
These historical checks lead to a large number of I/O operations on large
module setup like in the below example where a total of 1098 modulefiles are
available:
.. parsed-literal::
:ps:`$` module -o "" avail -t | wc -l
1098
:ps:`$` module config mcookie_check always
:ps:`$` strace -f -e open,openat,read,close -c $MODULES_CMD bash avail
...
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
44.29 0.044603 25 1734 166 open
34.15 0.034389 16 2056 close
11.87 0.011949 24 483 5 openat
9.69 0.009761 4 2146 read
------ ----------- ----------- --------- --------- ----------------
100.00 0.100702 6419 171 total
For each file, 3 I/O operations (``open``, ``read`` and ``close``) are
achieved to determine if it is a modulefile and include it in search results.
When modulefiles are located in a shared filesystem concurrently accessed by
hundreds of users, a ``module avail`` command may take some time to finish.
When setting the :mconfig:`mcookie_check` configuration option to the ``eval``
value, files are not checked anymore when searching for modulefiles, only when
evaluating them. All files under modulepaths are considered modulefiles, so
the content of these directories must be carefully checked to use this
:mconfig:`mcookie_check` mode which lead to a significant reduction of I/O
operations:
.. parsed-literal::
:ps:`$` module config mcookie_check eval
:ps:`$` strace -f -e open,openat,read,close -c $MODULES_CMD bash avail
...
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
30.56 0.013717 14 944 close
28.76 0.012911 21 612 156 open
26.41 0.011857 24 483 5 openat
14.26 0.006403 6 1034 read
------ ----------- ----------- --------- --------- ----------------
100.00 0.044888 3073 161 total
A substantial reduction of execution time may be noticed depending on the
storage setup used to host the modulepath directories. A special care should
be given to the content of these directories to ensure they only contain
modulefiles (see :envvar:`MODULES_MCOOKIE_CHECK`).
See the :ref:`reduce-io-load` cookbook recipe to learn additional features of
Modules that could be leveraged to lower the number of I/O operations.
Shell command completion
^^^^^^^^^^^^^^^^^^^^^^^^
New modulefile commands :mfcmd:`complete` and :mfcmd:`uncomplete` are added to
get the ability to respectively define and unset command completion. *bash*,
*tcsh* and *fish* shells are supported.
.. parsed-literal::
:ps:`>` module display foo
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1.0`:
:sgrcm:`append-path` PATH /path/to/foo-1.0/bin
:sgrcm:`complete` fish foo {-s V -l version --description 'Command version'}
:sgrcm:`complete` fish foo {-s h -l help --description 'Command help'}
-------------------------------------------------------------------
:ps:`>` module load foo
:ps:`>` foo -<TAB>
-h --help (Command help) -V --version (Command version)
:subcmd:`sh-to-mod` sub-command and :mfcmd:`source-sh` modulefile command have
also been updated to track shell completion changes.
.. parsed-literal::
:ps:`$` module sh-to-mod bash /path/to/foo-1.0/share/setup-env.sh
#%Module
:sgrcm:`complete` bash foo {-o default -F _foo}
:sgrcm:`append-path` PATH /path/to/foo-1.0/bin
:sgrcm:`set-function` _foo {
...bash completion code...}
Lmod Tcl modulefile support
^^^^^^^^^^^^^^^^^^^^^^^^^^^
With this new version, Modules now supports Tcl modulefiles written for
`Lmod`_, the alternative :command:`module` implementation developed in Lua.
Such modulefiles can be safely evaluated by Modules without raising error.
Support has been added for the following modulefile commands introduced by
Lmod: :mfcmd:`depends-on`, :mfcmd:`prereq-any`, :mfcmd:`always-load`,
:mfcmd:`module load-any<module>`, :mfcmd:`pushenv`, :mfcmd:`require-fullname`
and :mfcmd:`family`.
The :ref:`Compatibility with Lmod Tcl modulefile` section in the
:ref:`modulefile(5)` man page describes the differences existing between the
two implementations.
Note that when processing a :mfcmd:`family` command, the
:envvar:`LMOD_FAMILY_\<NAME\>` environment variable is defined by Modules to
be compatible with existing modulefiles or scripts relying on such variable.
.. _More tagging capabilities:
More tagging capabilities
^^^^^^^^^^^^^^^^^^^^^^^^^
The new :option:`--tag` option helps to define extra tags onto a loading
module. These tags comes in addition to those inherited from the module state
or those associated with the :mfcmd:`module-tag` modulefile command.
The :option:`--tag` option is available on :subcmd:`load`, :subcmd:`load-any`,
:subcmd:`switch` and :subcmd:`try-load` sub-commands and on
:mfcmd:`always-load`, :mfcmd:`depends-on`, :mfcmd:`module`, :mfcmd:`prereq`,
:mfcmd:`prereq-all` and :mfcmd:`prereq-any` modulefile commands.
Informational messages of module evaluation have been updated to mention in
module denomination the tags applying to it, as it is done in :subcmd:`list`
sub-command output:
.. parsed-literal::
:ps:`$` module load -v --tag=sticky:bar foo/1.0
Loading :sgrshi:`foo/1.0` <bar>
In case the designated module is already loaded, the additional tags are added
to the list of tags already applied to this module.
.. parsed-literal::
:ps:`$` module list
Currently Loaded Modulefiles:
1) foo/1.0
:ps:`$` module load -v --tag=sticky:bar foo/1.0
Tagging :sgrshi:`foo/1.0` <bar>
The ``keep-loaded`` tag is introduced in this version. It avoids an
auto-loaded module to get automatically unloaded when its dependent modules
are unloaded. This new tag can be set with the :mfcmd:`module-tag` modulefile
command or when module is loaded with the :mfcmd:`always-load` modulefile
command. Default :mconfig:`tag_abbrev` configuration option has been updated
to add the ``kL`` abbreviation for ``keep-loaded`` tag. Default dark and light
color palettes have been updated too.
.. parsed-literal::
:ps:`$` module show bar/1.0
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/bar/1.0`:
:sgrcm:`always-load` foo/1.0
-------------------------------------------------------------------
:ps:`$` module load bar/1.0
Loading :sgrhi:`bar/1.0`
:sgrin:`Loading requirement`: foo/1.0
:ps:`$` module unload bar/1.0
:ps:`$` module list
Currently Loaded Modulefiles:
1) :sgral:`foo`:sgrkl:`/1.0`
Key:
:sgral:`auto-loaded` :sgrkl:`keep-loaded`
When saving a collection, the tags defined with :option:`--tag` option are
recorded to set them again when collection is restored. Tags resulting from
module load state, like ``auto-loaded`` and ``keep-loaded``, are also
recorded.
.. parsed-literal::
:ps:`$` module load --tag=sticky bar/1.0
Loading :sgrshi:`bar/1.0`
:sgrin:`Loading requirement`: foo/1.0
:ps:`$` module save
:ps:`$` module saveshow
-------------------------------------------------------------------
:sgrhi:`/home/user/.module/default`:
:sgrcm:`module` use --append /path/to/modulefiles
:sgrcm:`module` load --tag=auto-loaded:keep-loaded foo
:sgrcm:`module` load --tag=sticky bar
-------------------------------------------------------------------
The :mconfig:`collection_pin_tag` configuration option is added to record in
collection all tags set on loaded modules. This configuration option is
disabled by default.
.. note:: Collection saved now starts with a ``#%Module5.1`` file signature if
:option:`--tag` option is recorded in it. Such collection could only be
handled by Modules version 5.1 and above.
v5.0
----
With this new major version the :command:`module` experience has been updated
to benefit by default from all the advanced behaviors and features developed
over the Modules 4 versions. Modules 5.0 also introduces some breaking
changes to improve the consistency of the whole solution. See the :ref:`5.0
release notes<5.0 release notes>` for a complete list of the changes between
Modules v4.8 and v5.0. The :ref:`changes<Modules 5 changes>` document gives an
in-depth view of the modified behaviors.
Upgraded default configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Release after release, new advanced features were added on Modules 4. They
were set off by default to avoid breaking change during the version 4 cycle.
With the move to a new major release, these features are set on to improve by
default usages for everybody. These features enabled by default are:
* :ref:`v42-automated-module-handling-mode` which provides the automatic
dependency resolution when loading and unloading modules
.. parsed-literal::
:ps:`$` module load foo/1.0
Loading :sgrhi:`foo/1.0`
:sgrin:`Loading requirement`: bar/1.0
* `Extended default`_ that enables to select a module when the first number
in its version is specified
.. parsed-literal::
:ps:`$` module load -v foo/1
Loading :sgrhi:`foo/1.2.3`
* :ref:`Advanced module version specifiers`, an improved syntax to designate
module version in range or list and module variant
.. parsed-literal::
:ps:`$` module load foo@:2.2 %gcc11
Loading :sgrhi:`foo/2.1`:sgrse:`{`:sgrva:`%gcc11`:sgrse:`}`
:sgrin:`Loading requirement`: bar/1.2\ :sgrse:`{`:sgrva:`-debug`:sgrse:`:`:sgrva:`%gcc11`:sgrse:`}`
* `Colored output`_ to graphically enhance parts of the produced output to
improve readability
.. parsed-literal::
:ps:`$` ml av
------------------ :sgrdi:`/path/to/modulefiles` ------------------
:sgrde:`bar/1.0` bar/2.0 :sgrf:`foo/1.0` :sgrs:`foo/2.0` :sgrali:`foo/2.2`
Key:
:sgrdi:`modulepath` :sgrali:`module-alias` :sgrs:`sticky`
:sgrde:`default-version` :sgrf:`forbidden`
* :ref:`Insensitive case` search that matches modules using a different
character case than the one expressed in search query
.. parsed-literal::
:ps:`$` ml av liba
------------------ :sgrdi:`/path/to/modulefiles` ------------------
LibA/1.0 LibA/2.0
Some other features that were enabled by default during the Modules 4 cycle
have been turned off as they may not be useful for basic usages. Among other
things setting off the following features makes the definition of the
:command:`module` function simpler. Even if off by default, these features
can now be enabled once Modules is installed through the :file:`initrc`
configuration file.
* *Set shell startup* files to ensure the :command:`module` command is defined
once shell has been initialized. See the :mconfig:`set_shell_startup`
configuration option to activate.
* *Quarantine mechanism* that protects the :command:`module` command
run-time environment from side effect coming from the current environment
definition. See the :mconfig:`quarantine_support` configuration option to
activate.
* *Silent shell debug* which disables the debugging property set on current
shell session for the duration of the :command:`module` command. See the
:mconfig:`silent_shell_debug` configuration option to activate.
Removing compatibility version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ability to co-install version 3.2 of Modules along newer version is
discontinued. The installation option ``--enable-compat-version``,
:command:`switchml` shell function and :envvar:`MODULES_USE_COMPAT_VERSION`
environment variables are thus removed.
The interesting features of Modules 3.2 that were missing in the
initial Modules 4 release in 2017 have been reintroduced progressively (like
:subcmd:`clear` sub-command or :option:`--icase` search). With Modules 5.0,
the :subcmd:`refresh` sub-command is even changed to the behavior it had on
Modules 3.2. So it is a good time for the big jump.
If you are still using Modules 3.2, please refer to the :ref:`changes`
document that describes the differences of this version compared to the newer
releases.
Improving Modules initialization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Modules initialization files are now installed by default in the *etc*
directory designated by the :instopt:`--etcdir` installation option. The
initialization configuration file is named :file:`initrc` in this directory,
and the modulepath-specific configuration file is named :file:`modulespath`.
When both files exist, now they are both evaluated instead of just the
:file:`modulespath` file.
Modules magic cookie (i.e., ``#%Module`` file signature) is now required at
the start of :file:`initrc`. An error is produced if the magic cookie is
missing or if the optional version number placed after the cookie string is
higher than the version of the :file:`modulecmd.tcl` script in use.
Note that :file:`initrc` configuration file can host more than
:subcmd:`module use<use>` and :subcmd:`module load<load>` commands.
:command:`module` configuration can also be achieved with this file through
the use of :subcmd:`module config<config>` commands.
Modules initialization has been enhanced for situations where a module
environment is found already defined. In this case the loaded modules are
automatically refreshed which is useful to re-apply the non-persistent
environment configuration (i.e., shell alias and function that are not
exported to the sub-shell). For instance when starting a sub-shell session it
ensures that the loaded environment is fully inherited from parent shell:
.. parsed-literal::
:ps:`$` ml show foo/1.0
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1.0`:
:sgrcm:`set-alias` foo {echo foo}
-------------------------------------------------------------------
:ps:`$` ml foo/1.0
:ps:`$` alias foo
alias foo='echo foo'
:ps:`$` bash
:ps:`$` ml
Currently Loaded Modulefiles:
1) foo/1.0
:ps:`$` alias foo
alias foo='echo foo'
Simplifying path-like variable reference counting
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The reference counting mechanism used for path-like environment variable
enables to determine if a path entry has been added several times (by several
loaded modules for instance) to know whether or not this path entry should be
unset when unloading a module. Entry is not removed if multiple loaded modules
rely on it.
The mechanism is not applied anymore to the Modules-specific path variables
(like :envvar:`LOADEDMODULES`) as an element entry in these variables cannot
be added multiple times without duplication. For instance, a given module name
and version cannot be added twice in :envvar:`LOADEDMODULES` as this module is
only loaded once. With this change a thinner environment is produced by
:command:`module`. An exception is made for :envvar:`MODULEPATH` environment
variable where the mechanism still applies.
.. parsed-literal::
:ps:`$` $MODULES_CMD bash load foo/2.0
_LMFILES_=/path/to/modulefiles/foo/2.0; export _LMFILES_;
LOADEDMODULES=foo/2.0; export LOADEDMODULES;
__MODULES_LMTAG=foo/2.0\&mytag; export __MODULES_LMTAG;
test 0;
Reference counting mechanism has also been simplified for entries in path-like
variable that are only referred once. For such entries no entry is set in the
reference counting variable (which are now called
:envvar:`__MODULES_SHARE_\<VAR\>`). A reference count entry is set only if the
entry in the path-like variable is referred more than one time.
.. parsed-literal::
:ps:`$` ml foo/3.0
:ps:`$` echo $PATHVAR
/path/to/dir1
:ps:`$` echo $__MODULES_SHARE_PATHVAR
:ps:`$` ml bar/1.0
:ps:`$` echo $PATHVAR
/path/to/dir1
:ps:`$` echo $__MODULES_SHARE_PATHVAR
/path/to/dir1:2
:ps:`$` ml -foo/3.0
:ps:`$` echo $PATHVAR
/path/to/dir1
:ps:`$` echo $__MODULES_SHARE_PATHVAR
:ps:`$`
When the :subcmd:`use` and :subcmd:`unuse` module sub-commands are not called
during a modulefile evaluation, the reference counter associated with each
entry in :envvar:`MODULEPATH` environment variable is ignored. In such
context, a :subcmd:`module use<use>` will not increase the reference counter
of a path entry already defined and a :subcmd:`module unuse<unuse>` will
remove specified path whatever its reference counter value. Same change applies
for :subcmd:`append-path`, :subcmd:`prepend-path` and :subcmd:`remove-path`
module sub-commands when called from the command-line.
.. parsed-literal::
:ps:`$` echo $MODULEPATH
/path/to/modulefiles
:ps:`$` echo $__MODULES_SHARE_MODULEPATH
/path/to/modulefiles:2
:ps:`$` ml use /path/to/modulefiles
:ps:`$` echo $__MODULES_SHARE_MODULEPATH
/path/to/modulefiles:2
:ps:`$` ml unuse /path/to/modulefiles
:ps:`$` echo $MODULEPATH
:ps:`$` echo $__MODULES_SHARE_MODULEPATH
:ps:`$`
v4.8
----
This new version is backward-compatible with previous version 4 releases. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`4.8 release notes<4.8 release notes>` for a complete
list of the changes between Modules v4.7 and v4.8.
.. _Editing modulefiles:
Editing modulefiles
^^^^^^^^^^^^^^^^^^^
:subcmd:`edit` sub-command is introduced to give the ability to open
modulefiles in a text editor. Modulefiles can be specified like with any other
sub-command: using regular, symbolic or aliased names or using advanced
version specifiers.
.. parsed-literal::
:ps:`$` ml edit foo
:subcmd:`edit` sub-command resolves the path toward the designated modulefile
then call configured text editor to open this modulefile with it. Below, the
modulefile is opened with the ``vi`` command:
.. parsed-literal::
#%Module
module-whatis [module-info name]
setenv PATH /path/to/foo-1.0/bin
~
~
~
"/path/to/modulefiles/foo/1.0" 3L, 42B 1,1 All
The :mconfig:`editor` configuration option controls the editor command to use.
This option can be configured at installation time with the
:instopt:`--with-editor` installation option. If not set, :mconfig:`editor`
configuration option is set by default to ``vi``.
:mconfig:`editor` configuration option can be changed with the
:subcmd:`config` sub-command. Which sets the :envvar:`MODULES_EDITOR`
environment variable.
The :envvar:`VISUAL` or the :envvar:`EDITOR` environment variables override
the default value of :mconfig:`editor` configuration option but are overridden
by the :envvar:`MODULES_EDITOR` environment variable.
Using version range in version list
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The :ref:`Advanced module version specifiers` mechanism has been improved to
allow the use of version range (*@:version*, *@vers1:vers2* or *@version:*)
within version list (*@version1,version2,...*).
It is now possible to write for instance ``mod@:1.2,1.4:1.6,1.8:`` to
designate all versions of module *mod*, except versions *1.3* and *1.7*.
This improvement is available where the advanced version specifier syntax is
supported. Thus it can be either used from the command-line or when writing
modulefiles, for instance to hide or tag modules or to declare requirements.
Try module load with no complain if not found
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Add the :subcmd:`try-load` sub-command that tries to load the modulefile
passed as argument, like the :subcmd:`load` sub-command, but does not raise an
error if this modulefile cannot be found.
.. parsed-literal::
:ps:`$` module load unknown
:sgrer:`ERROR`: Unable to locate a modulefile for 'unknown'
:ps:`$` echo $?
1
:ps:`$` module try-load unknown
:ps:`$` echo $?
0
:ps:`$` module list
No Modulefiles Currently Loaded.
This sub-command first introduced by the `Lmod`_ project is added to Modules
to improve the compatibility between the two ``module`` implementations.
:subcmd:`try-load` is also available within modulefile context to continue the
evaluation of a modulefile in case no module is found in its attempt to load
another modulefile
.. parsed-literal::
:ps:`$` module display foo/1.0
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1.0`:
:sgrcm:`module` try-load unknown/1.0
-------------------------------------------------------------------
:ps:`$` module load foo/1.0
:ps:`$` module list
Currently Loaded Modulefiles:
1) foo/1.0
Module variants
^^^^^^^^^^^^^^^
:ref:`Module variants` is a new mechanism that allows to pass arguments to
evaluated modulefiles in order to achieve different environment variable or
module requirement setup with a single modulefile.
Variant specification relies on the :ref:`Advanced module version specifiers`
mechanism, which leverages the `variant syntax`_ of the `Spack`_ package
manager:
.. _variant syntax: https://spack.readthedocs.io/en/latest/basic_usage.html#variants
.. parsed-literal::
:ps:`$` module config advanced_version_spec 1
:ps:`$` module load -v bar/1.2 toolchain=a -debug
Loading :sgrhi:`bar/1.2`:sgrse:`{`:sgrva:`-debug`:sgrse:`:`:sgrva:`toolchain=a`:sgrse:`}`
Variants are defined in modulefile with the :mfcmd:`variant` command, which
defines the variant type and its accepted values:
.. code-block:: tcl
#%Module4.8
variant toolchain a b c
variant --boolean --default off debug
# select software build depending on variant values
set suffix -[getvariant toolchain]
if {$ModuleVariant(debug)} {
append suffix -dbg
}
prepend-path PATH /path/to/bar-1.2$suffix/bin
prepend-path LD_LIBRARY_PATH /path/to/bar-1.2$suffix/lib
The *bar/1.2* modulefile defines a ``toolchain`` variant, which accepts the
``a``, ``b`` and ``c`` values, and a ``debug`` Boolean variant, which is set
``off`` by default. Once these two variants are declared, their value
specified on module designation are instantiated in the :mfvar:`ModuleVariant`
array variable which could also be queried with the :mfcmd:`getvariant`
modulefile command. Selected variant values enable to define a specific
installation build path for the *bar/1.2* software.
If a variant is not specified when designating module and if this variant is
not declared with a default value, an error is obtained:
.. parsed-literal::
:ps:`$` module purge
:ps:`$` module load :noparse:`bar@1.2`
Loading :sgrhi:`bar/1.2`
:sgrer:`ERROR`: No value specified for variant 'toolchain'
Allowed values are: a b c
Once module is loaded, selected variants are reported on the :subcmd:`list`
sub-command output:
.. parsed-literal::
:ps:`$` module load :noparse:`bar@1.2` toolchain=b
:ps:`$` module list
Currently Loaded Modulefiles:
1) bar/1.2\ :sgrse:`{`:sgrva:`-debug`:sgrse:`:`:sgrva:`toolchain=b`:sgrse:`}`
Key:
:sgrse:`{`:sgrva:`-variant`:sgrse:`}`\=\ :sgrse:`{`:sgrva:`variant=off`:sgrse:`}` :sgrse:`{`:sgrva:`variant=value`:sgrse:`}`
.. note:: The default value of the :instopt:`--with-list-output` installation
option has been updated to include variant information.
Variant specification could be used where the :ref:`Advanced module version
specifiers` is supported. For instance a module may express a dependency over
a specific module variant:
.. parsed-literal::
:ps:`$` module show foo/2.1 toolchain=c
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/2.1`:
:sgrcm:`variant` toolchain a b c
:sgrcm:`prereq` :noparse:`bar@1.2 toolchain=`:sgrva:`{toolchain}`
:sgrcm:`prepend-path` PATH /path/to/foo-2.1-:sgrva:`{toolchain}`/bin
:sgrcm:`prepend-path` LD_LIBRARY_PATH /path/to/foo-2.1-:sgrva:`{toolchain}`/lib
-------------------------------------------------------------------
In this example, *foo/2.1* module depends on *bar/1.2* and the same toolchain
variant should be selected for both modules in order to load two software
builds that are compatible between each other.
.. parsed-literal::
:ps:`$` module purge
:ps:`$` module config auto_handling 1
:ps:`$` module load foo/2.1 toolchain=a
Loading :sgrhi:`foo/2.1`:sgrse:`{`:sgrva:`toolchain=a`:sgrse:`}`
:sgrin:`Loading requirement`: bar/1.2\ :sgrse:`{`:sgrva:`-debug`:sgrse:`:`:sgrva:`toolchain=a`:sgrse:`}`
Variant shortcuts
^^^^^^^^^^^^^^^^^
The :mconfig:`variant_shortcut` configuration option is added to define
shortcut characters for easily specifying variants. Instead of writing the
variant name to specify it in module designation (e.g., *name=value*), the
shortcut associated to this variant could be used (i.e., *<shortcut>value*):
.. parsed-literal::
:ps:`$` module purge
:ps:`$` module config variant_shortcut toolchain=%
:ps:`$` module load foo/2.1 %a
Loading :sgrhi:`foo/2.1`:sgrse:`{`:sgrva:`%a`:sgrse:`}`
:sgrin:`Loading requirement`: bar/1.2\ :sgrse:`{`:sgrva:`-debug`:sgrse:`:`:sgrva:`%a`:sgrse:`}`
Configured shortcuts are also used to report the loaded variant on
:subcmd:`list` sub-command output (shortcuts are explained in key section):
.. parsed-literal::
:ps:`$` module list
Currently Loaded Modulefiles:
1) :sgral:`bar/1.2`\ :sgrse:`{`:sgrva:`-debug`:sgrse:`:`:sgrva:`%a`:sgrse:`}` 2) foo/2.1\ :sgrse:`{`:sgrva:`%a`:sgrse:`}`
Key:
:sgral:`auto-loaded` :sgrse:`{`:sgrva:`-variant`:sgrse:`}`\=\ :sgrse:`{`:sgrva:`variant=off`:sgrse:`}` :sgrse:`{`:sgrva:`%value`:sgrse:`}`\=\ :sgrse:`{`:sgrva:`toolchain=value`:sgrse:`}` :sgrse:`{`:sgrva:`variant=value`:sgrse:`}`
v4.7
----
This new version is backward-compatible with previous version 4 releases. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`4.7 release notes<4.7 release notes>` for a complete
list of the changes between Modules v4.6 and v4.7.
Determining module implementation and version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
New Modules variables are introduced to determine during the evaluation of a
modulefile or a modulerc what *module* implementation is currently in use. The
:mfvar:`ModuleTool` variable corresponds to the name of the *module*
implementation and is set to ``Modules`` for this project. The
:mfvar:`ModuleToolVersion` variable corresponds to the version number of the
implementation (e.g. ``4.7.0``).
With these new variables it is possible to precisely know what *module*
command is in use then adapt modulefile code to handle a specific behavior or
leverage a new feature.
The modulefile command :mfcmd:`versioncmp` is also introduced to provide a
simple way to compare two version strings and return if first version string
is less than, equal to or greater than second one.
.. code-block:: tcl
if {[info exists ModuleTool] && $ModuleTool eq {Modules}
&& [versioncmp $ModuleToolVersion 4.7] >= 0} {
# here some code specific for Modules 4.7 and later versions
}
The :mfvar:`ModuleTool` and :mfvar:`ModuleToolVersion` variables and the
:mfcmd:`versioncmp` modulefile command are supported by the `Lmod`_ project
starting version ``8.4.8``.
Symbolic version to designate module loaded version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When the `Advanced module version specifiers`_ is enabled, the ``loaded``
symbolic version may be used to designate the currently loaded version of
specified module.
.. parsed-literal::
:ps:`$` ml display :noparse:`foo@loaded`
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1.0`:
:sgrcm:`module-whatis` foo/1.0
-------------------------------------------------------------------
If no version of specified module can be found loaded, an error is returned.
.. parsed-literal::
:ps:`$` ml display :noparse:`foo@loaded`
:sgrer:`ERROR`: No loaded version found for 'foo' module
Module tags
^^^^^^^^^^^
Module tags are piece of information that can be associated to individual
modulefiles. Tags could be purely informational or may lead to specific
behaviors.
Module tags may be inherited from the module state set by a modulefile command
or consequence of a module action. Tags may also be associated to modules by
using the new :mfcmd:`module-tag` modulefile command.
Module tags are reported along the module they are associated to on
:subcmd:`avail` and :subcmd:`list` sub-command results. Tags could be reported
either:
* along the module name, all tags set within angle brackets, each tag
separated from the others with a colon character (e.g.,
``foo/1.2 <tag1:tag2>``).
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/.modulerc
#%Module
module-tag mytag foo
module-tag othertag foo/1.0
:ps:`$` ml av
--------------- :sgrdi:`/path/to/modulefiles` ---------------
foo/1.0 <mytag:othertag> foo/2.0 <mytag>
:ps:`$` ml foo/1.0
:ps:`$` ml
Currently Loaded Modulefiles:
1) foo/1.0 <mytag:othertag>
* graphically rendered over the module name for each tag associated to a
Select Graphic Rendition (SGR) code in the color palette (see
:envvar:`MODULES_COLORS`)
.. parsed-literal::
:ps:`$` # set SGR code to report 'mytag' with blue background color
:ps:`$` ml config colors "hi=1:di=94:L=90;47:mytag=102"
:ps:`$` ml av
--------------- :sgrdi:`/path/to/modulefiles` ---------------
:sgrl:`foo`:sgrss:`/1.0` <othertag> :sgrss:`foo/2.0`
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrl:`foo`:sgrss:`/1.0` <othertag>
The :mconfig:`tag_abbrev` configuration option is available to define
abbreviated strings for module tags and then use these abbreviations instead
of tag names when reporting tags on :subcmd:`avail` and :subcmd:`list` command
results.
.. parsed-literal::
:ps:`$` # add abbreviation for 'othertag' tag
:ps:`$` ml config tag_abbrev loaded=L:othertag=oT
:ps:`$` ml av
--------------- :sgrdi:`/path/to/modulefiles` ---------------
:sgrl:`foo`:sgrss:`/1.0` <oT> :sgrss:`foo/2.0`
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrl:`foo`:sgrss:`/1.0` <oT>
When a SGR code is set for a tag in the color palette, this graphical
rendition is applied by default over the module name and the tag name or its
abbreviation is not displayed. If tag name or abbreviation is added to the
:mconfig:`tag_color_name` configuration option, graphical rendering is applied
to the tag name or abbreviation rather than over the module name they are
attached to.
.. parsed-literal::
:ps:`$` # add SGR code for 'oT' tag and set rendition over tag name
:ps:`$` ml config colors "hi=1:di=94:L=90;47:mytag=44:oT=41"
:ps:`$` ml config tag_color_name oT
:ps:`$` ml av
--------------- :sgrdi:`/path/to/modulefiles` ---------------
:sgrl:`foo`:sgrss:`/1.0` <:sgrf:`oT`> :sgrss:`foo/2.0`
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrl:`foo`:sgrss:`/1.0` <:sgrf:`oT`>
Tags inherited from module state, consequence of a module action or set by
using :mfcmd:`module-tag` but that have a special meaning currently are:
.. only:: html
+------------------+-------------------------+------------------------+-------+------------------------+
| Tag | Description | Set with | Abbr. | Color |
| | | | | |
+==================+=========================+========================+=======+========================+
| auto-loaded | Module has been loaded | Inherited | aL | .. parsed-literal:: |
| | automatically | | | |
| | | | | :sgral:`mod/1.0` |
+------------------+-------------------------+------------------------+-------+------------------------+
| forbidden | Module cannot be loaded | Inherited from | F | .. parsed-literal:: |
| | | :mfcmd:`module-forbid` | | |
| | | | | :sgrf:`mod/1.0` |
+------------------+-------------------------+------------------------+-------+------------------------+
| hidden | Module is not visible | Inherited from | H | .. parsed-literal:: |
| | on :subcmd:`avail` | :mfcmd:`module-hide` | | |
| | | | | :sgrh:`mod/1.0` |
+------------------+-------------------------+------------------------+-------+------------------------+
| hidden-loaded | See `Hiding loaded | Inherited from | H | .. parsed-literal:: |
| | modules`_ | :mfcmd:`module-hide` | | |
| | | | | :sgrh:`mod/1.0` |
+------------------+-------------------------+------------------------+-------+------------------------+
| loaded | Module is currently | Inherited | L | .. parsed-literal:: |
| | loaded | | | |
| | | | | :sgrl:`mod/1.0` |
+------------------+-------------------------+------------------------+-------+------------------------+
| nearly-forbidden | Module will soon not be | Inherited from | nL | .. parsed-literal:: |
| | able to load anymore | :mfcmd:`module-forbid` | | |
| | | | | :sgrnf:`mod/1.0` |
+------------------+-------------------------+------------------------+-------+------------------------+
| sticky | See `Sticky modules`_ | :mfcmd:`module-tag` | S | .. parsed-literal:: |
| | | | | |
| | | | | :sgrs:`mod/1.0` |
+------------------+-------------------------+------------------------+-------+------------------------+
| super-sticky | See `Sticky modules`_ | :mfcmd:`module-tag` | sS | .. parsed-literal:: |
| | | | | |
| | | | | :sgrss:`mod/1.0` |
+------------------+-------------------------+------------------------+-------+------------------------+
.. only:: not html
+------------------+-------------------------+------------------------+-------+
| Tag | Description | Set with | Abbr. |
| | | | |
+==================+=========================+========================+=======+
| auto-loaded | Module has been loaded | Inherited | aL |
| | automatically | | |
| | | | |
+------------------+-------------------------+------------------------+-------+
| forbidden | Module cannot be loaded | Inherited from | F |
| | | :mfcmd:`module-forbid` | |
| | | | |
+------------------+-------------------------+------------------------+-------+
| hidden | Module is not visible | Inherited from | H |
| | on :subcmd:`avail` | :mfcmd:`module-hide` | |
| | | | |
+------------------+-------------------------+------------------------+-------+
| hidden-loaded | See `Hiding loaded | Inherited from | H |
| | modules`_ | :mfcmd:`module-hide` | |
| | | | |
+------------------+-------------------------+------------------------+-------+
| loaded | Module is currently | Inherited | L |
| | loaded | | |
| | | | |
+------------------+-------------------------+------------------------+-------+
| nearly-forbidden | Module will soon not be | Inherited from | nL |
| | able to load anymore | :mfcmd:`module-forbid` | |
| | | | |
+------------------+-------------------------+------------------------+-------+
| sticky | See `Sticky modules`_ | :mfcmd:`module-tag` | S |
| | | | |
| | | | |
+------------------+-------------------------+------------------------+-------+
| super-sticky | See `Sticky modules`_ | :mfcmd:`module-tag` | sS |
| | | | |
| | | | |
+------------------+-------------------------+------------------------+-------+
Hiding loaded modules
^^^^^^^^^^^^^^^^^^^^^
The ``--hidden-loaded`` option has been added to the :mfcmd:`module-hide`
modulefile command and it indicates that designated hidden modules remain
hidden after being loaded.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/1.0
#%Module
module load bar
:ps:`$` cat /path/to/modulefiles/bar/.modulerc
#%Module4.7
module-hide --soft --hidden-loaded bar
In this example, *foo* depends on *bar* which is set soft hidden and hidden
once loaded. As a consequence, automated load of *bar* module will not be
reported and *bar/1.0* will not appear in loaded module list by default:
.. parsed-literal::
:ps:`$` ml foo
:ps:`$` ml
Currently Loaded Modulefiles:
1) foo/1.0
However *bar/1.0* is loaded. Hidden loaded modules can be unveiled with the
:option:`--all`/:option:`-a` option set on the :subcmd:`list` sub-command.
``hidden-loaded`` tag (abbreviated by default to ``H`` when colored output is
disabled) applies to such modules.
.. parsed-literal::
:ps:`$` ml -a
Currently Loaded Modulefiles:
1) :sgral:`bar`:sgrh:`/1.0` 2) foo/1.0
To also get the informational messages about hidden loaded module automated
load or unload, the new verbosity level ``verbose2`` can be used (with
:option:`-vv` option for instance):
.. parsed-literal::
:ps:`$` ml purge
:ps:`$` ml -vv foo
Loading bar/1.0
Loading :sgrhi:`foo/1.0`
:sgrin:`Loading requirement`: bar/1.0
Sticky modules
^^^^^^^^^^^^^^
Module stickiness is introduced, in a similar fashion than on the `Lmod`_
project, to allow to glue modules to the loaded environment. A sticky module
cannot be unloaded, unless if the unload action is forced or if the module
reloads after being unloaded.
A modulefile is declared *sticky* by applying it the ``sticky`` tag with the
:mfcmd:`module-tag` modulefile command.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/.modulerc
#%Module4.7
module-tag sticky foo/1.0
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrs:`foo/1.0`
:ps:`$` ml -foo
Unloading :sgrhi:`foo/1.0`
:sgrer:`ERROR`: Unload of sticky module 'foo/1.0' skipped
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrs:`foo/1.0`
:ps:`$` ml --force -foo
Unloading :sgrhi:`foo/1.0`
:sgrwa:`WARNING`: Unload of sticky module 'foo/1.0' forced
:ps:`$` ml
No Modulefiles Currently Loaded.
Modulefile can also be defined ``super-sticky`` by applying the corresponding
module tag. *Super-sticky* module cannot be unloaded even if the unload action
is forced. It can only be unloaded if the module reloads afterward.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/bar/.modulerc
#%Module4.7
module-tag super-sticky bar/1.0
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrss:`bar/1.0`
:ps:`$` ml purge
Unloading :sgrhi:`bar/1.0`
:sgrer:`ERROR`: Unload of super-sticky module 'bar/1.0' skipped
:ps:`$` ml purge -f
Unloading :sgrhi:`bar/1.0`
:sgrer:`ERROR`: Unload of super-sticky module 'bar/1.0' skipped
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrss:`bar/1.0`
Modulefiles targeted by a ``sticky`` or a ``super-sticky`` tag are colored on
:subcmd:`avail` and :subcmd:`list` sub-command outputs to indicate such tag
applies. If colored output is disabled a tag abbreviation is reported along
module designation (respectively ``S`` and ``sS``).
In case the stickiness applies to the generic module name (and does not target
a specific module version or version-set), one version of the sticky or
super-sticky module can be swapped by another version of this same module:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/baz/.modulerc
#%Module4.7
module-tag sticky baz
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrs:`baz/2.0`
:ps:`$` ml switch baz/1.0
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrs:`baz/1.0`
Explaining avail/list output
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A *Key* section is added at the end of the :subcmd:`avail` and :subcmd:`list`
sub-commands output to give hints on the meaning of the graphical rendition
applied to elements or what the elements set in parentheses or chevrons along
module name stand for.
.. parsed-literal::
:ps:`$` ml av
------------------ :sgrdi:`/path/to/modulefiles` ------------------
:sgrs:`foo`:sgrl:`/1.0` <oT> :sgrde:`foo/2.0` :sgrali:`foo/3.0`
Key:
:sgrl:`loaded` :sgrde:`default-version` :sgrs:`sticky` <oT>=othertag
:sgrdi:`modulepath` :sgrali:`module-alias` <module-tag>
Configuring avail/list output
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
New configuration options are introduced to control what content to output in
addition to modules names on the regular and terse output modes of the
:subcmd:`avail` and :subcmd:`list` sub-commands.
These new configuration options named :mconfig:`avail_output`,
:mconfig:`avail_terse_output`, :mconfig:`list_output` and
:mconfig:`list_terse_output` can be updated using the :subcmd:`config`
sub-command or set at installation time respectively with the
:instopt:`--with-avail-output`, :instopt:`--with-avail-terse-output`,
:instopt:`--with-list-output` and :instopt:`--with-list-terse-output`
configure options.
The four options accept a colon separated list of elements as value. Accepted
elements for the :subcmd:`avail`-related options are: ``modulepath``,
``alias``, ``dirwsym``, ``sym``, ``tag`` and ``key``. Accepted elements for
the :subcmd:`list`-related options are: ``header``, ``idx``, ``sym``, ``tag``
and ``key``.
In the following example, default output configuration for the :subcmd:`avail`
sub-command is checked then module tags and key section are removed to get a
simpler output:
.. parsed-literal::
:ps:`$` ml config avail_output
Modules Release 4.7.0 (2021-02-19)
- Config. name ---------.- Value (set by if default overridden) ---------------
avail_output modulepath:alias:dirwsym:sym:tag:key
:ps:`$` ml av
------------------ :sgrdi:`/path/to/modulefiles` ------------------
:sgrde:`bar/1.0` bar/2.0 :sgrf:`foo/1.0` :sgrs:`foo/2.0` :sgrali:`foo/2.2`
Key:
:sgrdi:`modulepath` :sgrali:`module-alias` :sgrs:`sticky`
:sgrde:`default-version` :sgrf:`forbidden`
:ps:`$` ml config avail_output modulepath:alias:dirwsym:sym
:ps:`$` ml av
------------------ :sgrdi:`/path/to/modulefiles` ------------------
:sgrde:`bar/1.0` bar/2.0 foo/1.0 foo/2.0 :sgrali:`foo/2.2`
The :option:`--output`/:option:`-o` switches are added to define a specific
output configuration for the duration of the associated command line. The
following example shows how to limit the content reported on a module
:subcmd:`list` to the loaded index and the symbolic versions in addition to
the module names:
.. parsed-literal::
:ps:`$` ml
Currently Loaded Modulefiles:
1) :sgrde:`bar/1.0` 2) :sgrs:`foo/2.0`
Key:
:sgrde:`default-version` :sgrs:`sticky`
:ps:`$` ml -o idx:sym
1) :sgrde:`bar/1.0` 2) foo/2.0
When the new configuration options or command line switches are set to an
empty value, the module names are the sole information reported:
.. parsed-literal::
:ps:`$` ml -t -o ""
bar/1.0
foo/2.0
In case the ``modulepath`` element is withdrawn from the :subcmd:`avail`
sub-command output configuration, the available modules from all enabled
modulepaths are reported as a single list:
.. parsed-literal::
:ps:`$` ml av
--------------- :sgrdi:`/path/to/other/modulefiles` ---------------
baz/1.0 baz/2.0
------------------ :sgrdi:`/path/to/modulefiles` ------------------
:sgrde:`bar/1.0` bar/2.0 :sgrf:`foo/1.0` :sgrs:`foo/2.0` :sgrali:`foo/2.2`
Key:
:sgrdi:`modulepath` :sgrali:`module-alias` :sgrs:`sticky`
:sgrde:`default-version` :sgrf:`forbidden`
:ps:`$` ml av --output=alias:tag
bar/1.0 baz/1.0 :sgrf:`foo/1.0` :sgrali:`foo/2.2`
bar/2.0 baz/2.0 :sgrs:`foo/2.0`
.. note:: The ``avail_report_dir_sym`` and ``avail_report_mfile_sym`` locked
configuration options have been removed. Their behaviors can now be
obtained by respectively adding the ``dirwsym`` and ``sym`` elements to the
:mconfig:`avail_output` or :mconfig:`avail_terse_output` configuration
options.
v4.6
----
This new version is backward-compatible with previous version 4 releases. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`4.6 release notes<4.6 release notes>` for a complete
list of the changes between Modules v4.5 and v4.6.
.. _sh-to-mod_sub-command:
sh-to-mod sub-command
^^^^^^^^^^^^^^^^^^^^^
The :subcmd:`sh-to-mod` sub-command is added to output as a modulefile content
the environment changes done by the evaluation of a shell script passed as
argument. :subcmd:`sh-to-mod` is especially useful for software providing a
shell script for their enablement in shell session: it can convert these
scripts into modulefiles.
Say for instance, a *foo* software has been installed and it provides a
``foo-setup.sh`` script to activate *foo* software in user environment:
.. parsed-literal::
:ps:`$` cat /path/to/foo-1.2/foo-setup.sh
#!/bin/sh
export FOOENV="$1"
export PATH=/path/to/foo-1.2/bin:$PATH
alias foo='foobin -q -l'
Calling ``module sh-to-mod`` on this shell script outputs the environment
changes it performs as a modulefile content:
.. parsed-literal::
:ps:`$` module sh-to-mod sh /path/to/foo-1.2/foo-setup.sh arg1
#%Module
prepend-path PATH /path/to/foo-1.2/bin
set-alias foo {foobin -q -l}
setenv FOOENV arg1
Changes on environment variables, shell aliases, shell functions and current
working directory are tracked. The following shells are supported: *sh*,
*dash*, *csh*, *tcsh*, *bash*, *ksh*, *ksh93*, *zsh* and *fish*.
:subcmd:`sh-to-mod` acts as a full replacement for the standalone
:command:`createmodule.sh` and :command:`createmodule.py` scripts. However
those two scripts are currently still provided for compatibility purpose.
.. _source-sh_modulefile_command:
source-sh modulefile command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The :mfcmd:`source-sh` modulefile command is introduced to source environment
changes done by the evaluation of a shell script passed as argument. With
newly introduced :subcmd:`sh-to-mod` sub-command resulting environment changes
done by script are output as modulefile commands. :mfcmd:`source-sh` applies
those modulefile commands as if they were directly written in loading
modulefile.
:mfcmd:`source-sh` is useful for software providing a shell script for their
enablement. If you want to enable such software with :command:`module` yet
using shell script provided by software for this task, just write a modulefile
using :mfcmd:`source-sh` command to call the shell script.
Keeping the same example used to describe :subcmd:`sh-to-mod` sub-command:
*foo* software provides a ``foo-setup.sh`` script for its activation. Create a
modulefile ``foo/1.2`` that calls this script:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/1.2
#%Module4.6
source-sh sh /path/to/foo-1.2/foo-setup.sh arg1
Displaying this modulefile indicates the environment changes done by script:
.. parsed-literal::
:ps:`$` module display foo/1.2
-------------------------------------------------------------------
:sgrhi:`/path/to/modulefiles/foo/1.2`:
:sgrcm:`prepend-path` PATH /path/to/foo-1.2/bin
:sgrcm:`set-alias` foo {foobin -q -l}
:sgrcm:`setenv` FOOENV arg1
-------------------------------------------------------------------
Loading the modulefile applies the environment changes seen above:
.. parsed-literal::
:ps:`$` module load -v foo/1.2
Loading :sgrhi:`foo/1.2`
:ps:`$` echo $FOOENV
arg1
:ps:`$` alias foo
alias foo='foobin -q -l'
Track of these changes is kept in user environment to be able to undo them
when modulefile is unloaded:
.. parsed-literal::
:ps:`$` module unload -v foo/1.2
Unloading :sgrhi:`foo/1.2`
:ps:`$` echo $FOOENV
:ps:`$` alias foo
bash: alias: foo: not found
Changes on environment variables, shell aliases, shell functions and current
working directory are tracked. The following shells are supported: *sh*,
*dash*, *csh*, *tcsh*, *bash*, *ksh*, *ksh93*, *zsh* and *fish*.
Querying user's name and groups membership
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Two new sub-commands are introduced for the :mfcmd:`module-info` modulefile
command: ``username`` and ``usergroups``. They respectively fetch the name of
the user currently running :file:`modulecmd.tcl` or the name of all the groups
this user is member of.
These two new modulefile commands can help to adapt code to specific users or
groups. Like for instance to instantiate a modulefile for each group the user
is member of:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/.modulerc
#%Module4.6
foreach grp [module-info usergroups] {
module-virtual foo/$grp .common
}
:ps:`$` id -G -n
grp1 grp2 grp3
:ps:`$` module avail
--------------- :sgrdi:`/path/to/modulefiles` ---------------
foo/grp1 foo/grp2 foo/grp3
``username`` and ``usergroups`` sub-commands of :mfcmd:`module-info`
modulefile command are only supported on Unix platform.
Hiding modules
^^^^^^^^^^^^^^
The newly introduced :mfcmd:`module-hide` modulefile command enables to
dynamically hide modulefiles, module aliases or symbolic versions specified to
it:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/bar/.modulerc
#%Module4.6
module-version bar/1.0 old
# hide 'old' symbolic version
module-hide bar/old
# hide all version 2 and above
module-hide bar@2:
:ps:`$` cat /path/to/modulefiles/.modulerc
#%Module4.6
# hide all versions of foo module
module-hide foo
:mfcmd:`module-hide` commands should be placed in module rc files and can
leverage the `Advanced module version specifiers`_ syntax as shown in the
above example.
Hidden modules are excluded from available module search or module selection
unless query refers to hidden module by its exact name:
.. parsed-literal::
:ps:`$` ml av
--------------- :sgrdi:`/path/to/modulefiles` ---------------
bar/1.0 bar/2.0
:ps:`$` module load -v foo
:sgrer:`ERROR`: Unable to locate a modulefile for 'foo'
:ps:`$` module load -v foo/1.0
Loading foo/1.0
:ps:`$` module avail bar/old
--------------- :sgrdi:`/path/to/modulefiles` ---------------
bar/1.0\ :sgrse:`(`:sgrsy:`old`:sgrse:`)`
:mfcmd:`module-hide` command accepts a ``--soft`` option to apply a lighter of
hiding to modules:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/qux/.modulerc
#%Module4.6
# softly hide all qux modules
module-hide --soft qux
The soft hiding mode enables to hide modules from full availability listing
yet keeping the ability to select such module for load without having to use
module exact name:
.. parsed-literal::
:ps:`$` ml av
--------------- :sgrdi:`/path/to/modulefiles` ---------------
bar/1.0 bar/2.0
:ps:`$` ml av qux
--------------- :sgrdi:`/path/to/modulefiles` ---------------
qux/1.0 qux/2.0
:ps:`$` module load -v qux
Loading :sgrhi:`qux/2.0`
Alternatively, a ``--hard`` option can be set on :mfcmd:`module-hide` command
to ensure designated modules do not unveil even if referred by their exact
name:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/qux/.modulerc
#%Module4.6
# softly hide all qux modules
module-hide --soft qux
# set highest version of qux hard hidden
module-hide --hard qux/3.0
:ps:`$` ml av qux/3.0
:ps:`$` ml qux/3.0
:sgrer:`ERROR`: Unable to locate a modulefile for 'qux/3.0'
Some users or groups can be set unaffected by hiding mechanism with
the ``--not-user`` or ``--not-group`` options:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/quuz/.modulerc
#%Module4.6
# hiding does not apply to grp1 and grp2 groups
module-hide --not-group {grp1 grp2} quuz
.. parsed-literal::
:ps:`$` id --groups --name
grp1 grp7
:ps:`$` ml av quuz
--------------- :sgrdi:`/path/to/modulefiles` ---------------
quuz/1.0 quuz/2.0
:ps:`$` ml -v quuz
Loading :sgrhi:`quuz/2.0`
Hiding mechanism can also be set effective only before or after a given date
time with the ``--before`` and ``--after`` options. Accepted date time format
is ``YYYY-MM-DD[THH:MM]``.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/fum/.modulerc
#%Module4.6
# hide only before a given date
module-hide --hard --before 2020-09-01T12:00 fum/1.0
# hide only after a given date
module-hide --hard --after 2020-09-01 fum/2.0
.. parsed-literal::
:ps:`$` date
Fri 04 Sep 2020 06:21:48 AM CEST
:ps:`$` ml av fum
--------------- :sgrdi:`/path/to/modulefiles` ---------------
fum/1.0
Hidden modules can be included in available module searches if option
:option:`--all`/:option:`-a` is set on :subcmd:`avail`, :subcmd:`aliases`,
:subcmd:`whatis` or :subcmd:`search` sub-commands. Hard hidden modules are
unaffected by this option and stay hidden.
.. parsed-literal::
:ps:`$` ml av -a
--------------- :sgrdi:`/path/to/modulefiles` ---------------
bar/1.0\ :sgrse:`(`:sgrsy:`old`:sgrse:`)` foo/1.0 fum/1.0 quuz/2.0 qux/2.0
bar/2.0 foo/2.0 quuz/1.0 qux/1.0
Forbidding use of modules
^^^^^^^^^^^^^^^^^^^^^^^^^
The :mfcmd:`module-forbid` modulefile command is added to dynamically forbid
the evaluation of modulefiles it specifies. When forbidden, a module cannot be
loaded and an access error is returned when an attempt is made to evaluate it.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/foo/.modulerc
#%Module4.6
module-forbid foo@1:
:ps:`$` ml foo/1.0
:sgrer:`ERROR`: Access to module 'foo/1.0' is denied
:ps:`$` ml
No Modulefiles Currently Loaded.
:mfcmd:`module-forbid` statements can be coupled with :mfcmd:`module-hide`
statements to hide modules in addition to forbid their use.
:mfcmd:`module-forbid` supports the ``--not-user``, ``--not-group``,
``--before`` and ``--after`` options to still allow some users or forbid
modules before or after a given date time.
An additional error message can be defined with the ``--message`` option
to guide for instance users when they try to evaluate a forbidden module:
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/bar/.modulerc
#%Module4.6
module-forbid --message {Software bar/1.0 is decommissioned, please now use\\
bar/2.0} --after 2020-09-01 bar/1.0
:ps:`$` ml bar/1.0
:sgrer:`ERROR`: Access to module 'bar/1.0' is denied
Software bar/1.0 is decommissioned, please now use bar/2.0
When an evaluated module will soon be forbidden, a message is returned to the
user to warn them of the near limit. An additional warning message can also be
defined here with the ``--nearly-message`` option to guide users.
.. parsed-literal::
:ps:`$` cat /path/to/modulefiles/qux/.modulerc
#%Module4.6
module-forbid --nearly-message {Version 1.0 will soon expire, please now use\\
version 2.0} --after 2020-09-15 qux/1.0
:ps:`$` date
Tue 08 Sep 2020 06:49:43 AM CEST
:ps:`$` ml qux/1.0
Loading :sgrhi:`qux/1.0`
:sgrwa:`WARNING`: Access to module will be denied starting '2020-09-15'
Version 1.0 will soon expire, please now use version 2.0
The range of time the *nearly forbidden* warning appears can be controlled
with the :mconfig:`nearly_forbidden_days` configuration option, whose value
equals to the number of days prior the module starts to be forbidden. This
configuration is set to ``14`` (days) by default and this value can be
controlled at :file:`configure` time with
:instopt:`--with-nearly-forbidden-days` option. When the
:mconfig:`nearly_forbidden_days` configuration is set through the
:subcmd:`config` sub-command, the :envvar:`MODULES_NEARLY_FORBIDDEN_DAYS`
environment variable is set.
Tracing module execution
^^^^^^^^^^^^^^^^^^^^^^^^
The ``trace`` verbosity is introduced between the ``verbose`` and ``debug``
levels to report details on module searches, resolutions, selections and
evaluations. Trace mode can be enabled by setting the :mconfig:`verbosity`
config to the ``trace`` value or by using the :option:`-T`/:option:`--trace`
command-line switches.
To specifically render trace messages, the ``tr`` key is added to the color
palette with a default value of ``2`` (decreased intensity).
.. parsed-literal::
:ps:`$` ml -T foo
:sgrtr:`Evaluate modulerc: '/path/to/modulefiles/.modulerc'`
:sgrtr:`Get modules: {foo} matching 'foo' in '/path/to/modulefiles'`
:sgrtr:`Resolve: 'foo' into 'bar'`
:sgrtr:`Get modules: {bar bar/1.0} matching 'bar' in '/path/to/modulefiles'`
:sgrtr:`Select module: 'bar/1.0' (/path/to/modulefiles/bar/1.0) matching 'bar/1.0'`
Loading :sgrhi:`bar/1.0`
:sgrtr:`Evaluate modulefile: '/path/to/modulefiles/bar/1.0' as 'bar/1.0'`
v4.5
----
This new version is backward-compatible with previous version 4 releases. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`4.5 release notes<4.5 release notes>` for a complete
list of the changes between Modules v4.4 and v4.5.
ml command
^^^^^^^^^^
The ``ml`` command is added to Modules. ``ml`` is a frontend to the ``module``
command that reduces the number of characters to type to trigger module
actions.
With no argument provided ``ml`` is equivalent to ``module list``, ``ml foo``
corresponds to ``module load foo`` and ``ml -foo`` means ``module unload
foo``:
.. parsed-literal::
:ps:`$` ml foo
:ps:`$` ml
Currently Loaded Modulefiles:
1) foo/2
:ps:`$` ml -foo
:ps:`$` ml
No Modulefiles Currently Loaded.
Multiple modules to either load or unload can be combined on a single command.
The unloads are first processed then the loads.
``ml`` accepts all command-line switches and sub-commands accepted by
``module`` command:
.. parsed-literal::
:ps:`$` ml avail -t foo
foo/1
foo/2
This handy interface has been originally developed by the `Lmod`_ project.
Having this command line interface also supported on Modules helps to provide
a similar user experience whatever the module implementation used.
.. _Lmod: https://github.com/TACC/Lmod
JSON format output
^^^^^^^^^^^^^^^^^^
The ``-j`` and ``--json`` command line switches are added for the ``avail``,
``list``, ``savelist``, ``whatis`` and ``search`` module sub-commands. When
set, the output result of these sub-commands is rendered in `JSON`_ format:
.. parsed-literal::
:ps:`$` module avail --json bar | python -mjson.tool
{
"/path/to/modulefiles": {
"bar/2.3": {
"name": "bar/2.3",
"pathname": "/path/to/modulefiles/bar/2.3",
"symbols": [
"default"
],
"type": "modulefile"
},
"bar/3.4": {
"name": "bar/3.4",
"pathname": "/path/to/modulefiles/bar/3.4",
"symbols": [],
"type": "modulefile"
}
}
}
:ps:`$` ml whatis -j foo/1.2.3 | python -mjson.tool
{
"/path/to/modulefiles": {
"foo/1.2.3": {
"name": "foo/1.2.3",
"whatis": [
"The foo/1.2.3 modulefile"
]
}
}
}
.. _JSON: https://tools.ietf.org/html/rfc8259
Improved Windows support
^^^^^^^^^^^^^^^^^^^^^^^^
A new option to the ``./configure`` script named
:instopt:`--enable-windows-support` is introduced to install additional files
relative to the enablement of Modules on the Windows platform. When set, this
option installs ``module.cmd``, ``ml.cmd`` and ``envml.cmd`` scripts in
``bindir`` and initialization script ``cmd.cmd`` in ``initdir``. With these
four files the Modules installation may be used from either a Unix or a
Windows platform.
``module.cmd``, ``ml.cmd`` and ``envml.cmd`` scripts respectively provide the
``module``, ``ml`` and ``envml`` commands for Windows ``cmd`` terminal shell,
relying on ``modulecmd.tcl`` script which was already able to produce shell
code for this Windows shell. Initialization script ``cmd.cmd`` adds the
directory of ``module.cmd``, ``ml.cmd`` and ``envml.cmd`` to ``PATH``.
These Windows-specific files are relocatable: ``module.cmd``, ``ml.cmd`` and
``envml.cmd`` scripts expect to find initialization script ``cmd.cmd`` in the
``init`` directory next to them (to setup Modules-specific variables in
current environment) and ``cmd.cmd`` expects ``modulecmd.tcl`` to be found in
``libexec`` directory and the 3 commands in ``bin`` directory next to it.
Starting from this ``4.5`` release a distribution zipball is published to
install Modules on Windows. This zip archive ships an install and an uninstall
scripts (``INSTALL.bat`` and ``UNINSTALL.bat``). The zipball can be built
locally from Modules sources by running ``make dist-win``.
The :ref:`INSTALL-win` document describes how to install Modules on Windows
from the distribution zipball.
Error stack trace
^^^^^^^^^^^^^^^^^
Error messages will now embed a stack trace for unknown errors to help
localize the root cause of issues. This change applies to modulefile
evaluation:
.. parsed-literal::
Loading :sgrhi:`foo/1.2`
:sgrme:`Module ERROR`: add-path cannot handle path equals to separator string
while executing
"append-path PATH :"
(file "/path/to/modulefiles/foo/1.2" line 24)
Please contact <:noparse:`root@localhost`>
A stack trace is also returned when an unknown error occurs in
``modulecmd.tcl`` script, which facilitates issue report and analysis:
.. parsed-literal::
:ps:`$` module load bar
:sgrer:`ERROR`: invalid command name "badcommand"
while executing
"badcommand"
(procedure "module" line 14)
invoked from within
"module load bar"
("eval" body line 1)
invoked from within
"eval $execcmdlist"
Please report this issue at :noparse:`https://github.com/envmodules/modules/issues`
.. _Automatic default and latest syms:
Automatic default and latest symbolic versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When the implicit default mechanism and the `Advanced module version
specifiers`_ are both enabled, a ``default`` and a ``latest`` symbolic
versions are automatically defined for each module name.
This new feature gives the ability to select the highest version available for
a module, without knowing beforehand this version name:
.. parsed-literal::
:ps:`$` module load -v :noparse:`foo@latest`
Loading foo/1.10
The symbolic versions are automatically defined unless a symbolic version, an
alias or a regular module version already exists for these ``default`` or
``latest`` version names.
v4.4
----
This new version is backward-compatible with previous version 4 releases. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`4.4 release notes<4.4 release notes>` for a complete
list of the changes between Modules v4.3 and v4.4.
.. warning:: Modules configuration option handling has been reworked
internally to provide a unified way for all options to get initialized,
retrieved or set. Existing site-specific configuration script should be
reviewed to make use of the new ``getConf``, ``setConf``, ``unsetConf``
and ``lappendConf`` procedures to manipulate configuration options.
.. _Insensitive case:
Specify modules in a case insensitive manner
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ability to match module name in a case insensitive manner has been added.
This feature can be enabled at different level with the following values set
to the ``icase`` configuration option:
* ``never``: a case sensitive match is applied in any cases
* ``search``: a case insensitive match is applied to the ``avail``, ``whatis``
and ``paths`` sub-commands
* ``always``: a case insensitive match is applied to search contexts and also
to the other module sub-commands and modulefile Tcl commands for the module
specification they receive as argument.
It can help for instance to load a module without knowing the case used to
name its relative modulefile:
.. parsed-literal::
:ps:`$` module config icase always
:ps:`$` module load -v mysoftware
Loading :sgrhi:`MySoftware/1.0`
Insensitive case match activation can be controlled at configure time with
the ``--with-icase`` option, which could be passed any of the above activation
levels. This option could be superseded with the ``MODULES_ICASE`` environment
variable, which could be set through the **config** sub-command with the
``icase`` option. Command-line switch **--icase** supersedes in turns any
other icase configurations. When this command-line switch is passed, ``icase``
mode equals ``always``.
Extended default
^^^^^^^^^^^^^^^^
The extended default mechanism has been introduced to help selecting a module
when only the first numbers in its version are specified. Starting portion of
the version, part separated from the rest of the version string by a ``.``
character, could be used to refer to a more precise version number.
This mechanism is activated through the new configuration option
``extended_default``. It enables to refer to a module named ``foo/1.2.3`` as
``foo/1.2`` or ``foo/1``:
.. parsed-literal::
:ps:`$` module config extended_default 1
:ps:`$` module load -v foo/1
Loading :sgrhi:`foo/1.2.3`
When multiple versions match partial version specified and only one module
should be selected, the default version (whether implicitly or explicitly
defined) among matches is returned. The following example shows that
``foo/1.1.1``, the *foo* module default version, is selected when it matches
query. Elsewhere the highest version (also called the latest version or the
implicit default) among matching modules is returned:
.. parsed-literal::
:ps:`$` module av foo
--------------- :sgrdi:`/path/to/modulefiles` ---------------
foo/1.1.1\ :sgrse:`(`:sgrsy:`default`:sgrse:`)` foo/1.2.1 foo/1.10
foo/1.1.10 foo/1.2.3
:ps:`$` module load -v foo/1.1
Loading :sgrhi:`foo/1.1.1`
:ps:`$` module purge
:ps:`$` module load -v foo/1.2
Loading :sgrhi:`foo/1.2.3`
:ps:`$` module purge
:ps:`$` module load -v foo/1
Loading :sgrhi:`foo/1.1.1`
In case ``implicit_default`` option is disabled and no explicit default is
found among matches, an error is returned:
.. parsed-literal::
:ps:`$` module config implicit_default 0
:ps:`$` module load -v foo/1.2
:sgrer:`ERROR`: No default version defined for 'foo/1.2'
When it is enabled, extended default applies everywhere a module could be
specified, which means it could be used with any module sub-command or any
modulefile Tcl command receiving a module specification as argument. It may
help for instance to declare dependencies between modules:
.. parsed-literal::
:ps:`$` module show bar/3
----------------------------------------------------------
:sgrhi:`/path/to/modulefiles/bar/3.4`:
:sgrcm:`prereq` foo/1.2
----------------------------------------------------------
:ps:`$` module load --auto bar/3
Loading :sgrhi:`bar/3.4`
:sgrin:`Loading requirement`: foo/1.2.3
Extended default activation can be controlled at configure time with the
``--enable-extended-default`` option. This option could be superseded with the
``MODULES_EXTENDED_DEFAULT`` environment variable, which could be set through
the **config** sub-command with the ``extended_default`` option.
Advanced module version specifiers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ability to specify finer constraints on module version has been added to
Modules. It enables to filter the module selection to a given version list or
range by specifying after the module name a version constraint prefixed by the
``@`` character.
This new feature leverages the `version specifier syntax`_ of the `Spack`_
package manager as this syntax covers all the needs for a fine-grained
selection of module versions. It copes very well with command-line typing, by
avoiding characters having a special meaning on shells. Moreover the users of
Spack that also are users of Modules may already be familiar with this syntax.
.. _version specifier syntax: https://spack.readthedocs.io/en/latest/basic_usage.html#version-specifier
.. _Spack: https://github.com/spack/spack
The mechanism introduced here is called *advanced module version specifier*
and it can be activated through the new configuration option
``advanced_version_spec``. Constraints can be expressed to refine the
selection of module version to:
* a single version with the ``@version`` syntax, for instance ``foo@1.2.3``
syntax will select module ``foo/1.2.3``
* a list of versions with the ``@version1,version2,...`` syntax, for instance
``foo@1.2.3,1.10`` will match modules ``foo/1.2.3`` and ``foo/1.10``
* a range of versions with the ``@version1:``, ``@:version2`` and
``@version1:version2`` syntaxes, for instance ``foo@1.2:`` will select all
versions of module ``foo`` greater than or equal to ``1.2``, ``foo@:1.3``
will select all versions less than or equal to ``1.3`` and ``foo@1.2:1.3``
matches all versions between ``1.2`` and ``1.3`` including ``1.2`` and
``1.3`` versions
This new feature enables for instance to list available versions of module
``foo`` higher or equal to ``1.2``:
.. parsed-literal::
:ps:`$` module config advanced_version_spec 1
:ps:`$` module av foo
--------------- :sgrdi:`/path/to/modulefiles` ---------------
foo/1.1.1\ :sgrse:`(`:sgrsy:`default`:sgrse:`)` foo/1.2.1 foo/1.10
foo/1.1.10 foo/1.2.3
:ps:`$` module av :noparse:`foo@1.2:`
--------------- :sgrdi:`/path/to/modulefiles` ---------------
foo/1.2.1 foo/1.2.3 foo/1.10
Then choose to load for instance a version higher than or equal to ``1.2`` and
less than or equal to ``1.3``. Default version is selected if it corresponds
to a version included in the range, elsewhere the highest version (also called
latest version or implicit default) is selected:
.. parsed-literal::
:ps:`$` module load -v :noparse:`foo@1.2:1.3`
Loading :sgrhi:`foo/1.2.3`
In case ``implicit_default`` option is disabled and no explicit default is
found among version specifier matches, an error is returned:
.. parsed-literal::
:ps:`$` module config implicit_default 0
:ps:`$` module load -v :noparse:`foo@1.2:1.3`
:sgrer:`ERROR`: No default version defined for ':noparse:`foo@1.2:1.3`'
When advanced module version specifier is enabled, it applies everywhere a
module could be specified, which means it could be used with any module
sub-command or any modulefile Tcl command receiving a module specification
as argument. It may help for instance to declare smoother dependencies between
modules:
.. parsed-literal::
:ps:`$` module show bar@:2
----------------------------------------------------------
:sgrhi:`/path/to/modulefiles/bar/2.3`:
:sgrcm:`prereq` :noparse:`foo@1.1.10,1.2.1`
----------------------------------------------------------
:ps:`$` module load --auto bar@:2
Loading :sgrhi:`bar/2.3`
:sgrin:`Loading requirement`: foo/1.2.1
Advanced specification of single version or list of versions may benefit from
the activation of the `Extended default`_ mechanism (range of versions
natively handles abbreviated versions):
.. parsed-literal::
:ps:`$` module config extended_default 1
:ps:`$` module load -v :noparse:`foo@1.2`
Loading :sgrhi:`foo/1.2.3`
:ps:`$` module unload -v foo @1.2,1.5
Unloading :sgrhi:`foo/1.2.3`
Advanced module version specifier activation can be controlled at configure
time with the ``--enable-advanced-version-spec`` option. This option could be
superseded with the ``MODULES_ADVANCED_VERSION_SPEC`` environment variable,
which could be set through the **config** sub-command with the
``advanced_version_spec`` option.
v4.3
----
This new version is backward-compatible with previous version 4 releases. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`4.3 release notes<4.3 release notes>` for a complete
list of the changes between Modules v4.2 and v4.3.
Modulepath rc file
^^^^^^^^^^^^^^^^^^
A ``.modulerc`` file found at the root of an enabled modulepath directory is
now evaluated when modulepath is walked through to locate modulefiles. This
modulepath rc file gives for instance the ability to define module alias whose
name does not correspond to any module directory in this modulepath. Thus this
kind of module alias would not be found unless if it is defined at the
modulepath global scope.
Further I/O operations optimization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Additional work has been performed to save a significant number of filesystem
I/O operations made to search and evaluate modulefiles.
When fully read, the content of a modulefile is now cached in memory to avoid
new I/O operations in case this modulefile should be read one more time during
the same module command evaluation.
Except for ``path``, ``paths``, ``list``, ``avail`` and ``aliases`` module
commands always fully read a modulefile whether its full content is needed or
just its header to verify its validity. This way modulefiles are only read
once on commands that first check modulefile validity then read again valid
files to get their full content.
Last but not least, Modules Tcl extension library is introduced to extend the
Tcl language in order to provide more optimized I/O commands to read a file or
a directory content than native Tcl commands do. This library is built and
enabled in ``modulecmd.tcl`` script with ``--enable-libtclenvmodules``
configure argument (it is enabled by default). As this library is written in
C, it must be compiled and ``--with-tcl`` or ``--with-tclinclude`` configure
arguments may be used to indicate where to find Tcl development files.
Modules Tcl extension library greatly reduces the number of filesystem I/O
operations by removing unneeded ``ioctl``, ``fcntl`` and ``lstat`` system
calls done (by Tcl ``open`` command) to read each modulefile. Directory
content read is also improved by fetching hidden and regular files in one
pass. Moreover ``.modulerc`` and ``.version`` read access is tested only if
these files are found in the directory.
Colored output
^^^^^^^^^^^^^^
The ability to graphically enhance some part of the produced output has been
added to improve readability. Among others, error, warning and info message
prefixes can be colored as well as modulepath, module alias and symbolic
version.
Color mode can be set to ``never``, ``auto`` or ``always``. When color mode is
set to ``auto``, output is colored only if the standard error output channel
is attached to a terminal.
Default color mode could be controlled at configure time with the
``--enable-color`` and the ``--disable-color`` option, which respectively
correspond to the ``auto`` and ``never`` color mode. This default mode could
be superseded with the ``CLICOLOR``, ``CLICOLOR_FORCE`` and ``MODULES_COLOR``
environment variables and the ``--color`` command-line switch.
Color to apply to each element can be controlled with the ``MODULES_COLORS``
environment variable or the ``--with-dark-background-colors`` and
``--with-light-background-colors`` configure options. These variable and
options take as value a colon-separated list in the same fashion ``LS_COLORS``
does. In this list, output item that should be highlighted is designated by
a key which is associated to a `Select Graphic Rendition (SGR) code`_.
.. _Select Graphic Rendition (SGR) code: https://en.wikipedia.org/wiki/ANSI_escape_code#Select_Graphic_Rendition_parameters
The ``MODULES_TERM_BACKGROUND`` environment variable and the
``--with-terminal-background`` configure option help Modules to determine if
the color set for dark background or the color set for light background should
be used to color output in case no specific color set is defined with the
``MODULES_COLORS`` variable.
Output items able to be colorized and their relative key are: highlighted
element (``hi``), debug information (``db``), tag separator (``se``); Error
(``er``), warning (``wa``), module error (``me``) and info (``in``) message
prefixes; Modulepath (``mp``), directory (``di``), module alias (``al``),
module symbolic version (``sy``), module ``default`` version (``de``) and
modulefile command (``cm``).
For instance the default color set for a terminal with dark background is
defined to:
.. parsed-literal::
:noparse:`hi=1:db=2:se=2:er=91:wa=93:me=95:in=94:mp=1;94:di=94:al=96:sy=95:de=4:cm=92`
When colored output is enabled and a specific graphical rendition is defined
for module *default* version, the ``default`` symbol is omitted and instead
the defined graphical rendition is applied to the relative modulefile. When
colored output is enabled and a specific graphical rendition is defined for
module alias, the ``@`` symbol is omitted.
``CLICOLOR`` and ``CLICOLOR_FORCE`` environment variables are also honored to
define color mode. The ``never`` mode is set if ``CLICOLOR`` equals to ``0``.
If ``CLICOLOR`` is set to another value, it corresponds to the ``auto`` mode.
The ``always`` mode is set if ``CLICOLOR_FORCE`` is set to a value different
than ``0``. Color mode set with these two variables is superseded by mode set
with ``MODULES_COLOR`` environment variable.
Configure modulecmd with config sub-command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The **config** sub-command has been added to ``module`` to help getting or
setting the **modulecmd.tcl** options. With no additional command-line
argument, this sub-command reports the current value of all existing options
with a mention to indicate if this value has been overridden from a
command-line switch or from an environment variable.
See the description of this sub-command in the :ref:`module(1)` man page for a
complete reference on existing configuration options.
Most of the options can be altered by passing the option name and a value to
the sub-command. Setting an option by this mean overrides its default value,
set at installation time in **modulecmd.tcl** script, by defining the
environment variable which supersedes this default.:
.. parsed-literal::
:ps:`$` module config auto_handling 1
:ps:`$` module config auto_handling
Modules Release 4.3.0 (2019-07-26)
- Config. name ---------.- Value (set by if default overridden) ---------------
auto_handling 1 (env-var)
Setting options with ``module config`` could be done in the Modules
initialization RC file to change default value of options when ``module``
command is initialized.
When command-line switch ``--reset`` and an option name is passed to the
**config** sub-command, it restores default value for configuration option by
unsetting related environment variable.
With command-line switch ``--dump-state``, the **config** sub-command reports,
in addition to currently set options, the current state of **modulecmd.tcl**
script and Modules-related environment variables. Providing the output of the
``module config --dump-state`` command when submitting an issue to the Modules
project will help to analyze the situation.
Control module command verbosity
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ability to control message verbosity has been added so ``module`` command
can be configured whether it should display more or less information.
Available verbosity levels from the least to the most verbose are:
* ``silent``: turn off error, warning and informational messages but does not
affect module command output result.
* ``concise``: enable error and warning messages but disable informational
messages.
* ``normal``: turn on informational messages, like a report of the additional
module evaluations triggered by loading or unloading modules, aborted
evaluation issues or a report of each module evaluation occurring during a
**restore** or **source** sub-commands.
* ``verbose``: add additional informational messages, like a systematic report
of the loading or unloading module evaluations.
* ``debug``: print debugging messages about module command execution.
Default verbosity level can be controlled at configure time with the
``--with-verbosity`` option, which could be passed any of the above level
names. This default verbosity level could be superseded with the
``MODULES_VERBOSITY`` environment variable, which could be set through the
**config** sub-command with the ``verbosity`` option. Command-line switches
**--silent**, **--verbose** and **--debug** supersede in turns any other
verbosity configuration to respectively set module command silent, verbose or
in debug mode.
Other new sub-commands, command-line switches and environment variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* The **avail** sub-command gets two new command-line switches: **--indepth**
and **--no-indepth**. These options control whether search results should
recursively include or not modulefiles from directories matching search
query. Shell completion scripts have been updated to complete available
modulefiles in the no in depth mode.
* The **MODULES_AVAIL_INDEPTH** environment variable defines if the **avail**
sub-command should include or exclude by default the modulefiles from
directories matching search query. Its value is superseded by the use of the
**--indepth** and **--no-indepth** command-line switches.
* The **clear** sub-command, which was available on Modules version 3.2, has
been reintroduced. This sub-command resets the Modules runtime information
but does not apply further changes to the environment at all. This
sub-command now leverages the **--force** command-line switch to skip its
confirmation dialog.
* The **MODULES_SITECONFIG** environment variable defines an additional
siteconfig script which is loaded if it exists after the siteconfig script
configured at build time in ``modulecmd.tcl``. This ability is enabled by
default and could be disabled with configure option
``--with-locked-configs=extra_siteconfig``.
* The **MODULES_UNLOAD_MATCH_ORDER** environment variable sets whether the
firstly or the lastly loaded module should be selected for unload when
multiple loaded modules match unload request. Configure option
``--with-unload-match-order`` defines this setting which can be superseded
by the environment variable. By default, lastly loaded module is selected
and it is recommended to keep this behavior when used modulefiles express
dependencies between each other.
* The **MODULES_IMPLICIT_DEFAULT** environment variable sets whether an
implicit default version should be defined for modules with no default
version explicitly defined. When enabled, which is the default behavior, a
module version is automatically selected (latest one) when the generic
name of the module is passed. When implicit default is disabled and no
default version is explicitly defined for a module, the name of this module
to evaluate should be fully qualified elsewhere an error is returned.
Configure option ``--enable-implicit-default`` defines this setting which
can be superseded by the environment variable. This superseding mechanism
can be disabled with configure option
``--with-locked-configs=implicit_default``.
* The **MODULES_SEARCH_MATCH** environment variable defines the matching style
to perform when searching for available modules. With **starts_with** value,
modules whose name begins by search query string are returned. When search
match style is set to **contains**, modules returned are those whose fully
qualified name contains search query string. Configure option
``--with-search-match`` defines this setting which can be superseded by the
environment variable, which in turns can be superseded by the
**--starts-with** and **--contains** command-line switches of **avail**
module sub-command.
* The **MODULES_SET_SHELL_STARTUP** environment variable controls whether or
not shell startup file should be set to ensure ``module`` command is defined
once shell has been initialized. When enabled, the ``ENV`` and ``BASH_ENV``
environment variables are set, when ``module`` function is defined, to the
Modules bourne shell initialization script. Configure options
``--enable-set-shell-startup`` and ``--disable-set-shell-startup`` define
this setting which can be superseded by the environment variable.
* When initializing the ``module`` command in a shell session, initialization
configuration files stored in the defined configuration directory are taken
into account if present instead of the configuration files stored in the
initialization script directory. When they are stored in the configuration
directory, these configuration files are named ``initrc`` and
``modulespath`` instead of respectively ``modulerc`` and ``.modulespath``.
The location of the installation of those files can be controlled with
configure option ``--with-initconf-in``, which accepts ``etcdir`` and
``initdir`` values.
* The **MODULES_WA_277** environment variable helps to define an alternative
``module`` alias on Tcsh shell when set to *1*. It workarounds an issue on
Tcsh history mechanism occurring with default ``module`` command alias:
erroneous history entries are recorded each time the ``module`` command is
called. However the alternative definition of the module alias weakens shell
evaluation of the code produced by modulefiles. Characters with special
meaning for Tcsh shell (like *{* and *}*) may not be used anymore in shell
alias definition elsewhere the evaluation of the code produced by
modulefiles will return a syntax error.
v4.2
----
This new version is backward-compatible with previous version 4 releases. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`4.2 release notes<4.2 release notes>` for a complete
list of the changes between Modules v4.1 and v4.2.
.. _v42-conflict-constraints-consistency:
Modulefile conflict constraints consistency
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With the **conflict** modulefile command, a given modulefile can list the
other modulefiles it conflicts with. To load this modulefile, the modulefiles
it conflicts with cannot be loaded.
This constraint was until now satisfied when loading the modulefile declaring
the **conflict** but it vanished as soon as this modulefile was loaded. In the
following example ``a`` modulefile declares a conflict with ``b``:
.. parsed-literal::
:ps:`$` module load b a
WARNING: a cannot be loaded due to a conflict.
HINT: Might try "module unload b" first.
:ps:`$` module list
Currently Loaded Modulefiles:
1) b
:ps:`$` module purge
:ps:`$` module load a b
:ps:`$` module list
Currently Loaded Modulefiles:
1) a 2) b
Consistency of the declared **conflict** is now ensured to satisfy this
constraint even after the load of the modulefile declaring it. This is
achieved by keeping track of the conflict constraints of the loaded
modulefiles in an environment variable called ``MODULES_LMCONFLICT``:
.. parsed-literal::
:ps:`$` module load a b
ERROR: WARNING: b cannot be loaded due to a conflict.
HINT: Might try "module unload a" first.
:ps:`$` module list
Currently Loaded Modulefiles:
1) a
An environment variable is used to keep track of this conflict information to
proceed the same way than used to keep track of the loaded modulefiles with
the ``LOADEDMODULES`` environment variable.
In case a conflict constraint toward a modulefile is set by an already loaded
modulefile, loading the conflicting modulefile will lead to a load evaluation
attempt in order for this modulefile to get the chance to solve the constraint
violation. If at the end of the load evaluation, the conflict has not been
solved, modulefile load will be discarded.
.. warning:: On versions ``4.2.0`` and ``4.2.1``, a conflict constraint set by
an already loaded modulefile forbade the load of the conflicting
modulefile. This has been changed starting version ``4.2.2`` to better cope
with behaviors of previous Modules version: an evaluation attempt of the
conflicting modulefile is made to give it the opportunity to solve this
conflict by using **module unload** modulefile command.
.. _v42-prereq-constraints-consistency:
Modulefile prereq constraints consistency
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With the **prereq** modulefile command, a given modulefile can list the
other modulefiles it pre-requires. To load this modulefile, the modulefiles it
pre-requires must be loaded prior its own load.
This constraint was until now satisfied when loading the modulefile declaring
the **prereq** but, as for the declared **conflict**, it vanished as soon as
this modulefile was loaded. In the following example ``c`` modulefile declares
a prereq on ``a``:
.. parsed-literal::
:ps:`$` module load c
WARNING: c cannot be loaded due to missing prereq.
HINT: the following module must be loaded first: a
:ps:`$` module list
No Modulefiles Currently Loaded.
:ps:`$` module load a c
:ps:`$` module list
Currently Loaded Modulefiles:
1) a 2) c
:ps:`$` module unload a
:ps:`$` module list
Currently Loaded Modulefiles:
1) c
Consistency of the declared **prereq** is now ensured to satisfy this
constraint even after the load of the modulefile declaring it. This is
achieved, like for the conflict consistency, by keeping track of the prereq
constraints of the loaded modulefiles in an environment variable called
``MODULES_LMPREREQ``:
.. parsed-literal::
:ps:`$` module load a c
:ps:`$` module list
Currently Loaded Modulefiles:
1) a 2) c
:ps:`$` module unload a
ERROR: WARNING: a cannot be unloaded due to a prereq.
HINT: Might try "module unload c" first.
:ps:`$` module list
Currently Loaded Modulefiles:
1) a 2) c
.. _v42-by-passing-module-constraints:
By-passing module defined constraints
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ability to by-pass a **conflict** or a **prereq** constraint defined by
modulefiles is introduced with the ``--force`` command line switch (``-f`` for
short notation) for the **load**, **unload** and **switch** sub-commands.
With this new command line switch, a given modulefile is loaded even if it
conflicts with other loaded modulefiles or even if the modulefiles it
pre-requires are not loaded. Some example reusing the same modulefiles ``a``,
``b`` and ``c`` than above:
.. parsed-literal::
:ps:`$` module load b
:ps:`$` module load --force a
WARNING: a conflicts with b
:ps:`$` module list
Currently Loaded Modulefiles:
1) b 2) a
:ps:`$` module purge
:ps:`$` module load --force c
WARNING: c requires a loaded
:ps:`$` module list
Currently Loaded Modulefiles:
1) c
``--force`` also enables to unload a modulefile required by another loaded
modulefiles:
.. parsed-literal::
:ps:`$` module load a c
:ps:`$` module list
Currently Loaded Modulefiles:
1) a 2) c
:ps:`$` module unload --force a
WARNING: a is required by c
:ps:`$` module list
Currently Loaded Modulefiles:
1) c
In a situation where some of the loaded modulefiles have unsatisfied
constraints corresponding to the **prereq** and **conflict** they declare, the
**save** and **reload** sub-commands do not perform and return an error.
.. _v42-automated-module-handling-mode:
Automated module handling mode
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
An automatic management of the dependencies between modulefiles has been added
and it is called *automated module handling mode*. This new mode consists in
additional actions triggered when loading or unloading a modulefile to satisfy
the constraints it declares.
When loading a modulefile, following actions are triggered:
* Requirement Load (ReqLo): load of the modulefiles declared as a **prereq**
of the loading modulefile.
* Dependent Reload (DepRe): reload of the modulefiles declaring a **prereq**
onto loaded modulefile or declaring a **prereq** onto a modulefile part of
this reloading batch.
When unloading a modulefile, following actions are triggered:
* Dependent Unload (DepUn): unload of the modulefiles declaring a non-optional
**prereq** onto unloaded modulefile or declaring a non-optional **prereq**
onto a modulefile part of this unloading batch. A **prereq** modulefile is
considered optional if the **prereq** definition order is made of multiple
modulefiles and at least one alternative modulefile is loaded.
* Useless Requirement Unload (UReqUn): unload of the **prereq** modulefiles
that have been automatically loaded for either the unloaded modulefile, an
unloaded dependent modulefile or a modulefile part of this useless
requirement unloading batch. Modulefiles are added to this unloading batch
only if they are not required by any other loaded modulefiles.
``MODULES_LMNOTUASKED`` environment variable helps to keep track of these
automatically loaded modulefiles and to distinguish them from modulefiles
asked by user.
* Dependent Reload (DepRe): reload of the modulefiles declaring a **conflict**
or an optional **prereq** onto either the unloaded modulefile, an unloaded
dependent or an unloaded useless requirement or declaring a **prereq** onto
a modulefile part of this reloading batch.
In case a loaded modulefile has some of its declared constraints unsatisfied
(pre-required modulefile not loaded or conflicting modulefile loaded for
instance), this loaded modulefile is excluded from the automatic reload
actions described above.
For the specific case of the **switch** sub-command, where a modulefile is
unloaded to then load another modulefile. Dependent modulefiles to Unload are
merged into the Dependent modulefiles to Reload that are reloaded after the
load of the switched-to modulefile.
This automated module handling mode integrates concepts (like the Dependent
Reload mechanism) of the Flavours_ extension, which was designed for Modules
compatibility version. As a whole, automated module handling mode can be seen
as a generalization and as an expansion of the Flavours_ concepts.
.. _Flavours: https://sourceforge.net/projects/flavours/
This new feature can be controlled at build time with the
``--enable-auto-handling`` configure option. This default configuration can be
superseded at run-time with the ``MODULES_AUTO_HANDLING`` environment variable
or the command line switches ``--auto`` and ``--no-auto``.
By default, automated module handling mode is disabled and will stay so until
the next major release version (5.0) where it will be enabled by default. This
new feature is currently considered experimental and the set of triggered
actions will be refined over the next feature releases.
.. _v42-consistency-module-load-unload-commands:
Consistency of module load/unload commands in modulefile
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With the **module load** modulefile command, a given modulefile can
automatically load a modulefile it pre-requires. Similarly with the **module
unload** modulefile command, a given modulefile can automatically unload a
modulefile it conflicts with.
Both commands imply additional actions on the loaded environment (loading or
unloading extra modulefiles) that should cope with the constraints defined by
the loaded environment.
Additionally **module load** and **module unload** modulefile commands express
themselves constraints on loaded environment that should stay satisfied to
ensure consistency.
To ensure the consistency of **module load** modulefile command once the
modulefile defining it has been loaded, this command is assimilated to a
**prereq** command. Thus the defined constraint is recorded in the
``MODULES_LMPREREQ`` environment variable. Same approach is used for **module
unload** modulefile command which is assimilated to a **conflict** command.
Thus the defined constraint is recorded in the ``MODULES_LMCONFLICT``
environment variable.
To ensure the consistency of the loaded environment, the additional actions of
the **module load** and **module unload** modulefile commands have been
adapted in particular situations:
* When unloading modulefile, **module load** command will unload the
modulefile it targets only if no other loaded modulefile requires it and if
this target has not been explicitly loaded by user.
* When unloading modulefile, **module unload** command does nothing as the
relative conflict registered at load time ensure environment consistency and
will forbid conflicting modulefile load.
Please note that loading and unloading results may differ than from previous
Modules version now that consistency is checked:
* Modulefile targeted by a **module load** modulefile command may not be able
to load due to a registered conflict in the currently loaded environment.
Which in turn will break the load of the modulefile declaring the **module
load** command.
* Modulefile targeted by a **module unload** modulefile command may not be
able to unload due to a registered prereq in the loaded environment. Which
in turn will break the load of the modulefile declaring the **module
unload** command.
* If automated module handling mode is enabled, **module load** modulefile
command is interpreted when unloading modulefile as part of the Useless
Requirement Unload (UReqUn) mechanism not through modulefile evaluation.
As a consequence, an error occurring when unloading the modulefile targeted
by the **module load** command does not break the unload of the modulefile
declaring this command. Moreover unload of the **module load** targets is
done in the reverse loaded order, not in the **module load** command
definition order.
.. _v42-alias-symbolic-name-consistency:
Modulefile alias and symbolic modulefile name consistency
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With the **module-alias** and **module-version** modulefile commands,
alternative names can be given to a modulefile. When these names are used to
load for instance a modulefile, they are resolved to the modulefile they
target which is then processed for the load action.
Until now, the alias and symbolic version names were correctly resolved for
the **load** and **unload** actions and also for the querying sub-commands
(like **avail** or **whatis**). However this alternative name information
vanishes once the modulefile it resolves to is loaded. As a consequence there
was no consistency over these alternative designations. In the following
example ``f`` modulefile declares a conflict on ``e`` alias which resolves to
``d`` modulefile:
.. parsed-literal::
:ps:`$` module load e
:ps:`$` module list
Currently Loaded Modulefiles:
1) d
:ps:`$` module info-loaded e
:ps:`$` module load f
:ps:`$` module list
Currently Loaded Modulefiles:
1) d 2) f
Consistency of the alternative names set on a modulefile with **module-alias**
and **module-version** commands is now ensured to enable modulefile commands
**prereq**, **conflict**, **is-loaded** and **module-info loaded** using these
alternative designations as argument. This consistency is achieved, like for
the conflict and prereq consistencies, by keeping track of the alternative
names of the loaded modulefiles in an environment variable called
``MODULES_LMALTNAME``:
.. parsed-literal::
:ps:`$` module load e
:ps:`$` module list
Currently Loaded Modulefiles:
1) d
:ps:`$` module info-loaded e
d
:ps:`$` module load f
WARNING: f cannot be loaded due to a conflict.
HINT: Might try "module unload e" first.
:ps:`$` module list
Currently Loaded Modulefiles:
1) d
.. _v42-variable-change-through-modulefile-evaluation:
Environment variable change through modulefile evaluation context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
All environment variable edition commands (``setenv``, ``unsetenv``,
``append-path``, ``prepend-path`` and ``remove-path``) have been updated to:
* Reflect environment variable value change on the environment of the current
modulefile Tcl interpreter. So using ``$env(VAR)`` will return the currently
defined value for environment variable ``VAR``, not the one found prior
modulefile evaluation.
* Clear environment variable content instead of unsetting it on the
environment of the current modulefile Tcl interpreter to avoid raising
error about accessing an undefined element in ``$env()``. Code is still
produced to purely unset environment variable in shell environment.
Exception is made for the ``whatis`` evaluation mode: environment variables
targeted by variable edition commands are not set to the defined value in the
evaluation context during this ``whatis`` evaluation. These variables are
only initialized to an empty value if undefined. This exception is made to
save performances on this global evaluation mode.
.. _v42-versioned-magic-cookie:
Express Modules compatibility of modulefile with versioned magic cookie
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Any modulefile should start with the ``#%Module`` file signature (also called
the Modules magic cookie) and sometimes a version number may be placed right
after this string. Until now this version number corresponded to a modulefile
format version but it was never checked.
Starting with this new Modules release, this version number reflects the
minimum version of Modules required to interpret the modulefile. If the
version number is set along the magic cookie string it is now checked and the
modulefile is interpreted only if Modules version is greater or equal to this
version number. For instance, if a modulefile begins with the ``#%Module4.3``
string, it can only be evaluated by Modules version 4.3 and above. Elsewhere
the modulefile is ignored like files without the ``#%Module`` magic cookie
set.
.. _v42-module-message-report:
Improved module message report
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Module sub-commands like ``load``, ``unload`` or ``switch``, may perform
multiple load or unload modulefile evaluations in a row. Also these kind of
evaluation modes may sometimes trigger additional load or unload evaluations,
when for instance a modulefile contains a ``module load`` command.
To improve the readability of the module messages produced relatively to
a load or an unload evaluation, these messages are now stacked under a
*Loading* or an *Unloading* message block that gathers all the messages
produced for a given modulefile evaluation:
.. parsed-literal::
:ps:`$` module load --no-auto foo
Loading foo/1.2
ERROR: foo/1.2 cannot be loaded due to missing prereq.
HINT: the following module must be loaded first: bar/4.5
In addition, foreground ``load``, ``unload``, ``switch`` and ``restore``
actions (i.e., asked on the command-line) now report a summary of the
additional load and unload evaluations that were eventually triggered in
the process:
.. parsed-literal::
:ps:`$` module load --auto foo
Loading foo/1.2
Loading requirement: bar/4.5
New modulefile commands
^^^^^^^^^^^^^^^^^^^^^^^
2 new modulefile Tcl commands have been introduced:
* **set-function**: define a shell function on sh-kind and fish shells.
* **unset-function**: unset a shell function on sh-kind and fish shells.
v4.1
----
This new version is backward-compatible with previous version 4 releases. It
fixes bugs but also introduces new functionalities that are described in this
section. See the :ref:`4.1 release notes<4.1 release notes>` for a complete
list of the changes between Modules v4.0 and v4.1.
.. _Virtual modules:
Virtual modules
^^^^^^^^^^^^^^^
A virtual module stands for a module name associated to a modulefile. The
modulefile is the script interpreted when loading or unloading the virtual
module which appears or can be found with its virtual name.
The **module-virtual** modulefile command is introduced to give the ability
to define these virtual modules. This new command takes a module name as
first argument and a modulefile location as second argument::
module-virtual app/1.2.3 /path/to/virtualmod/app
With this feature it is now possible to dynamically define modulefiles
depending on the context.
Extend module command with site-specific Tcl code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``module`` command can now be extended with site-specific Tcl
code. ``modulecmd.tcl`` now looks at a **siteconfig.tcl** file in an
``etcdir`` defined at configure time (by default ``$prefix/etc``). If
it finds this Tcl script file, it is sourced within ``modulecmd.tcl`` at the
beginning of the main procedure code.
``siteconfig.tcl`` enables to supersede any global variable or procedure
definitions made in ``modulecmd.tcl`` with site-specific code. A module
sub-command can for instance be redefined to make it fit local needs
without having to touch the main ``modulecmd.tcl``.
.. _Quarantine mechanism:
Quarantine mechanism to protect module execution
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To protect the module command run-time environment from side effect
coming from the current environment definition a quarantine mechanism
is introduced. This mechanism, sets within module function definition
and shell initialization script, modifies the ``modulecmd.tcl`` run-time
environment to sanitize it.
The mechanism is piloted by environment variables. First of all
``MODULES_RUN_QUARANTINE``, a space-separated list of environment variable
names. Every variable found in ``MODULES_RUN_QUARANTINE`` will be set in
quarantine during the ``modulecmd.tcl`` run-time. Their value will be set
empty or set to the value of the corresponding ``MODULES_RUNENV_<VAR>``
environment variable if defined. Once ``modulecmd.tcl`` is started it
restores quarantine variables to their original values.
``MODULES_RUN_QUARANTINE`` and ``MODULES_RUNENV_<VAR>`` environment variables
can be defined at build time by using the following configure option::
--with-quarantine-vars='VARNAME[=VALUE] ...'
Quarantine mechanism is available for all supported shells except ``csh``
and ``tcsh``.
Pager support
^^^^^^^^^^^^^
The informational messages Modules sends on the *stderr* channel may
sometimes be quite long. This is especially the case for the avail
sub-command when hundreds of modulefiles are handled. To improve the
readability of those messages, *stderr* output can now be piped into a
paging command.
This new feature can be controlled at build time with the ``--with-pager``
and ``--with-pager-opts`` configure options. Default pager command is set
to ``less`` and its relative options are by default ``-eFKRX``. Default
configuration can be supersedes at run-time with ``MODULES_PAGER`` environment
variables or command-line switches (``--no-pager``, ``--paginate``).
.. warning:: On version ``4.1.0``, the ``PAGER`` environment variable was
taken in consideration to supersede pager configuration at run-time. Since
version ``4.1.1``, ``PAGER`` environment variable is ignored to avoid side
effects coming from the system general pager configuration.
Module function to return value in scripting languages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
On Tcl, Perl, Python, Ruby, CMake and R scripting shells, module function
was not returning value and until now an occurred error led to raising a
fatal exception.
To make ``module`` function more friendly to use on these scripting shells
it now returns a value. False in case of error, true if everything goes well.
As a consequence, returned value of a module sub-command can be checked. For
instance in Python::
if module('load', 'foo'):
# success
else:
# failure
New modulefile commands
^^^^^^^^^^^^^^^^^^^^^^^
4 new modulefile Tcl commands have been introduced:
* **is-saved**: returns true or false whether a collection, corresponding to
currently set collection target, exists or not.
* **is-used**: returns true or false whether a given directory is currently
enabled in ``MODULEPATH``.
* **is-avail**: returns true or false whether a given modulefile exists in
currently enabled module paths.
* **module-info loaded**: returns the exact name of the modulefile currently
loaded corresponding to the name argument.
Multiple collections, paths or modulefiles can be passed respectively to
``is-saved``, ``is-used`` and ``is-avail`` in which case true is returned if
at least one argument matches condition (acts as a OR boolean operation). No
argument may be passed to ``is-loaded``, ``is-saved`` and ``is-used``
commands to return if anything is respectively loaded, saved or used.
If no loaded modulefile matches the ``module-info loaded`` query, an empty
string is returned.
New module sub-commands
^^^^^^^^^^^^^^^^^^^^^^^
Modulefile-specific commands are sometimes wished to be used outside of a
modulefile context. Especially for the commands managing path variables
or commands querying current environment context. So the following
modulefile-specific commands have been made reachable as module sub-commands
with same arguments and properties as if called from within a modulefile:
* **append-path**
* **prepend-path**
* **remove-path**
* **is-loaded**
* **info-loaded**
The ``is-loaded`` sub-command returns a boolean value. Small Python example::
if module('is-loaded', 'app'):
print 'app is loaded'
else:
print 'app not loaded'
``info-loaded`` returns a string value and is the sub-command counterpart
of the ``module-info loaded`` modulefile command:
.. parsed-literal::
:ps:`$` module load app/0.8
:ps:`$` module info-loaded app
app/0.8
v4.0
----
Major evolution occurs with this v4.0 release as the traditional *module*
command implemented in C is replaced by the native Tcl version. This full
Tcl rewrite of the Modules package was started in 2002 and has now reached
maturity to take over the binary version. This flavor change enables to
refine and push forward the *module* concept.
This document provides an outlook of what is changing when migrating from
v3.2 to v4.0 by first describing the introduced new features. Both v3.2
and v4.0 are quite similar and transition to the new major version should
be smooth. Slights differences may be noticed in a few use-cases. So the
second part of the document will help to learn about them by listing the
features that have been discontinued in this new major release or the
features where a behavior change can be noticed.
New features
^^^^^^^^^^^^
On its overall this major release brings a lot more robustness to the
*module* command with now more than 4000 non-regression tests crafted
to ensure correct operations over the time. This version 4.0 also comes
with fair amount of improved functionalities. The major new features are
described in this section.
Additional shells supported
"""""""""""""""""""""""""""
Modules v4 introduces support for **fish**, **lisp**, **tcl** and **R**
code output.
Non-zero exit code in case of error
"""""""""""""""""""""""""""""""""""
All module sub-commands will now return a non-zero exit code in case of error
whereas Modules v3.2 always returned zero exit code even if issue occurred.
Output redirect
"""""""""""""""
Traditionally the *module* command output text that should be seen by the
user on *stderr* since shell commands are output to *stdout* to change
shell's environment. Now on *sh*, *bash*, *ksh*, *zsh* and *fish* shells,
output text is redirected to *stdout* after shell command evaluation if
shell is in interactive mode.
Filtering avail output
""""""""""""""""""""""
Results obtained from the **avail** sub-command can now be filtered to only
get the default version of each module name with use of the **--default**
or **-d** command line switch. Default version is either the explicitly
set default version or the highest numerically sorted modulefile or module
alias if no default version set.
It is also possible to filter results to only get the highest numerically
sorted version of each module name with use of the **--latest** or **-L**
command line switch.
Extended support for module alias and symbolic version
""""""""""""""""""""""""""""""""""""""""""""""""""""""
Module aliases are now included in the result of the **avail**, **whatis**
and **apropos** sub-commands. They are displayed in the module path
section where they are defined or in a *global/user modulerc* section for
aliases set in user's or global ``modulerc`` file. A **@** symbol is added
in parenthesis next to their name to distinguish them from modulefiles.
Search may be performed with an alias or a symbolic version-name passed
as argument on **avail**, **whatis** and **apropos** sub-commands.
Modules v4 resolves module alias or symbolic version passed to **unload**
command to then remove the loaded modulefile pointed by the mentioned
alias or symbolic version.
A symbolic version sets on a module alias is now propagated toward the
resolution path to also apply to the relative modulefile if it still
correspond to the same module name.
Hiding modulefiles
""""""""""""""""""
Visibility of modulefiles can be adapted by use of file mode bits or file
ownership. If a modulefile should only be used by a given subset of persons,
its mode an ownership can be tailored to provide read rights to this group of
people only. In this situation, module only reports the modulefile, during an
**avail** command for instance, if this modulefile can be read by the current
user.
These hidden modulefiles are simply ignored when walking through the
modulepath content. Access issues (permission denied) occur only when trying
to access directly a hidden modulefile or when accessing a symbol or an alias
targeting a hidden modulefile.
Improved modulefiles location
"""""""""""""""""""""""""""""
When looking for an implicit default in a modulefile directory, aliases
are now taken into account in addition to modulefiles and directories to
determine the highest numerically sorted element.
Modules v4 resolves module alias or symbolic version when it points to a
modulefile located in another modulepath.
Access issues (permission denied) are now distinguished from find issues
(cannot locate) when trying to access directly a directory or a modulefile
as done on **load**, **display** or **whatis** commands. In addition,
on this kind of access not readable ``.modulerc`` or ``.version`` files are
ignored rather producing a missing magic cookie error.
Module collection
"""""""""""""""""
Modules v4 introduces support for module *collections*. Collections
describe a sequence of **module use** then **module load** commands that
are interpreted by Modules to set the user environment as described by this
sequence. When a collection is activated, with the **restore** sub-command,
modulepaths and loaded modules are unused or unloaded if they are not part
or if they are not ordered the same way as in the collection.
Collections are generated by the **save** sub-command that dumps the current
user environment state in terms of modulepaths and loaded modules. By default
collections are saved under the ``$HOME/.module`` directory. Collections
can be listed with **savelist** sub-command, displayed with **saveshow**
and removed with **saverm**.
Collections may be valid for a given target if they are suffixed. In this
case these collections can only be restored if their suffix correspond
to the current value of the ``MODULES_COLLECTION_TARGET`` environment
variable. Saving collection registers the target footprint by suffixing
the collection filename with ``.$MODULES_COLLECTION_TARGET``.
Path variable element counter
"""""""""""""""""""""""""""""
Modules 4 provides path element counting feature which increases a
reference counter each time a given path entry is added to a given
path-like environment variable. As consequence a path entry element is
removed from a path-like variable only if the related element counter is
equal to 1. If this counter is greater than 1, path element is kept in
variable and reference counter is decreased by 1.
This feature allows shared usage of particular path elements. For instance,
modulefiles can append ``/usr/local/bin`` to ``PATH``, which is not unloaded
until all the modulefiles that loaded it unload too.
Optimized I/O operations
""""""""""""""""""""""""
Substantial work has been done to reduce the number of I/O operations
done during global modulefile analysis commands like **avail** or
**whatis**. ``stat``, ``open``, ``read`` and ``close`` I/O operations have
been cut down to the minimum required when walking through the modulepath
directories to check if files are modulefiles or to resolve module aliases.
Interpretation of modulefiles and modulerc are handled by the minimum
required Tcl interpreters. Which means a configured Tcl interpreter is
reused as much as possible between each modulefile interpretation or
between each modulerc interpretation.
.. _Sourcing modulefiles:
Sourcing modulefiles
""""""""""""""""""""
Modules 4 introduces the possibility to **source** a modulefile rather
loading it. When it is sourced, a modulefile is interpreted into the shell
environment but then it is not marked loaded in shell environment which
differ from **load** sub-command.
This functionality is used in shell initialization scripts once **module**
function is defined. There the ``etc/modulerc`` modulefile is sourced to
setup the initial state of the environment, composed of *module use*
and *module load* commands.
Removed features and substantial behavior changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Following sections provide list of Modules v3.2 features that are
discontinued on Modules v4 or features with a substantial behavior change
that should be taken in consideration when migrating to v4.
Package initialization
""""""""""""""""""""""
``MODULESBEGINENV`` environment snapshot functionality is not supported
anymore on Modules v4. Modules collection mechanism should be used instead to
**save** and **restore** sets of enabled modulepaths and loaded modulefiles.
Command line switches
"""""""""""""""""""""
Some command line switches are not supported anymore on v4.0. When still
using them, a warning message is displayed and the command is ran with these
unsupported switches ignored. Following command line switches are concerned:
* ``--force``, ``-f``
* ``--human``
* ``--verbose``, ``-v``
* ``--silent``, ``-s``
* ``--create``, ``-c``
* ``--icase``, ``-i``
* ``--userlvl`` lvl, ``-u`` lvl
Module sub-commands
"""""""""""""""""""
During an **help** sub-command, Modules v4 does not redirect output made
on stdout in *ModulesHelp* Tcl procedure to stderr. Moreover when running
**help**, version 4 interprets all the content of the modulefile, then call
the *ModulesHelp* procedure if it exists, whereas Modules 3.2 only interprets
the *ModulesHelp* procedure and not the rest of the modulefile content.
When **load** is asked on an already loaded modulefiles, Modules v4 ignores
this new load order whereas v3.2 refreshed shell alias definitions found
in this modulefile.
When **switching** on version 4 an *old* modulefile by a *new* one,
no error is raised if *old* modulefile is not currently loaded. In this
situation v3.2 threw an error and abort switch action. Additionally on
**switch** sub-command, *new* modulefile does not keep the position held
by *old* modulefile in loaded modules list on Modules v4 as it was the
case on v3.2. Same goes for path-like environment variables: replaced
path component is appended to the end or prepended to the beginning of
the relative path-like variable, not appended or prepended relatively to
the position hold by the swapped path component.
During a **switch** command, version 4 interprets the swapped-out modulefile
in *unload* mode, so the sub-modulefiles loaded, with ``module load``
order in the swapped-out modulefile are also unloaded during the switch.
Modules 4 provides path element counting feature which increases a reference
counter each time a given path entry is added to a given environment
variable. This feature also applies to the ``MODULEPATH`` environment
variable. As consequence a modulepath entry element is removed from the
modulepath enabled list only if the related element counter is equal to 1.
When **unusing** a modulepath if its reference counter is greater than 1,
modulepath is kept enabled and reference counter is decreased by 1.
On Modules 3.2 paths composing the ``MODULEPATH`` environment variable
may contain reference to environment variable. These variable references
are resolved dynamically when ``MODULEPATH`` is looked at during module
sub-command action. This feature has been discontinued on Modules v4.
Following Modules sub-commands are not supported anymore on v4.0:
* ``clear``
* ``update``
Modules specific Tcl commands
"""""""""""""""""""""""""""""
Modules v4 provides path element counting feature which increases a reference
counter each time a given path entry is added to a given environment
variable. As a consequence a path entry element is not always removed
from a path-like variable when calling to ``remove-path`` or calling to
``append-path`` or ``append-path`` at unloading time. The path element is
removed only if its related element counter is equal to 1. If this counter
is greater than 1, path element is kept in variable and reference counter
is decreased by 1.
On Modules v4, **module-info mode** returns during an **unload** sub-command
the ``unload`` value instead of ``remove`` on Modules v3.2. However if *mode*
is tested against ``remove`` value, true will be returned. During a **switch**
sub-command on Modules v4, ``unload`` then ``load`` is returned instead of
``switch1`` then ``switch2`` then ``switch3`` on Modules v3.2. However if
*mode* is tested against ``switch`` value, true will be returned.
When using **set-alias**, Modules v3.2 defines a shell function when
variables are in use in alias value on Bourne shell derivatives, Modules
4 always defines a shell alias never a shell function.
Some Modules specific Tcl commands are not supported anymore on v4.0. When
still using them, a warning message is displayed and these unsupported Tcl
commands are ignored. Following Modules specific Tcl commands are concerned:
* ``module-info flags``
* ``module-info trace``
* ``module-info tracepat``
* ``module-info user``
* ``module-log``
* ``module-trace``
* ``module-user``
* ``module-verbosity``
Further reading
^^^^^^^^^^^^^^^
To get a complete list of the differences between Modules v3.2 and v4,
please read the :ref:`changes` document.
A significant number of issues reported for v3.2 have been closed on v4.
List of these closed issues can be found at:
https://github.com/envmodules/modules/milestone/1?closed=1
|