summaryrefslogtreecommitdiffstats
path: root/release_docs
Commit message (Expand)AuthorAgeFilesLines
* [svn-r5012] Purpose:Binh-Minh Ribler2002-02-261-0/+116
* [svn-r4965] Purpose:Quincey Koziol2002-02-141-0/+3
* [svn-r4947] Purpose:Quincey Koziol2002-02-131-0/+3
* [svn-r4930] Snapshot version 1.5 release 20HDF Admin2002-02-091-1/+1
* [svn-r4913] Purpose:Quincey Koziol2002-02-071-0/+3
* [svn-r4891] Purpose:Quincey Koziol2002-01-311-0/+3
* [svn-r4864] Snapshot version 1.5 release 19HDF Admin2002-01-261-1/+1
* [svn-r4851] Purpose:Quincey Koziol2002-01-231-0/+2
* [svn-r4812] Snapshot version 1.5 release 18HDF Admin2002-01-111-1/+1
* [svn-r4789] Purpose:Quincey Koziol2002-01-071-0/+3
* [svn-r4780] Snapshot version 1.5 release 17HDF Admin2002-01-051-1/+1
* [svn-r4778] Purpose:Quincey Koziol2002-01-041-0/+2
* [svn-r4767] Updated with the new feature of enable-threadsafe.Albert Cheng2002-01-021-0/+2
* [svn-r4758] Updated with the information of the retirement of DPSS VFD.Albert Cheng2001-12-301-0/+2
* [svn-r4753] Bill Wendling2001-12-212-17/+19
* [svn-r4747] Purpose:Quincey Koziol2001-12-201-0/+5
* [svn-r4735] Purpose:Quincey Koziol2001-12-181-0/+2
* [svn-r4716] Raymond Lu2001-12-131-0/+8
* [svn-r4706] Purpose:Quincey Koziol2001-12-121-0/+2
* [svn-r4695] Purpose:Quincey Koziol2001-12-111-0/+2
* [svn-r4693] Purpose:Quincey Koziol2001-12-111-0/+3
* [svn-r4680] Purpose:Quincey Koziol2001-12-061-0/+2
* [svn-r4679] Snapshot version 1.5 release 16Albert Cheng2001-12-061-1/+1
* [svn-r4617] Purpose:Quincey Koziol2001-11-201-0/+2
* [svn-r4601] Purpose:Quincey Koziol2001-11-121-0/+2
* [svn-r4598] Snapshot version 1.5 release 15HDF Admin2001-11-101-1/+1
* [svn-r4588] Purpose:Quincey Koziol2001-11-021-0/+2
* [svn-r4578] Snapshot version 1.5 release 14HDF Admin2001-10-271-1/+1
* [svn-r4562] Purpose:Quincey Koziol2001-10-201-0/+5
* [svn-r4540] Snapshot version 1.5 release 13HDF Admin2001-10-131-1/+1
* [svn-r4529] Snapshot version 1.5 release 12HDF Admin2001-10-061-1/+1
* [svn-r4523] MuQun Yang2001-10-051-17/+6
* [svn-r4519] Updated with the change in configure to require compress2 for theAlbert Cheng2001-10-041-0/+5
* [svn-r4507] Purpose:Quincey Koziol2001-10-021-0/+2
* [svn-r4505] Purpose:Quincey Koziol2001-10-011-0/+2
* [svn-r4501] Snapshot version 1.5 release 11HDF Admin2001-09-301-1/+1
* [svn-r4493] Purpose:Quincey Koziol2001-09-281-0/+4
* [svn-r4490] Purpose:Quincey Koziol2001-09-281-0/+2
* [svn-r4482] Purpose:Quincey Koziol2001-09-261-0/+5
* [svn-r4476] Updated with changes of H5Pset_split and the new test of configure.Albert Cheng2001-09-261-1/+4
* [svn-r4471] Bill Wendling2001-09-241-10/+11
* [svn-r4465] MuQun Yang2001-09-211-2/+3
* [svn-r4439] Bill Wendling2001-09-131-0/+3
* [svn-r4414] Bill Wendling2001-08-271-31/+43
* [svn-r4347] Purpose:Albert Cheng2001-08-141-0/+2
* [svn-r4344] Purpose:Albert Cheng2001-08-141-0/+25
* [svn-r4343] Purpose:Albert Cheng2001-08-141-0/+15
* [svn-r4312] Purpose:Quincey Koziol2001-08-061-57/+7
* [svn-r4311] Snapshot version 1.5 release 10HDF Admin2001-08-041-1/+1
* [svn-r4270] Snapshot version 1.5 release 9HDF Admin2001-07-281-1/+1
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 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271
/*
 * Copyright (C) 1998-2001 NCSA
 *                         All rights reserved.
 *
 * Programmer:  Quincey Koziol <koziol@ncsa.uiuc.edu>
 *              Thursday, June 18, 1998
 *
 * Purpose:	Hyperslab selection data space I/O functions.
 */

#define H5S_PACKAGE		/*suppress error about including H5Spkg	  */

#include "H5private.h"
#include "H5Dprivate.h"
#include "H5Eprivate.h"
#include "H5Fprivate.h"
#include "H5FLprivate.h"	/*Free Lists	  */
#include "H5Iprivate.h"
#include "H5MMprivate.h"
#include "H5Pprivate.h"
#include "H5Spkg.h"
#include "H5Vprivate.h"

/* Interface initialization */
#define PABLO_MASK      H5Shyper_mask
#define INTERFACE_INIT  NULL
static intn             interface_initialize_g = 0;

/* Local datatypes */
/* Parameter block for H5S_hyper_fread, H5S_hyper_fwrite, H5S_hyper_mread & H5S_hyper_mwrite */
typedef struct {
    H5F_t *f;
    const struct H5O_layout_t *layout;
    const struct H5O_pline_t *pline;
    const struct H5O_fill_t *fill;
    const struct H5O_efl_t *efl;
    size_t elmt_size;
    const H5S_t *space;
    H5S_sel_iter_t *iter;
	hsize_t nelmts;
    hid_t dxpl_id;
    const void *src;
    void *dst;
    hsize_t	mem_size[H5O_LAYOUT_NDIMS];
    hssize_t offset[H5O_LAYOUT_NDIMS];
    hsize_t	hsize[H5O_LAYOUT_NDIMS];
} H5S_hyper_io_info_t;

/* Parameter block for H5S_hyper_select_iter_mem */
typedef struct {
    hid_t dt;
    size_t elem_size;
    const H5S_t *space;
    H5S_sel_iter_t *iter;
    void *src;
    hsize_t	mem_size[H5O_LAYOUT_NDIMS];
    hssize_t mem_offset[H5O_LAYOUT_NDIMS];
    H5D_operator_t op;
    void * op_data;
} H5S_hyper_iter_info_t;

/* Static function prototypes */
static H5S_hyper_region_t * H5S_hyper_get_regions (size_t *num_regions,
               uintn rank, uintn dim, size_t bound_count,
               H5S_hyper_bound_t **lo_bounds, hssize_t *pos, hssize_t *offset);
static hsize_t H5S_hyper_fread (intn dim, H5S_hyper_io_info_t *io_info);
static hsize_t H5S_hyper_fread_opt (H5F_t *f, const struct H5O_layout_t *layout,
		 const struct H5O_pline_t *pline, const struct H5O_fill_t *fill,
		 const struct H5O_efl_t *efl, size_t elmt_size,
		 const H5S_t *file_space, H5S_sel_iter_t *file_iter,
		 hsize_t nelmts, hid_t dxpl_id, void *_buf/*out*/);
static hsize_t H5S_hyper_fwrite (intn dim,
				H5S_hyper_io_info_t *io_info);
static hsize_t H5S_hyper_fwrite_opt (H5F_t *f, const struct H5O_layout_t *layout,
		 const struct H5O_pline_t *pline, const struct H5O_fill_t *fill,
		 const struct H5O_efl_t *efl, size_t elmt_size,
		 const H5S_t *file_space, H5S_sel_iter_t *file_iter,
		 hsize_t nelmts, hid_t dxpl_id, const void *_buf);
static herr_t H5S_hyper_init (const H5S_t *space, H5S_sel_iter_t *iter);
static hsize_t H5S_hyper_favail (const H5S_t *space, const H5S_sel_iter_t *iter,
				hsize_t max);
static hsize_t H5S_hyper_fgath (H5F_t *f, const struct H5O_layout_t *layout,
			       const struct H5O_pline_t *pline,
			       const struct H5O_fill_t *fill,
			       const struct H5O_efl_t *efl, size_t elmt_size,
			       const H5S_t *file_space,
			       H5S_sel_iter_t *file_iter, hsize_t nelmts,
			       hid_t dxpl_id, void *buf/*out*/);
static herr_t H5S_hyper_fscat (H5F_t *f, const struct H5O_layout_t *layout,
			       const struct H5O_pline_t *pline,
			       const struct H5O_fill_t *fill,
			       const struct H5O_efl_t *efl, size_t elmt_size,
			       const H5S_t *file_space,
			       H5S_sel_iter_t *file_iter, hsize_t nelmts,
			       hid_t dxpl_id, const void *buf);
static hsize_t H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info);
static hsize_t H5S_hyper_mread_opt (const void *_buf, size_t elmt_size,
		 const H5S_t *mem_space, H5S_sel_iter_t *mem_iter,
		 hsize_t nelmts, void *_tconv_buf/*out*/);
static hsize_t H5S_hyper_mgath (const void *_buf, size_t elmt_size,
			       const H5S_t *mem_space,
			       H5S_sel_iter_t *mem_iter, hsize_t nelmts,
			       void *_tconv_buf/*out*/);
static size_t H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info);
static hsize_t H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size,
		 const H5S_t *mem_space, H5S_sel_iter_t *mem_iter,
		 hsize_t nelmts, void *_buf/*out*/);
static herr_t H5S_hyper_mscat (const void *_tconv_buf, size_t elmt_size,
			       const H5S_t *mem_space,
			       H5S_sel_iter_t *mem_iter, hsize_t nelmts,
			       void *_buf/*out*/);

const H5S_fconv_t	H5S_HYPER_FCONV[1] = {{
    "hslab",	 				/*name			*/
    H5S_SEL_HYPERSLABS,				/*selection type	*/
    H5S_hyper_init,				/*initialize		*/
    H5S_hyper_favail,				/*available		*/
    H5S_hyper_fgath,				/*gather		*/
    H5S_hyper_fscat,				/*scatter		*/
}};

const H5S_mconv_t	H5S_HYPER_MCONV[1] = {{
    "hslab",					/*name			*/
    H5S_SEL_HYPERSLABS,				/*selection type	*/
    H5S_hyper_init, 				/*initialize		*/
    H5S_hyper_mgath,				/*gather		*/
    H5S_hyper_mscat,				/*scatter		*/
}};

/* Array for use with I/O algorithms which frequently need array of zeros */
static const hssize_t	zero[H5O_LAYOUT_NDIMS]={0};		/* Array of zeros */

/* Declare a free list to manage the H5S_hyper_node_t struct */
H5FL_DEFINE_STATIC(H5S_hyper_node_t);

/* Declare a free list to manage the H5S_hyper_list_t struct */
H5FL_DEFINE_STATIC(H5S_hyper_list_t);

/* Declare a free list to manage arrays of size_t */
H5FL_ARR_DEFINE_STATIC(size_t,-1);

/* Declare a free list to manage arrays of hsize_t */
H5FL_ARR_DEFINE_STATIC(hsize_t,-1);

typedef H5S_hyper_bound_t *H5S_hyper_bound_ptr_t;
/* Declare a free list to manage arrays of H5S_hyper_bound_ptr_t */
H5FL_ARR_DEFINE_STATIC(H5S_hyper_bound_ptr_t,H5S_MAX_RANK);

/* Declare a free list to manage arrays of H5S_hyper_dim_t */
H5FL_ARR_DEFINE_STATIC(H5S_hyper_dim_t,H5S_MAX_RANK);

/* Declare a free list to manage arrays of H5S_hyper_bound_t */
H5FL_ARR_DEFINE_STATIC(H5S_hyper_bound_t,-1);

/* Declare a free list to manage arrays of H5S_hyper_region_t */
H5FL_ARR_DEFINE_STATIC(H5S_hyper_region_t,-1);

/* Declare a free list to manage blocks of hyperslab data */
H5FL_BLK_DEFINE_STATIC(hyper_block);


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_init
 *
 * Purpose:	Initializes iteration information for hyperslab selection.
 *
 * Return:	non-negative on success, negative on failure.
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5S_hyper_init (const H5S_t *space, H5S_sel_iter_t *sel_iter)
{
    FUNC_ENTER (H5S_hyper_init, FAIL);

    /* Check args */
    assert (space && H5S_SEL_HYPERSLABS==space->select.type);
    assert (sel_iter);

    /* Initialize the number of points to iterate over */
    sel_iter->hyp.elmt_left=space->select.num_elem;

    /* Allocate the position & initialize to invalid location */
    sel_iter->hyp.pos = H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0);
    sel_iter->hyp.pos[0]=(-1);
    H5V_array_fill(sel_iter->hyp.pos, sel_iter->hyp.pos, sizeof(hssize_t),
		   space->extent.u.simple.rank);
    
    FUNC_LEAVE (SUCCEED);
}   /* H5S_hyper_init() */

/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_favail
 *
 * Purpose:	Figure out the optimal number of elements to transfer to/from the file
 *
 * Return:	non-negative number of elements on success, zero on failure
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_favail (const H5S_t UNUSED *space,
		  const H5S_sel_iter_t *sel_iter, hsize_t max)
{
    FUNC_ENTER (H5S_hyper_favail, 0);

    /* Check args */
    assert (space && H5S_SEL_HYPERSLABS==space->select.type);
    assert (sel_iter);

#ifdef QAK
    printf("%s: sel_iter->hyp.elmt_left=%u, max=%u\n",FUNC,(unsigned)sel_iter->hyp.elmt_left,(unsigned)max);
#endif /* QAK */
    FUNC_LEAVE (MIN(sel_iter->hyp.elmt_left,max));
}   /* H5S_hyper_favail() */

/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_compare_regions
 *
 * Purpose:	Compares two regions for equality (regions must not overlap!)
 *
 * Return:	an integer less than, equal to, or greater than zero if the
 *		first region is considered to be respectively less than,
 *		equal to, or greater than the second
 *
 * Programmer:	Quincey Koziol
 *              Friday, July 17, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
int
H5S_hyper_compare_regions (const void *r1, const void *r2)
{
    if (((const H5S_hyper_region_t *)r1)->start < ((const H5S_hyper_region_t *)r2)->start)
        return(-1);
    else if (((const H5S_hyper_region_t *)r1)->start > ((const H5S_hyper_region_t *)r2)->start)
        return(1);
    else
        return(0);
}   /* end H5S_hyper_compare_regions */

/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_get_regions
 *
 * Purpose:	Builds a sorted array of the overlaps in a dimension
 *
 * Return:	Success:	Pointer to valid array (num_regions parameter
 *				set to array size)
 *
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Monday, June 29, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static H5S_hyper_region_t *
H5S_hyper_get_regions (size_t *num_regions, uintn rank, uintn dim,
    size_t bound_count, H5S_hyper_bound_t **lo_bounds, hssize_t *pos,
   hssize_t *offset)
{
    H5S_hyper_region_t *ret_value=NULL;	/* Pointer to array of regions to return */
    H5S_hyper_region_t *reg=NULL;	    /* Pointer to array of regions */
    H5S_hyper_bound_t *lo_bound_dim;    /* Pointer to the boundary nodes for a given dimension */
    H5S_hyper_node_t *node;             /* Region node for a given boundary */
    hssize_t *node_start,*node_end;     /* Extra pointers to node's start & end arrays */
    hssize_t *tmp_pos,*tmp_off;         /* Extra pointers into the position and offset arrays */
    hssize_t pos_dim,off_dim;           /* The position & offset in the dimension passed in */
    size_t num_reg=0;                   /* Number of regions in array */
    intn curr_reg=-1;                   /* The current region we are working with */
    intn temp_dim;                      /* Temporary dim. holder */
    size_t i;                           /* Counters */

    FUNC_ENTER (H5S_hyper_get_regions, NULL);
    
    assert(num_regions);
    assert(lo_bounds);
    assert(pos);

#ifdef QAK
    printf("%s: check 1.0, rank=%u, dim=%d\n",FUNC,rank,dim);
    for(i=0; i<rank; i++)
        printf("%s: %d - pos=%d, offset=%d\n",FUNC,i,(int)pos[i],offset!=NULL ? (int)offset[i] : 0);
#endif /* QAK */

    /* Iterate over the blocks which fit the position, or all of the blocks, if pos[dim]==-1 */
    lo_bound_dim=lo_bounds[dim];
    pos_dim=pos[dim];
    off_dim=offset[dim];
#ifdef QAK
    printf("%s: check 1.1, bound_count=%d, pos_dim=%d\n",FUNC,bound_count,(int)pos_dim);
#endif /* QAK */

    for(i=0; i<bound_count; i++,lo_bound_dim++) {
#ifdef QAK
    printf("%s: check 1.2, i=%d, num_reg=%d, curr_reg=%d\n",FUNC,(int)i,(int)num_reg,(int)curr_reg);
    printf("%s: check 1.2.1, lo_bound_dim->bound=%d\n",FUNC,(int)lo_bound_dim->bound);
#endif /* QAK */
        /* Check if each boundary overlaps in the higher dimensions */
        node=lo_bound_dim->node;
        if(pos_dim<0 || (node->end[dim]+off_dim)>=pos_dim) {
            temp_dim=(dim-1);
            if(temp_dim>=0) {
                node_start=node->start+temp_dim;
                node_end=node->end+temp_dim;
                tmp_pos=pos+temp_dim;
                tmp_off=offset+temp_dim;
                while(temp_dim>=0 && *tmp_pos>=(*node_start+*tmp_off) && *tmp_pos<=(*node_end+*tmp_off)) {
                    temp_dim--;
                    node_start--;
                    node_end--;
                    tmp_pos--;
                    tmp_off--;
                } /* end while */
            } /* end if */

#ifdef QAK
        printf("%s: check 1.3, i=%d, temp_dim=%d\n",FUNC,(int)i,(int)temp_dim);
#endif /* QAK */
            /* Yes, all previous positions match, this is a valid region */
            if(temp_dim<0) {
#ifdef QAK
        printf("%s: check 1.4, node->start[%d]=%d, node->end[%d]=%d\n",FUNC,(int)dim,(int)node->start[dim],(int)dim,(int)node->end[dim]);
#endif /* QAK */
                /* Check if we've allocated the array yet */
                if(num_reg==0) {
                    /* Allocate temporary buffer, big enough for worst case size */
                    reg=H5FL_ARR_ALLOC(H5S_hyper_region_t,bound_count,0);

                    /* Initialize with first region */
                    reg[num_reg].start=MAX(node->start[dim],pos[dim])+offset[dim];
                    reg[num_reg].end=node->end[dim]+offset[dim];
                    reg[num_reg].node=node;

                    /* Increment the number of regions */
                    num_reg++;
                    curr_reg++;
                } else {
                    /* Try to merge regions together in all dimensions, except the final one */
                    if(dim<(rank-1) && (node->start[dim]+offset[dim])<=(reg[curr_reg].end+1)) {
#ifdef QAK
        printf("%s: check 1.4.1\n",FUNC);
#endif /* QAK */
                        reg[curr_reg].end=MAX(node->end[dim],reg[curr_reg].end)+offset[dim];
                    } else { /* no overlap with previous region, add new region */
#ifdef QAK
        printf("%s: check 1.4.2\n",FUNC);
#endif /* QAK */
                        /* Initialize with new region */
                        reg[num_reg].start=node->start[dim]+offset[dim];
                        reg[num_reg].end=node->end[dim]+offset[dim];
                        reg[num_reg].node=node;

                        /*
                         * Increment the number of regions & the current
                         * region.
                         */
                        num_reg++;
                        curr_reg++;
                    } /* end else */
                } /* end else */
            } /* end if */
        } /* end if */
    } /* end for */

    /* Save the number of regions we generated */
    *num_regions=num_reg;

    /* Set return value */
    ret_value=reg;

#ifdef QAK
    printf("%s: check 10.0, reg=%p, num_reg=%d\n",
	   FUNC,reg,num_reg);
    for(i=0; i<num_reg; i++)
        printf("%s: start[%d]=%d, end[%d]=%d\n",
	       FUNC,i,(int)reg[i].start,i,(int)reg[i].end);
#endif /* QAK */

    FUNC_LEAVE (ret_value);
} /* end H5S_hyper_get_regions() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_block_cache
 *
 * Purpose:	Cache a hyperslab block for reading or writing.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *              Monday, September 21, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5S_hyper_block_cache (H5S_hyper_node_t *node,
		       H5S_hyper_io_info_t *io_info, uintn block_read)
{
    hssize_t	file_offset[H5O_LAYOUT_NDIMS];	/*offset of slab in file*/
    hsize_t	hsize[H5O_LAYOUT_NDIMS];	/*size of hyperslab	*/
    uintn u;                   /* Counters */

    FUNC_ENTER (H5S_hyper_block_cache, SUCCEED);

    assert(node);
    assert(io_info);

    /* Allocate temporary buffer of proper size */
    if((node->cinfo.block=H5FL_BLK_ALLOC(hyper_block,(node->cinfo.size*io_info->elmt_size),0))==NULL)
        HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
            "can't allocate hyperslab cache block");

    /* Read in block, if we are read caching */
    if(block_read) {
        /* Copy the location of the region in the file */
        HDmemcpy(file_offset,node->start,(io_info->space->extent.u.simple.rank * sizeof(hssize_t)));
        file_offset[io_info->space->extent.u.simple.rank]=0;

        /* Set the hyperslab size to read */
        for(u=0; u<io_info->space->extent.u.simple.rank; u++)
            hsize[u]=(node->end[u]-node->start[u])+1;
        hsize[io_info->space->extent.u.simple.rank]=io_info->elmt_size;

        if (H5F_arr_read(io_info->f, io_info->dxpl_id,
			 io_info->layout, io_info->pline,
			 io_info->fill, io_info->efl, hsize, hsize,
			 zero, file_offset, node->cinfo.block/*out*/)<0)
            HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, FAIL, "read error");
    } /* end if */
    else {
/* keep information for writing block later? */
    } /* end else */
    
    /* Set up parameters for accessing block (starting the read and write information at the same point) */
    node->cinfo.wleft=node->cinfo.rleft=(uintn)node->cinfo.size;
    node->cinfo.wpos=node->cinfo.rpos=node->cinfo.block;

    /* Set cached flag */
    node->cinfo.cached=1;

    FUNC_LEAVE (SUCCEED);
}   /* H5S_hyper_block_cache() */

/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_block_read
 *
 * Purpose:	Read in data from a cached hyperslab block
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *              Monday, September 21, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5S_hyper_block_read (H5S_hyper_node_t *node, H5S_hyper_io_info_t *io_info, hsize_t region_size)
{
    FUNC_ENTER (H5S_hyper_block_read, SUCCEED);

    assert(node && node->cinfo.cached);
    assert(io_info);

    /* Copy the elements into the user's buffer */
    /*
        !! NOTE !! This will need to be changed for different dimension
            permutations from the standard 'C' ordering!
    */
#ifdef QAK
	printf("%s: check 1.0, io_info->dst=%p, node->cinfo.rpos=%p, region_size=%lu, io_info->elmt_size=%lu\n",FUNC,io_info->dst,node->cinfo.rpos,(unsigned long)region_size,(unsigned long)io_info->elmt_size);
#endif /* QAK */
    HDmemcpy(io_info->dst, node->cinfo.rpos, (size_t)(region_size*io_info->elmt_size));

    /*
     * Decrement the number of elements left in block to read & move the
     * offset
     */
    node->cinfo.rpos+=region_size*io_info->elmt_size;
    node->cinfo.rleft-=region_size;

    /* If we've read in all the elements from the block, throw it away */
    if(node->cinfo.rleft==0 && (node->cinfo.wleft==0 || node->cinfo.wleft==node->cinfo.size)) {
        /* Release the temporary buffer */
        H5FL_BLK_FREE(hyper_block,node->cinfo.block);

        /* Reset the caching flag for next time */
        node->cinfo.cached=0;
    } /* end if */

    FUNC_LEAVE (SUCCEED);
}   /* H5S_hyper_block_read() */

/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_block_write
 *
 * Purpose:	Write out data to a cached hyperslab block
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *              Monday, September 21, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5S_hyper_block_write (H5S_hyper_node_t *node,
		       H5S_hyper_io_info_t *io_info,
		       hsize_t region_size)
{
    hssize_t	file_offset[H5O_LAYOUT_NDIMS];	/*offset of slab in file*/
    hsize_t	hsize[H5O_LAYOUT_NDIMS];	/*size of hyperslab	*/
    uintn u;                   /* Counters */

    FUNC_ENTER (H5S_hyper_block_write, SUCCEED);

    assert(node && node->cinfo.cached);
    assert(io_info);

    /* Copy the elements into the user's buffer */
    /*
        !! NOTE !! This will need to be changed for different dimension
            permutations from the standard 'C' ordering!
    */
    HDmemcpy(node->cinfo.wpos, io_info->src, (size_t)(region_size*io_info->elmt_size));

    /*
     * Decrement the number of elements left in block to read & move the
     * offset
     */
    node->cinfo.wpos+=region_size*io_info->elmt_size;
    node->cinfo.wleft-=region_size;

    /* If we've read in all the elements from the block, throw it away */
    if(node->cinfo.wleft==0 && (node->cinfo.rleft==0 || node->cinfo.rleft==node->cinfo.size)) {
        /* Copy the location of the region in the file */
        HDmemcpy(file_offset, node->start, (io_info->space->extent.u.simple.rank * sizeof(hssize_t)));
        file_offset[io_info->space->extent.u.simple.rank]=0;

        /* Set the hyperslab size to write */
        for(u=0; u<io_info->space->extent.u.simple.rank; u++)
            hsize[u]=(node->end[u]-node->start[u])+1;
        hsize[io_info->space->extent.u.simple.rank]=io_info->elmt_size;

        if (H5F_arr_write(io_info->f, io_info->dxpl_id, io_info->layout,
			  io_info->pline, io_info->fill, io_info->efl, hsize,
			  hsize, zero, file_offset,
			  node->cinfo.block/*out*/)<0)
            HRETURN_ERROR (H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error");

        /* Release the temporary buffer */
        H5FL_BLK_FREE(hyper_block,node->cinfo.block);

        /* Reset the caching flag for next time */
        node->cinfo.cached=0;
    } /* end if */

    FUNC_LEAVE (SUCCEED);
}   /* H5S_hyper_block_write() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_fread
 *
 * Purpose:	Recursively gathers data points from a file using the
 *		parameters passed to H5S_hyper_fgath.
 *
 * Return:	Success:	Number of elements copied.
 *
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_fread (intn dim, H5S_hyper_io_info_t *io_info)
{
    hsize_t region_size;                /* Size of lowest region */
    uintn parm_init=0;          /* Whether one-shot parameters set up */
    H5S_hyper_region_t *regions;  /* Pointer to array of hyperslab nodes overlapped */
    size_t num_regions;         /* number of regions overlapped */
    size_t i;                   /* Counters */
    intn j;
#ifdef QAK
    uintn u;
#endif /* QAK */
    hsize_t num_read=0;          /* Number of elements read */
    uintn cache_hyper;          /* Hyperslab caching turned on? */
    uintn block_limit;          /* Hyperslab cache limit */

    FUNC_ENTER (H5S_hyper_fread, 0);

    assert(io_info);

    /* Get the hyperslab cache setting and limit */
    if (H5P_get(io_info->dxpl_id,H5D_XFER_HYPER_CACHE_NAME,&cache_hyper)<0)
        HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, 0, "unable to get value");
    if (H5P_get(io_info->dxpl_id,H5D_XFER_HYPER_CACHE_LIM_NAME,&block_limit)<0)
        HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, 0, "unable to get value");

#ifdef QAK
    printf("%s: check 1.0, dim=%d\n",FUNC,dim);
#endif /* QAK */

    /* Get a sorted list (in the next dimension down) of the regions which */
    /*  overlap the current index in this dim */
    if((regions=H5S_hyper_get_regions(&num_regions,io_info->space->extent.u.simple.rank,
            (uintn)(dim+1),
            io_info->space->select.sel_info.hslab.hyper_lst->count,
            io_info->space->select.sel_info.hslab.hyper_lst->lo_bounds,
            io_info->iter->hyp.pos,io_info->space->select.offset))!=NULL) {

        /*
	 * Check if this is the second to last dimension in dataset (Which
	 * means that we've got a list of the regions in the fastest changing
	 * dimension and should input those regions).
	 */
#ifdef QAK
    if(dim>=0) {
        printf("%s: check 2.0, rank=%d, ",
               FUNC,(int)io_info->space->extent.u.simple.rank);
        printf("%s: pos={",FUNC);
        for(u=0; u<io_info->space->extent.u.simple.rank; u++) {
            printf("%d",(int)io_info->iter->hyp.pos[u]);
            if(u<io_info->space->extent.u.simple.rank-1)
                printf(", ");
        } /* end for */
        printf("}\n");
    } /* end if */
    else
        printf("%s: check 2.0, rank=%d\n",
               FUNC,(int)io_info->space->extent.u.simple.rank);
    for(i=0; i<num_regions; i++)
        printf("%s: check 2.1, region #%d: start=%d, end=%d\n",
		   FUNC,i,(int)regions[i].start,(int)regions[i].end);
#endif /* QAK */
        if((uintn)(dim+2)==io_info->space->extent.u.simple.rank) {
#ifdef QAK
	printf("%s: check 2.1.1, num_regions=%d\n",FUNC,(int)num_regions);
#endif /* QAK */
            /* perform I/O on data from regions */
            for(i=0; i<num_regions && io_info->nelmts>0; i++) {
                /* Compute the size of the region to read */
                H5_CHECK_OVERFLOW(io_info->nelmts,hsize_t,hssize_t);
                region_size=MIN((hssize_t)io_info->nelmts, (regions[i].end-regions[i].start)+1);

#ifdef QAK
	printf("%s: check 2.1.2, region=%d, region_size=%d, num_read=%lu\n",FUNC,(int)i,(int)region_size,(unsigned long)num_read);
#endif /* QAK */
                /* Check if this hyperslab block is cached or could be cached */
                if(!regions[i].node->cinfo.cached &&
		   (cache_hyper &&
		    (block_limit==0 || block_limit>=(regions[i].node->cinfo.size*io_info->elmt_size)))) {
                    /* if we aren't cached, attempt to cache the block */
#ifdef QAK
	printf("%s: check 2.1.3, caching block\n",FUNC);
#endif /* QAK */
                    H5S_hyper_block_cache(regions[i].node,io_info,1);
                } /* end if */

                /* Read information from the cached block */
                if(regions[i].node->cinfo.cached) {
#ifdef QAK
	printf("%s: check 2.1.4, reading block from cache\n",FUNC);
#endif /* QAK */
                    if(H5S_hyper_block_read(regions[i].node,io_info,region_size)<0)
                        HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0, "read error");
                }
                else {
#ifdef QAK
	printf("%s: check 2.1.5, reading block from file, parm_init=%d\n",FUNC,(int)parm_init);
#endif /* QAK */
                    /* Set up hyperslab I/O parameters which apply to all regions */
                    if(!parm_init) {
                        /* Copy the location of the region in the file */
                        HDmemcpy(io_info->offset,io_info->iter->hyp.pos,(io_info->space->extent.u.simple.rank * sizeof(hssize_t)));
                        io_info->offset[io_info->space->extent.u.simple.rank]=0;

                        /* Set flag */
                        parm_init=1;
                    } /* end if */

#ifdef QAK
    printf("%s: check 2.2, i=%d, region_size=%d\n",FUNC,(int)i,(int)region_size);
#endif /* QAK */
                    /* Fill in the region specific parts of the I/O request */
                    io_info->hsize[io_info->space->extent.u.simple.rank-1]=region_size;
                    io_info->offset[io_info->space->extent.u.simple.rank-1]=regions[i].start;

                    /*
                     * Gather from file.
                     */
                    if (H5F_arr_read(io_info->f, io_info->dxpl_id,
				     io_info->layout, io_info->pline,
				     io_info->fill, io_info->efl,
				     io_info->hsize, io_info->hsize,
				     zero, io_info->offset,
				     io_info->dst/*out*/)<0) {
                        HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0,
				       "read error");
                    }
                } /* end else */
#ifdef QAK
    printf("%s: check 2.3, region #%d\n",FUNC,(int)i);
    printf("pos={");
    for(u=0; u<io_info->space->extent.u.simple.rank; u++) {
        printf("%d",(int)io_info->iter->hyp.pos[u]);
        if(u<io_info->space->extent.u.simple.rank-1)
            printf(", ");
    } /* end for */
    printf("}\n");
#endif /* QAK */

                /* Advance the pointer in the buffer */
                io_info->dst = ((uint8_t *)io_info->dst) + region_size*io_info->elmt_size;

                /* Increment the number of elements read */
                num_read+=region_size;

                /* Decrement the buffer left */
                io_info->nelmts-=region_size;

                /* Set the next position to start at */
                if(region_size==(hsize_t)((regions[i].end-regions[i].start)+1)
                        && i==(num_regions-1))
                    io_info->iter->hyp.pos[dim+1]=(-1);
                else
                    io_info->iter->hyp.pos[dim+1] = regions[i].start + region_size;
#ifdef QAK
    printf("%s: check 2.3.5, region #%d\n",FUNC,(int)i);
    printf("pos={");
    for(j=0; j<io_info->space->extent.u.simple.rank; j++) {
        printf("%d",(int)io_info->iter->hyp.pos[j]);
        if(j<io_info->space->extent.u.simple.rank-1)
            printf(", ");
    } /* end for */
    printf("}\n");
#endif /* QAK */

                /* Decrement the iterator count */
                io_info->iter->hyp.elmt_left-=region_size;
            } /* end for */
        } else { /* recurse on each region to next dimension down */
#ifdef QAK
    printf("%s: check 3.0, num_regions=%d\n",FUNC,(int)num_regions);
    for(i=0; i<num_regions; i++)
        printf("%s: region %d={%d, %d}\n", FUNC,i,(int)regions[i].start,(int)regions[i].end);
#endif /* QAK */

            /* Increment the dimension we are working with */
            dim++;

            /* Step through each region in this dimension */
            for(i=0; i<num_regions && io_info->nelmts>0; i++) {
#ifdef QAK
    printf("%s: check 3.5, dim=%d, region #%d={%d, %d}\n",FUNC,(int)dim,(int)i,(int)regions[i].start,(int)regions[i].end);
{
    intn k;

    printf("pos={");
    for(k=0; k<io_info->space->extent.u.simple.rank; k++) {
        printf("%d",(int)io_info->iter->hyp.pos[k]);
        if(k<io_info->space->extent.u.simple.rank-1)
            printf(", ");
    } /* end for */
    printf("}\n");
}
#endif /* QAK */
                /* Step through each location in each region */
                for(j=MAX(io_info->iter->hyp.pos[dim],regions[i].start); j<=regions[i].end && io_info->nelmts>0; j++) {
#ifdef QAK
    printf("%s: check 4.0, dim=%d, j=%d, num_read=%lu\n",FUNC,dim,j,(unsigned long)num_read);
#endif /* QAK */

                    /* Set the correct position we are working on */
                    io_info->iter->hyp.pos[dim]=j;

                    /* Go get the regions in the next lower dimension */
                    num_read+=H5S_hyper_fread(dim, io_info);

                    /* Advance to the next row if we got the whole region */
                    if(io_info->iter->hyp.pos[dim+1]==(-1))
                        io_info->iter->hyp.pos[dim]=j+1;
                } /* end for */
#ifdef QAK
{
    printf("%s: check 5.0, dim=%d, j=%d, region #%d={%d, %d}\n",FUNC,(int)dim,(int)j,(int)i,(int)regions[i].start,(int)regions[i].end);
    printf("%s: pos={",FUNC);
    for(u=0; u<io_info->space->extent.u.simple.rank; u++) {
        printf("%d",(int)io_info->iter->hyp.pos[u]);
        if(u<io_info->space->extent.u.simple.rank-1)
            printf(", ");
    } /* end for */
    printf("}\n");
}
#endif /* QAK */
                if(j>regions[i].end && io_info->iter->hyp.pos[dim+1]==(-1)
                        && i==(num_regions-1))
                    io_info->iter->hyp.pos[dim]=(-1);
            } /* end for */
#ifdef QAK
{
    intn k;

    printf("%s: check 6.0, dim=%d\n",FUNC,(int)dim);
    printf("pos={");
    for(k=0; k<io_info->space->extent.u.simple.rank; k++) {
        printf("%d",(int)io_info->iter->hyp.pos[k]);
        if(k<io_info->space->extent.u.simple.rank-1)
            printf(", ");
    } /* end for */
    printf("}\n");
}
#endif /* QAK */
        } /* end else */

        /* Release the temporary buffer */
        H5FL_ARR_FREE(H5S_hyper_region_t,regions);
    } /* end if */

    FUNC_LEAVE (num_read);
}   /* H5S_hyper_fread() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_iter_next
 *
 * Purpose:	Moves a hyperslab iterator to the beginning of the next sequence
 *      of elements to read.  Handles walking off the end in all dimensions.
 *
 * Return:	Success:	non-negative
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Friday, September 8, 2000
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static int
H5S_hyper_iter_next (const H5S_t *file_space, H5S_sel_iter_t *file_iter)
{
    hsize_t iter_offset[H5O_LAYOUT_NDIMS];
    hsize_t iter_count[H5O_LAYOUT_NDIMS];
    intn fast_dim;  /* Rank of the fastest changing dimension for the dataspace */
    intn temp_dim;  /* Temporary rank holder */
    uintn i;        /* Counters */
    uintn ndims;    /* Number of dimensions of dataset */

    FUNC_ENTER (H5S_hyper_iter_next, FAIL);

    /* Set some useful rank information */
    fast_dim=file_space->extent.u.simple.rank-1;
    ndims=file_space->extent.u.simple.rank;

    /* Calculate the offset and block count for each dimension */
    for(i=0; i<ndims; i++) {
        iter_offset[i]=(file_iter->hyp.pos[i]-file_space->select.sel_info.hslab.diminfo[i].start)%file_space->select.sel_info.hslab.diminfo[i].stride;
        iter_count[i]=(file_iter->hyp.pos[i]-file_space->select.sel_info.hslab.diminfo[i].start)/file_space->select.sel_info.hslab.diminfo[i].stride;
    } /* end for */

    /* Start with the fastest changing dimension */
    temp_dim=fast_dim;
    while(temp_dim>=0) {
        if(temp_dim==fast_dim) {
            /* Move to the next block in the current dimension */
            iter_offset[temp_dim]=0;    /* reset the offset in the fastest dimension */
            iter_count[temp_dim]++;

            /* If this block is still in the range of blocks to output for the dimension, break out of loop */
            if(iter_count[temp_dim]<file_space->select.sel_info.hslab.diminfo[temp_dim].count)
                break;
            else
                iter_count[temp_dim]=0; /* reset back to the beginning of the line */
        } /* end if */
        else {
            /* Move to the next row in the curent dimension */
            iter_offset[temp_dim]++;

            /* If this block is still in the range of blocks to output for the dimension, break out of loop */
            if(iter_offset[temp_dim]<file_space->select.sel_info.hslab.diminfo[temp_dim].block)
                break;
            else {
                /* Move to the next block in the current dimension */
                iter_offset[temp_dim]=0;
                iter_count[temp_dim]++;

                /* If this block is still in the range of blocks to output for the dimension, break out of loop */
                if(iter_count[temp_dim]<file_space->select.sel_info.hslab.diminfo[temp_dim].count)
                    break;
                else
                    iter_count[temp_dim]=0; /* reset back to the beginning of the line */
            } /* end else */
        } /* end else */

        /* Decrement dimension count */
        temp_dim--;
    } /* end while */

    /* Translate current iter_offset and iter_count into iterator position */
    for(i=0; i<ndims; i++)
        file_iter->hyp.pos[i]=file_space->select.sel_info.hslab.diminfo[i].start+(file_space->select.sel_info.hslab.diminfo[i].stride*iter_count[i])+iter_offset[i];

    FUNC_LEAVE (SUCCEED);
} /* H5S_hyper_iter_next() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_fread_opt
 *
 * Purpose:	Performs an optimized gather from the file, based on a regular
 *      hyperslab (i.e. one which was generated from just one call to
 *      H5Sselect_hyperslab).
 *
 * Return:	Success:	Number of elements copied.
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Friday, September 8, 2000
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_fread_opt (H5F_t *f, const struct H5O_layout_t *layout,
		 const struct H5O_pline_t *pline,
		 const struct H5O_fill_t *fill,
		 const struct H5O_efl_t *efl, size_t elmt_size,
		 const H5S_t *file_space, H5S_sel_iter_t *file_iter,
		 hsize_t nelmts, hid_t dxpl_id, void *_buf/*out*/)
{
    size_t *seq_len_arr=NULL;   /* Array of sequence lengths */
    hsize_t *buf_off_arr=NULL;  /* Array of dataset offsets */
    size_t nseq=0;              /* Number of sequence/offsets stored in the arrays */
    size_t tot_buf_size=0;      /* Total number of bytes in buffer */

    hssize_t offset[H5O_LAYOUT_NDIMS];      /* Offset on disk */
    hsize_t	slab[H5O_LAYOUT_NDIMS];         /* Hyperslab size */
    hssize_t	wrap[H5O_LAYOUT_NDIMS];         /* Bytes to wrap around at the end of a row */
    hsize_t	skip[H5O_LAYOUT_NDIMS];         /* Bytes to skip between blocks */
    hsize_t	tmp_count[H5O_LAYOUT_NDIMS];    /* Temporary block count */
    hsize_t	tmp_block[H5O_LAYOUT_NDIMS];    /* Temporary block offset */
    uint8_t	*buf=(uint8_t *)_buf;   /* Alias for pointer arithmetic */
    const H5S_hyper_dim_t *tdiminfo;    /* Local pointer to diminfo information */
    hssize_t fast_dim_start,            /* Local copies of fastest changing dimension info */
        fast_dim_offset;
    hsize_t fast_dim_stride,            /* Local copies of fastest changing dimension info */
        fast_dim_block,
        fast_dim_count,
        fast_dim_buf_off;
    hsize_t tot_blk_count;      /* Total number of blocks left to output */
    size_t act_blk_count;      /* Actual number of blocks to output */
    intn fast_dim;  /* Rank of the fastest changing dimension for the dataspace */
    intn temp_dim;  /* Temporary rank holder */
    hsize_t	acc;	/* Accumulator */
    hsize_t	buf_off;        /* Current buffer offset for copying memory */
    intn i;         /* Counters */
    uintn u;        /* Counters */
    intn   	ndims;      /* Number of dimensions of dataset */
    size_t actual_read;     /* The actual number of elements to read in */
    size_t actual_bytes;    /* The actual number of bytes to copy */
    size_t io_left;         /* The number of elements left in I/O operation */
    size_t tot_seq;         /* The number of sequences filled */
    hsize_t *buf_off_arr_p;     /* Pointer into the buffer offset array */
    size_t seq_count;           /* Temporary count of sequences left to process */
#ifndef NO_DUFFS_DEVICE
    size_t duffs_index;         /* Counting index for Duff's device */
#endif /* NO_DUFFS_DEVICE */
    size_t vector_size;         /* Value for vector size */
    hsize_t ret_value=0;        /* Return value */

    FUNC_ENTER (H5S_hyper_fread_opt, 0);

#ifdef QAK
printf("%s: Called!\n",FUNC);
#endif /* QAK */
    /* Check if this is the first element read in from the hyperslab */
    if(file_iter->hyp.pos[0]==(-1)) {
        for(u=0; u<file_space->extent.u.simple.rank; u++)
            file_iter->hyp.pos[u]=file_space->select.sel_info.hslab.diminfo[u].start;
    } /* end if */

#ifdef QAK
for(i=0; i<file_space->extent.u.simple.rank; i++)
    printf("%s: file_file->hyp.pos[%d]=%d\n",FUNC,(int)i,(int)file_iter->hyp.pos[i]);
#endif /* QAK */

    /* Get the hyperslab vector size */
    if (H5P_get(dxpl_id,H5D_XFER_HYPER_VECTOR_SIZE_NAME,&vector_size)<0)
        HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, 0, "unable to get value");

    /* Allocate the vector I/O arrays */
    if((seq_len_arr = H5FL_ARR_ALLOC(size_t,vector_size,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate vector I/O array");
    if((buf_off_arr = H5FL_ARR_ALLOC(hsize_t,vector_size,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate vector I/O array");

    /* Set the rank of the fastest changing dimension */
    fast_dim=file_space->extent.u.simple.rank-1;
    ndims=file_space->extent.u.simple.rank;

    /* initialize row sizes for each dimension */
    for(i=(ndims-1),acc=1; i>=0; i--) {
        slab[i]=acc*elmt_size;
        acc*=file_space->extent.u.simple.size[i];
    } /* end for */

    /* Set the number of elements left for I/O */
    assert(nelmts==(hsize_t)((size_t)nelmts)); /*check for overflow*/
    io_left=(size_t)nelmts;

#ifdef QAK
    printf("%s: fast_dim=%d\n",FUNC,(int)fast_dim);
    printf("%s: file_space->select.sel_info.hslab.diminfo[%d].start=%d\n",FUNC,(int)fast_dim,(int)file_space->select.sel_info.hslab.diminfo[fast_dim].start);
    printf("%s: file_space->select.sel_info.hslab.diminfo[%d].stride=%d\n",FUNC,(int)fast_dim,(int)file_space->select.sel_info.hslab.diminfo[fast_dim].stride);
#endif /* QAK */
    /* Check if we stopped in the middle of a sequence of elements */
    if((file_iter->hyp.pos[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start)%file_space->select.sel_info.hslab.diminfo[fast_dim].stride!=0 ||
        ((file_iter->hyp.pos[fast_dim]!=file_space->select.sel_info.hslab.diminfo[fast_dim].start) && file_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)) {
        hsize_t leftover;  /* The number of elements left over from the last sequence */

#ifdef QAK
printf("%s: Check 1.0\n",FUNC);
#endif /* QAK */
        /* Calculate the number of elements left in the sequence */
        if(file_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)
            leftover=file_space->select.sel_info.hslab.diminfo[fast_dim].block-(file_iter->hyp.pos[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start);
        else
            leftover=file_space->select.sel_info.hslab.diminfo[fast_dim].block-((file_iter->hyp.pos[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start)%file_space->select.sel_info.hslab.diminfo[fast_dim].stride);

        /* Make certain that we don't read too many */
        actual_read=MIN(leftover,nelmts);
        actual_bytes=actual_read*elmt_size;

        /* Copy the location of the point to get */
        HDmemcpy(offset, file_iter->hyp.pos,ndims*sizeof(hssize_t));
        offset[ndims] = 0;

        /* Add in the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] += file_space->select.offset[i];
#ifdef QAK
for(i=0; i<ndims+1; i++)
    printf("%s: offset[%d]=%d\n",FUNC,(int)i,(int)offset[i]);
#endif /* QAK */

        /* Compute the initial buffer offset */
        for(i=0,buf_off=0; i<ndims; i++)
            buf_off+=offset[i]*slab[i];
#ifdef QAK
printf("%s: buf_off=%ld, actual_read=%d, actual_bytes=%d\n",FUNC,(long)buf_off,(int)actual_read,(int)actual_bytes);
#endif /* QAK */

        /* Read in the rest of the sequence */
        if (H5F_seq_read(f, dxpl_id, layout, pline, fill, efl, file_space,
            elmt_size, actual_bytes, buf_off, buf/*out*/)<0) {
            HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error");
        }

        /* Increment the offset of the buffer */
        buf+=actual_bytes;

        /* Decrement the amount left to read */
        io_left-=actual_read;

        /* Advance the point iterator */
        /* If we had enough buffer space to read in the rest of the sequence
         * in the fastest changing dimension, move the iterator offset to
         * the beginning of the next block to read.  Otherwise, just advance
         * the iterator in the fastest changing dimension.
         */
        if(actual_read==leftover) {
            /* Move iterator offset to beginning of next sequence in the fastest changing dimension */
            H5S_hyper_iter_next(file_space,file_iter);
        } /* end if */
        else {
            file_iter->hyp.pos[fast_dim]+=actual_read; /* whole sequence not read in, just advance fastest dimension offset */
        } /* end if */
    } /* end if */

    /* Now that we've cleared the "remainder" of the previous fastest dimension
     * sequence, we must be at the beginning of a sequence, so use the fancy
     * algorithm to compute the offsets and run through as many as possible,
     * until the buffer fills up.
     */
    if(io_left>0) { /* Just in case the "remainder" above filled the buffer */
#ifdef QAK
printf("%s: Check 2.0, ndims=%d, io_left=%d, nelmts=%d\n",FUNC,(int)ndims,(int)io_left,(int)nelmts);
#endif /* QAK */
        /* Compute the arrays to perform I/O on */
        /* Copy the location of the point to get */
        HDmemcpy(offset, file_iter->hyp.pos,ndims*sizeof(hssize_t));
        offset[ndims] = 0;
#ifdef QAK
for(i=0; i<ndims+1; i++)
    printf("%s: offset[%d]=%d\n",FUNC,(int)i,(int)offset[i]);
#endif /* QAK */

        /* Add in the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] += file_space->select.offset[i];

        /* Compute the current "counts" for this location */
        for(i=0; i<ndims; i++) {
            tmp_count[i] = (file_iter->hyp.pos[i]-file_space->select.sel_info.hslab.diminfo[i].start)%file_space->select.sel_info.hslab.diminfo[i].stride;
            tmp_block[i] = (file_iter->hyp.pos[i]-file_space->select.sel_info.hslab.diminfo[i].start)/file_space->select.sel_info.hslab.diminfo[i].stride;
        } /* end for */
#ifdef QAK
for(i=0; i<ndims; i++) {
    printf("%s: tmp_count[%d]=%d, tmp_block[%d]=%d\n",FUNC,(int)i,(int)tmp_count[i],(int)i,(int)tmp_block[i]);
    printf("%s: slab[%d]=%d\n",FUNC,(int)i,(int)slab[i]);
}
#endif /* QAK */

        /* Compute the initial buffer offset */
        for(i=0,buf_off=0; i<ndims; i++)
            buf_off+=offset[i]*slab[i];

        /* Set the number of elements to read each time */
        actual_read=file_space->select.sel_info.hslab.diminfo[fast_dim].block;

        /* Set the number of actual bytes */
        actual_bytes=actual_read*elmt_size;
#ifdef QAK
printf("%s: buf_off=%ld, actual_read=%d, actual_bytes=%d\n",FUNC,(long)buf_off,(int)actual_read,(int)actual_bytes);
#endif /* QAK */

#ifdef QAK
for(i=0; i<file_space->extent.u.simple.rank; i++)
    printf("%s: diminfo: start[%d]=%d, stride[%d]=%d, block[%d]=%d, count[%d]=%d\n",FUNC,
        (int)i,(int)file_space->select.sel_info.hslab.diminfo[i].start,
        (int)i,(int)file_space->select.sel_info.hslab.diminfo[i].stride,
        (int)i,(int)file_space->select.sel_info.hslab.diminfo[i].block,
        (int)i,(int)file_space->select.sel_info.hslab.diminfo[i].count);
#endif /* QAK */

        /* Set the local copy of the diminfo pointer */
        tdiminfo=file_space->select.sel_info.hslab.diminfo;

        /* Set local copies of information for the fastest changing dimension */
        fast_dim_start=tdiminfo[fast_dim].start;
        fast_dim_stride=tdiminfo[fast_dim].stride;
        fast_dim_block=tdiminfo[fast_dim].block;
        fast_dim_buf_off=slab[fast_dim]*fast_dim_stride;
        fast_dim_offset=fast_dim_start+file_space->select.offset[fast_dim];

        /* Compute the number of blocks which would fit into the buffer */
        tot_blk_count=io_left/fast_dim_block;

        /* Compute the amount to wrap at the end of each row */
        for(i=0; i<ndims; i++)
            wrap[i]=(file_space->extent.u.simple.size[i]-(tdiminfo[i].stride*tdiminfo[i].count))*slab[i];

        /* Compute the amount to skip between blocks */
        for(i=0; i<ndims; i++)
            skip[i]=(tdiminfo[i].stride-tdiminfo[i].block)*slab[i];

        /* Fill the sequence length array (since they will all be the same for optimized hyperslabs) */
        for(u=0; u<vector_size; u++)
            seq_len_arr[u]=actual_bytes;

        /* Read in data until an entire sequence can't be read in any longer */
        while(io_left>0) {
            /* Reset copy of number of blocks in fastest dimension */
            fast_dim_count=tdiminfo[fast_dim].count-tmp_count[fast_dim];

            /* Check if this entire row will fit into buffer */
            if(fast_dim_count<=tot_blk_count) {

                /* Entire row of blocks fits into buffer */
                act_blk_count=fast_dim_count;

                /* Loop over all the blocks in the fastest changing dimension */
                while(fast_dim_count>0) {
                    /* Gather the sequence */

                    /* Compute the number of sequences to fill */
                    tot_seq=MIN(vector_size-nseq,fast_dim_count);

                    /* Get a copy of the number of sequences to fill */
                    seq_count=tot_seq;

                    /* Set the pointer to the correct starting array element */
                    buf_off_arr_p=&buf_off_arr[nseq];

#ifdef NO_DUFFS_DEVICE
                    /* Fill up the buffer, or finish up the blocks in this dimension */
                    while(seq_count>0) {
                        /* Store of length & offset */
                        /* seq_len_arr[nseq] already has the correct value */
                        *buf_off_arr_p++=buf_off;

                        /* Increment the source offset */
                        buf_off+=fast_dim_buf_off;

                        seq_count--;
                    } /* end while */
#else /* NO_DUFFS_DEVICE */
                    duffs_index = (seq_count + 7) / 8;
                    switch (seq_count % 8) {
                        case 0:
                            do
                              {
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 7:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 6:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 5:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 4:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 3:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 2:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 1:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                          } while (--duffs_index > 0);
                    } /* end switch */
#endif /* NO_DUFFS_DEVICE */

                    /* Increment number of array elements used */
                    nseq+=tot_seq;

                    /* Increment the total number of bytes contained in arrays */
                    tot_buf_size += tot_seq*actual_bytes;

                    /* Decrement number of blocks left */
                    fast_dim_count -= tot_seq;

                    /* If the sequence & offset arrays are full, read them in */
                    if(nseq>=vector_size) {
                        /* Read in the sequences */
                        if (H5F_seq_readv(f, dxpl_id, layout, pline, fill, efl, file_space,
                            elmt_size, nseq, seq_len_arr, buf_off_arr, buf/*out*/)<0) {
                            HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error");
                        } /* end if */

                        /* Increment the offset of the destination buffer */
                        buf+=tot_buf_size;

                        /* Reset the number of bytes & sequences */
                        tot_buf_size=0;
                        nseq=0;
                    } /* end else */
                } /* end while */

                /* Decrement number of elements left */
                io_left -= actual_read*act_blk_count;

                /* Decrement number of blocks left */
                tot_blk_count -= act_blk_count;

                /* Increment information to reflect block just processed */
                offset[fast_dim]=fast_dim_offset;    /* reset the offset in the fastest dimension */
                tmp_count[fast_dim]=0;

                /* Increment offset in destination buffer */
                buf_off += wrap[fast_dim];
            } /* end if */
            else {

                /* Entire row of blocks doesn't fit into buffer */
                act_blk_count=tot_blk_count;

                /* Reduce number of blocks to output */
                fast_dim_count=tot_blk_count;

                /* Loop over all the blocks in the fastest changing dimension */
                while(fast_dim_count>0) {
                    /* Gather the sequence */

                    /* Compute the number of sequences to fill */
                    tot_seq=MIN(vector_size-nseq,fast_dim_count);

                    /* Get a copy of the number of sequences to fill */
                    seq_count=tot_seq;

                    /* Set the pointer to the correct starting array element */
                    buf_off_arr_p=&buf_off_arr[nseq];

                    /* Fill up the buffer, or finish up the blocks in this dimension */
                    while(seq_count>0) {
                        /* Store of length & offset */
                        /* seq_len_arr[nseq] already has the correct value */
                        *buf_off_arr_p++=buf_off;

                        /* Increment the source offset */
                        buf_off+=fast_dim_buf_off;

                        seq_count--;
                    } /* end while */

                    /* Increment number of array elements used */
                    nseq+=tot_seq;

                    /* Increment the total number of bytes contained in arrays */
                    tot_buf_size += tot_seq*actual_bytes;

                    /* Decrement number of blocks left */
                    fast_dim_count -= tot_seq;

                    /* If the sequence & offset arrays are full, read them in */
                    if(nseq>=vector_size) {
                        /* Read in the sequences */
                        if (H5F_seq_readv(f, dxpl_id, layout, pline, fill, efl, file_space,
                            elmt_size, nseq, seq_len_arr, buf_off_arr, buf/*out*/)<0) {
                            HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error");
                        } /* end if */

                        /* Increment the offset of the destination buffer */
                        buf+=tot_buf_size;

                        /* Reset the number of bytes & sequences */
                        tot_buf_size=0;
                        nseq=0;
                    } /* end else */
                } /* end while */

                /* Decrement number of elements left */
                io_left -= actual_read*act_blk_count;

                /* Decrement number of blocks left */
                tot_blk_count -= act_blk_count;

                /* Increment information to reflect block just processed */
                offset[fast_dim]+=(fast_dim_stride*act_blk_count);    /* reset the offset in the fastest dimension */
                tmp_count[fast_dim]+=act_blk_count;

                /* Handle any leftover, partial blocks in this row */
                if(io_left>0) {
                    actual_read=io_left;
                    actual_bytes=actual_read*elmt_size;

                    /* Gather the sequence */

                    /* Store of length & offset */
                    seq_len_arr[nseq]=actual_bytes;
                    buf_off_arr[nseq]=buf_off;

                    /* Increment the total number of bytes contained in arrays */
                    tot_buf_size += actual_bytes;

                    /* Increment the number of sequences in arrays */
                    nseq++;

                    /* If the sequence & offset arrays are full, read them in */
                    if(nseq>=vector_size) {
                        /* Read in the sequences */
                        if (H5F_seq_readv(f, dxpl_id, layout, pline, fill, efl, file_space,
                            elmt_size, nseq, seq_len_arr, buf_off_arr, buf/*out*/)<0) {
                            HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error");
                        } /* end if */

                        /* Increment the offset of the destination buffer */
                        buf+=tot_buf_size;

                        /* Reset the number of bytes & sequences */
                        tot_buf_size=0;
                        nseq=0;
                    } /* end else */

                    /* Increment the source offset */
                    buf_off+=fast_dim_buf_off;

                    /* Decrement the number of elements left */
                    io_left -= actual_read;

                    /* Increment buffer correctly */
                    offset[fast_dim]+=actual_read;
                } /* end if */

                /* don't bother checking slower dimensions */
                assert(tot_blk_count==0);
                assert(io_left==0);
                break;
            } /* end else */

            /* Increment the offset and count for the other dimensions */
            temp_dim=fast_dim-1;
            while(temp_dim>=0) {
                /* Move to the next row in the curent dimension */
                offset[temp_dim]++;
                tmp_block[temp_dim]++;

                /* If this block is still in the range of blocks to output for the dimension, break out of loop */
                if(tmp_block[temp_dim]<tdiminfo[temp_dim].block)
                    break;
                else {
                    /* Move to the next block in the current dimension */
                    offset[temp_dim]+=(tdiminfo[temp_dim].stride-tdiminfo[temp_dim].block);
                    buf_off += skip[temp_dim];
                    tmp_block[temp_dim]=0;
                    tmp_count[temp_dim]++;

                    /* If this block is still in the range of blocks to output for the dimension, break out of loop */
                    if(tmp_count[temp_dim]<tdiminfo[temp_dim].count)
                        break;
                    else {
                        offset[temp_dim]=tdiminfo[temp_dim].start+file_space->select.offset[temp_dim];
                        buf_off += wrap[temp_dim];
                        tmp_count[temp_dim]=0; /* reset back to the beginning of the line */
                        tmp_block[temp_dim]=0;
                    } /* end else */
                } /* end else */

                /* Decrement dimension count */
                temp_dim--;
            } /* end while */
        } /* end while */

        /* Check for any stored sequences which need to be flushed */
        if(nseq>0) {
            /* Read in the sequence */
            if (H5F_seq_readv(f, dxpl_id, layout, pline, fill, efl, file_space,
                elmt_size, nseq, seq_len_arr, buf_off_arr, buf/*out*/)<0) {
                HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error");
            } /* end if */
        } /* end if */

        /* Subtract out the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] -= file_space->select.offset[i];

        /* Update the iterator with the location we stopped */
        HDmemcpy(file_iter->hyp.pos, offset, ndims*sizeof(hssize_t));
    } /* end if */

    /* Decrement the number of elements left in selection */
    file_iter->hyp.elmt_left -= (nelmts-io_left);

    /* Set the return value */
    ret_value= (nelmts-io_left);

done:
    if(seq_len_arr!=NULL)
        H5FL_ARR_FREE(size_t,seq_len_arr);
    if(buf_off_arr!=NULL)
        H5FL_ARR_FREE(hsize_t,buf_off_arr);

    FUNC_LEAVE (ret_value);
} /* H5S_hyper_fread_opt() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_fgath
 *
 * Purpose:	Gathers data points from file F and accumulates them in the
 *		type conversion buffer BUF.  The LAYOUT argument describes
 *		how the data is stored on disk and EFL describes how the data
 *		is organized in external files.  ELMT_SIZE is the size in
 *		bytes of a datum which this function treats as opaque.
 *		FILE_SPACE describes the data space of the dataset on disk
 *		and the elements that have been selected for reading (via
 *		hyperslab, etc).  This function will copy at most NELMTS elements.
 *
 * Return:	Success:	Number of elements copied.
 *
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *		Robb Matzke, 1999-08-03
 *		The data transfer properties are passed by ID since that's
 *		what the virtual file layer needs.
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_fgath (H5F_t *f, const struct H5O_layout_t *layout,
		 const struct H5O_pline_t *pline,
		 const struct H5O_fill_t *fill,
		 const struct H5O_efl_t *efl, size_t elmt_size,
		 const H5S_t *file_space, H5S_sel_iter_t *file_iter,
		 hsize_t nelmts, hid_t dxpl_id, void *_buf/*out*/)
{
    H5S_hyper_io_info_t io_info;  /* Block of parameters to pass into recursive calls */
    hsize_t  num_read=0;       /* number of elements read into buffer */
    herr_t  ret_value=SUCCEED;

    FUNC_ENTER (H5S_hyper_fgath, 0);

    /* Check args */
    assert (f);
    assert (layout);
    assert (elmt_size>0);
    assert (file_space);
    assert (file_iter);
    assert (nelmts>0);
    assert (_buf);

#ifdef QAK
    printf("%s: check 1.0\n", FUNC);
#endif /* QAK */

    /* Check for the special case of just one H5Sselect_hyperslab call made */
    if(file_space->select.sel_info.hslab.diminfo!=NULL) {
        /* Use optimized call to read in regular hyperslab */
        num_read=H5S_hyper_fread_opt(f,layout,pline,fill,efl,elmt_size,file_space,file_iter,nelmts,dxpl_id,_buf);
    } /* end if */
    /* Perform generic hyperslab operation */
    else {
        /* Initialize parameter block for recursive calls */
        io_info.f=f;
        io_info.layout=layout;
        io_info.pline=pline;
        io_info.fill=fill;
        io_info.efl=efl;
        io_info.elmt_size=elmt_size;
        io_info.space=file_space;
        io_info.iter=file_iter;
        io_info.nelmts=nelmts;
        io_info.dxpl_id = dxpl_id;
        io_info.src=NULL;
        io_info.dst=_buf;

        /* Set the hyperslab size to copy */
        io_info.hsize[0]=1;
        H5V_array_fill(io_info.hsize,io_info.hsize,sizeof(io_info.hsize[0]),file_space->extent.u.simple.rank);
        io_info.hsize[file_space->extent.u.simple.rank]=elmt_size;

        /* Recursively input the hyperslabs currently defined */
        /* starting with the slowest changing dimension */
        num_read=H5S_hyper_fread(-1,&io_info);
#ifdef QAK
        printf("%s: check 5.0, num_read=%d\n",FUNC,(int)num_read);
#endif /* QAK */
    } /* end else */

    FUNC_LEAVE (ret_value==SUCCEED ? num_read : 0);
} /* H5S_hyper_fgath() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_fwrite
 *
 * Purpose:	Recursively scatters data points to a file using the parameters
 *      passed to H5S_hyper_fscat.
 *
 * Return:	Success:	Number of elements copied.
 *
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_fwrite (intn dim, H5S_hyper_io_info_t *io_info)
{
    hsize_t region_size;                /* Size of lowest region */
    uintn parm_init=0;          /* Whether one-shot parameters set up */
    H5S_hyper_region_t *regions;  /* Pointer to array of hyperslab nodes overlapped */
    size_t num_regions;         /* number of regions overlapped */
    size_t i;                   /* Counters */
    intn j;
    hsize_t num_written=0;          /* Number of elements read */
    uintn cache_hyper;          /* Hyperslab caching turned on? */
    uintn block_limit;          /* Hyperslab cache limit */

    FUNC_ENTER (H5S_hyper_fwrite, 0);

    assert(io_info);

    /* Get the hyperslab cache setting and limit */
    if (H5P_get(io_info->dxpl_id,H5D_XFER_HYPER_CACHE_NAME,&cache_hyper)<0)
        HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, 0, "unable to get value");
    if (H5P_get(io_info->dxpl_id,H5D_XFER_HYPER_CACHE_LIM_NAME,&block_limit)<0)
        HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, 0, "unable to get value");


#ifdef QAK
    printf("%s: check 1.0\n", FUNC);
#endif /* QAK */
    /* Get a sorted list (in the next dimension down) of the regions which */
    /*  overlap the current index in this dim */
    if((regions=H5S_hyper_get_regions(&num_regions,io_info->space->extent.u.simple.rank,
            (uintn)(dim+1),
            io_info->space->select.sel_info.hslab.hyper_lst->count,
            io_info->space->select.sel_info.hslab.hyper_lst->lo_bounds,
            io_info->iter->hyp.pos,io_info->space->select.offset))!=NULL) {

#ifdef QAK
    printf("%s: check 1.1, regions=%p\n", FUNC,regions);
	printf("%s: check 1.2, rank=%d\n",
	       FUNC,(int)io_info->space->extent.u.simple.rank);
	for(i=0; i<num_regions; i++)
	    printf("%s: check 2.1, region #%d: start=%d, end=%d\n",
		   FUNC,i,(int)regions[i].start,(int)regions[i].end);
#endif /* QAK */

        /* Check if this is the second to last dimension in dataset */
        /*  (Which means that we've got a list of the regions in the fastest */
        /*   changing dimension and should input those regions) */
        if((uintn)(dim+2)==io_info->space->extent.u.simple.rank) {

            /* perform I/O on data from regions */
            for(i=0; i<num_regions && io_info->nelmts>0; i++) {
                /* Compute the size of the region to read */
                H5_CHECK_OVERFLOW(io_info->nelmts,hsize_t,hssize_t);
                region_size=MIN((hssize_t)io_info->nelmts, (regions[i].end-regions[i].start)+1);

                /* Check if this hyperslab block is cached or could be cached */
                if(!regions[i].node->cinfo.cached && (cache_hyper && (block_limit==0 || block_limit>=(regions[i].node->cinfo.size*io_info->elmt_size)))) {
                    /* if we aren't cached, attempt to cache the block */
                    H5S_hyper_block_cache(regions[i].node,io_info,0);
                } /* end if */

                /* Write information to the cached block */
                if(regions[i].node->cinfo.cached) {
                    if(H5S_hyper_block_write(regions[i].node,io_info,region_size)<0)
                        HRETURN_ERROR (H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
                }
                else {
                    /* Set up hyperslab I/O parameters which apply to all regions */
                    if(!parm_init) {
                        /* Copy the location of the region in the file */
                        HDmemcpy(io_info->offset, io_info->iter->hyp.pos, (io_info->space->extent.u.simple.rank * sizeof(hssize_t)));
                        io_info->offset[io_info->space->extent.u.simple.rank]=0;

                        /* Set flag */
                        parm_init=1;
                    } /* end if */

                    io_info->hsize[io_info->space->extent.u.simple.rank-1]=region_size;
                    io_info->offset[io_info->space->extent.u.simple.rank-1]=regions[i].start;

                    /*
                     * Scatter to file.
                     */
                    if (H5F_arr_write(io_info->f, io_info->dxpl_id,
				      io_info->layout, io_info->pline,
				      io_info->fill, io_info->efl,
				      io_info->hsize, io_info->hsize, zero,
				      io_info->offset, io_info->src)<0) {
                        HRETURN_ERROR (H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
                    }
                } /* end else */

                /* Advance the pointer in the buffer */
                io_info->src = ((const uint8_t *)io_info->src) +
				   region_size*io_info->elmt_size;

                /* Increment the number of elements read */
                num_written+=region_size;

                /* Decrement the buffer left */
                io_info->nelmts-=region_size;

                /* Set the next position to start at */
                if(region_size==(hsize_t)((regions[i].end-regions[i].start)+1)
                        && i==(num_regions-1))
                    io_info->iter->hyp.pos[dim+1]=(-1);
                else
                    io_info->iter->hyp.pos[dim+1] = regions[i].start +
							region_size;

                /* Decrement the iterator count */
                io_info->iter->hyp.elmt_left-=region_size;
            } /* end for */
        } else { /* recurse on each region to next dimension down */

            /* Increment the dimension we are working with */
            dim++;

            /* Step through each region in this dimension */
            for(i=0; i<num_regions && io_info->nelmts>0; i++) {
                /* Step through each location in each region */
                for(j=MAX(io_info->iter->hyp.pos[dim],regions[i].start); j<=regions[i].end && io_info->nelmts>0; j++) {
                    /* Set the correct position we are working on */
                    io_info->iter->hyp.pos[dim]=j;

                    /* Go get the regions in the next lower dimension */
                    num_written+=H5S_hyper_fwrite(dim, io_info);

                    /* Advance to the next row if we got the whole region */
                    if(io_info->iter->hyp.pos[dim+1]==(-1))
                        io_info->iter->hyp.pos[dim]=j+1;
                } /* end for */
                if(j>regions[i].end && io_info->iter->hyp.pos[dim+1]==(-1)
                        && i==(num_regions-1))
                    io_info->iter->hyp.pos[dim]=(-1);
            } /* end for */
        } /* end else */

        /* Release the temporary buffer */
        H5FL_ARR_FREE(H5S_hyper_region_t,regions);
    } /* end if */

#ifdef QAK
    printf("%s: check 2.0\n", FUNC);
#endif /* QAK */
    FUNC_LEAVE (num_written);
}   /* H5S_hyper_fwrite() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_fwrite_opt
 *
 * Purpose:	Performs an optimized scatter to the file, based on a regular
 *      hyperslab (i.e. one which was generated from just one call to
 *      H5Sselect_hyperslab).
 *
 * Return:	Success:	Number of elements copied.
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Friday, July 6, 2001
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_fwrite_opt (H5F_t *f, const struct H5O_layout_t *layout,
		 const struct H5O_pline_t *pline,
		 const struct H5O_fill_t *fill,
		 const struct H5O_efl_t *efl, size_t elmt_size,
		 const H5S_t *file_space, H5S_sel_iter_t *file_iter,
		 hsize_t nelmts, hid_t dxpl_id, const void *_buf)
{
    size_t *seq_len_arr=NULL;      /* Array of sequence lengths */
    hsize_t *buf_off_arr=NULL;     /* Array of dataset offsets */
    size_t nseq=0;              /* Number of sequence/offsets stored in the arrays */
    size_t tot_buf_size=0;      /* Total number of bytes in buffer */

    hssize_t offset[H5O_LAYOUT_NDIMS];      /* Offset on disk */
    hsize_t	slab[H5O_LAYOUT_NDIMS];         /* Hyperslab size */
    hssize_t	wrap[H5O_LAYOUT_NDIMS];         /* Bytes to wrap around at the end of a row */
    hsize_t	skip[H5O_LAYOUT_NDIMS];         /* Bytes to skip between blocks */
    hsize_t	tmp_count[H5O_LAYOUT_NDIMS];    /* Temporary block count */
    hsize_t	tmp_block[H5O_LAYOUT_NDIMS];    /* Temporary block offset */
    const uint8_t	*buf=_buf;      /* Alias for pointer arithmetic */
    const H5S_hyper_dim_t *tdiminfo;    /* Local pointer to diminfo information */
    hssize_t fast_dim_start,            /* Local copies of fastest changing dimension info */
        fast_dim_offset;
    hsize_t fast_dim_stride,            /* Local copies of fastest changing dimension info */
        fast_dim_block,
        fast_dim_count,
        fast_dim_buf_off;
    hsize_t tot_blk_count;      /* Total number of blocks left to output */
    size_t act_blk_count;      /* Actual number of blocks to output */
    intn fast_dim;  /* Rank of the fastest changing dimension for the dataspace */
    intn temp_dim;  /* Temporary rank holder */
    hsize_t	acc;	/* Accumulator */
    hsize_t	buf_off;        /* Current buffer offset for copying memory */
    intn i;         /* Counters */
    uintn u;        /* Counters */
    intn   	ndims;      /* Number of dimensions of dataset */
    size_t actual_write;     /* The actual number of elements to write out */
    size_t actual_bytes;    /* The actual number of bytes to copy */
    size_t io_left;         /* The number of elements left in I/O operation */
    size_t tot_seq;         /* The number of sequences filled */
    hsize_t *buf_off_arr_p;     /* Pointer into the buffer offset array */
    size_t seq_count;           /* Temporary count of sequences left to process */
#ifndef NO_DUFFS_DEVICE
    size_t duffs_index;         /* Counting index for Duff's device */
#endif /* NO_DUFFS_DEVICE */
    size_t vector_size;         /* Value for vector size */
    hsize_t ret_value=0;        /* Return value */

    FUNC_ENTER (H5S_hyper_fwrite_opt, 0);

#ifdef QAK
printf("%s: Called!, file_iter->hyp.pos[0]==%d\n",FUNC,(int)file_iter->hyp.pos[0]);
#endif /* QAK */
    /* Check if this is the first element written from the hyperslab */
    if(file_iter->hyp.pos[0]==(-1)) {
        for(u=0; u<file_space->extent.u.simple.rank; u++)
            file_iter->hyp.pos[u]=file_space->select.sel_info.hslab.diminfo[u].start;
    } /* end if */

#ifdef QAK
for(i=0; i<file_space->extent.u.simple.rank; i++)
    printf("%s: file_file->hyp.pos[%d]=%d\n",FUNC,(int)i,(int)file_iter->hyp.pos[i]);
#endif /* QAK */

    /* Get the hyperslab vector size */
    if (H5P_get(dxpl_id,H5D_XFER_HYPER_VECTOR_SIZE_NAME,&vector_size)<0)
        HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, 0, "unable to get value");

    /* Allocate the vector I/O arrays */
    if((seq_len_arr = H5FL_ARR_ALLOC(size_t,vector_size,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate vector I/O array");
    if((buf_off_arr = H5FL_ARR_ALLOC(hsize_t,vector_size,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate vector I/O array");

    /* Set the rank of the fastest changing dimension */
    fast_dim=file_space->extent.u.simple.rank-1;
    ndims=file_space->extent.u.simple.rank;

    /* initialize row sizes for each dimension */
    for(i=(ndims-1),acc=1; i>=0; i--) {
        slab[i]=acc*elmt_size;
        acc*=file_space->extent.u.simple.size[i];
    } /* end for */

    /* Set the number of elements left for I/O */
    assert(nelmts==(hsize_t)((size_t)nelmts)); /*check for overflow*/
    io_left=(size_t)nelmts;

#ifdef QAK
    printf("%s: fast_dim=%d\n",FUNC,(int)fast_dim);
    printf("%s: file_space->select.sel_info.hslab.diminfo[%d].start=%d\n",FUNC,(int)fast_dim,(int)file_space->select.sel_info.hslab.diminfo[fast_dim].start);
    printf("%s: file_space->select.sel_info.hslab.diminfo[%d].stride=%d\n",FUNC,(int)fast_dim,(int)file_space->select.sel_info.hslab.diminfo[fast_dim].stride);
#endif /* QAK */
    /* Check if we stopped in the middle of a sequence of elements */
    if((file_iter->hyp.pos[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start)%file_space->select.sel_info.hslab.diminfo[fast_dim].stride!=0 ||
        ((file_iter->hyp.pos[fast_dim]!=file_space->select.sel_info.hslab.diminfo[fast_dim].start) && file_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)) {
        hsize_t leftover;  /* The number of elements left over from the last sequence */

#ifdef QAK
printf("%s: Check 1.0\n",FUNC);
#endif /* QAK */
        /* Calculate the number of elements left in the sequence */
        if(file_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)
            leftover=file_space->select.sel_info.hslab.diminfo[fast_dim].block-(file_iter->hyp.pos[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start);
        else
            leftover=file_space->select.sel_info.hslab.diminfo[fast_dim].block-((file_iter->hyp.pos[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start)%file_space->select.sel_info.hslab.diminfo[fast_dim].stride);

        /* Make certain that we don't write too many */
        actual_write=MIN(leftover,nelmts);
        actual_bytes=actual_write*elmt_size;

        /* Copy the location of the point to get */
        HDmemcpy(offset, file_iter->hyp.pos,ndims*sizeof(hssize_t));
        offset[ndims] = 0;

        /* Add in the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] += file_space->select.offset[i];
#ifdef QAK
for(i=0; i<ndims+1; i++)
    printf("%s: offset[%d]=%d\n",FUNC,(int)i,(int)offset[i]);
#endif /* QAK */

        /* Compute the initial buffer offset */
        for(i=0,buf_off=0; i<ndims; i++)
            buf_off+=offset[i]*slab[i];
#ifdef QAK
printf("%s: buf_off=%ld, actual_write=%d, actual_bytes=%d\n",FUNC,(long)buf_off,(int)actual_write,(int)actual_bytes);
#endif /* QAK */

        /* Write out the rest of the sequence */
        if (H5F_seq_write(f, dxpl_id, layout, pline, fill, efl, file_space,
            elmt_size, actual_bytes, buf_off, buf)<0) {
            HRETURN_ERROR(H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
        }

        /* Increment the offset of the buffer */
        buf+=actual_bytes;

        /* Decrement the amount left to write */
        io_left-=actual_write;

        /* Advance the point iterator */
        /* If we had enough buffer space to write out the rest of the sequence
         * in the fastest changing dimension, move the iterator offset to
         * the beginning of the next block to write.  Otherwise, just advance
         * the iterator in the fastest changing dimension.
         */
        if(actual_write==leftover) {
            /* Move iterator offset to beginning of next sequence in the fastest changing dimension */
            H5S_hyper_iter_next(file_space,file_iter);
        } /* end if */
        else {
            file_iter->hyp.pos[fast_dim]+=actual_write; /* whole sequence not written out, just advance fastest dimension offset */
        } /* end if */
    } /* end if */

    /* Now that we've cleared the "remainder" of the previous fastest dimension
     * sequence, we must be at the beginning of a sequence, so use the fancy
     * algorithm to compute the offsets and run through as many as possible,
     * until the buffer runs dry.
     */
    if(io_left>0) { /* Just in case the "remainder" above emptied the buffer */
#ifdef QAK
printf("%s: Check 2.0, ndims=%d, io_left=%d, nelmts=%d\n",FUNC,(int)ndims,(int)io_left,(int)nelmts);
#endif /* QAK */
        /* Compute the arrays to perform I/O on */
        /* Copy the location of the point to get */
        HDmemcpy(offset, file_iter->hyp.pos,ndims*sizeof(hssize_t));
        offset[ndims] = 0;
#ifdef QAK
for(i=0; i<ndims+1; i++)
    printf("%s: offset[%d]=%d\n",FUNC,(int)i,(int)offset[i]);
#endif /* QAK */

        /* Add in the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] += file_space->select.offset[i];

        /* Compute the current "counts" for this location */
        for(i=0; i<ndims; i++) {
            tmp_count[i] = (file_iter->hyp.pos[i]-file_space->select.sel_info.hslab.diminfo[i].start)%file_space->select.sel_info.hslab.diminfo[i].stride;
            tmp_block[i] = (file_iter->hyp.pos[i]-file_space->select.sel_info.hslab.diminfo[i].start)/file_space->select.sel_info.hslab.diminfo[i].stride;
        } /* end for */
#ifdef QAK
for(i=0; i<ndims; i++) {
    printf("%s: tmp_count[%d]=%d, tmp_block[%d]=%d\n",FUNC,(int)i,(int)tmp_count[i],(int)i,(int)tmp_block[i]);
    printf("%s: slab[%d]=%d\n",FUNC,(int)i,(int)slab[i]);
}
#endif /* QAK */

        /* Compute the initial buffer offset */
        for(i=0,buf_off=0; i<ndims; i++)
            buf_off+=offset[i]*slab[i];

        /* Set the number of elements to write each time */
        actual_write=file_space->select.sel_info.hslab.diminfo[fast_dim].block;

        /* Set the number of actual bytes */
        actual_bytes=actual_write*elmt_size;
#ifdef QAK
printf("%s: buf_off=%ld, actual_write=%d, actual_bytes=%d\n",FUNC,(long)buf_off,(int)actual_write,(int)actual_bytes);
#endif /* QAK */

#ifdef QAK
for(i=0; i<file_space->extent.u.simple.rank; i++)
    printf("%s: diminfo: start[%d]=%d, stride[%d]=%d, block[%d]=%d, count[%d]=%d\n",FUNC,
        (int)i,(int)file_space->select.sel_info.hslab.diminfo[i].start,
        (int)i,(int)file_space->select.sel_info.hslab.diminfo[i].stride,
        (int)i,(int)file_space->select.sel_info.hslab.diminfo[i].block,
        (int)i,(int)file_space->select.sel_info.hslab.diminfo[i].count);
#endif /* QAK */

        /* Set the local copy of the diminfo pointer */
        tdiminfo=file_space->select.sel_info.hslab.diminfo;

        /* Set local copies of information for the fastest changing dimension */
        fast_dim_start=tdiminfo[fast_dim].start;
        fast_dim_stride=tdiminfo[fast_dim].stride;
        fast_dim_block=tdiminfo[fast_dim].block;
        fast_dim_buf_off=slab[fast_dim]*fast_dim_stride;
        fast_dim_offset=fast_dim_start+file_space->select.offset[fast_dim];

        /* Compute the number of blocks which would fit into the buffer */
        tot_blk_count=io_left/fast_dim_block;

        /* Compute the amount to wrap at the end of each row */
        for(i=0; i<ndims; i++)
            wrap[i]=(file_space->extent.u.simple.size[i]-(tdiminfo[i].stride*tdiminfo[i].count))*slab[i];

        /* Compute the amount to skip between blocks */
        for(i=0; i<ndims; i++)
            skip[i]=(tdiminfo[i].stride-tdiminfo[i].block)*slab[i];

        /* Fill the sequence length array (since they will all be the same for optimized hyperslabs) */
        for(u=0; u<vector_size; u++)
            seq_len_arr[u]=actual_bytes;

        /* Write out data until an entire sequence can't be written any longer */
        while(io_left>0) {
            /* Reset copy of number of blocks in fastest dimension */
            fast_dim_count=tdiminfo[fast_dim].count-tmp_count[fast_dim];

            /* Check if this entire row will fit into buffer */
            if(fast_dim_count<=tot_blk_count) {

                /* Entire row of blocks fits into buffer */
                act_blk_count=fast_dim_count;

                /* Loop over all the blocks in the fastest changing dimension */
                while(fast_dim_count>0) {
                    /* Gather the sequence */

                    /* Compute the number of sequences to fill */
                    tot_seq=MIN(vector_size-nseq,fast_dim_count);

                    /* Get a copy of the number of sequences to fill */
                    seq_count=tot_seq;

                    /* Set the pointer to the correct starting array element */
                    buf_off_arr_p=&buf_off_arr[nseq];

#ifdef NO_DUFFS_DEVICE
                    /* Fill up the buffer, or finish up the blocks in this dimension */
                    while(seq_count>0) {
                        /* Store of length & offset */
                        /* seq_len_arr[nseq] already has the correct value */
                        *buf_off_arr_p++=buf_off;

                        /* Increment the source offset */
                        buf_off+=fast_dim_buf_off;

                        seq_count--;
                    } /* end while */
#else /* NO_DUFFS_DEVICE */
                    duffs_index = (seq_count + 7) / 8;
                    switch (seq_count % 8) {
                        case 0:
                            do
                              {
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 7:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 6:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 5:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 4:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 3:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 2:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                        case 1:
                                /* Store of length & offset */
                                /* seq_len_arr[nseq] already has the correct value */
                                *buf_off_arr_p++=buf_off;

                                /* Increment the source offset */
                                buf_off+=fast_dim_buf_off;

                          } while (--duffs_index > 0);
                    } /* end switch */
#endif /* NO_DUFFS_DEVICE */

                    /* Increment number of array elements used */
                    nseq+=tot_seq;

                    /* Increment the total number of bytes contained in arrays */
                    tot_buf_size += tot_seq*actual_bytes;

                    /* Decrement number of blocks left */
                    fast_dim_count -= tot_seq;

                    /* If the sequence & offset arrays are full, write them out */
                    if(nseq>=vector_size) {
                        /* Write out the sequences */
                        if (H5F_seq_writev(f, dxpl_id, layout, pline, fill, efl, file_space,
                            elmt_size, nseq, seq_len_arr, buf_off_arr, buf)<0) {
                                HRETURN_ERROR(H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
                        } /* end if */

                        /* Increment the offset of the destination buffer */
                        buf+=tot_buf_size;

                        /* Reset the number of bytes & sequences */
                        tot_buf_size=0;
                        nseq=0;
                    } /* end else */
                } /* end while */

                /* Decrement number of elements left */
                io_left -= actual_write*act_blk_count;

                /* Decrement number of blocks left */
                tot_blk_count -= act_blk_count;

                /* Increment information to reflect block just processed */
                offset[fast_dim]=fast_dim_offset;    /* reset the offset in the fastest dimension */
                tmp_count[fast_dim]=0;

                /* Increment offset in destination buffer */
                buf_off += wrap[fast_dim];
            } /* end if */
            else {

                /* Entire row of blocks doesn't fit into buffer */
                act_blk_count=tot_blk_count;

                /* Reduce number of blocks to output */
                fast_dim_count=tot_blk_count;

                /* Loop over all the blocks in the fastest changing dimension */
                while(fast_dim_count>0) {
                    /* Gather the sequence */

                    /* Compute the number of sequences to fill */
                    tot_seq=MIN(vector_size-nseq,fast_dim_count);

                    /* Get a copy of the number of sequences to fill */
                    seq_count=tot_seq;

                    /* Set the pointer to the correct starting array element */
                    buf_off_arr_p=&buf_off_arr[nseq];

                    /* Fill up the buffer, or finish up the blocks in this dimension */
                    while(seq_count>0) {
                        /* Store of length & offset */
                        /* seq_len_arr[nseq] already has the correct value */
                        *buf_off_arr_p++=buf_off;

                        /* Increment the source offset */
                        buf_off+=fast_dim_buf_off;

                        seq_count--;
                    } /* end while */

                    /* Increment number of array elements used */
                    nseq+=tot_seq;

                    /* Increment the total number of bytes contained in arrays */
                    tot_buf_size += tot_seq*actual_bytes;

                    /* Decrement number of blocks left */
                    fast_dim_count -= tot_seq;

                    /* If the sequence & offset arrays are full, write them out */
                    if(nseq>=vector_size) {
                        /* Write out the sequences */
                        if (H5F_seq_writev(f, dxpl_id, layout, pline, fill, efl, file_space,
                            elmt_size, nseq, seq_len_arr, buf_off_arr, buf)<0) {
                            HRETURN_ERROR(H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
                        } /* end if */

                        /* Increment the offset of the destination buffer */
                        buf+=tot_buf_size;

                        /* Reset the number of bytes & sequences */
                        tot_buf_size=0;
                        nseq=0;
                    } /* end else */
                } /* end while */

                /* Decrement number of elements left */
                io_left -= actual_write*act_blk_count;

                /* Decrement number of blocks left */
                tot_blk_count -= act_blk_count;

                /* Increment information to reflect block just processed */
                offset[fast_dim]+=(fast_dim_stride*act_blk_count);    /* reset the offset in the fastest dimension */
                tmp_count[fast_dim]+=act_blk_count;

                /* Handle any leftover, partial blocks in this row */
                if(io_left>0) {
                    actual_write=io_left;
                    actual_bytes=actual_write*elmt_size;

                    /* Gather the sequence */

                    /* Store of length & offset */
                    seq_len_arr[nseq]=actual_bytes;
                    buf_off_arr[nseq]=buf_off;

                    /* Increment the total number of bytes contained in arrays */
                    tot_buf_size += actual_bytes;

                    /* Increment the number of sequences in arrays */
                    nseq++;

                    /* If the sequence & offset arrays are full, write them out */
                    if(nseq>=vector_size) {
                        /* Write out the sequences */
                        if (H5F_seq_writev(f, dxpl_id, layout, pline, fill, efl, file_space,
                            elmt_size, nseq, seq_len_arr, buf_off_arr, buf)<0) {
                            HRETURN_ERROR(H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
                        } /* end if */

                        /* Increment the offset of the destination buffer */
                        buf+=tot_buf_size;

                        /* Reset the number of bytes & sequences */
                        tot_buf_size=0;
                        nseq=0;
                    } /* end else */

                    /* Increment the source offset */
                    buf_off+=fast_dim_buf_off;

                    /* Decrement the number of elements left */
                    io_left -= actual_write;

                    /* Increment buffer correctly */
                    offset[fast_dim]+=actual_write;
                } /* end if */

                /* don't bother checking slower dimensions */
                assert(tot_blk_count==0);
                assert(io_left==0);
                break;
            } /* end else */

            /* Increment the offset and count for the other dimensions */
            temp_dim=fast_dim-1;
            while(temp_dim>=0) {
                /* Move to the next row in the curent dimension */
                offset[temp_dim]++;
                tmp_block[temp_dim]++;

                /* If this block is still in the range of blocks to output for the dimension, break out of loop */
                if(tmp_block[temp_dim]<tdiminfo[temp_dim].block)
                    break;
                else {
                    /* Move to the next block in the current dimension */
                    offset[temp_dim]+=(tdiminfo[temp_dim].stride-tdiminfo[temp_dim].block);
                    buf_off += skip[temp_dim];
                    tmp_block[temp_dim]=0;
                    tmp_count[temp_dim]++;

                    /* If this block is still in the range of blocks to output for the dimension, break out of loop */
                    if(tmp_count[temp_dim]<tdiminfo[temp_dim].count)
                        break;
                    else {
                        offset[temp_dim]=tdiminfo[temp_dim].start+file_space->select.offset[temp_dim];
                        buf_off += wrap[temp_dim];
                        tmp_count[temp_dim]=0; /* reset back to the beginning of the line */
                        tmp_block[temp_dim]=0;
                    } /* end else */
                } /* end else */

                /* Decrement dimension count */
                temp_dim--;
            } /* end while */
        } /* end while */

        /* Check for any stored sequences which need to be flushed */
        if(nseq>0) {
            /* Write out the sequence */
            if (H5F_seq_writev(f, dxpl_id, layout, pline, fill, efl, file_space,
                elmt_size, nseq, seq_len_arr, buf_off_arr, buf)<0) {
                HRETURN_ERROR(H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
            } /* end if */
        } /* end if */

        /* Subtract out the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] -= file_space->select.offset[i];

        /* Update the iterator with the location we stopped */
        HDmemcpy(file_iter->hyp.pos, offset, ndims*sizeof(hssize_t));
    } /* end if */

    /* Decrement the number of elements left in selection */
    file_iter->hyp.elmt_left -= (nelmts-io_left);

    ret_value= (nelmts-io_left);

done:
    if(seq_len_arr!=NULL)
        H5FL_ARR_FREE(size_t,seq_len_arr);
    if(buf_off_arr!=NULL)
        H5FL_ARR_FREE(hsize_t,buf_off_arr);

    FUNC_LEAVE (ret_value);
} /* H5S_hyper_fwrite_opt() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_fscat
 *
 * Purpose:	Scatters dataset elements from the type conversion buffer BUF
 *		to the file F where the data points are arranged according to
 *		the file data space FILE_SPACE and stored according to
 *		LAYOUT and EFL. Each element is ELMT_SIZE bytes.
 *		The caller is requesting that NELMTS elements are copied.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *		Robb Matzke, 1999-08-03
 *		The data transfer properties are passed by ID since that's
 *		what the virtual file layer needs.
 *-------------------------------------------------------------------------
 */
static herr_t
H5S_hyper_fscat (H5F_t *f, const struct H5O_layout_t *layout,
		 const struct H5O_pline_t *pline,
		 const struct H5O_fill_t *fill,
		 const struct H5O_efl_t *efl, size_t elmt_size,
		 const H5S_t *file_space, H5S_sel_iter_t *file_iter,
		 hsize_t nelmts, hid_t dxpl_id, const void *_buf)
{
    H5S_hyper_io_info_t io_info;  /* Block of parameters to pass into recursive calls */
    hsize_t  num_written=0;       /* number of elements read into buffer */
    herr_t  ret_value=SUCCEED;

    FUNC_ENTER (H5S_hyper_fscat, 0);

    /* Check args */
    assert (f);
    assert (layout);
    assert (elmt_size>0);
    assert (file_space);
    assert (file_iter);
    assert (nelmts>0);
    assert (_buf);

#ifdef QAK
    printf("%s: check 1.0\n", FUNC);
#endif /* QAK */

    /* Check for the special case of just one H5Sselect_hyperslab call made */
    if(file_space->select.sel_info.hslab.diminfo!=NULL) {
        /* Use optimized call to write out regular hyperslab */
        num_written=H5S_hyper_fwrite_opt(f,layout,pline,fill,efl,elmt_size,file_space,file_iter,nelmts,dxpl_id,_buf);
    }
    else {
        /* Initialize parameter block for recursive calls */
        io_info.f=f;
        io_info.layout=layout;
        io_info.pline=pline;
        io_info.fill=fill;
        io_info.efl=efl;
        io_info.elmt_size=elmt_size;
        io_info.space=file_space;
        io_info.iter=file_iter;
        io_info.nelmts=nelmts;
        io_info.dxpl_id = dxpl_id;
        io_info.src=_buf;
        io_info.dst=NULL;

        /* Set the hyperslab size to copy */
        io_info.hsize[0]=1;
        H5V_array_fill(io_info.hsize,io_info.hsize,sizeof(io_info.hsize[0]),file_space->extent.u.simple.rank);
        io_info.hsize[file_space->extent.u.simple.rank]=elmt_size;

        /* Recursively input the hyperslabs currently defined */
        /* starting with the slowest changing dimension */
        num_written=H5S_hyper_fwrite(-1,&io_info);
#ifdef QAK
        printf("%s: check 2.0\n", FUNC);
#endif /* QAK */
    } /* end else */

    FUNC_LEAVE (ret_value==FAIL ? ret_value : (num_written >0) ? SUCCEED : FAIL);
} /* H5S_hyper_fscat() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_mread
 *
 * Purpose:	Recursively gathers data points from memory using the
 *		parameters passed to H5S_hyper_mgath.
 *
 * Return:	Success:	Number of elements copied.
 *
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info)
{
    hsize_t region_size;                /* Size of lowest region */
    H5S_hyper_region_t *regions;  /* Pointer to array of hyperslab nodes overlapped */
    size_t num_regions;         /* number of regions overlapped */
    size_t i;                   /* Counters */
    intn j;
    hsize_t num_read=0;          /* Number of elements read */

    FUNC_ENTER (H5S_hyper_mread, 0);

    assert(io_info);

#ifdef QAK
    printf("%s: check 1.0, dim=%d\n",FUNC,dim);
#endif /* QAK */

    /* Get a sorted list (in the next dimension down) of the regions which */
    /*  overlap the current index in this dim */
    if((regions=H5S_hyper_get_regions(&num_regions,io_info->space->extent.u.simple.rank,
            (uintn)(dim+1),
            io_info->space->select.sel_info.hslab.hyper_lst->count,
            io_info->space->select.sel_info.hslab.hyper_lst->lo_bounds,
            io_info->iter->hyp.pos,io_info->space->select.offset))!=NULL) {

        /* Check if this is the second to last dimension in dataset */
        /*  (Which means that we've got a list of the regions in the fastest */
        /*   changing dimension and should input those regions) */
#ifdef QAK
	printf("%s: check 2.0, rank=%d, num_regions=%d\n",
	       FUNC, (int)io_info->space->extent.u.simple.rank,
	       (int)num_regions);
	for(i=0; i<num_regions; i++)
	    printf("%s: check 2.1, region #%d: start=%d, end=%d\n",
		   FUNC,i,(int)regions[i].start,(int)regions[i].end);
#endif /* QAK */

        if((uintn)(dim+2)==io_info->space->extent.u.simple.rank) {

            /* Set up hyperslab I/O parameters which apply to all regions */

            /* Copy the location of the region in the file */
            HDmemcpy(io_info->offset, io_info->iter->hyp.pos, (io_info->space->extent.u.simple.rank * sizeof(hssize_t)));
            io_info->offset[io_info->space->extent.u.simple.rank]=0;

            /* perform I/O on data from regions */
            for(i=0; i<num_regions && io_info->nelmts>0; i++) {
                H5_CHECK_OVERFLOW(io_info->nelmts,hsize_t,hssize_t);
                region_size=MIN((hssize_t)io_info->nelmts,(regions[i].end-regions[i].start)+1);
                io_info->hsize[io_info->space->extent.u.simple.rank-1]=region_size;
                io_info->offset[io_info->space->extent.u.simple.rank-1]=regions[i].start;
#ifdef QAK
		printf("%s: check 2.1, i=%d, region_size=%d\n",
		       FUNC,(int)i,(int)region_size);
#endif /* QAK */

                /*
                 * Gather from memory.
                 */
                if (H5V_hyper_copy (io_info->space->extent.u.simple.rank+1,
                        io_info->hsize, io_info->hsize, zero, io_info->dst,
                        io_info->mem_size, io_info->offset, io_info->src)<0) {
                    HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0,
				   "unable to gather data from memory");
                }

                /* Advance the pointer in the buffer */
                io_info->dst = ((uint8_t *)io_info->dst) + region_size*io_info->elmt_size;

                /* Increment the number of elements read */
                num_read+=region_size;

                /* Decrement the buffer left */
                io_info->nelmts-=region_size;

                /* Set the next position to start at */
                if(region_size==(hsize_t)((regions[i].end-regions[i].start)+1)
                        && i==(num_regions-1))
                    io_info->iter->hyp.pos[dim+1]=(-1);
                else
                    io_info->iter->hyp.pos[dim+1] =regions[i].start +
						       region_size;

                /* Decrement the iterator count */
                io_info->iter->hyp.elmt_left-=region_size;
            } /* end for */
        } else { /* recurse on each region to next dimension down */
#ifdef QAK
	    printf("%s: check 3.0, num_regions=%d\n",FUNC,(int)num_regions);
#endif /* QAK */

            /* Increment the dimension we are working with */
            dim++;

            /* Step through each region in this dimension */
            for(i=0; i<num_regions && io_info->nelmts>0; i++) {
                /* Step through each location in each region */
                for(j=MAX(io_info->iter->hyp.pos[dim],regions[i].start); j<=regions[i].end && io_info->nelmts>0; j++) {
#ifdef QAK
		    printf("%s: check 4.0, dim=%d, location=%d\n",FUNC,dim,j);
#endif /* QAK */

                    /* Set the correct position we are working on */
                    io_info->iter->hyp.pos[dim]=j;

                    /* Go get the regions in the next lower dimension */
                    num_read+=H5S_hyper_mread(dim, io_info);

                    /* Advance to the next row if we got the whole region */
                    if(io_info->iter->hyp.pos[dim+1]==(-1))
                        io_info->iter->hyp.pos[dim]=j+1;
                } /* end for */
                if(j>regions[i].end && io_info->iter->hyp.pos[dim+1]==(-1)
                        && i==(num_regions-1))
                    io_info->iter->hyp.pos[dim]=(-1);
            } /* end for */
        } /* end else */

        /* Release the temporary buffer */
        H5FL_ARR_FREE(H5S_hyper_region_t,regions);
    } /* end if */

    FUNC_LEAVE (num_read);
}   /* H5S_hyper_mread() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_mread_opt
 *
 * Purpose:	Performs an optimized gather from a memory buffer, based on a
 *      regular hyperslab (i.e. one which was generated from just one call to
 *      H5Sselect_hyperslab).
 *
 * Return:	Success:	Number of elements copied.
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, September 12, 2000
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_mread_opt (const void *_buf, size_t elmt_size,
		 const H5S_t *mem_space, H5S_sel_iter_t *mem_iter,
		 hsize_t nelmts, void *_tconv_buf/*out*/)
{
    hsize_t	mem_size[H5O_LAYOUT_NDIMS];     /* Size of the source buffer */
    hsize_t	slab[H5O_LAYOUT_NDIMS];         /* Hyperslab size */
    hssize_t	wrap[H5O_LAYOUT_NDIMS];         /* Bytes to wrap around at the end of a row */
    hsize_t	skip[H5O_LAYOUT_NDIMS];         /* Bytes to skip between blocks */
    hssize_t offset[H5O_LAYOUT_NDIMS];      /* Offset on disk */
    hsize_t	tmp_count[H5O_LAYOUT_NDIMS];    /* Temporary block count */
    hsize_t	tmp_block[H5O_LAYOUT_NDIMS];    /* Temporary block offset */
    const uint8_t	*src=(const uint8_t *)_buf;   /* Alias for pointer arithmetic */
    uint8_t	*dst=(uint8_t *)_tconv_buf;   /* Alias for pointer arithmetic */
    const H5S_hyper_dim_t *tdiminfo;      /* Temporary pointer to diminfo information */
    hssize_t fast_dim_start,            /* Local copies of fastest changing dimension info */
        fast_dim_offset;
    hsize_t fast_dim_stride,            /* Local copies of fastest changing dimension info */
        fast_dim_block,
        fast_dim_count;
    hsize_t tot_blk_count;              /* Total number of blocks left to output */
    size_t act_blk_count;              /* Actual number of blocks to output */
    size_t fast_dim_buf_off;            /* Local copy of amount to move fastest dimension buffer offset */
    intn fast_dim;  /* Rank of the fastest changing dimension for the dataspace */
    intn temp_dim;  /* Temporary rank holder */
    hsize_t	acc;	/* Accumulator */
    intn i;         /* Counters */
    uintn u;         /* Counters */
    intn   	ndims;      /* Number of dimensions of dataset */
    size_t actual_read;     /* The actual number of elements to read in */
    size_t actual_bytes;    /* The actual number of bytes to copy */
    size_t io_left;         /* The number of elements left in I/O operation */
#ifndef NO_DUFFS_DEVICE
    hsize_t duffs_index;    /* Counting index for Duff's device */
#endif /* NO_DUFFS_DEVICE */

    FUNC_ENTER (H5S_hyper_mread_opt, 0);

#ifdef QAK
printf("%s: Called!, nelmts=%lu, elmt_size=%d\n",FUNC,(unsigned long)nelmts,(int)elmt_size);
#endif /* QAK */
    /* Check if this is the first element read in from the hyperslab */
    if(mem_iter->hyp.pos[0]==(-1)) {
        for(u=0; u<mem_space->extent.u.simple.rank; u++)
            mem_iter->hyp.pos[u]=mem_space->select.sel_info.hslab.diminfo[u].start;
    } /* end if */

#ifdef QAK
for(u=0; u<mem_space->extent.u.simple.rank; u++)
    printf("%s: mem_file->hyp.pos[%u]=%d\n",FUNC,(unsigned)u,(int)mem_iter->hyp.pos[u]);
#endif /* QAK */

    /* Set the aliases for a few important dimension ranks */
    fast_dim=mem_space->extent.u.simple.rank-1;
    ndims=mem_space->extent.u.simple.rank;

    /* Set up the size of the memory space */
    HDmemcpy(mem_size, mem_space->extent.u.simple.size,mem_space->extent.u.simple.rank*sizeof(hsize_t));
    mem_size[mem_space->extent.u.simple.rank]=elmt_size;

    /* initialize row sizes for each dimension */
    for(i=(ndims-1),acc=1; i>=0; i--) {
        slab[i]=acc*elmt_size;
        acc*=mem_size[i];
    } /* end for */
#ifdef QAK
for(i=0; i<ndims; i++)
    printf("%s: mem_size[%d]=%d, slab[%d]=%d\n",FUNC,(int)i,(int)mem_size[i],(int)i,(int)slab[i]);
#endif /* QAK */

    /* Set the number of elements left for I/O */
    assert(nelmts==(hsize_t)((size_t)nelmts)); /*check for overflow*/
    io_left=(size_t)nelmts;

    /* Check if we stopped in the middle of a sequence of elements */
    if((mem_iter->hyp.pos[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride!=0 ||
        ((mem_iter->hyp.pos[fast_dim]!=mem_space->select.sel_info.hslab.diminfo[fast_dim].start) && mem_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)) {
        uintn leftover;  /* The number of elements left over from the last sequence */

#ifdef QAK
printf("%s: Check 1.0, io_left=%lu\n",FUNC,(unsigned long)io_left);
#endif /* QAK */
        /* Calculate the number of elements left in the sequence */
        if(mem_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)
            leftover=mem_space->select.sel_info.hslab.diminfo[fast_dim].block-(mem_iter->hyp.pos[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start);
        else
            leftover=mem_space->select.sel_info.hslab.diminfo[fast_dim].block-((mem_iter->hyp.pos[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride);

        /* Make certain that we don't write too many */
        actual_read=MIN(leftover,nelmts);
        actual_bytes=actual_read*elmt_size;

        /* Copy the location of the point to get */
        HDmemcpy(offset, mem_iter->hyp.pos,ndims*sizeof(hssize_t));
        offset[ndims] = 0;

        /* Add in the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] += mem_space->select.offset[i];

        /* Compute the initial buffer offset */
        for(i=0,src=_buf; i<ndims; i++)
            src+=offset[i]*slab[i];

        /* Scatter out the rest of the sequence */
        HDmemcpy(dst,src,actual_bytes);

        /* Increment the offset of the buffer */
        dst+=actual_bytes;

        /* Decrement the number of elements written out */
        io_left -= actual_read;

        /* Advance the point iterator */
        /* If we had enough buffer space to read in the rest of the sequence
         * in the fastest changing dimension, move the iterator offset to
         * the beginning of the next block to read.  Otherwise, just advance
         * the iterator in the fastest changing dimension.
         */
        if(actual_read==leftover) {
            /* Move iterator offset to beginning of next sequence in the fastest changing dimension */
            H5S_hyper_iter_next(mem_space,mem_iter);
        } /* end if */
        else {
            mem_iter->hyp.pos[fast_dim]+=actual_read; /* whole sequence not written out, just advance fastest dimension offset */
        } /* end if */
    } /* end if */

    /* Now that we've cleared the "remainder" of the previous fastest dimension
     * sequence, we must be at the beginning of a sequence, so use the fancy
     * algorithm to compute the offsets and run through as many as possible,
     * until the buffer fills up.
     */
    if(io_left>0) { /* Just in case the "remainder" above filled the buffer */
#ifdef QAK
printf("%s: Check 2.0, io_left=%lu\n",FUNC,(unsigned long)io_left);
#endif /* QAK */
        /* Compute the arrays to perform I/O on */
        /* Copy the location of the point to get */
        HDmemcpy(offset, mem_iter->hyp.pos,ndims*sizeof(hssize_t));
        offset[ndims] = 0;

        /* Add in the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] += mem_space->select.offset[i];

        /* Compute the current "counts" for this location */
        for(i=0; i<ndims; i++) {
            tmp_count[i] = (mem_iter->hyp.pos[i]-mem_space->select.sel_info.hslab.diminfo[i].start)%mem_space->select.sel_info.hslab.diminfo[i].stride;
            tmp_block[i] = (mem_iter->hyp.pos[i]-mem_space->select.sel_info.hslab.diminfo[i].start)/mem_space->select.sel_info.hslab.diminfo[i].stride;
        } /* end for */

        /* Compute the initial buffer offset */
        for(i=0,src=_buf; i<ndims; i++)
            src+=offset[i]*slab[i];

        /* Set the number of elements to write each time */
        actual_read=mem_space->select.sel_info.hslab.diminfo[fast_dim].block;

        /* Set the number of actual bytes */
        actual_bytes=actual_read*elmt_size;
#ifdef QAK
printf("%s: src=%p, actual_bytes=%u\n",FUNC,src,(int)actual_bytes);
#endif /* QAK */

#ifdef QAK
printf("%s: actual_read=%d\n",FUNC,(int)actual_read);
for(i=0; i<ndims; i++)
    printf("%s: diminfo: start[%d]=%d, stride[%d]=%d, block[%d]=%d, count[%d]=%d\n",FUNC,
        (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].start,
        (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].stride,
        (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].block,
        (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].count);
#endif /* QAK */

        /* Set the local copy of the diminfo pointer */
        tdiminfo=mem_space->select.sel_info.hslab.diminfo;

        /* Set local copies of information for the fastest changing dimension */
        fast_dim_start=tdiminfo[fast_dim].start;
        fast_dim_stride=tdiminfo[fast_dim].stride;
        fast_dim_block=tdiminfo[fast_dim].block;
        fast_dim_buf_off=slab[fast_dim]*fast_dim_stride;
        fast_dim_offset=fast_dim_start+mem_space->select.offset[fast_dim];

        /* Compute the number of blocks which would fit into the buffer */
        tot_blk_count=io_left/fast_dim_block;

        /* Compute the amount to wrap at the end of each row */
        for(i=0; i<ndims; i++)
            wrap[i]=(mem_size[i]-(tdiminfo[i].stride*tdiminfo[i].count))*slab[i];

        /* Compute the amount to skip between blocks */
        for(i=0; i<ndims; i++)
            skip[i]=(tdiminfo[i].stride-tdiminfo[i].block)*slab[i];

        /* Read in data until an entire sequence can't be written out any longer */
        while(io_left>0) {
            /* Reset copy of number of blocks in fastest dimension */
            fast_dim_count=tdiminfo[fast_dim].count-tmp_count[fast_dim];

            /* Check if this entire row will fit into buffer */
            if(fast_dim_count<=tot_blk_count) {

                /* Entire row of blocks fits into buffer */
                act_blk_count=fast_dim_count;

#ifdef NO_DUFFS_DEVICE
                /* Loop over all the blocks in the fastest changing dimension */
                while(fast_dim_count>0) {
                    /* Scatter out the sequence */
                    HDmemcpy(dst,src,actual_bytes);

                    /* Increment the offset of the buffer */
                    dst+=actual_bytes;

                    /* Increment information to reflect block just processed */
                    src+=fast_dim_buf_off;

                    /* Decrement number of blocks */
                    fast_dim_count--;
                } /* end while */
#else /* NO_DUFFS_DEVICE */
                duffs_index = (fast_dim_count + 7) / 8;
                /* The following size_t cast is required on HPUX 10.20 in
                 * order to make the system compuiler happy.  It can be
                 * removed when we are no longer supporting that platform. -QAK
                 */
                switch (((size_t)fast_dim_count) % 8) {
                    case 0:
                        do
                          {
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            dst+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            src+=fast_dim_buf_off;

                    case 7:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            dst+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            src+=fast_dim_buf_off;

                    case 6:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            dst+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            src+=fast_dim_buf_off;

                    case 5:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            dst+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            src+=fast_dim_buf_off;

                    case 4:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            dst+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            src+=fast_dim_buf_off;

                    case 3:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            dst+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            src+=fast_dim_buf_off;

                    case 2:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            dst+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            src+=fast_dim_buf_off;

                    case 1:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            dst+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            src+=fast_dim_buf_off;

                      } while (--duffs_index > 0);
                } /* end switch */
#endif /* NO_DUFFS_DEVICE */

                /* Decrement number of elements left */
                io_left -= actual_read*act_blk_count;

                /* Decrement number of blocks left */
                tot_blk_count -= act_blk_count;

                /* Increment information to reflect block just processed */
                offset[fast_dim]=fast_dim_offset;    /* reset the offset in the fastest dimension */
                tmp_count[fast_dim]=0;

                /* Increment offset in destination buffer */
                src += wrap[fast_dim];
            } /* end if */
            else {

                /* Entire row of blocks doesn't fit into buffer */
                act_blk_count=tot_blk_count;

                /* Reduce number of blocks to output */
                fast_dim_count=tot_blk_count;

                /* Loop over all the blocks in the fastest changing dimension */
                while(fast_dim_count>0) {
                    /* Scatter out the sequence */
                    HDmemcpy(dst,src,actual_bytes);

                    /* Increment the offset of the buffer */
                    dst+=actual_bytes;

                    /* Increment information to reflect block just processed */
                    src+=fast_dim_buf_off;

                    /* Decrement number of blocks */
                    fast_dim_count--;
                } /* end while */

                /* Decrement number of elements left */
                io_left -= actual_read*act_blk_count;

                /* Decrement number of blocks left */
                tot_blk_count -= act_blk_count;

                /* Increment information to reflect block just processed */
                offset[fast_dim]+=(fast_dim_stride*act_blk_count);    /* reset the offset in the fastest dimension */
                tmp_count[fast_dim]+=act_blk_count;

                /* Handle any leftover, partial blocks in this row */
                if(io_left>0) {
                    actual_read=io_left;
                    actual_bytes=actual_read*elmt_size;

                    /* Scatter out the rest of the sequence */
                    HDmemcpy(dst,src,actual_bytes);

                    /* Increment the offset of the buffer */
                    dst+=actual_bytes;

                    /* Decrement the number of elements left */
                    io_left -= actual_read;

                    /* Increment buffer correctly */
                    offset[fast_dim]+=actual_read;
                } /* end if */

                /* don't bother checking slower dimensions */
                assert(tot_blk_count==0);
                assert(io_left==0);
                break;
            } /* end else */

            /* Increment the offset and count for the other dimensions */
            temp_dim=fast_dim-1;
            while(temp_dim>=0) {
                /* Move to the next row in the curent dimension */
                offset[temp_dim]++;
                tmp_block[temp_dim]++;

                /* If this block is still in the range of blocks to output for the dimension, break out of loop */
                if(tmp_block[temp_dim]<tdiminfo[temp_dim].block)
                    break;
                else {
                    /* Move to the next block in the current dimension */
                    offset[temp_dim]+=(tdiminfo[temp_dim].stride-tdiminfo[temp_dim].block);
                    src += skip[temp_dim];
                    tmp_block[temp_dim]=0;
                    tmp_count[temp_dim]++;

                    /* If this block is still in the range of blocks to output for the dimension, break out of loop */
                    if(tmp_count[temp_dim]<tdiminfo[temp_dim].count)
                        break;
                    else {
                        offset[temp_dim]=tdiminfo[temp_dim].start+mem_space->select.offset[temp_dim];
                        src += wrap[temp_dim];
                        tmp_count[temp_dim]=0; /* reset back to the beginning of the line */
                        tmp_block[temp_dim]=0;
                    } /* end else */
                } /* end else */

                /* Decrement dimension count */
                temp_dim--;
            } /* end while */
        } /* end while */

        /* Subtract out the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] -= mem_space->select.offset[i];

        /* Update the iterator with the location we stopped */
        HDmemcpy(mem_iter->hyp.pos, offset, ndims*sizeof(hssize_t));
    } /* end if */

    /* Decrement the number of elements left in selection */
    mem_iter->hyp.elmt_left-=(nelmts-io_left);

    FUNC_LEAVE (nelmts-io_left);
} /* end H5S_hyper_mread_opt() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_mgath
 *
 * Purpose:	Gathers dataset elements from application memory BUF and
 *		copies them into the data type conversion buffer TCONV_BUF.
 *		Each element is ELMT_SIZE bytes and arranged in application
 *		memory according to MEM_SPACE.  
 *		The caller is requesting that at most NELMTS be gathered.
 *
 * Return:	Success:	Number of elements copied.
 *
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_mgath (const void *_buf, size_t elmt_size,
		 const H5S_t *mem_space, H5S_sel_iter_t *mem_iter,
		 hsize_t nelmts, void *_tconv_buf/*out*/)
{
    H5S_hyper_io_info_t io_info;  /* Block of parameters to pass into recursive calls */
    hsize_t  num_read;       /* number of elements read into buffer */

    FUNC_ENTER (H5S_hyper_mgath, 0);

#ifdef QAK
    printf("%s: check 1.0, elmt_size=%d, mem_space=%p\n",
	   FUNC,(int)elmt_size,mem_space);
    printf("%s: check 1.0, mem_iter=%p, nelmts=%d\n",FUNC,mem_iter,nelmts);
    printf("%s: check 1.0, _buf=%p, _tconv_buf=%p\n",FUNC,_buf,_tconv_buf);
#endif /* QAK */

    /* Check args */
    assert (elmt_size>0);
    assert (mem_space);
    assert (mem_iter);
    assert (nelmts>0);
    assert (_buf);
    assert (_tconv_buf);

    /* Check for the special case of just one H5Sselect_hyperslab call made */
    if(mem_space->select.sel_info.hslab.diminfo!=NULL) {
        /* Use optimized call to read in regular hyperslab */
        num_read=H5S_hyper_mread_opt(_buf,elmt_size,mem_space,mem_iter,nelmts,_tconv_buf);
    }
    else {
        /* Initialize parameter block for recursive calls */
        io_info.elmt_size=elmt_size;
        io_info.space=mem_space;
        io_info.iter=mem_iter;
        io_info.nelmts=nelmts;
        io_info.src=_buf;
        io_info.dst=_tconv_buf;

        /* Set up the size of the memory space */
        HDmemcpy(io_info.mem_size, mem_space->extent.u.simple.size,mem_space->extent.u.simple.rank*sizeof(hsize_t));
        io_info.mem_size[mem_space->extent.u.simple.rank]=elmt_size;

        /* Set the hyperslab size to copy */
        io_info.hsize[0]=1;
        H5V_array_fill(io_info.hsize, io_info.hsize, sizeof(io_info.hsize[0]),mem_space->extent.u.simple.rank);
        io_info.hsize[mem_space->extent.u.simple.rank]=elmt_size;

        /* Recursively input the hyperslabs currently defined */
        /* starting with the slowest changing dimension */
        num_read=H5S_hyper_mread(-1,&io_info);
#ifdef QAK
        printf("%s: check 5.0, num_read=%d\n",FUNC,(int)num_read);
#endif /* QAK */
    } /* end else */

    FUNC_LEAVE (num_read);
}   /* H5S_hyper_mgath() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_mwrite
 *
 * Purpose:	Recursively scatters data points from memory using the parameters
 *      passed to H5S_hyper_mscat.
 *
 * Return:	Success:	Number of elements copied.
 *
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static size_t
H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info)
{
    hsize_t region_size;        /* Size of lowest region */
    H5S_hyper_region_t *regions;  /* Pointer to array of hyperslab nodes overlapped */
    size_t num_regions;         /* number of regions overlapped */
    size_t i;                   /* Counters */
    intn j;
    hsize_t num_write=0;         /* Number of elements written */

    FUNC_ENTER (H5S_hyper_mwrite, 0);

    assert(io_info);
#ifdef QAK
    printf("%s: check 1.0\n",FUNC);
#endif /* QAK */

    /* Get a sorted list (in the next dimension down) of the regions which */
    /*  overlap the current index in this dim */
    if((regions=H5S_hyper_get_regions(&num_regions,io_info->space->extent.u.simple.rank,
            (uintn)(dim+1),
            io_info->space->select.sel_info.hslab.hyper_lst->count,
            io_info->space->select.sel_info.hslab.hyper_lst->lo_bounds,
            io_info->iter->hyp.pos,io_info->space->select.offset))!=NULL) {

#ifdef QAK
	printf("%s: check 2.0, rank=%d\n",
	       FUNC,(int)io_info->space->extent.u.simple.rank);
	for(i=0; i<num_regions; i++)
	    printf("%s: check 2.1, region #%d: start=%d, end=%d\n",
		   FUNC,i,(int)regions[i].start,(int)regions[i].end);
#endif /* QAK */
        /* Check if this is the second to last dimension in dataset */
        /*  (Which means that we've got a list of the regions in the fastest */
        /*   changing dimension and should input those regions) */
        if((uintn)(dim+2)==io_info->space->extent.u.simple.rank) {

            /* Set up hyperslab I/O parameters which apply to all regions */

            /* Copy the location of the region in the file */
            HDmemcpy(io_info->offset, io_info->iter->hyp.pos, (io_info->space->extent.u.simple.rank* sizeof(hssize_t)));
            io_info->offset[io_info->space->extent.u.simple.rank]=0;

#ifdef QAK
	    printf("%s: check 3.0\n",FUNC);
#endif /* QAK */
            /* perform I/O on data from regions */
            for(i=0; i<num_regions && io_info->nelmts>0; i++) {
                H5_CHECK_OVERFLOW(io_info->nelmts,hsize_t,hssize_t);
                region_size=MIN((hssize_t)io_info->nelmts, (regions[i].end-regions[i].start)+1);
                io_info->hsize[io_info->space->extent.u.simple.rank-1]=region_size;
                io_info->offset[io_info->space->extent.u.simple.rank-1]=regions[i].start;

                /*
                 * Scatter to memory
                 */
                if (H5V_hyper_copy (io_info->space->extent.u.simple.rank+1,
				    io_info->hsize, io_info->mem_size, io_info->offset,
				    io_info->dst, io_info->hsize, zero,
				    io_info->src)<0) {
                    HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0, "unable to gather data from memory");
                }

                /* Advance the pointer in the buffer */
                io_info->src = ((const uint8_t *)io_info->src) +
				   region_size*io_info->elmt_size;

                /* Increment the number of elements read */
                num_write+=region_size;

                /* Decrement the buffer left */
                io_info->nelmts-=region_size;

                /* Set the next position to start at */
                if(region_size==(hsize_t)((regions[i].end-regions[i].start)+1)
                        && i==(num_regions-1))
                    io_info->iter->hyp.pos[dim+1]=(-1);
                else
                    io_info->iter->hyp.pos[dim+1] = regions[i].start +
							region_size;

                /* Decrement the iterator count */
                io_info->iter->hyp.elmt_left-=region_size;
            } /* end for */
        } else { /* recurse on each region to next dimension down */

            /* Increment the dimension we are working with */
            dim++;

#ifdef QAK
	    printf("%s: check 6.0, num_regions=%d\n",FUNC,(int)num_regions);
#endif /* QAK */
            /* Step through each region in this dimension */
            for(i=0; i<num_regions && io_info->nelmts>0; i++) {
                /* Step through each location in each region */
#ifdef QAK
		printf("%s: check 7.0, start[%d]=%d, end[%d]=%d, nelmts=%d\n",
		       FUNC, i, (int)regions[i].start, i,
		       (int)regions[i].end, (int)io_info->nelmts);
#endif /* QAK */
                for(j=MAX(io_info->iter->hyp.pos[dim],regions[i].start); j<=regions[i].end && io_info->nelmts>0; j++) {

                    /* Set the correct position we are working on */
                    io_info->iter->hyp.pos[dim]=j;

                    /* Go get the regions in the next lower dimension */
                    num_write+=H5S_hyper_mwrite(dim, io_info);

                    /* Advance to the next row if we got the whole region */
                    if(io_info->iter->hyp.pos[dim+1]==(-1))
                        io_info->iter->hyp.pos[dim]=j+1;
                } /* end for */
                if(j>regions[i].end && io_info->iter->hyp.pos[dim+1]==(-1)
                        && i==(num_regions-1))
                    io_info->iter->hyp.pos[dim]=(-1);
            } /* end for */
        } /* end else */

        /* Release the temporary buffer */
        H5FL_ARR_FREE(H5S_hyper_region_t,regions);
    } /* end if */

    FUNC_LEAVE (num_write);
}   /* H5S_hyper_mwrite() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_mwrite_opt
 *
 * Purpose:	Performs an optimized scatter to a memory buffer, based on a
 *      regular hyperslab (i.e. one which was generated from just one call to
 *      H5Sselect_hyperslab).
 *
 * Return:	Success:	Number of elements copied.
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, September 12, 2000
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static hsize_t
H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size,
		 const H5S_t *mem_space, H5S_sel_iter_t *mem_iter,
		 hsize_t nelmts, void *_buf/*out*/)
{
    hsize_t	mem_size[H5O_LAYOUT_NDIMS];     /* Size of the source buffer */
    hsize_t	slab[H5O_LAYOUT_NDIMS];         /* Hyperslab size */
    hssize_t	wrap[H5O_LAYOUT_NDIMS];         /* Bytes to wrap around at the end of a row */
    hsize_t	skip[H5O_LAYOUT_NDIMS];         /* Bytes to skip between blocks */
    hssize_t offset[H5O_LAYOUT_NDIMS];      /* Offset on disk */
    hsize_t	tmp_count[H5O_LAYOUT_NDIMS];    /* Temporary block count */
    hsize_t	tmp_block[H5O_LAYOUT_NDIMS];    /* Temporary block offset */
    const uint8_t	*src=(const uint8_t *)_tconv_buf;   /* Alias for pointer arithmetic */
    uint8_t	*dst=(uint8_t *)_buf;   /* Alias for pointer arithmetic */
    const H5S_hyper_dim_t *tdiminfo;      /* Temporary pointer to diminfo information */
    hssize_t fast_dim_start,            /* Local copies of fastest changing dimension info */
        fast_dim_offset;
    hsize_t fast_dim_stride,            /* Local copies of fastest changing dimension info */
        fast_dim_block,
        fast_dim_count;
    hsize_t tot_blk_count;              /* Total number of blocks left to output */
    size_t act_blk_count;              /* Actual number of blocks to output */
    size_t fast_dim_buf_off;            /* Local copy of amount to move fastest dimension buffer offset */
    intn fast_dim;  /* Rank of the fastest changing dimension for the dataspace */
    intn temp_dim;  /* Temporary rank holder */
    hsize_t	acc;	/* Accumulator */
    intn i;         /* Counters */
    uintn u;         /* Counters */
    intn   	ndims;      /* Number of dimensions of dataset */
    size_t actual_write;       /* The actual number of elements to read in */
    size_t actual_bytes;     /* The actual number of bytes to copy */
    size_t io_left;             /* The number of elements left in I/O operation */
#ifndef NO_DUFFS_DEVICE
    hsize_t duffs_index;        /* Counting index for Duff's device */
#endif /* NO_DUFFS_DEVICE */

    FUNC_ENTER (H5S_hyper_mwrite_opt, 0);

#ifdef QAK
printf("%s: Called!, nelmts=%lu, elmt_size=%d\n",FUNC,(unsigned long)nelmts,(int)elmt_size);
#endif /* QAK */
    /* Check if this is the first element read in from the hyperslab */
    if(mem_iter->hyp.pos[0]==(-1)) {
        for(u=0; u<mem_space->extent.u.simple.rank; u++)
            mem_iter->hyp.pos[u]=mem_space->select.sel_info.hslab.diminfo[u].start;
    } /* end if */

#ifdef QAK
for(u=0; u<mem_space->extent.u.simple.rank; u++)
    printf("%s: mem_file->hyp.pos[%u]=%d\n",FUNC,(unsigned)u,(int)mem_iter->hyp.pos[u]);
#endif /* QAK */

    /* Set the aliases for a few important dimension ranks */
    fast_dim=mem_space->extent.u.simple.rank-1;
    ndims=mem_space->extent.u.simple.rank;

    /* Set up the size of the memory space */
    HDmemcpy(mem_size, mem_space->extent.u.simple.size,mem_space->extent.u.simple.rank*sizeof(hsize_t));
    mem_size[mem_space->extent.u.simple.rank]=elmt_size;

    /* initialize row sizes for each dimension */
    for(i=(ndims-1),acc=1; i>=0; i--) {
        slab[i]=acc*elmt_size;
        acc*=mem_size[i];
    } /* end for */
#ifdef QAK
for(i=0; i<ndims; i++)
    printf("%s: mem_size[%d]=%d, slab[%d]=%d\n",FUNC,(int)i,(int)mem_size[i],(int)i,(int)slab[i]);
#endif /* QAK */

    /* Set the number of elements left for I/O */
    assert(nelmts==(hsize_t)((size_t)nelmts)); /*check for overflow*/
    io_left=(size_t)nelmts;

    /* Check if we stopped in the middle of a sequence of elements */
    if((mem_iter->hyp.pos[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride!=0 ||
        ((mem_iter->hyp.pos[fast_dim]!=mem_space->select.sel_info.hslab.diminfo[fast_dim].start) && mem_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)) {
        uintn leftover;  /* The number of elements left over from the last sequence */

#ifdef QAK
printf("%s: Check 1.0, io_left=%lu\n",FUNC,(unsigned long)io_left);
#endif /* QAK */
        /* Calculate the number of elements left in the sequence */
        if(mem_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)
            leftover=mem_space->select.sel_info.hslab.diminfo[fast_dim].block-(mem_iter->hyp.pos[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start);
        else
            leftover=mem_space->select.sel_info.hslab.diminfo[fast_dim].block-((mem_iter->hyp.pos[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride);

        /* Make certain that we don't write too many */
        actual_write=MIN(leftover,nelmts);
        actual_bytes=actual_write*elmt_size;

        /* Copy the location of the point to get */
        HDmemcpy(offset, mem_iter->hyp.pos,ndims*sizeof(hssize_t));
        offset[ndims] = 0;

        /* Add in the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] += mem_space->select.offset[i];

        /* Compute the initial buffer offset */
        for(i=0,dst=(unsigned char *)_buf; i<ndims; i++)
            dst+=offset[i]*slab[i];

        /* Scatter out the rest of the sequence */
        HDmemcpy(dst,src,actual_bytes);

        /* Increment the offset of the buffer */
        src+=actual_bytes;

        /* Decrement the number of elements written out */
        io_left -= actual_write;

        /* Advance the point iterator */
        /* If we had enough buffer space to write out the rest of the sequence
         * in the fastest changing dimension, move the iterator offset to
         * the beginning of the next block to write.  Otherwise, just advance
         * the iterator in the fastest changing dimension.
         */
        if(actual_write==leftover) {
            /* Move iterator offset to beginning of next sequence in the fastest changing dimension */
            H5S_hyper_iter_next(mem_space,mem_iter);
        } /* end if */
        else {
            mem_iter->hyp.pos[fast_dim]+=actual_write; /* whole sequence not written out, just advance fastest dimension offset */
        } /* end if */
    } /* end if */

    /* Now that we've cleared the "remainder" of the previous fastest dimension
     * sequence, we must be at the beginning of a sequence, so use the fancy
     * algorithm to compute the offsets and run through as many as possible,
     * until the buffer fills up.
     */
    if(io_left>0) { /* Just in case the "remainder" above filled the buffer */
#ifdef QAK
printf("%s: Check 2.0, io_left=%lu\n",FUNC,(unsigned long)io_left);
#endif /* QAK */
        /* Compute the arrays to perform I/O on */
        /* Copy the location of the point to get */
        HDmemcpy(offset, mem_iter->hyp.pos,ndims*sizeof(hssize_t));
        offset[ndims] = 0;

        /* Add in the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] += mem_space->select.offset[i];

        /* Compute the current "counts" for this location */
        for(i=0; i<ndims; i++) {
            tmp_count[i] = (mem_iter->hyp.pos[i]-mem_space->select.sel_info.hslab.diminfo[i].start)%mem_space->select.sel_info.hslab.diminfo[i].stride;
            tmp_block[i] = (mem_iter->hyp.pos[i]-mem_space->select.sel_info.hslab.diminfo[i].start)/mem_space->select.sel_info.hslab.diminfo[i].stride;
        } /* end for */

        /* Compute the initial buffer offset */
        for(i=0,dst=(unsigned char *)_buf; i<ndims; i++)
            dst+=offset[i]*slab[i];

        /* Set the number of elements to write each time */
        actual_write=mem_space->select.sel_info.hslab.diminfo[fast_dim].block;

        /* Set the number of actual bytes */
        actual_bytes=actual_write*elmt_size;
#ifdef QAK
printf("%s: dst=%p, actual_bytes=%u\n",FUNC,dst,(int)actual_bytes);
#endif /* QAK */

#ifdef QAK
printf("%s: actual_write=%d\n",FUNC,(int)actual_write);
for(i=0; i<ndims; i++)
    printf("%s: diminfo: start[%d]=%d, stride[%d]=%d, block[%d]=%d, count[%d]=%d\n",FUNC,
        (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].start,
        (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].stride,
        (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].block,
        (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].count);
#endif /* QAK */

        /* Set the local copy of the diminfo pointer */
        tdiminfo=mem_space->select.sel_info.hslab.diminfo;

        /* Set local copies of information for the fastest changing dimension */
        fast_dim_start=tdiminfo[fast_dim].start;
        fast_dim_stride=tdiminfo[fast_dim].stride;
        fast_dim_block=tdiminfo[fast_dim].block;
        fast_dim_buf_off=slab[fast_dim]*fast_dim_stride;
        fast_dim_offset=fast_dim_start+mem_space->select.offset[fast_dim];

        /* Compute the number of blocks which would fit into the buffer */
        tot_blk_count=io_left/fast_dim_block;

        /* Compute the amount to wrap at the end of each row */
        for(i=0; i<ndims; i++)
            wrap[i]=(mem_size[i]-(tdiminfo[i].stride*tdiminfo[i].count))*slab[i];

        /* Compute the amount to skip between blocks */
        for(i=0; i<ndims; i++)
            skip[i]=(tdiminfo[i].stride-tdiminfo[i].block)*slab[i];

        /* Read in data until an entire sequence can't be written out any longer */
        while(io_left>0) {
            /* Reset copy of number of blocks in fastest dimension */
            fast_dim_count=tdiminfo[fast_dim].count-tmp_count[fast_dim];

            /* Check if this entire row will fit into buffer */
            if(fast_dim_count<=tot_blk_count) {

                /* Entire row of blocks fits into buffer */
                act_blk_count=fast_dim_count;

#ifdef NO_DUFFS_DEVICE
                /* Loop over all the blocks in the fastest changing dimension */
                while(fast_dim_count>0) {
                    /* Scatter out the sequence */
                    HDmemcpy(dst,src,actual_bytes);

                    /* Increment the offset of the buffer */
                    src+=actual_bytes;

                    /* Increment information to reflect block just processed */
                    dst+=fast_dim_buf_off;

                    /* Decrement number of blocks */
                    fast_dim_count--;
                } /* end while */
#else /* NO_DUFFS_DEVICE */
                duffs_index = (fast_dim_count + 7) / 8;
                /* The following size_t cast is required on HPUX 10.20 in
                 * order to make the system compuiler happy.  It can be
                 * removed when we are no longer supporting that platform. -QAK
                 */
                switch (((size_t)fast_dim_count) % 8) {
                    case 0:
                        do
                          {
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            src+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            dst+=fast_dim_buf_off;

                    case 7:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            src+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            dst+=fast_dim_buf_off;

                    case 6:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            src+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            dst+=fast_dim_buf_off;

                    case 5:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            src+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            dst+=fast_dim_buf_off;

                    case 4:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            src+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            dst+=fast_dim_buf_off;

                    case 3:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            src+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            dst+=fast_dim_buf_off;

                    case 2:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            src+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            dst+=fast_dim_buf_off;

                    case 1:
                            /* Scatter out the sequence */
                            HDmemcpy(dst,src,actual_bytes);

                            /* Increment the offset of the buffer */
                            src+=actual_bytes;

                            /* Increment information to reflect block just processed */
                            dst+=fast_dim_buf_off;

                      } while (--duffs_index > 0);
                } /* end switch */
#endif /* NO_DUFFS_DEVICE */

                /* Decrement number of elements left */
                io_left -= actual_write*act_blk_count;

                /* Decrement number of blocks left */
                tot_blk_count -= act_blk_count;

                /* Increment information to reflect block just processed */
                offset[fast_dim]=fast_dim_offset;    /* reset the offset in the fastest dimension */
                tmp_count[fast_dim]=0;

                /* Increment offset in destination buffer */
                dst += wrap[fast_dim];
            } /* end if */
            else {

                /* Entire row of blocks doesn't fit into buffer */
                act_blk_count=tot_blk_count;

                /* Reduce number of blocks to output */
                fast_dim_count=tot_blk_count;

                /* Loop over all the blocks in the fastest changing dimension */
                while(fast_dim_count>0) {
                    /* Scatter out the sequence */
                    HDmemcpy(dst,src,actual_bytes);

                    /* Increment the offset of the buffer */
                    src+=actual_bytes;

                    /* Increment information to reflect block just processed */
                    dst+=fast_dim_buf_off;

                    /* Decrement number of blocks */
                    fast_dim_count--;
                } /* end while */

                /* Decrement number of elements left */
                io_left -= actual_write*act_blk_count;

                /* Decrement number of blocks left */
                tot_blk_count -= act_blk_count;

                /* Increment information to reflect block just processed */
                offset[fast_dim]+=(fast_dim_stride*act_blk_count);    /* reset the offset in the fastest dimension */
                tmp_count[fast_dim]+=act_blk_count;

                /* Handle any leftover, partial blocks in this row */
                if(io_left>0) {
                    actual_write=io_left;
                    actual_bytes=actual_write*elmt_size;

                    /* Scatter out the rest of the sequence */
                    HDmemcpy(dst,src,actual_bytes);

                    /* Increment the offset of the buffer */
                    src+=actual_bytes;

                    /* Decrement the number of elements left */
                    io_left -= actual_write;

                    /* Increment buffer correctly */
                    offset[fast_dim]+=actual_write;
                } /* end if */

                /* don't bother checking slower dimensions */
                assert(tot_blk_count==0);
                assert(io_left==0);
                break;
            } /* end else */

            /* Increment the offset and count for the other dimensions */
            temp_dim=fast_dim-1;
            while(temp_dim>=0) {
                /* Move to the next row in the curent dimension */
                offset[temp_dim]++;
                tmp_block[temp_dim]++;

                /* If this block is still in the range of blocks to output for the dimension, break out of loop */
                if(tmp_block[temp_dim]<tdiminfo[temp_dim].block)
                    break;
                else {
                    /* Move to the next block in the current dimension */
                    offset[temp_dim]+=(tdiminfo[temp_dim].stride-tdiminfo[temp_dim].block);
                    dst += skip[temp_dim];
                    tmp_block[temp_dim]=0;
                    tmp_count[temp_dim]++;

                    /* If this block is still in the range of blocks to output for the dimension, break out of loop */
                    if(tmp_count[temp_dim]<tdiminfo[temp_dim].count)
                        break;
                    else {
                        offset[temp_dim]=tdiminfo[temp_dim].start+mem_space->select.offset[temp_dim];
                        dst += wrap[temp_dim];
                        tmp_count[temp_dim]=0; /* reset back to the beginning of the line */
                        tmp_block[temp_dim]=0;
                    } /* end else */
                } /* end else */

                /* Decrement dimension count */
                temp_dim--;
            } /* end while */
        } /* end while */

        /* Subtract out the selection offset */
        for(i=0; i<ndims; i++)
            offset[i] -= mem_space->select.offset[i];

        /* Update the iterator with the location we stopped */
        HDmemcpy(mem_iter->hyp.pos, offset, ndims*sizeof(hssize_t));
    } /* end if */

    /* Decrement the number of elements left in selection */
    mem_iter->hyp.elmt_left-=(nelmts-io_left);

    FUNC_LEAVE (nelmts-io_left);
} /* end H5S_hyper_mwrite_opt() */


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_mscat
 *
 * Purpose:	Scatters NELMTS data points from the type conversion buffer
 *		TCONV_BUF to the application buffer BUF.  Each element is
 *		ELMT_SIZE bytes and they are organized in application memory
 *		according to MEM_SPACE.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *              Wednesday, June 17, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5S_hyper_mscat (const void *_tconv_buf, size_t elmt_size,
		 const H5S_t *mem_space, H5S_sel_iter_t *mem_iter,
		 hsize_t nelmts, void *_buf/*out*/)
{
    H5S_hyper_io_info_t io_info;    /* Block of parameters to pass into recursive calls */
    hsize_t  num_written;            /* number of elements written into buffer */

    FUNC_ENTER (H5S_hyper_mscat, 0);

    /* Check args */
    assert (elmt_size>0);
    assert (mem_space);
    assert (mem_iter);
    assert (nelmts>0);
    assert (_buf);
    assert (_tconv_buf);

    /* Check for the special case of just one H5Sselect_hyperslab call made */
    if(mem_space->select.sel_info.hslab.diminfo!=NULL) {
        /* Use optimized call to write out regular hyperslab */
        num_written=H5S_hyper_mwrite_opt(_tconv_buf,elmt_size,mem_space,mem_iter,nelmts,_buf);
    }
    else {
        /* Initialize parameter block for recursive calls */
        io_info.elmt_size=elmt_size;
        io_info.space=mem_space;
        io_info.iter=mem_iter;
        io_info.nelmts=nelmts;
        io_info.src=_tconv_buf;
        io_info.dst=_buf;

        /* Set up the size of the memory space */
        HDmemcpy(io_info.mem_size, mem_space->extent.u.simple.size,mem_space->extent.u.simple.rank*sizeof(hsize_t));
        io_info.mem_size[mem_space->extent.u.simple.rank]=elmt_size;

        /* Set the hyperslab size to copy */
        io_info.hsize[0]=1;
        H5V_array_fill(io_info.hsize, io_info.hsize, sizeof(io_info.hsize[0]), mem_space->extent.u.simple.rank);
        io_info.hsize[mem_space->extent.u.simple.rank]=elmt_size;

        /* Recursively input the hyperslabs currently defined */
        /* starting with the slowest changing dimension */
#ifdef QAK
        printf("%s: check 1.0\n",FUNC);
#endif /* QAK */
        num_written=H5S_hyper_mwrite(-1,&io_info);
#ifdef QAK
        printf("%s: check 2.0\n",FUNC);
#endif /* QAK */
    } /* end else */

    FUNC_LEAVE (num_written>0 ? SUCCEED : FAIL);
}   /* H5S_hyper_mscat() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_bound_comp
 PURPOSE
    Compare two hyperslab boundary elements (for qsort)
 USAGE
    herr_t H5S_hyper_bound_comp(b1,b2)
        const H5S_hyper_bound_t *b1;  IN: Pointer to the first boundary element
        const H5S_hyper_bound_t *b2;  IN: Pointer to the first boundary element
 RETURNS
    <0 if b1 compares less than b2
    0 if b1 compares equal to b2
    >0 if b1 compares greater than b2
 DESCRIPTION
    Callback routine for qsort to compary boundary elements.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
intn
H5S_hyper_bound_comp(const void *_b1, const void *_b2)
{
    const H5S_hyper_bound_t *b1=(const H5S_hyper_bound_t *)_b1; /* Ptr to first boundary element */
    const H5S_hyper_bound_t *b2=(const H5S_hyper_bound_t *)_b2; /* Ptr to second boundary element */

#ifdef LATER
    FUNC_ENTER (H5S_hyper_bsearch, FAIL);
#endif /* LATER */

    assert(b1);
    assert(b2);

    if(b1->bound<b2->bound)
        return(-1);
    if(b1->bound>b2->bound)
        return(1);
    return(0);

#ifdef LATER
    FUNC_LEAVE (ret_value);
#endif /* LATER */
}   /* H5S_hyper_bsearch() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_node_add
 PURPOSE
    Add a new node to a list of hyperslab nodes
 USAGE
    herr_t H5S_hyper_node_add(head, start, size)
        H5S_hyper_node_t *head;   IN: Pointer to head of hyperslab list
        intn endflag;             IN: "size" array actually contains "end" array
        uintn rank;                IN: # of dimensions of the node
        const hssize_t *start;    IN: Offset of block
        const hsize_t *size;      IN: Size of block
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Adds a new hyperslab node to a list of them.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_node_add (H5S_hyper_node_t **head, intn endflag, uintn rank, const hssize_t *start, const hsize_t *size)
{
    H5S_hyper_node_t *slab;     /* New hyperslab node to add */
    uintn u;     /* Counters */
    herr_t ret_value=SUCCEED;

    FUNC_ENTER (H5S_hyper_node_add, FAIL);

    /* Check args */
    assert (head);
    assert (start);
    assert (size);

#ifdef QAK
    printf("%s: check 1.0, head=%p, *head=%p, rank=%u, endflag=%d\n",FUNC,head,*head,rank,endflag);
#endif /* QAK */
    /* Create new hyperslab node to insert */
    if((slab = H5FL_ALLOC(H5S_hyper_node_t,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab node");
    if((slab->start = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab start boundary");
    if((slab->end = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab end boundary");

#ifdef QAK
    printf("%s: check 2.0, slab=%p, slab->start=%p, slab->end=%p\n",FUNC,slab,slab->start,slab->end);
#endif /* QAK */
    /* Set boundary on new node */
    for(u=0; u<rank; u++) {
        slab->start[u]=start[u];
        if(endflag)
            slab->end[u]=size[u];
        else
            slab->end[u]=start[u]+size[u]-1;
    } /* end for */

    /* Prepend on list of hyperslabs for this selection */
    slab->next=*head;
    *head=slab;

done:
    FUNC_LEAVE (ret_value);
}   /* H5S_hyper_node_add() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_node_prepend
 PURPOSE
    Prepend an existing node to an existing list of hyperslab nodes
 USAGE
    herr_t H5S_hyper_node_prepend(head, node)
        H5S_hyper_node_t **head;  IN: Pointer to pointer to head of hyperslab list
        H5S_hyper_node_t *node;   IN: Pointer to node to prepend
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Prepends an existing hyperslab node to a list of them.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
H5S_hyper_node_prepend (H5S_hyper_node_t **head, H5S_hyper_node_t *node)
{
    herr_t ret_value=SUCCEED;

    FUNC_ENTER (H5S_hyper_node_prepend, FAIL);

    /* Check args */
    assert (head);
    assert (node);

    /* Prepend on list of hyperslabs for this selection */
    node->next=*head;
    *head=node;

    FUNC_LEAVE (ret_value);
}   /* H5S_hyper_node_prepend() */

/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_node_release
 PURPOSE
    Free the memory for a hyperslab node
 USAGE
    herr_t H5S_hyper_node_release(node)
        H5S_hyper_node_t *node;   IN: Pointer to node to free
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Frees a hyperslab node.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
H5S_hyper_node_release (H5S_hyper_node_t *node)
{
    herr_t ret_value=SUCCEED;

    FUNC_ENTER (H5S_hyper_node_release, FAIL);

    /* Check args */
    assert (node);

    /* Free the hyperslab node */
    H5FL_ARR_FREE(hsize_t,node->start);
    H5FL_ARR_FREE(hsize_t,node->end);
    H5FL_FREE(H5S_hyper_node_t,node);

    FUNC_LEAVE (ret_value);
}   /* H5S_hyper_node_release() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_add
 PURPOSE
    Add a block to hyperslab selection
 USAGE
    herr_t H5S_hyper_add(space, start, size)
        H5S_t *space;       	  IN: Pointer to dataspace
        const hssize_t *start;    IN: Offset of block
        const hsize_t *end;       IN: Offset of end of block
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Adds a block to an existing hyperslab selection.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
H5S_hyper_add (H5S_t *space, H5S_hyper_node_t *piece_lst)
{
    H5S_hyper_node_t *slab;     /* New hyperslab node to insert */
    H5S_hyper_node_t *tmp_slab; /* Temporary hyperslab node */
    H5S_hyper_bound_t *tmp;     /* Temporary pointer to an hyperslab bound array */
    size_t elem_count;          /* Number of elements in hyperslab selection */
    uintn piece_count;          /* Number of hyperslab pieces being added */
    uintn u;     /* Counters */
    herr_t ret_value=SUCCEED;

    FUNC_ENTER (H5S_hyper_add, FAIL);

    /* Check args */
    assert (space);

    /* Count the number of hyperslab pieces to add to the selection */
    piece_count=0;
    tmp_slab=piece_lst;
    while(tmp_slab!=NULL) {
        piece_count++;
        tmp_slab=tmp_slab->next;
    } /* end while */
    
#ifdef QAK
    printf("%s: check 1.0, piece_count=%u, lo_bounds=%p\n",
	   FUNC, (unsigned)piece_count,space->select.sel_info.hslab.hyper_lst->lo_bounds);
#endif /* QAK */
    /* Increase size of boundary arrays for dataspace's selection by piece_count */
    for(u=0; u<space->extent.u.simple.rank; u++) {
        tmp=space->select.sel_info.hslab.hyper_lst->lo_bounds[u];
#ifdef QAK
	printf("%s: check 1.1, u=%u, space->sel_info.count=%d, tmp=%p\n",FUNC,(unsigned)u, space->select.sel_info.hslab.hyper_lst->count,tmp);
#endif /* QAK */
        if((space->select.sel_info.hslab.hyper_lst->lo_bounds[u]=H5FL_ARR_REALLOC(H5S_hyper_bound_t,tmp,(space->select.sel_info.hslab.hyper_lst->count+piece_count)))==NULL) {
            space->select.sel_info.hslab.hyper_lst->lo_bounds[u]=tmp;
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
                "can't allocate hyperslab lo boundary array");
        } /* end if */
    } /* end for */

    while(piece_lst!=NULL) {
#ifdef QAK
        printf("%s: check 2.0\n",FUNC);
#endif /* QAK */
        /* Re-use the current H5S_hyper_node_t */
        slab=piece_lst;

        /* Don't loose place in list of nodes to add.. */
        piece_lst=piece_lst->next;

#ifdef QAK
        printf("%s: check 3.0\n",FUNC);
#endif /* QAK */
        /* Set boundary on new node */
        for(u=0,elem_count=1; u<space->extent.u.simple.rank; u++) {
#ifdef QAK
            printf("%s: check 3.1, %u: start=%d, end=%d, elem_count=%d\n",
               FUNC,(unsigned)u,(int)start[u],(int)end[u],(int)elem_count);
#endif /* QAK */
            elem_count*=(slab->end[u]-slab->start[u])+1;
        } /* end for */

        /* Initialize caching parameters */
        slab->cinfo.cached=0;
        slab->cinfo.size=elem_count;
        slab->cinfo.wleft=slab->cinfo.rleft=0;
        slab->cinfo.block=slab->cinfo.wpos=slab->cinfo.rpos=NULL;

#ifdef QAK
        printf("%s: check 4.0\n",FUNC);
        {
            uintn v;
            
            for(u=0; u<space->extent.u.simple.rank; u++) {
                for(v=0; v<space->select.sel_info.hslab.hyper_lst->count; v++) {
                    printf("%s: lo_bound[%u][%u]=%d(%p)\n", FUNC,
                        u,v,(int)space->select.sel_info.hslab.hyper_lst->lo_bounds[u][v].bound,
                            space->select.sel_info.hslab.hyper_lst->lo_bounds[u][v].node);
                }
            }
        }
#endif /* QAK */
        /* Insert each boundary of the hyperslab into the sorted lists of bounds */
        for(u=0; u<space->extent.u.simple.rank; u++) {
#ifdef QAK
            printf("%s: check 4.1, start[%u]=%d, end[%u]=%d\n",
               FUNC, u, (int)slab->start[u],u,(int)slab->end[u]);
            printf("%s: check 4.1,.hslab.hyper_lst->count=%d\n",
               FUNC,(int)space->select.sel_info.hslab.hyper_lst->count);
#endif /* QAK */
            space->select.sel_info.hslab.hyper_lst->lo_bounds[u][space->select.sel_info.hslab.hyper_lst->count].bound=slab->start[u];
            space->select.sel_info.hslab.hyper_lst->lo_bounds[u][space->select.sel_info.hslab.hyper_lst->count].node=slab;
        } /* end for */

        /* Increment the number of bounds in the array */
        space->select.sel_info.hslab.hyper_lst->count++;
#ifdef QAK
        printf("%s: check 5.0, count=%d\n",FUNC,(int)space->select.sel_info.hslab.hyper_lst->count);
#endif /* QAK */
        
        /* Prepend on list of hyperslabs for this selection */
        slab->next=space->select.sel_info.hslab.hyper_lst->head;
        space->select.sel_info.hslab.hyper_lst->head=slab;

        /* Increment the number of elements in the hyperslab selection */
        space->select.num_elem+=elem_count;
#ifdef QAK
        printf("%s: check 6.0, elem_count=%d\n",FUNC,(int)elem_count);
        {
            uintn v;
            
            for(u=0; u<space->extent.u.simple.rank; u++) {
                for(v=0; v<space->select.sel_info.hslab.hyper_lst->count; v++) {
                    printf("%s: lo_bound[%u][%u]=%d(%p)\n", FUNC,
                        u,v,(int)space->select.sel_info.hslab.hyper_lst->lo_bounds[u][v].bound,
                            space->select.sel_info.hslab.hyper_lst->lo_bounds[u][v].node);
                }
            }
        }
#endif /* QAK */
    } /* end while */

    /* Sort each dimension's array of bounds, now that they are all in the array */
    for(u=0; u<space->extent.u.simple.rank; u++)
        HDqsort(space->select.sel_info.hslab.hyper_lst->lo_bounds[u],space->select.sel_info.hslab.hyper_lst->count,sizeof(H5S_hyper_bound_t),H5S_hyper_bound_comp);

done:
    FUNC_LEAVE (ret_value);
}   /* H5S_hyper_add() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_clip
 PURPOSE
    Clip a list of nodes against the current selection
 USAGE
    herr_t H5S_hyper_clip(space, nodes, uniq, overlap)
        H5S_t *space;       	  IN: Pointer to dataspace
        H5S_hyper_node_t *nodes;  IN: Pointer to list of nodes
        H5S_hyper_node_t **uniq;  IN: Handle to list of non-overlapping nodes
        H5S_hyper_node_t **overlap;  IN: Handle to list of overlapping nodes
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Clips a list of hyperslab nodes against the current hyperslab selection.
    The list of non-overlapping and overlapping nodes which are generated from
    this operation are returned in the 'uniq' and 'overlap' pointers.  If
    either of those lists are not needed, they may be set to NULL and the
    list will be released.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
    Clipping a multi-dimensional space against another multi-dimensional
    space generates at most 1 overlapping region and 2*<rank> non-overlapping
    regions, falling into the following categories in each dimension:
        Case 1 - A overlaps B on both sides:
            node            <----AAAAAAAA--->
                clipped against:
            existing        <-----BBBBB----->
                generates:
            overlapping     <-----CCCCC----->
            non-overlapping <----D---------->
            non-overlapping <----------EE--->

        Case 2 - A overlaps B on one side: (need to check both sides!)
            Case 2a:
                node            <------AAAAAA--->
                    clipped against:
                existing        <-----BBBBB----->
                    generates:
                overlapping     <------CCCC----->
                non-overlapping <----------EE--->
            Case 2b:
                node            <---AAAAA------->
                    clipped against:
                existing        <-----BBBBB----->
                    generates:
                overlapping     <-----CCC------->
                non-overlapping <---EE---------->

        Case 3 - A is entirely within B:
            node            <------AA------->
                clipped against:
            existing        <-----BBBBB----->
                generates:
            overlapping     <------CC------->

        Case 4 - A is entirely outside B: (doesn't matter which side)
            node            <-----------AAA->
                clipped against:
            existing        <-----BBBBB----->
                generates:
            non-overlapping <-----------AAA->

    This algorithm could be sped up by keeping track of the last (existing)
    region the new node was compared against when it was split and resume
    comparing against the region following that one when it's returned to
    later (for non-overlapping blocks).

    Another optimization is to build a n-tree (not certain about how many
    times each dimension should be cut, but at least once) for the dataspace
    and build a list of existing blocks which overlap each "n"-tant and only
    compare the new nodes against existing node in the region of the n-tree
    which the are located in.

 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq,
        H5S_hyper_node_t **overlap)
{
    H5S_hyper_node_t *region,   /* Temp. hyperslab selection region pointer */
        *node,                  /* Temp. hyperslab node pointer */
        *next_node,             /* Pointer to next node in node list */
        *new_nodes=NULL;        /* List of new nodes added */
    hssize_t *start=NULL;       /* Temporary arrays of start & sizes (for splitting nodes) */
    hsize_t *end=NULL;          /* Temporary arrays of start & sizes (for splitting nodes) */
    uintn rank;                 /* Cached copy of the rank of the dataspace */
    intn overlapped;            /* Flag for overlapping nodes */
    intn non_intersect;         /* Flag for non-intersecting nodes */
    uintn u;     /* Counters */
    enum               /* Cases for edge overlaps */
        {OVERLAP_BOTH,OVERLAP_LOWER,OVERLAP_UPPER,WITHIN,NO_OVERLAP} clip_case;
    herr_t ret_value=SUCCEED;

    FUNC_ENTER (H5S_hyper_clip, FAIL);

    /* Check args */
    assert (space);
    assert (nodes);
    assert (uniq || overlap);

    /* Allocate space for the temporary starts & sizes */
    if((start = H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab start array");
    if((end = H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab size array");

    /* Set up local variables */
    rank=space->extent.u.simple.rank;
#ifdef QAK
    printf("%s: check 1.0, start=%p, end=%p\n",FUNC,start,end);
#endif /* QAK */

    /*
     * Cycle through all the hyperslab nodes, clipping them against the 
     * existing hyperslab selection.
     */
    node=nodes;
    while(node!=NULL) {
#ifdef QAK
    printf("%s: check 2.0, node=%p, nodes=%p\n",FUNC,node,nodes);
#endif /* QAK */
        /* Remove current node from head of list to evaulate it */
        next_node=node->next;   /* retain next node in list */
        node->next=NULL;    /* just to be safe */
#ifdef QAK
    printf("%s: check 2.1, node=%p, next_node=%p\n",FUNC,node,next_node);
    printf("node->start={",FUNC);
    for(u=0; u<rank; u++) {
        printf("%d",(int)node->start[u]);
        if(u<rank-1)
            printf(", ");
    } /* end for */
    printf("}\n");
    printf("node->end={",FUNC);
    for(u=0; u<rank; u++) {
        printf("%d",(int)node->end[u]);
        if(u<rank-1)
            printf(", ");
    } /* end for */
    printf("}\n");
    region=new_nodes;
    while(region!=NULL) {
        printf("new_nodes=%p, new_nodes->next=%p\n",region,region->next);
        printf("\tstart={",FUNC);
        for(u=0; u<rank; u++) {
            printf("%d",(int)region->start[u]);
            if(u<rank-1)
                printf(", ");
        } /* end for */
        printf("}\n");
        printf("\tend={",FUNC);
        for(u=0; u<rank; u++) {
            printf("%d",(int)region->end[u]);
            if(u<rank-1)
                printf(", ");
        } /* end for */
        printf("}\n");
        region=region->next;
    } /* end while */

    region=space->select.sel_info.hslab.hyper_lst->head;
    while(region!=NULL) {
        printf("region=%p, region->next=%p\n",region,region->next);
        printf("\tstart={",FUNC);
        for(u=0; u<rank; u++) {
            printf("%d",(int)region->start[u]);
            if(u<rank-1)
                printf(", ");
        } /* end for */
        printf("}\n");
        printf("\tend={",FUNC);
        for(u=0; u<rank; u++) {
            printf("%d",(int)region->end[u]);
            if(u<rank-1)
                printf(", ");
        } /* end for */
        printf("}\n");
        region=region->next;
    } /* end while */
#endif /* QAK */

        overlapped=0;       /* Reset overlapped flag */
        region=space->select.sel_info.hslab.hyper_lst->head;
        while(region!=NULL && overlapped==0) {
#ifdef QAK
    printf("%s: check 3.0, new_nodes=%p, region=%p, head=%p, overlapped=%d\n",FUNC,new_nodes,region,space->select.sel_info.hslab.hyper_lst->head,overlapped);
    printf("region->start={",FUNC);
    for(u=0; u<rank; u++) {
        printf("%d",(int)region->start[u]);
        if(u<rank-1)
            printf(", ");
    } /* end for */
    printf("}\n");
    printf("region->end={",FUNC);
    for(u=0; u<rank; u++) {
        printf("%d",(int)region->end[u]);
        if(u<rank-1)
            printf(", ");
    } /* end for */
    printf("}\n");
#endif /* QAK */
            /* Check for intersection */
            for(u=0, non_intersect=0; u<rank && non_intersect==0; u++) {
                if(node->end[u]<region->start[u] || node->start[u]>region->end[u])
                    non_intersect=1;
            } /* end for */

#ifdef QAK
    printf("%s: check 3.0.1, new_nodes=%p, region=%p, head=%p, non_intersect=%d\n",FUNC,new_nodes,region,space->select.sel_info.hslab.hyper_lst->head,non_intersect);
#endif /* QAK */
            /* Only compare node with regions that actually intersect */
            if(non_intersect==0) {
                /* Compare the boundaries of the two objects in each dimension */
                for(u=0; u<rank && overlapped==0; u++) {
                    /* Find overlap case we are in */

                    /* True if case 1, 4 or 2b */
                    if(node->start[u]<region->start[u]) {
#ifdef QAK
    printf("%s: check 3.1, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                        /* Test for case 4 */
                        /* NO_OVERLAP cases could be taken out, but are left in for clarity */
                        if(node->end[u]<region->start[u]) {
#ifdef QAK
    printf("%s: check 3.1.1, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                            clip_case=NO_OVERLAP;
                            assert("invalid clipping case" && 0);
                        } /* end if */
                        else {
#ifdef QAK
    printf("%s: check 3.1.2, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                            /* Test for case 2b */
                            if(node->end[u]<=region->end[u]) {
#ifdef QAK
    printf("%s: check 3.1.2.1, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                                clip_case=OVERLAP_LOWER;
                            } /* end if */
                            /* Must be case 1 */
                            else {
#ifdef QAK
    printf("%s: check 3.1.2.2, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                                clip_case=OVERLAP_BOTH;
                            } /* end else */
                        } /* end else */
                    } /* end if */
                    /* Case 2a, 3 or 4 (on the other side)*/
                    else {
#ifdef QAK
    printf("%s: check 3.2, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                        /* Test for case 4 */
                        if(node->start[u]>region->end[u]) {
#ifdef QAK
    printf("%s: check 3.2.1, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                            clip_case=NO_OVERLAP;
                            assert("invalid clipping case" && 0);
                        } /* end if */
                        /* Case 2a or 3 */
                        else {
#ifdef QAK
    printf("%s: check 3.2.2, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                            /* Test for case 2a */
                            if(node->end[u]>region->end[u]) {
#ifdef QAK
    printf("%s: check 3.2.2.1, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                                clip_case=OVERLAP_UPPER;
                            } /* end if */
                            /* Must be case 3 */
                            else {
#ifdef QAK
    printf("%s: check 3.2.2.2, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                                clip_case=WITHIN;
                            } /* end else */
                        } /* end else */
                    } /* end else */
                    
                    if(clip_case!=WITHIN) {
#ifdef QAK
    printf("%s: check 3.3, new_nodes=%p\n",FUNC,new_nodes);
#endif /* QAK */
                        /* Copy all the dimensions start & end points */
                        HDmemcpy(start,node->start,rank*sizeof(hssize_t));
                        HDmemcpy(end,node->end,rank*sizeof(hssize_t));
                    } /* end if */

                    /* Work on upper overlapping block */
                    if(clip_case==OVERLAP_BOTH || clip_case==OVERLAP_LOWER) {
#ifdef QAK
    printf("%s: check 3.4, new_nodes=%p\n",FUNC,new_nodes);
#endif /* QAK */
                        /* Modify the end point in the current dimension of the overlap */
                        end[u]=region->start[u]-1;
                        /* Clip the existing non-overlapped portion off the current node */
                        node->start[u]=region->start[u];
                        /* Add the non-overlapping portion to the list of new nodes */
                        if(H5S_hyper_node_add(&new_nodes,1,rank,(const hssize_t *)start,(const hsize_t *)end)<0)
                            HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab");
#ifdef QAK
    printf("%s: check 3.4.1, new_nodes=%p\n",FUNC,new_nodes);
#ifdef QAK
{
    H5S_hyper_node_t *tmp_reg;   /* Temp. hyperslab selection region pointer */
    uintn v;

    tmp_reg=space->select.sel_info.hslab.hyper_lst->head;
    while(tmp_reg!=NULL) {
        printf("tmp_reg=%p\n",tmp_reg);
        printf("\tstart={",FUNC);
        for(v=0; v<rank; v++) {
            printf("%d",(int)tmp_reg->start[v]);
            if(v<rank-1)
                printf(", ");
        } /* end for */
        printf("}\n");
        printf("\tend={",FUNC);
        for(v=0; v<rank; v++) {
            printf("%d",(int)tmp_reg->end[v]);
            if(v<rank-1)
                printf(", ");
        } /* end for */
        printf("}\n");
        tmp_reg=tmp_reg->next;
    } /* end while */
}
#endif /* QAK */
#endif /* QAK */
                    } /* end if */

#ifdef QAK
    printf("%s: check 3.4.5, new_nodes=%p\n",FUNC,new_nodes);
#endif /* QAK */
                    /* Work on lower overlapping block */
                    if(clip_case==OVERLAP_BOTH || clip_case==OVERLAP_UPPER) {
                        /* Modify the start & end point in the current dimension of the overlap */
                        start[u]=region->end[u]+1;
                        end[u]=node->end[u];
                        /* Clip the existing non-overlapped portion off the current node */
                        node->end[u]=region->end[u];
                        /* Add the non-overlapping portion to the list of new nodes */
#ifdef QAK
    printf("%s: check 3.5, &new_nodes=%p, new_nodes=%p\n",FUNC,&new_nodes,new_nodes);
#endif /* QAK */
                        if(H5S_hyper_node_add(&new_nodes,1,rank,(const hssize_t *)start,(const hsize_t *)end)<0)
                            HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab");
#ifdef QAK
    printf("%s: check 3.5.1, &new_nodes=%p, new_nodes=%p\n",FUNC,&new_nodes,new_nodes);
#ifdef QAK
{
    H5S_hyper_node_t *tmp_reg;   /* Temp. hyperslab selection region pointer */
    uintn v;

    tmp_reg=space->select.sel_info.hslab.hyper_lst->head;
    while(tmp_reg!=NULL) {
        printf("tmp_reg=%p\n",tmp_reg);
        printf("\tstart={",FUNC);
        for(v=0; v<rank; v++) {
            printf("%d",(int)tmp_reg->start[v]);
            if(v<rank-1)
                printf(", ");
        } /* end for */
        printf("}\n");
        printf("\tend={",FUNC);
        for(v=0; v<rank; v++) {
            printf("%d",(int)tmp_reg->end[v]);
            if(v<rank-1)
                printf(", ");
        } /* end for */
        printf("}\n");
        tmp_reg=tmp_reg->next;
    } /* end while */
}
#endif /* QAK */
#endif /* QAK */
                    } /* end if */

#ifdef QAK
    printf("%s: check 3.5.5, new_nodes=%p\n",FUNC,new_nodes);
#endif /* QAK */
                    /* Check if this is the last dimension */
                    /* Add the block to the "overlapped" list, if so */
                    /* Allow the algorithm to proceed to the next dimension otherwise */
                    if(u==(rank-1)) {   
#ifdef QAK
    printf("%s: check 3.6, overlapped=%d\n",FUNC,overlapped);
#endif /* QAK */
                        if(overlap!=NULL) {
                            if(H5S_hyper_node_prepend(overlap,node)<0)
                                HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab");
                        }
                        else {  /* Free the node if we aren't going to keep it */
#ifdef QAK
    printf("%s: check 3.6.1, node=%p\n",FUNC,node);
#endif /* QAK */
                            H5S_hyper_node_release(node);
                        } /* end else */
                        overlapped=1;   /* stop the algorithm for this block */
                    } /* end if */
                } /* end for */
            } /* end if */

            /* Advance to next hyperslab region */
            region=region->next;
        } /* end while */

        /* Check whether we should add the node to the non-overlapping list */
        if(!overlapped) {
#ifdef QAK
    printf("%s: check 3.7, node=%p\n",FUNC,node);
#endif /* QAK */
            if(uniq!=NULL) {
                if(H5S_hyper_node_prepend(uniq,node)<0)
                    HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab");
            }
            else {  /* Free the node if we aren't going to keep it */
#ifdef QAK
    printf("%s: check 3.7.1\n",FUNC);
#endif /* QAK */
                H5S_hyper_node_release(node);
            } /* end else */
        } /* end if */

        /* Advance to next hyperslab node */
        node=next_node;

        /* Check if we've added more nodes from splitting to the list */
        if(node==NULL && new_nodes!=NULL) {
            node=new_nodes;
            new_nodes=NULL;
        } /* end if */
    } /* end while */

done:
    if(start!=NULL)
        H5FL_ARR_FREE(hsize_t,start);
    if(end!=NULL)
        H5FL_ARR_FREE(hsize_t,end);

    FUNC_LEAVE (ret_value);
}   /* H5S_hyper_clip() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_release
 PURPOSE
    Release hyperslab selection information for a dataspace
 USAGE
    herr_t H5S_hyper_release(space)
        H5S_t *space;       IN: Pointer to dataspace
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Releases all hyperslab selection information for a dataspace
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
 * 	Robb Matzke, 1998-08-25
 *	The fields which are freed are set to NULL to prevent them from being
 *	freed again later.  This fixes some allocation problems where
 *	changing the hyperslab selection of one data space causes a core dump
 *	when closing some other data space.
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_release (H5S_t *space)
{
    H5S_hyper_node_t *curr,*next;   /* Pointer to hyperslab nodes */
    uintn u;     /* Counters */

    FUNC_ENTER (H5S_hyper_release, FAIL);

    /* Check args */
    assert (space && H5S_SEL_HYPERSLABS==space->select.type);
#ifdef QAK
    printf("%s: check 1.0\n",FUNC);
#endif /* QAK */

    /* Reset the number of points selected */
    space->select.num_elem=0;

    /* Release the regular selection info */
    if(space->select.sel_info.hslab.diminfo!=NULL) {
        H5FL_ARR_FREE(H5S_hyper_dim_t,space->select.sel_info.hslab.diminfo);
        space->select.sel_info.hslab.diminfo = NULL;
        H5FL_ARR_FREE(H5S_hyper_dim_t,space->select.sel_info.hslab.app_diminfo);
        space->select.sel_info.hslab.app_diminfo = NULL;
    } /* end if */

    /* Release irregular hyperslab information */
    if(space->select.sel_info.hslab.hyper_lst!=NULL) {
        /* Release hi and lo boundary information */
        if(space->select.sel_info.hslab.hyper_lst->lo_bounds!=NULL) {
            for(u=0; u<space->extent.u.simple.rank; u++) {
                H5FL_ARR_FREE(H5S_hyper_bound_t,space->select.sel_info.hslab.hyper_lst->lo_bounds[u]);
                space->select.sel_info.hslab.hyper_lst->lo_bounds[u] = NULL;
            } /* end for */
            H5FL_ARR_FREE(H5S_hyper_bound_ptr_t,space->select.sel_info.hslab.hyper_lst->lo_bounds);
            space->select.sel_info.hslab.hyper_lst->lo_bounds = NULL;
        } /* end if */

        /* Release list of selected regions */
        curr=space->select.sel_info.hslab.hyper_lst->head;
        while(curr!=NULL) {
            next=curr->next;
            H5S_hyper_node_release(curr);
            curr=next;
        } /* end while */

        /* Release hyperslab selection node itself */
        H5FL_FREE(H5S_hyper_list_t,space->select.sel_info.hslab.hyper_lst);
        space->select.sel_info.hslab.hyper_lst=NULL;
    } /* end if */

#ifdef QAK
    printf("%s: check 2.0\n",FUNC);
#endif /* QAK */

    FUNC_LEAVE (SUCCEED);
}   /* H5S_hyper_release() */

/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_npoints
 PURPOSE
    Compute number of elements in current selection
 USAGE
    hsize_t H5S_hyper_npoints(space)
        H5S_t *space;       IN: Pointer to dataspace
 RETURNS
    The number of elements in selection on success, 0 on failure
 DESCRIPTION
    Compute number of elements in current selection.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
hsize_t
H5S_hyper_npoints (const H5S_t *space)
{
    FUNC_ENTER (H5S_hyper_npoints, 0);

    /* Check args */
    assert (space);

    FUNC_LEAVE (space->select.num_elem);
}   /* H5S_hyper_npoints() */

/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_sel_iter_release
 PURPOSE
    Release hyperslab selection iterator information for a dataspace
 USAGE
    herr_t H5S_hyper_sel_iter_release(sel_iter)
        H5S_t *space;                   IN: Pointer to dataspace iterator is for
        H5S_sel_iter_t *sel_iter;       IN: Pointer to selection iterator
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Releases all information for a dataspace hyperslab selection iterator
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_sel_iter_release (H5S_sel_iter_t *sel_iter)
{
    FUNC_ENTER (H5S_hyper_sel_iter_release, FAIL);

    /* Check args */
    assert (sel_iter);

    if(sel_iter->hyp.pos!=NULL)
        H5FL_ARR_FREE(hsize_t,sel_iter->hyp.pos);

    FUNC_LEAVE (SUCCEED);
}   /* H5S_hyper_sel_iter_release() */

/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_compare_bounds
 *
 * Purpose:	Compares two bounds for equality
 *
 * Return:	an integer less than, equal to, or greater than zero if the first
 *          region is considered to be respectively less than, equal to, or
 *          greater than the second
 *
 * Programmer:	Quincey Koziol
 *              Friday, July 17, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
int
H5S_hyper_compare_bounds (const void *r1, const void *r2)
{
    if(((const H5S_hyper_bound_t *)r1)->bound<((const H5S_hyper_bound_t *)r2)->bound)
        return(-1);
    else
        if(((const H5S_hyper_bound_t *)r1)->bound>((const H5S_hyper_bound_t *)r2)->bound)
            return(1);
        else
            return(0);
}   /* end H5S_hyper_compare_bounds */

/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_copy
 PURPOSE
    Copy a selection from one dataspace to another
 USAGE
    herr_t H5S_hyper_copy(dst, src)
        H5S_t *dst;  OUT: Pointer to the destination dataspace
        H5S_t *src;  IN: Pointer to the source dataspace
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Copies all the hyperslab selection information from the source
    dataspace to the destination dataspace.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_copy (H5S_t *dst, const H5S_t *src)
{
    H5S_hyper_list_t *new_hyper=NULL;    /* New hyperslab selection */
    H5S_hyper_node_t *curr, *new, *new_head;    /* Hyperslab information nodes */
    H5S_hyper_dim_t *new_diminfo=NULL;	/* New per-dimension info array[rank] */
    uintn u;                    /* Counters */
    size_t v;                   /* Counters */
    herr_t ret_value=SUCCEED;   /* return value */

    FUNC_ENTER (H5S_hyper_copy, FAIL);

    assert(src);
    assert(dst);

#ifdef QAK
    printf("%s: check 3.0\n", FUNC);
#endif /* QAK */
    /* Check if there is regular hyperslab information to copy */
    if(src->select.sel_info.hslab.diminfo!=NULL) {
        /* Create the per-dimension selection info */
        if((new_diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,src->extent.u.simple.rank,0))==NULL)
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate per-dimension array");

        /* Copy the per-dimension selection info */
        for(u=0; u<src->extent.u.simple.rank; u++) {
            new_diminfo[u].start = src->select.sel_info.hslab.diminfo[u].start;
            new_diminfo[u].stride = src->select.sel_info.hslab.diminfo[u].stride;
            new_diminfo[u].count = src->select.sel_info.hslab.diminfo[u].count;
            new_diminfo[u].block = src->select.sel_info.hslab.diminfo[u].block;
        } /* end for */
        dst->select.sel_info.hslab.diminfo = new_diminfo;

        /* Create the per-dimension selection info */
        if((new_diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,src->extent.u.simple.rank,0))==NULL)
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate per-dimension array");

        /* Copy the per-dimension selection info */
        for(u=0; u<src->extent.u.simple.rank; u++) {
            new_diminfo[u].start = src->select.sel_info.hslab.app_diminfo[u].start;
            new_diminfo[u].stride = src->select.sel_info.hslab.app_diminfo[u].stride;
            new_diminfo[u].count = src->select.sel_info.hslab.app_diminfo[u].count;
            new_diminfo[u].block = src->select.sel_info.hslab.app_diminfo[u].block;
        } /* end for */
        dst->select.sel_info.hslab.app_diminfo = new_diminfo;
    } /* end if */
    else {
        dst->select.sel_info.hslab.diminfo = new_diminfo;
        dst->select.sel_info.hslab.app_diminfo = new_diminfo;
    } /* end else */

    /* Check if there is irregular hyperslab information to copy */
    if(src->select.sel_info.hslab.hyper_lst!=NULL) {
        /* Create the new hyperslab information node */
        if((new_hyper = H5FL_ALLOC(H5S_hyper_list_t,0))==NULL)
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
                "can't allocate point node");

        /* Copy the basic hyperslab selection information */
        *new_hyper=*(src->select.sel_info.hslab.hyper_lst);

#ifdef QAK
        printf("%s: check 4.0\n", FUNC);
#endif /* QAK */
        /* Allocate space for the low & high bound arrays */
        if((new_hyper->lo_bounds = H5FL_ARR_ALLOC(H5S_hyper_bound_ptr_t,src->extent.u.simple.rank,0))==NULL)
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
                "can't allocate boundary node");
        for(u=0; u<src->extent.u.simple.rank; u++) {
            if((new_hyper->lo_bounds[u] = H5FL_ARR_ALLOC(H5S_hyper_bound_t,src->select.sel_info.hslab.hyper_lst->count,0))==NULL)
                HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
                    "can't allocate boundary list");
        } /* end for */

#ifdef QAK
        printf("%s: check 5.0\n", FUNC);
#endif /* QAK */
        /* Copy the hyperslab selection nodes, adding them to the lo & hi bound arrays also */
        curr=src->select.sel_info.hslab.hyper_lst->head;
        new_head=NULL;
        v=0;
        while(curr!=NULL) {
#ifdef QAK
        printf("%s: check 5.1\n", FUNC);
#endif /* QAK */
            /* Create each point */
            if((new = H5FL_ALLOC(H5S_hyper_node_t,0))==NULL)
                HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
                    "can't allocate point node");
            HDmemcpy(new,curr,sizeof(H5S_hyper_node_t));    /* copy caching information */
            if((new->start = H5FL_ARR_ALLOC(hsize_t,src->extent.u.simple.rank,0))==NULL)
                HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
                    "can't allocate coordinate information");
            if((new->end = H5FL_ARR_ALLOC(hsize_t,src->extent.u.simple.rank,0))==NULL)
                HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
                    "can't allocate coordinate information");
            HDmemcpy(new->start,curr->start,(src->extent.u.simple.rank*sizeof(hssize_t)));
            HDmemcpy(new->end,curr->end,(src->extent.u.simple.rank*sizeof(hssize_t)));
            new->next=NULL;

            /* Insert into low & high bound arrays */
            for(u=0; u<src->extent.u.simple.rank; u++) {
                new_hyper->lo_bounds[u][v].bound=new->start[u];
                new_hyper->lo_bounds[u][v].node=new;
            } /* end for */
            v++;    /* Increment the location of the next node in the boundary arrays */

            /* Keep the order the same when copying */
            if(new_head==NULL)
                new_head=new_hyper->head=new;
            else {
                new_head->next=new;
                new_head=new;
            } /* end else */

            curr=curr->next;
        } /* end while */
#ifdef QAK
        printf("%s: check 6.0\n", FUNC);
#endif /* QAK */

        /* Sort the boundary array */
        for(u=0; u<src->extent.u.simple.rank; u++)
            HDqsort(new_hyper->lo_bounds[u], new_hyper->count, sizeof(H5S_hyper_bound_t), H5S_hyper_compare_bounds);
#ifdef QAK
        printf("%s: check 7.0\n", FUNC);
#endif /* QAK */
    } /* end if */

    /* Attach the hyperslab information to the destination dataspace */
    dst->select.sel_info.hslab.hyper_lst=new_hyper;

done:
    FUNC_LEAVE (ret_value);
} /* end H5S_hyper_copy() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_select_valid
 PURPOSE
    Check whether the selection fits within the extent, with the current
    offset defined.
 USAGE
    htri_t H5S_hyper_select_valid(space);
        H5S_t *space;             IN: Dataspace pointer to query
 RETURNS
    TRUE if the selection fits within the extent, FALSE if it does not and
        Negative on an error.
 DESCRIPTION
    Determines if the current selection at the current offet fits within the
    extent for the dataspace.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
htri_t
H5S_hyper_select_valid (const H5S_t *space)
{
    H5S_hyper_node_t *curr;     /* Hyperslab information nodes */
    uintn u;                    /* Counter */
    htri_t ret_value=TRUE;      /* return value */

    FUNC_ENTER (H5S_hyper_select_valid, FAIL);

    assert(space);

    /* Check for a "regular" hyperslab selection */
    if(space->select.sel_info.hslab.diminfo != NULL) {
        const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab.diminfo; /* local alias for diminfo */
        hssize_t end;      /* The high bound of a region in a dimension */

        /* Check each dimension */
        for(u=0; u<space->extent.u.simple.rank; u++) {
            /* if block or count is zero, then can skip the test since */
            /* no data point is chosen */
            if (diminfo[u].count*diminfo[u].block != 0) {
                /* Bounds check the start point in this dimension */
                if((diminfo[u].start+space->select.offset[u])<0 ||
                    (diminfo[u].start+space->select.offset[u])>=(hssize_t)space->extent.u.simple.size[u]) {
                    ret_value=FALSE;
                    break;
                } /* end if */

                /* Compute the largest location in this dimension */
                end=diminfo[u].start+diminfo[u].stride*(diminfo[u].count-1)+(diminfo[u].block-1)+space->select.offset[u];

                /* Bounds check the end point in this dimension */
                if(end<0 || end>=(hssize_t)space->extent.u.simple.size[u]) {
                    ret_value=FALSE;
                    break;
                } /* end if */
            }
        } /* end for */
    } /* end if */
    else {
        /* Check each point to determine whether selection+offset is within extent */
        curr=space->select.sel_info.hslab.hyper_lst->head;
        while(curr!=NULL && ret_value==TRUE) {
            /* Check each dimension */
            for(u=0; u<space->extent.u.simple.rank; u++) {
                /* Check if an offset has been defined */
                /* Bounds check the selected point + offset against the extent */
                if(((curr->start[u]+space->select.offset[u])>(hssize_t)space->extent.u.simple.size[u])
                        || ((curr->start[u]+space->select.offset[u])<0)
                        || ((curr->end[u]+space->select.offset[u])>(hssize_t)space->extent.u.simple.size[u])
                        || ((curr->end[u]+space->select.offset[u])<0)) {
                    ret_value=FALSE;
                    break;
                } /* end if */
            } /* end for */

            curr=curr->next;
        } /* end while */
    } /* end while */

    FUNC_LEAVE (ret_value);
} /* end H5S_hyper_select_valid() */

/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_select_serial_size
 PURPOSE
    Determine the number of bytes needed to store the serialized hyperslab
        selection information.
 USAGE
    hssize_t H5S_hyper_select_serial_size(space)
        H5S_t *space;             IN: Dataspace pointer to query
 RETURNS
    The number of bytes required on success, negative on an error.
 DESCRIPTION
    Determines the number of bytes required to serialize the current hyperslab
    selection information for storage on disk.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
hssize_t
H5S_hyper_select_serial_size (const H5S_t *space)
{
    H5S_hyper_node_t *curr;     /* Hyperslab information nodes */
    uintn u;                    /* Counter */
    hssize_t block_count;       /* block counter for regular hyperslabs */
    hssize_t ret_value=FAIL;    /* return value */

    FUNC_ENTER (H5S_hyper_select_serial_size, FAIL);

    assert(space);

    /* Basic number of bytes required to serialize point selection:
     *  <type (4 bytes)> + <version (4 bytes)> + <padding (4 bytes)> + 
     *      <length (4 bytes)> + <rank (4 bytes)> + <# of blocks (4 bytes)> = 24 bytes
     */
    ret_value=24;

    /* Check for a "regular" hyperslab selection */
    if(space->select.sel_info.hslab.diminfo != NULL) {
        /* Check each dimension */
        for(block_count=1,u=0; u<space->extent.u.simple.rank; u++)
            block_count*=space->select.sel_info.hslab.diminfo[u].count;
        ret_value+=8*block_count*space->extent.u.simple.rank;
    } /* end if */
    else {
        /* Spin through hyperslabs to total the space needed to store them */
        curr=space->select.sel_info.hslab.hyper_lst->head;
        while(curr!=NULL) {
            /* Add 8 bytes times the rank for each element selected */
            ret_value+=8*space->extent.u.simple.rank;
            curr=curr->next;
        } /* end while */
    } /* end else */

    FUNC_LEAVE (ret_value);
} /* end H5S_hyper_select_serial_size() */

/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_select_serialize
 PURPOSE
    Serialize the current selection into a user-provided buffer.
 USAGE
    herr_t H5S_hyper_select_serialize(space, buf)
        H5S_t *space;           IN: Dataspace pointer of selection to serialize
        uint8 *buf;             OUT: Buffer to put serialized selection into
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Serializes the current element selection into a buffer.  (Primarily for
    storing on disk).
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_select_serialize (const H5S_t *space, uint8_t *buf)
{
    H5S_hyper_dim_t *diminfo;               /* Alias for dataspace's diminfo information */
    hsize_t tmp_count[H5O_LAYOUT_NDIMS];    /* Temporary hyperslab counts */
    hssize_t offset[H5O_LAYOUT_NDIMS];      /* Offset of element in dataspace */
    hssize_t temp_off;            /* Offset in a given dimension */
    H5S_hyper_node_t *curr;     /* Hyperslab information nodes */
    uint8_t *lenp;          /* pointer to length location for later storage */
    uint32_t len=0;         /* number of bytes used */
    intn i;                 /* local counting variable */
    uintn u;                /* local counting variable */
    hssize_t block_count;       /* block counter for regular hyperslabs */
    intn fast_dim;      /* Rank of the fastest changing dimension for the dataspace */
    intn temp_dim;      /* Temporary rank holder */
    intn ndims;         /* Rank of the dataspace */
    intn done;          /* Whether we are done with the iteration */
    herr_t ret_value=FAIL;  /* return value */

    FUNC_ENTER (H5S_point_select_serialize, FAIL);

    assert(space);

    /* Store the preamble information */
    UINT32ENCODE(buf, (uint32_t)space->select.type);  /* Store the type of selection */
    UINT32ENCODE(buf, (uint32_t)1);  /* Store the version number */
    UINT32ENCODE(buf, (uint32_t)0);  /* Store the un-used padding */
    lenp=buf;           /* keep the pointer to the length location for later */
    buf+=4;             /* skip over space for length */

    /* Encode number of dimensions */
    UINT32ENCODE(buf, (uint32_t)space->extent.u.simple.rank);
    len+=4;

    /* Check for a "regular" hyperslab selection */
    if(space->select.sel_info.hslab.diminfo != NULL) {
        /* Set some convienence values */
        ndims=space->extent.u.simple.rank;
        fast_dim=ndims-1;
        diminfo=space->select.sel_info.hslab.diminfo;

#ifdef QAK
    printf("%s: Serializing regular selection\n",FUNC);
    for(i=0; i<ndims; i++)
        printf("%s: (%d) start=%d, stride=%d, count=%d, block=%d\n",FUNC,i,(int)diminfo[i].start,(int)diminfo[i].stride,(int)diminfo[i].count,(int)diminfo[i].block);
#endif /*QAK */
        /* Check each dimension */
        for(block_count=1,i=0; i<ndims; i++)
            block_count*=diminfo[i].count;
#ifdef QAK
printf("%s: block_count=%d\n",FUNC,(int)block_count);
#endif /*QAK */

        /* Encode number of hyperslabs */
        UINT32ENCODE(buf, (uint32_t)block_count);
        len+=4;

        /* Now serialize the information for the regular hyperslab */

        /* Build the tables of count sizes as well as the initial offset */
        for(i=0; i<ndims; i++) {
            tmp_count[i]=diminfo[i].count;
            offset[i]=diminfo[i].start;
        } /* end for */

        /* We're not done with the iteration */
        done=0;

        /* Go iterate over the hyperslabs */
        while(done==0) {
            /* Iterate over the blocks in the fastest dimension */
            while(tmp_count[fast_dim]>0) {
                /* Add 8 bytes times the rank for each hyperslab selected */
                len+=8*ndims;

#ifdef QAK
for(i=0; i<ndims; i++)
    printf("%s: offset(%d)=%d\n",FUNC,i,(int)offset[i]);
#endif /*QAK */
                /* Encode hyperslab starting location */
                for(i=0; i<ndims; i++)
                    UINT32ENCODE(buf, (uint32_t)offset[i]);

#ifdef QAK
for(i=0; i<ndims; i++)
    printf("%s: offset+block-1(%d)=%d\n",FUNC,i,(int)(offset[i]+(diminfo[i].block-1)));
#endif /*QAK */
                /* Encode hyperslab ending location */
                for(i=0; i<ndims; i++)
                    UINT32ENCODE(buf, (uint32_t)(offset[i]+(diminfo[i].block-1)));

                /* Move the offset to the next sequence to start */
                offset[fast_dim]+=diminfo[fast_dim].stride;

                /* Decrement the block count */
                tmp_count[fast_dim]--;
            } /* end while */

            /* Work on other dimensions if necessary */
            if(fast_dim>0) {
                /* Reset the block counts */
                tmp_count[fast_dim]=diminfo[fast_dim].count;

                /* Bubble up the decrement to the slower changing dimensions */
                temp_dim=fast_dim-1;
                while(temp_dim>=0 && done==0) {
                    /* Decrement the block count */
                    tmp_count[temp_dim]--;

                    /* Check if we have more blocks left */
                    if(tmp_count[temp_dim]>0)
                        break;

                    /* Check for getting out of iterator */
                    if(temp_dim==0)
                        done=1;

                    /* Reset the block count in this dimension */
                    tmp_count[temp_dim]=diminfo[temp_dim].count;
                
                    /* Wrapped a dimension, go up to next dimension */
                    temp_dim--;
                } /* end while */
            } /* end if */

            /* Re-compute offset array */
            for(i=0; i<ndims; i++) {
                temp_off=diminfo[i].start
                    +diminfo[i].stride*(diminfo[i].count-tmp_count[i]);
                offset[i]=temp_off;
            } /* end for */
        } /* end while */
    } /* end if */
    else {
        /* Encode number of hyperslabs */
        UINT32ENCODE(buf, (uint32_t)space->select.sel_info.hslab.hyper_lst->count);
        len+=4;

        /* Encode each hyperslab in selection */
        curr=space->select.sel_info.hslab.hyper_lst->head;
        while(curr!=NULL) {
            /* Add 8 bytes times the rank for each hyperslab selected */
            len+=8*space->extent.u.simple.rank;

            /* Encode starting point */
            for(u=0; u<space->extent.u.simple.rank; u++)
                UINT32ENCODE(buf, (uint32_t)curr->start[u]);

            /* Encode ending point */
            for(u=0; u<space->extent.u.simple.rank; u++)
                UINT32ENCODE(buf, (uint32_t)curr->end[u]);

            curr=curr->next;
        } /* end while */
    } /* end else */

    /* Encode length */
    UINT32ENCODE(lenp, (uint32_t)len);  /* Store the length of the extra information */
    
    /* Set success */
    ret_value=SUCCEED;

    FUNC_LEAVE (ret_value);
}   /* H5S_hyper_select_serialize() */

/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_select_deserialize
 PURPOSE
    Deserialize the current selection from a user-provided buffer.
 USAGE
    herr_t H5S_hyper_select_deserialize(space, buf)
        H5S_t *space;           IN/OUT: Dataspace pointer to place selection into
        uint8 *buf;             IN: Buffer to retrieve serialized selection from
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Deserializes the current selection into a buffer.  (Primarily for retrieving
    from disk).
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_select_deserialize (H5S_t *space, const uint8_t *buf)
{
    uint32_t rank;           	/* rank of points */
    size_t num_elem=0;      	/* number of elements in selection */
    hssize_t *start=NULL;	/* hyperslab start information */
    hssize_t *end=NULL;	    /* hyperslab end information */
    hsize_t *count=NULL;    	/* hyperslab count information */
    hsize_t *block=NULL;    	/* hyperslab block information */
    hssize_t *tstart=NULL;	/* temporary hyperslab pointers */
    hssize_t *tend=NULL;	/* temporary hyperslab pointers */
    hsize_t *tcount=NULL;	/* temporary hyperslab pointers */
    hsize_t *tblock=NULL;	/* temporary hyperslab pointers */
    uintn i,j;              	/* local counting variables */
    herr_t ret_value=FAIL;  	/* return value */

    FUNC_ENTER (H5S_hyper_select_deserialize, FAIL);

    /* Check args */
    assert(space);
    assert(buf);

    /* Deserialize slabs to select */
    buf+=16;    /* Skip over selection header */
    UINT32DECODE(buf,rank);  /* decode the rank of the point selection */
    if(rank!=space->extent.u.simple.rank)
        HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of pointer does not match dataspace");
    UINT32DECODE(buf,num_elem);  /* decode the number of points */

    /* Allocate space for the coordinates */
    if((start = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab information");
    if((end = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab information");
    if((block = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab information");
    if((count = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL)
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab information");
    
    /* Set the count for all blocks */
    for(tcount=count,j=0; j<rank; j++,tcount++)
        *tcount=1;

    /* Retrieve the coordinates from the buffer */
    for(i=0; i<num_elem; i++) {
        /* Decode the starting points */
        for(tstart=start,j=0; j<rank; j++,tstart++)
            UINT32DECODE(buf, *tstart);

        /* Decode the ending points */
        for(tend=end,j=0; j<rank; j++,tend++)
            UINT32DECODE(buf, *tend);

        /* Change the ending points into blocks */
        for(tblock=block,tstart=start,tend=end,j=0; j<(unsigned)rank; j++,tstart++,tend++,tblock++)
            *tblock=(*tend-*tstart)+1;

        /* Select or add the hyperslab to the current selection */
        if((ret_value=H5S_select_hyperslab(space,(i==0 ? H5S_SELECT_SET : H5S_SELECT_OR),start,NULL,count,block))<0) {
            HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
        } /* end if */
    } /* end for */

    /* Free temporary buffers */
    H5FL_ARR_FREE(hsize_t,start);
    H5FL_ARR_FREE(hsize_t,end);
    H5FL_ARR_FREE(hsize_t,count);
    H5FL_ARR_FREE(hsize_t,block);

done:
    FUNC_LEAVE (ret_value);
}   /* H5S_hyper_select_deserialize() */

/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_bounds
 PURPOSE
    Gets the bounding box containing the selection.
 USAGE
    herr_t H5S_hyper_bounds(space, hsize_t *start, hsize_t *end)
        H5S_t *space;           IN: Dataspace pointer of selection to query
        hsize_t *start;         OUT: Starting coordinate of bounding box
        hsize_t *end;           OUT: Opposite coordinate of bounding box
 RETURNS
    Non-negative on success, negative on failure
 DESCRIPTION
    Retrieves the bounding box containing the current selection and places
    it into the user's buffers.  The start and end buffers must be large
    enough to hold the dataspace rank number of coordinates.  The bounding box
    exactly contains the selection, ie. if a 2-D element selection is currently
    defined with the following points: (4,5), (6,8) (10,7), the bounding box
    with be (4, 5), (10, 8).
        The bounding box calculations _does_ include the current offset of the
    selection within the dataspace extent.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
{
    H5S_hyper_node_t *node;     /* Hyperslab node */
    intn rank;                  /* Dataspace rank */
    intn i;                     /* index variable */
    herr_t ret_value=SUCCEED;   /* return value */

    FUNC_ENTER (H5S_hyper_bounds, FAIL);

    assert(space);
    assert(start);
    assert(end);

    /* Get the dataspace extent rank */
    rank=space->extent.u.simple.rank;

    /* Check for a "regular" hyperslab selection */
    if(space->select.sel_info.hslab.diminfo!=NULL) {
        const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab.diminfo; /* local alias for diminfo */

        /* Check each dimension */
        for(i=0; i<rank; i++) {
            /* Compute the smallest location in this dimension */
            start[i]=diminfo[i].start+space->select.offset[i];

            /* Compute the largest location in this dimension */
            end[i]=diminfo[i].start+diminfo[i].stride*(diminfo[i].count-1)+(diminfo[i].block-1)+space->select.offset[i];
        } /* end for */
    } /* end if */
    else {
        /* Iterate through the node, copying each hyperslab's information */
        node=space->select.sel_info.hslab.hyper_lst->head;
        while(node!=NULL) {
            for(i=0; i<rank; i++) {
                if(start[i]>(hsize_t)(node->start[i]+space->select.offset[i]))
                    start[i]=node->start[i]+space->select.offset[i];
                if(end[i]<(hsize_t)(node->end[i]+space->select.offset[i]))
                    end[i]=node->end[i]+space->select.offset[i];
            } /* end for */
            node=node->next;
          } /* end while */
    } /* end if */

    FUNC_LEAVE (ret_value);
}   /* H5Sget_hyper_bounds() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_select_contiguous
 PURPOSE
    Check if a hyperslab selection is contiguous within the dataspace extent.
 USAGE
    htri_t H5S_select_contiguous(space)
        H5S_t *space;           IN: Dataspace pointer to check
 RETURNS
    TRUE/FALSE/FAIL
 DESCRIPTION
    Checks to see if the current selection in the dataspace is contiguous.
    This is primarily used for reading the entire selection in one swoop.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
htri_t
H5S_hyper_select_contiguous(const H5S_t *space)
{
    htri_t ret_value=FAIL;  /* return value */
    H5S_hyper_node_t *node;     /* Hyperslab node */
    uintn rank;                 /* Dataspace rank */
    uintn u;                    /* index variable */

    FUNC_ENTER (H5S_hyper_select_contiguous, FAIL);

    assert(space);

    /* Check for a "regular" hyperslab selection */
    if(space->select.sel_info.hslab.diminfo != NULL) {
        /*
         * For a regular hyperslab to be contiguous, it must have only one
         * block (i.e. count==1 in all dimensions) and the block size must be
         * the same as the dataspace extent's in all but the slowest changing
         * dimension.
         */
        ret_value=TRUE;	/* assume true and reset if the dimensions don't match */
        for(u=1; u<space->extent.u.simple.rank; u++) {
            if(space->select.sel_info.hslab.diminfo[u].count>1 || space->select.sel_info.hslab.diminfo[u].block!=space->extent.u.simple.size[u]) {
                ret_value=FALSE;
                break;
            } /* end if */
        } /* end for */
    } /* end if */
    else {
        /* If there is more than one hyperslab in the selection, they are not contiguous */
        if(space->select.sel_info.hslab.hyper_lst->count>1)
            ret_value=FALSE;
        else {	/* If there is one hyperslab, then it might be contiguous */
            /* Get the dataspace extent rank */
            rank=space->extent.u.simple.rank;

            /* Get the hyperslab node */
            node=space->select.sel_info.hslab.hyper_lst->head;

            /*
             * For a hyperslab to be contiguous, it's size must be the same as the
             * dataspace extent's in all but the slowest changing dimension
             */
            ret_value=TRUE;	/* assume true and reset if the dimensions don't match */
            for(u=1; u<rank; u++) {
                if(((node->end[u]-node->start[u])+1)!=(hssize_t)space->extent.u.simple.size[u]) {
                    ret_value=FALSE;
                    break;
                } /* end if */
            } /* end for */
        } /* end else */
    } /* end else */
    FUNC_LEAVE (ret_value);
}   /* H5S_hyper_select_contiguous() */


/*-------------------------------------------------------------------------
 * Function:	H5S_generate_hyperlab
 *
 * Purpose:	Generate hyperslab information from H5S_select_hyperslab()
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol (split from HS_select_hyperslab()).
 *              Tuesday, September 12, 2000
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
		      const hssize_t start[/*space_id*/],
		      const hsize_t stride[/*space_id*/],
		      const hsize_t count[/*space_id*/],
		      const hsize_t block[/*space_id*/])
{
    hssize_t slab[H5O_LAYOUT_NDIMS]; /* Location of the block to add for strided selections */
    size_t slice[H5O_LAYOUT_NDIMS];	 /* Size of preceding dimension's slice */
    H5S_hyper_node_t *add=NULL, /* List of hyperslab nodes to add */
        *uniq=NULL;         /* List of unique hyperslab nodes */
    uintn acc;                /* Accumulator for building slices */
    uintn contig;             /* whether selection is contiguous or not */
    intn i;                   /* Counters */
    uintn u,v;                /* Counters */
    herr_t ret_value=FAIL;    /* return value */

    FUNC_ENTER (H5S_generate_hyperslab, FAIL);

    /* Check args */
    assert(block);
    assert(stride);
    assert(space);
    assert(start);
    assert(count);
    assert(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID);
    
    /* Determine if selection is contiguous */
    /* assume hyperslab is contiguous, until proven otherwise */
    contig=1;
    for(u=0; u<space->extent.u.simple.rank; u++) {
        /* contiguous hyperslabs have the block size equal to the stride */
        if(stride[u]!=block[u]) {
            contig=0;   /* hyperslab isn't contiguous */
            break;      /* no use looking further */
        } /* end if */
    } /* end for */

#ifdef QAK
    printf("%s: check 1.0, contig=%d, op=%s\n",FUNC,(int)contig,(op==H5S_SELECT_SET? "H5S_SELECT_SET" : (op==H5S_SELECT_OR ? "H5S_SELECT_OR" : "Unknown")));
#endif /* QAK */

#ifdef QAK
    printf("%s: check 2.0, rank=%d\n",FUNC,(int)space->extent.u.simple.rank);
#endif /* QAK */
    /* Allocate space for the hyperslab selection information if necessary */
    if(space->select.type!=H5S_SEL_HYPERSLABS || space->select.sel_info.hslab.hyper_lst==NULL) {
        if((space->select.sel_info.hslab.hyper_lst = H5FL_ALLOC(H5S_hyper_list_t,0))==NULL)
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab information");

        /* Set the fields for the hyperslab list */
        space->select.sel_info.hslab.hyper_lst->count=0;
        space->select.sel_info.hslab.hyper_lst->head=NULL;
        if((space->select.sel_info.hslab.hyper_lst->lo_bounds = H5FL_ARR_ALLOC(H5S_hyper_bound_ptr_t,space->extent.u.simple.rank,1))==NULL)
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab lo bound information");
    } /* end if */

#ifdef QAK
    printf("%s: check 3.0\n",FUNC);
#endif /* QAK */
    /* Generate list of blocks to add/remove based on selection operation */
    switch(op) {
        case H5S_SELECT_SET:
        case H5S_SELECT_OR:
#ifdef QAK
    printf("%s: check 4.0\n",FUNC);
#endif /* QAK */
            /* Generate list of blocks to add to selection */
            if(contig) { /* Check for trivial case */
#ifdef QAK
    printf("%s: check 4.1\n",FUNC);
#endif /* QAK */

                /* Account for strides & blocks being equal, but larger than one */
                /* (Why someone would torture us this way, I don't know... -QAK :-) */
                for(u=0; u<space->extent.u.simple.rank; u++)
                    slab[u]=count[u]*stride[u];
#ifdef QAK
    printf("%s: check 4.2\n",FUNC);
    printf("%s: start = {",FUNC);
    for(u=0; u<space->extent.u.simple.rank; u++) {
        printf("%d",(int)start[u]);
        if(u<(space->extent.u.simple.rank-1))
            printf(", ");
        else
            printf("}\n");
    }
    printf("%s: slab = {",FUNC);
    for(u=0; u<space->extent.u.simple.rank; u++) {
        printf("%d",(int)slab[u]);
        if(u<(space->extent.u.simple.rank-1))
            printf(", ");
        else
            printf("}\n");
    }
#endif /* QAK */

                /* Add the contiguous hyperslab to the selection */
                if(H5S_hyper_node_add(&add,0,space->extent.u.simple.rank,start,(const hsize_t *)slab)<0) {
                    HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab");
                }
            } else {
#ifdef QAK
    printf("%s: check 4.3\n",FUNC);
#endif /* QAK */
                /* Build the slice sizes for each dimension */
                for(u=0, acc=1; u<space->extent.u.simple.rank; u++) {
                    slice[u]=acc;
                    acc*=count[u];
                } /* end for */

                /* Step through all the blocks to add */
                /* (reuse the count in ACC above) */
                /* Adding the blocks in reverse order reduces the time spent moving memory around in H5S_hyper_add() */
                for(i=(int)acc-1; i>=0; i--) {
                    /* Build the location of the block */
                    for(v=0; v<space->extent.u.simple.rank; v++)
                        slab[v]=start[v]+((i/slice[v])%count[v])*stride[v];
                    
                    /* Add the block to the list of hyperslab selections */
                    if(H5S_hyper_node_add(&add,0,space->extent.u.simple.rank,(const hssize_t *)slab, (const hsize_t *)block)<0) {
                        HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab");
                    } /* end if */
                } /* end for */
            } /* end else */

#ifdef QAK
    printf("%s: check 4.5\n",FUNC);
#endif /* QAK */
            /* Clip list of new blocks to add against current selection */
            if(op==H5S_SELECT_OR) {
#ifdef QAK
    printf("%s: check 4.5.1\n",FUNC);
#endif /* QAK */
                H5S_hyper_clip(space,add,&uniq,NULL);
                add=uniq;
            } /* end if */
#ifdef QAK
    printf("%s: check 4.5.5\n",FUNC);
#endif /* QAK */
            break;

        default:
            HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
    } /* end switch */

#ifdef QAK
    printf("%s: check 5.0\n",FUNC);
#endif /* QAK */
    /* Add new blocks to current selection */
    if(H5S_hyper_add(space,add)<0)
        HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs");

    /* Merge blocks for better I/O performance */
    /* Regenerate lo/hi bounds arrays? */

#ifdef QAK
    printf("%s: check 6.0\n",FUNC);
#endif /* QAK */

    /* Set return value */
    ret_value=SUCCEED;

done:
    FUNC_LEAVE (ret_value);
} /* end H5S_generate_hyperslab() */


/*-------------------------------------------------------------------------
 * Function:	H5S_select_hyperslab
 *
 * Purpose:	Internal version of H5Sselect_hyperslab().
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Robb Matzke (split from HSselect_hyperslab()).
 *              Tuesday, August 25, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
		      const hssize_t start[/*space_id*/],
		      const hsize_t stride[/*space_id*/],
		      const hsize_t count[/*space_id*/],
		      const hsize_t block[/*space_id*/])
{
    hsize_t *_stride=NULL;      /* Stride array */
    hsize_t *_block=NULL;       /* Block size array */
    uintn u;                    /* Counters */
    H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */
    herr_t ret_value=FAIL;    /* return value */

    FUNC_ENTER (H5S_select_hyperslab, FAIL);

    /* Check args */
    assert(space);
    assert(start);
    assert(count);
    assert(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID);
    
    /* Fill in the correct stride values */
    if(stride==NULL) {
        hssize_t fill=1;

        /* Allocate temporary buffer */
        if ((_stride=H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0))==NULL)
                HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
                     "memory allocation failed for stride buffer");
        H5V_array_fill(_stride,&fill,sizeof(hssize_t),space->extent.u.simple.rank);
        stride = _stride;
    }

    /* Fill in the correct block values */
    if(block==NULL) {
        hssize_t fill=1;

        /* Allocate temporary buffer */
        if ((_block=H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0))==NULL)
                HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
                     "memory allocation failed for stride buffer");
        H5V_array_fill(_block,&fill,sizeof(hssize_t),space->extent.u.simple.rank);
        block = _block;
    }

#ifdef QAK
    printf("%s: check 1.0, op=%s\n",FUNC,(op==H5S_SELECT_SET? "H5S_SELECT_SET" : (op==H5S_SELECT_OR ? "H5S_SELECT_OR" : "Unknown")));
#endif /* QAK */
    if(op==H5S_SELECT_SET) {
        /*
         * Check for overlapping hyperslab blocks in new selection
         *  (remove when real block-merging algorithm is in place? -QAK).
         */
#ifdef QAK
for(u=0; u<space->extent.u.simple.rank; u++)
    printf("%s: (%u) start=%d, stride=%d, count=%d, block=%d\n",FUNC,u,(int)start[u],(int)stride[u],(int)count[u],(int)block[u]);
#endif /* QAK */
        for(u=0; u<space->extent.u.simple.rank; u++) {
            if(count[u]>1 && stride[u]<block[u]) {
                HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
                    "hyperslab blocks overlap");
            } /* end if */
        } /* end for */

        /* If we are setting a new selection, remove current selection first */
        if(H5S_select_release(space)<0) {
            HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL,
                "can't release hyperslab");
        } /* end if */

        /* Copy all the application per-dimension selection info into the space descriptor */
        if((diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,space->extent.u.simple.rank,0))==NULL) {
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate per-dimension vector");
        } /* end if */
        for(u=0; u<space->extent.u.simple.rank; u++) {
            diminfo[u].start = start[u];
            diminfo[u].stride = stride[u];
            diminfo[u].count = count[u];
            diminfo[u].block = block[u];
        } /* end for */
        space->select.sel_info.hslab.app_diminfo = diminfo;

        /* Allocate room for the optimized per-dimension selection info */
        if((diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,space->extent.u.simple.rank,0))==NULL) {
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate per-dimension vector");
        } /* end if */

        /* Optimize the hyperslab selection to detect contiguously selected block/stride information */
        /* Modify the stride, block & count for contiguous hyperslab selections */
        for(u=0; u<space->extent.u.simple.rank; u++) {
            /* Starting location doesn't get optimized */
            diminfo[u].start = start[u];

            /* contiguous hyperslabs have the block size equal to the stride */
            if(stride[u]==block[u]) {
                diminfo[u].stride=1;
                diminfo[u].count=1;
                diminfo[u].block=count[u]*block[u];
            } /* end if */
            else {
                diminfo[u].stride=stride[u];
                diminfo[u].count=count[u];
                diminfo[u].block=block[u];
            } /* end else */
        } /* end for */
        space->select.sel_info.hslab.diminfo = diminfo;

        /* Set the number of elements in the hyperslab selection */
        for(space->select.num_elem=1,u=0; u<space->extent.u.simple.rank; u++)
            space->select.num_elem*=block[u]*count[u];
    } /* end if */
    else if(op==H5S_SELECT_OR) {
        switch(space->select.type) {
            case H5S_SEL_ALL:
                /* break out now, 'or'ing with an all selection leaves the all selection */
                HGOTO_DONE(SUCCEED);

            case H5S_SEL_HYPERSLABS:
                /* Is this the first 'or' operation? */
                if(space->select.sel_info.hslab.diminfo != NULL) {
                    /* yes, a "regular" hyperslab is selected currently */

                    hssize_t tmp_start[H5O_LAYOUT_NDIMS];
                    hsize_t tmp_stride[H5O_LAYOUT_NDIMS];
                    hsize_t tmp_count[H5O_LAYOUT_NDIMS];
                    hsize_t tmp_block[H5O_LAYOUT_NDIMS];

                    /* Generate the hyperslab information for the regular hyperslab */

                    /* Copy over the 'diminfo' information */
                    for(u=0; u<space->extent.u.simple.rank; u++) {
                        tmp_start[u]=space->select.sel_info.hslab.diminfo[u].start;
                        tmp_stride[u]=space->select.sel_info.hslab.diminfo[u].stride;
                        tmp_count[u]=space->select.sel_info.hslab.diminfo[u].count;
                        tmp_block[u]=space->select.sel_info.hslab.diminfo[u].block;
                    } /* end for */

                    /* Reset the number of selection elements */
                    space->select.num_elem=0;

                    /* Build the hyperslab information */
                    H5S_generate_hyperslab (space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block);

                    /* Remove the 'diminfo' information, since we're adding to it */
                    H5FL_ARR_FREE(H5S_hyper_dim_t,space->select.sel_info.hslab.diminfo);
                    space->select.sel_info.hslab.diminfo = NULL;

                    /* Remove the 'app_diminfo' information also, since we're adding to it */
                    H5FL_ARR_FREE(H5S_hyper_dim_t,space->select.sel_info.hslab.app_diminfo);
                    space->select.sel_info.hslab.app_diminfo = NULL;

                    /* Add in the new hyperslab information */
                    H5S_generate_hyperslab (space, op, start, stride, count, block);
                } /* end if */
                else {
                    /* nope, an "irregular" hyperslab is selected currently */
                    /* Add in the new hyperslab information */
                    H5S_generate_hyperslab (space, op, start, stride, count, block);
                } /* end else */
                break;

            default:
                HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
        } /* end switch() */
    } /* end if */
    else {
        HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
    } /* end else */

    /* Set selection type */
    space->select.type=H5S_SEL_HYPERSLABS;

    ret_value=SUCCEED;

done:
    if(_stride!=NULL)
        H5FL_ARR_FREE(hsize_t,_stride);
    if(_block!=NULL)
        H5FL_ARR_FREE(hsize_t,_block);
    FUNC_LEAVE (ret_value);
}   /* end H5S_select_hyperslab() */


/*--------------------------------------------------------------------------
 NAME
    H5Sselect_hyperslab
 PURPOSE
    Specify a hyperslab to combine with the current hyperslab selection
 USAGE
    herr_t H5Sselect_hyperslab(dsid, op, start, stride, count, block)
        hid_t dsid;             IN: Dataspace ID of selection to modify
        H5S_seloper_t op;       IN: Operation to perform on current selection
        const hssize_t *start;        IN: Offset of start of hyperslab
        const hssize_t *stride;       IN: Hyperslab stride
        const hssize_t *count;        IN: Number of blocks included in hyperslab
        const hssize_t *block;        IN: Size of block in hyperslab
 RETURNS
    Non-negative on success/Negative on failure
 DESCRIPTION
    Combines a hyperslab selection with the current selection for a dataspace.
    If the current selection is not a hyperslab, it is freed and the hyperslab
    parameters passed in are combined with the H5S_SEL_ALL hyperslab (ie. a
    selection composing the entire current extent).  Currently, only the
    H5S_SELECT_SET & H5S_SELECT_OR operations are supported.  If STRIDE or
    BLOCK is NULL, they are assumed to be set to all '1'.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op,
		     const hssize_t start[/*space_id*/],
		     const hsize_t _stride[/*space_id*/],
		     const hsize_t count[/*space_id*/],
		     const hsize_t _block[/*space_id*/])
{
    H5S_t	*space = NULL;  /* Dataspace to modify selection of */

    FUNC_ENTER (H5Sselect_hyperslab, FAIL);
    H5TRACE6("e","iSs*[a0]Hs*[a0]h*[a0]h*[a0]h",space_id,op,start,_stride,
             count,_block);

    /* Check args */
    if (H5I_DATASPACE != H5I_get_type(space_id) ||
            NULL == (space=H5I_object(space_id))) {
        HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
    }
    if(start==NULL || count==NULL) {
        HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
    } /* end if */

    if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID)) {
        HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
    } /* end if */

    if (H5S_select_hyperslab(space, op, start, _stride, count, _block)<0) {
        HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
		      "unable to set hyperslab selection");
    }

    FUNC_LEAVE (SUCCEED);
}


/*-------------------------------------------------------------------------
 * Function:	H5S_hyper_select_iterate_mem
 *
 * Purpose:	Recursively iterates over data points in memory using the parameters
 *      passed to H5S_hyper_select_iterate.
 *
 * Return:	Success:	Number of elements copied.
 *
 *		Failure:	0
 *
 * Programmer:	Quincey Koziol
 *              Tuesday, June 22, 1999
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5S_hyper_select_iterate_mem (intn dim, H5S_hyper_iter_info_t *iter_info)
{
    hsize_t offset;             /* offset of region in buffer */
    void *tmp_buf;              /* temporary location of the element in the buffer */
    H5S_hyper_region_t *regions;  /* Pointer to array of hyperslab nodes overlapped */
    size_t num_regions;         /* number of regions overlapped */
    herr_t user_ret=0;          /* User's return value */
    size_t i;                   /* Counters */
    intn j;

    FUNC_ENTER (H5S_hyper_select_iterate_mem, 0);

    assert(iter_info);

    /* Get a sorted list (in the next dimension down) of the regions which */
    /*  overlap the current index in this dim */
    if((regions=H5S_hyper_get_regions(&num_regions,iter_info->space->extent.u.simple.rank,
            (uintn)(dim+1),
            iter_info->space->select.sel_info.hslab.hyper_lst->count,
            iter_info->space->select.sel_info.hslab.hyper_lst->lo_bounds,
            iter_info->iter->hyp.pos,iter_info->space->select.offset))!=NULL) {

        /* Check if this is the second to last dimension in dataset */
        /*  (Which means that we've got a list of the regions in the fastest */
        /*   changing dimension and should input those regions) */
        if((uintn)(dim+2)==iter_info->space->extent.u.simple.rank) {
            HDmemcpy(iter_info->mem_offset, iter_info->iter->hyp.pos,(iter_info->space->extent.u.simple.rank*sizeof(hssize_t)));
            iter_info->mem_offset[iter_info->space->extent.u.simple.rank]=0;

            /* Iterate over data from regions */
            for(i=0; i<num_regions && user_ret==0; i++) {
                /* Set the location of the current hyperslab */
                iter_info->mem_offset[iter_info->space->extent.u.simple.rank-1]=regions[i].start;

                /* Get the offset in the memory buffer */
                offset=H5V_array_offset(iter_info->space->extent.u.simple.rank+1,
                    iter_info->mem_size,iter_info->mem_offset);
                tmp_buf=((char *)iter_info->src+offset);

                /* Iterate over each element in the current region */
                for(j=regions[i].start; j<=regions[i].end && user_ret==0; j++) {
                    /* Call the user's function */
                    user_ret=(*(iter_info->op))(tmp_buf,iter_info->dt,(hsize_t)iter_info->space->extent.u.simple.rank,iter_info->mem_offset,iter_info->op_data);

                    /* Subtract the element from the selected region (not implemented yet) */

                    /* Increment the coordinate offset */
                    iter_info->mem_offset[iter_info->space->extent.u.simple.rank-1]=j;

                    /* Advance the pointer in the buffer */
                    tmp_buf=((char *)tmp_buf+iter_info->elem_size);
                } /* end for */

                /* Decrement the iterator count */
                iter_info->iter->hyp.elmt_left-=((regions[i].end-regions[i].start)+1);
            } /* end for */

            /* Set the next position to start at */
            iter_info->iter->hyp.pos[dim+1]=(-1);
        } else { /* recurse on each region to next dimension down */

            /* Increment the dimension we are working with */
            dim++;

            /* Step through each region in this dimension */
            for(i=0; i<num_regions && user_ret==0; i++) {
                /* Step through each location in each region */
                for(j=regions[i].start; j<=regions[i].end && user_ret==0; j++) {

                    /*
                     * If we are moving to a new position in this dim, reset
                     * the next lower dim. location.
                     */
                    if(iter_info->iter->hyp.pos[dim]!=j)
                        iter_info->iter->hyp.pos[dim+1]=(-1);

                    /* Set the correct position we are working on */
                    iter_info->iter->hyp.pos[dim]=j;

                    /* Go get the regions in the next lower dimension */
                    user_ret=H5S_hyper_select_iterate_mem(dim, iter_info);
                } /* end for */
            } /* end for */
        } /* end else */

        /* Release the temporary buffer */
        H5FL_ARR_FREE(H5S_hyper_region_t,regions);
    } /* end if */

    FUNC_LEAVE (user_ret);
}   /* H5S_hyper_select_iterate_mem() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_select_iterate_mem_opt
 PURPOSE
    Iterate over the data points in a regular hyperslab selection, calling a
    user's function for each element.
 USAGE
    herr_t H5S_hyper_select_iterate_mem_opt(buf, type_id, space, op, operator_data)
        H5S_sel_iter_t *iter;   IN/OUT: Selection iterator
        void *buf;      IN/OUT: Buffer containing elements to iterate over
        hid_t type_id;  IN: Datatype ID of BUF array.
        H5S_t *space;   IN: Dataspace object containing selection to iterate over
        H5D_operator_t op; IN: Function pointer to the routine to be
                                called for each element in BUF iterated over.
        void *op_data;  IN/OUT: Pointer to any user-defined data associated
                                with the operation.
 RETURNS
    Returns the return value of the last operator if it was non-zero, or zero
    if all elements were processed. Otherwise returns a negative value.
 DESCRIPTION
    Iterates over the selected elements in a memory buffer, calling the user's
    callback function for each element.  The selection in the dataspace is
    modified so that any elements already iterated over are removed from the
    selection if the iteration is interrupted (by the H5D_operator_t function
    returning non-zero) in the "middle" of the iteration and may be re-started
    by the user where it left off.

    NOTE: Until "subtracting" elements from a selection is implemented,
        the selection is not modified.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
H5S_hyper_select_iterate_mem_opt(H5S_sel_iter_t UNUSED *iter, void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op,
        void *op_data)
{
    H5S_hyper_dim_t *diminfo;               /* Alias for dataspace's diminfo information */
    hsize_t tmp_count[H5O_LAYOUT_NDIMS];    /* Temporary hyperslab counts */
    hsize_t tmp_block[H5O_LAYOUT_NDIMS];    /* Temporary hyperslab blocks */
    hssize_t offset[H5O_LAYOUT_NDIMS];      /* Offset of element in dataspace */
    hsize_t slab[H5O_LAYOUT_NDIMS];         /* Size of objects in buffer */
    size_t elem_size;           /* Size of data element in buffer */
    hssize_t temp_off;            /* Offset in a given dimension */
    uint8_t *loc;               /* Current element location */
    intn i;                     /* Counter */
    uintn u;                    /* Counter */
    intn fast_dim;      /* Rank of the fastest changing dimension for the dataspace */
    intn temp_dim;      /* Temporary rank holder */
    uintn ndims;        /* Rank of the dataspace */
    herr_t user_ret=0;          /* User's return value */

    FUNC_ENTER (H5S_hyper_select_iterate_mem_opt, FAIL);

    /* Set some convienence values */
    ndims=space->extent.u.simple.rank;
    fast_dim=ndims-1;
    diminfo=space->select.sel_info.hslab.diminfo;

    /* Get the data element size */
    elem_size=H5Tget_size(type_id);

    /* Elements in the fastest dimension are 'elem_size' */
    slab[ndims-1]=elem_size;

    /* If we have two or more dimensions, build the other dimension's element sizes */
    if(ndims>=2) {
        /* Build the table of next-dimension down 'element' sizes */
        for(i=ndims-2; i>=0; i--)
            slab[i]=slab[i+1]*space->extent.u.simple.size[i+1];
    } /* end if */

    /* Build the tables of count & block sizes as well as the initial offset */
    for(u=0; u<ndims; u++) {
        tmp_count[u]=diminfo[u].count;
        tmp_block[u]=diminfo[u].block;
        offset[u]=diminfo[u].start;
    } /* end for */

    /* Initialize the starting location */
    for(loc=buf,u=0; u<ndims; u++)
        loc+=diminfo[u].start*slab[u];

    /* Go iterate over the hyperslabs */
    while(user_ret==0) {
        /* Iterate over the blocks in the fastest dimension */
        while(tmp_count[fast_dim]>0 && user_ret==0) {

            /* Iterate over the elements in the fastest dimension */
            while(tmp_block[fast_dim]>0 && user_ret==0) {
                user_ret=(*op)(loc,type_id,(hsize_t)ndims,offset,op_data);

                /* Increment the buffer location */
                loc+=slab[fast_dim];

                /* Increment the offset in the dataspace */
                offset[fast_dim]++;

                /* Decrement the sequence count */
                tmp_block[fast_dim]--;
            } /* end while */

            /* Reset the sequence count */
            tmp_block[fast_dim]=diminfo[fast_dim].block;

            /* Move the location to the next sequence to start */
            loc+=(diminfo[fast_dim].stride-diminfo[fast_dim].block)*slab[fast_dim];
             
            /* Move the offset to the next sequence to start */
            offset[fast_dim]+=(diminfo[fast_dim].stride-diminfo[fast_dim].block);

            /* Decrement the block count */
            tmp_count[fast_dim]--;
        } /* end while */

        /* Check for getting out of iterator, we're done in the 1-D case */
        if(ndims==1)
            goto done; /* Yes, an evil goto.. :-) -QAK */

        /* Work on other dimensions if necessary */
        if(fast_dim>0 && user_ret==0) {
            /* Reset the sequence and block counts */
            tmp_block[fast_dim]=diminfo[fast_dim].block;
            tmp_count[fast_dim]=diminfo[fast_dim].count;

            /* Bubble up the decrement to the slower changing dimensions */
            temp_dim=fast_dim-1;
            while(temp_dim>=0) {
                /* Decrement the sequence count in this dimension */
                tmp_block[temp_dim]--;

                /* Check if we are still in the sequence */
                if(tmp_block[temp_dim]>0)
                    break;

                /* Reset the sequence count in this dimension */
                tmp_block[temp_dim]=diminfo[temp_dim].block;

                /* Decrement the block count */
                tmp_count[temp_dim]--;

                /* Check if we have more blocks left */
                if(tmp_count[temp_dim]>0)
                    break;

                /* Check for getting out of iterator */
                if(temp_dim==0)
                    goto done; /* Yes, an evil goto.. :-) -QAK */

                /* Reset the block count in this dimension */
                tmp_count[temp_dim]=diminfo[temp_dim].count;
            
                /* Wrapped a dimension, go up to next dimension */
                temp_dim--;
            } /* end while */
        } /* end if */

        /* Re-compute buffer location & offset array */
        for(loc=buf,u=0; u<ndims; u++) {
            temp_off=diminfo[u].start
                +diminfo[u].stride*(diminfo[u].count-tmp_count[u])
                    +(diminfo[u].block-tmp_block[u]);
            loc+=temp_off*slab[u];
            offset[u]=temp_off;
        } /* end for */
    } /* end while */

done:
    FUNC_LEAVE (user_ret);
} /* end H5S_hyper_select_iterate_mem_opt() */


/*--------------------------------------------------------------------------
 NAME
    H5S_hyper_select_iterate
 PURPOSE
    Iterate over a hyperslab selection, calling a user's function for each
        element.
 USAGE
    herr_t H5S_hyper_select_iterate(buf, type_id, space, op, operator_data)
        void *buf;      IN/OUT: Buffer containing elements to iterate over
        hid_t type_id;  IN: Datatype ID of BUF array.
        H5S_t *space;   IN: Dataspace object containing selection to iterate over
        H5D_operator_t op; IN: Function pointer to the routine to be
                                called for each element in BUF iterated over.
        void *operator_data;    IN/OUT: Pointer to any user-defined data
                                associated with the operation.
 RETURNS
    Returns the return value of the last operator if it was non-zero, or zero
    if all elements were processed. Otherwise returns a negative value.
 DESCRIPTION
    Iterates over the selected elements in a memory buffer, calling the user's
    callback function for each element.  The selection in the dataspace is
    modified so that any elements already iterated over are removed from the
    selection if the iteration is interrupted (by the H5D_operator_t function
    returning non-zero) in the "middle" of the iteration and may be re-started
    by the user where it left off.

    NOTE: Until "subtracting" elements from a selection is implemented,
        the selection is not modified.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op,
        void *operator_data)
{
    H5S_hyper_iter_info_t iter_info;  /* Block of parameters to pass into recursive calls */
    H5S_sel_iter_t	iter;   /* selection iteration info*/
    herr_t ret_value=FAIL;      /* return value */

    FUNC_ENTER (H5S_hyper_select_iterate, FAIL);

    assert(buf);
    assert(space);
    assert(op);
    assert(H5I_DATATYPE == H5I_get_type(type_id));

    /* Initialize the selection iterator */
    if (H5S_hyper_init(space, &iter)<0) {
        HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
		     "unable to initialize selection information");
    } 

    /* Check for the special case of just one H5Sselect_hyperslab call made */
    if(space->select.sel_info.hslab.diminfo!=NULL) {
        /* Use optimized call to iterate over regular hyperslab */
        ret_value=H5S_hyper_select_iterate_mem_opt(&iter,buf,type_id,space,op,operator_data);
    }
    else {
        /* Initialize parameter block for recursive calls */
        iter_info.dt=type_id;
        iter_info.elem_size=H5Tget_size(type_id);
        iter_info.space=space;
        iter_info.iter=&iter;
        iter_info.src=buf;

        /* Set up the size of the memory space */
        HDmemcpy(iter_info.mem_size, space->extent.u.simple.size, space->extent.u.simple.rank*sizeof(hsize_t));
        iter_info.mem_size[space->extent.u.simple.rank]=iter_info.elem_size;

        /* Copy the location of the region in the file */
        iter_info.op=op;
        iter_info.op_data=operator_data;

        /* Recursively input the hyperslabs currently defined */
        /* starting with the slowest changing dimension */
        ret_value=H5S_hyper_select_iterate_mem(-1,&iter_info);
    } /* end else */

    /* Release selection iterator */
    H5S_sel_iter_release(space,&iter);

done:
    FUNC_LEAVE (ret_value);
}   /* H5S_hyper_select_iterate() */