summaryrefslogtreecommitdiffstats
path: root/configure.in
blob: f1152a31dae850058768739a2b440c2c2551d74e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
dnl Process this file with autoconf to produce configure.
dnl
dnl Copyright by the Board of Trustees of the University of Illinois.
dnl All rights reserved.
dnl
dnl This file is part of HDF5.  The full HDF5 copyright notice, including
dnl terms governing use, modification, and redistribution, is contained in
dnl the files COPYING and Copyright.html.  COPYING can be found at the root
dnl of the source code distribution tree; Copyright.html can be found at the
dnl root level of an installed copy of the electronic HDF5 document set and
dnl is linked from the top-level documents page.  It can also be found at
dnl http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html.  If you do not have
dnl access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu.

dnl ----------------------------------------------------------------------
dnl Initialize configure.
dnl
AC_REVISION($Id$)

dnl AC_INIT takes the name of the package, the version number, and an
dnl email address to report bugs. AC_CONFIG_SRCDIR takes a unique file
dnl as its argument.
dnl
dnl NOTE: Don't forget to change the version number here when we do a
dnl release!!!
dnl
AC_INIT([HDF5], [1.5.54], [hdfhelp@ncsa.uiuc.edu])
AC_CONFIG_SRCDIR([src/H5.c])
AC_CONFIG_HEADER([src/H5config.h])

AC_CONFIG_AUX_DIR([bin])

AC_OUTPUT_COMMANDS([
  echo "creating src/H5pubconf.h"
  sed 's/#define /#define H5_/' <src/H5config.h |\
    sed 's/#undef /#undef H5_/' >pubconf
  if test ! -f src/H5pubconf.h; then
    /bin/mv -f pubconf src/H5pubconf.h
  elif (diff pubconf src/H5pubconf.h >/dev/null); then
    /bin/rm -f pubconf
    echo "src/H5pubconf.h is unchanged"
  else
    /bin/mv -f pubconf src/H5pubconf.h
  fi
])

AC_CANONICAL_HOST
AC_SUBST([CPPFLAGS])

dnl ----------------------------------------------------------------------
dnl Dump all shell variables values.
dnl
AC_MSG_CHECKING([shell variables initial values])
set >&AS_MESSAGE_LOG_FD
AC_MSG_RESULT([done])

dnl ----------------------------------------------------------------------
dnl Check that the cache file was build on the same host as what we're
dnl running on now.
dnl
AC_CACHE_CHECK([for cached host], [hdf5_cv_host], [hdf5_cv_host="none"]);
if test $hdf5_cv_host = "none"; then
  hdf5_cv_host=$host
elif test $hdf5_cv_host != $host; then
  echo "The config.cache file was generated on $hdf5_cv_host but"
  echo "this is $host.  Please remove that file and try again."
  AC_MSG_ERROR(config.cache file is invalid)
fi

dnl ----------------------------------------------------------------------
dnl Source any special files that we need.  These files normally aren't
dnl present but can be used by the maintainers to fine tune things like
dnl turning on debug or profiling flags for the compiler.  The search order
dnl is:
dnl
dnl	CPU-VENDOR-OS
dnl	VENDOR-OS
dnl	CPU-OS
dnl	CPU-VENDOR
dnl	OS
dnl	VENDOR
dnl	CPU
dnl
dnl If the `OS' ends with a version number then remove it. For instance,
dnl `freebsd3.1' would become `freebsd'
case $host_os in
  aix4.*)
    host_os_novers=aix4.x
    ;;
  aix5.*)
    host_os_novers=aix5.x
    ;;
  freebsd*)
    host_os_novers=freebsd
    ;;
  irix5.*)
    host_os_novers=irix5.x
    ;;
  irix6.*)
    host_os_novers=irix6.x
    ;;
  osf4.*)
    host_os_novers=osf4.x
    ;;
  osf5.*)
    host_os_novers=osf5.x
    ;;
  solaris2.*)
    host_os_novers=solaris2.x
    ;;
  *)
    host_os_novers=$host_os
    ;;
esac

AC_ARG_ENABLE([hsizet],
              [AC_HELP_STRING([--disable-hsizet],
                              [Datasets can normally be larger than
                               memory and/or files but some compilers are
                               unable to handle this (including versions
                               of GCC before 2.8.0). Disabling the
                               feature causes dataset sizes to be
                               restricted to the size of core memory, or
                               'size_t'.])],
              [HSIZET=$enableval])

AC_MSG_CHECKING([for sizeof hsize_t and hssize_t])

AC_SUBST(HSIZET)
case $HSIZET in
  no|small)
    AC_MSG_RESULT([small])
    HSIZET=small
    ;;
  *)
    AC_MSG_RESULT([large])
    HSIZET=large
    AC_DEFINE([HAVE_LARGE_HSIZET], [1],
              [Define if it's safe to use \`long long' for hsize_t and hssize_t])
    ;;
esac

host_config="none"
for f in $host_cpu-$host_vendor-$host_os \
         $host_cpu-$host_vendor-$host_os_novers \
         $host_vendor-$host_os \
         $host_vendor-$host_os_novers \
         $host_cpu-$host_os \
         $host_cpu-$host_os_novers \
         $host_cpu-$host_vendor \
         $host_os \
         $host_os_novers \
         $host_vendor \
         $host_cpu ; do
  AC_MSG_CHECKING([for config $f])
  if test -f "$srcdir/config/$f"; then
    host_config=$srcdir/config/$f
    AC_MSG_RESULT([found])
    break
  fi
  AC_MSG_RESULT([no])
done
if test "X$host_config" != "Xnone"; then
  CC_BASENAME="`echo $CC | cut -f1 -d' ' | xargs basename 2>/dev/null`"
  . $host_config
fi

dnl Source any special site-specific file
hname="`hostname`"
while test -n "$hname"; do
  file=$srcdir/config/site-specific/host-$hname
  AC_MSG_CHECKING([for config $file])
  if test -f "$file"; then
    . $file
    AC_MSG_RESULT([found])
    break
  fi
  AC_MSG_RESULT([no])
  hname_tmp=$hname
  hname="`echo $hname | cut -d. -f2-99`"
  test "$hname_tmp" = "$hname" && break
done

dnl ----------------------------------------------------------------------
dnl Check for programs.
dnl
AC_PROG_CC
CC_BASENAME="`echo $CC | cut -f1 -d' ' | xargs basename 2>/dev/null`"

AC_SUBST([config_dirs]) config_dirs=""

dnl ----------------------------------------------------------------------
dnl Check if they would like the Fortran interface compiled
dnl
AC_MSG_CHECKING([if fortran interface enabled])
AC_ARG_ENABLE([fortran],
              [AC_HELP_STRING([--enable-fortran],
                              [Compile the Fortran interface [default=no]])],
              [HDF_FORTRAN=$enableval])

if test "X$HDF_FORTRAN" = "Xyes"; then
  echo "yes"
  if test -z "$config_dirs"; then
    config_dirs="fortran"
  else
    config_dirs="${config_dirs} fortran"
  fi
else
  echo "no"
fi

dnl ----------------------------------------------------------------------
dnl Check if they would like the C++ interface compiled
dnl
AC_MSG_CHECKING([if c++ interface enabled])
AC_ARG_ENABLE([cxx],
              [AC_HELP_STRING([--enable-cxx],
                              [Compile the C++ interface [default=no]])],
              [HDF_CXX=$enableval])

if test "X$HDF_CXX" = "Xyes"; then
  echo "yes"
  if test -z "$config_dirs"; then
    config_dirs="c++"
  else
    config_dirs="${config_dirs} c++"
  fi
else
  echo "no"
fi

dnl Run configure in the subdirectories if specified
AC_CONFIG_SUBDIRS([${config_dirs}])

dnl ----------------------------------------------------------------------
dnl If we should build only static executables
dnl
AC_MSG_CHECKING([if should build only statically linked executables])
AC_ARG_ENABLE([static_exec],
              [AC_HELP_STRING([--enable-static-exec],
                              [Build only statically linked executables
                               [default=no]])],
              [STATIC_EXEC=$enableval])

if test "X$STATIC_EXEC" = "Xyes"; then
  echo "yes"
  LT_STATIC_EXEC="-all-static"
else
  echo "no"
  LT_STATIC_EXEC=""
fi
AC_SUBST([LT_STATIC_EXEC])

dnl ----------------------------------------------------------------------
dnl Check if they have Perl installed on their system. We only need Perl
dnl if they're using a GNU compiler.
dnl
AC_SUBST([PERL]) PERL=""
if test "X$GCC" = "Xyes"; then
  AC_CHECK_PROGS([PERL], [perl],, [$PATH])
fi

dnl ----------------------------------------------------------------------
dnl Check which archiving tool to use. This needs to be done before
dnl the AC_PROG_LIBTOOL macro.
dnl
if test -z "$AR"; then
  AC_CHECK_PROGS([AR], [ar xar], [:], [$PATH])
fi
AC_SUBST([AR])

dnl Export the AR macro so that it will be placed in the libtool file
dnl correctly.
export AR

AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL

dnl Post processing to patch up some deficiencies in libtool
case $host_os in
  linux*)
    # If gcc is not used, need to set $wl to use "-Wl,"
    if $CC -v 2>&1 | grep '^gcc' > /dev/null ; then
      : using gcc
    else
      echo 'fixing $wl in' $ofile
ed - $ofile <<EOF 2> /dev/null
/^wl=""/s//wl="-Wl,"/
w
q
EOF
    fi
    ;;
esac

dnl Fix up the INSTALL macro if it's a relative path. We want the
dnl full-path to the binary instead.
case "$INSTALL" in
  *install-sh*)
    INSTALL='\${top_srcdir}/bin/install-sh -c'
    ;;
esac

AC_MSG_CHECKING([make])
AC_SUBST_FILE([DEPEND])

if test "`${MAKE-make} --version -f /dev/null 2>/dev/null |\
          sed -n 1p|cut -c1-8`" = "GNU Make"; then
  AC_MSG_RESULT([GNU make])
  GMAKE=yes
  if test "X$GCC" = "Xyes"; then
    DEPEND=config/depend1
  else
    DEPEND=config/depend2
  fi
else
  AC_MSG_RESULT([generic])
fi

dnl How do we include another file into a Makefile?
if test -z "$DEPEND"; then
  AC_MSG_CHECKING([how to include a makefile])

  dnl The include file contains the target for `foo'
  cat >makeinc <<EOF
foo:
	@:
EOF

  while true; do #for break
    dnl pmake. We have to be careful because some pmake think that the
    dnl contents of the MAKE environment variable is a target.
    echo '.include <makeinc>' >maketest
    if (MAKE= ${MAKE-make} -f maketest foo) >/dev/null 2>&1; then
      AC_MSG_RESULT([.include <FILE>])
      DEPEND=config/depend3
      break
    fi

    dnl Most make's use `include FILE'
    echo 'include makeinc' >maketest
    if (${MAKE-make} -f maketest foo) >/dev/null 2>&1; then
      AC_MSG_RESULT([include FILE])
      DEPEND=config/depend4
      break;
    fi

    dnl default
    AC_MSG_RESULT([you have a deficient make command])
    DEPEND=config/dependN
    break
  done

  rm makeinc maketest
fi

dnl ----------------------------------------------------------------------
dnl Sometimes makes think the `.PATH:' appearing before the first rule
dnl with an action should override the `all' default target. So we have
dnl to decide what the proper syntax is.
dnl
AC_MSG_CHECKING([how make searches directories])
while true; do #for break
  # The most common method is `VPATH=DIR1 DIR2 ...'
  cat >maketest <<EOF
VPATH=$srcdir/config $srcdir/src $srcdir/bin
.c.o:
	cp $< H5.o

foo: H5.o
	/bin/rm -f H5.o
	@echo works
EOF

  if (${MAKE-make} -f maketest foo) >/dev/null 2>&1; then
    SEARCH_RULE='VPATH='
    SEARCH_SEP=' '
    AC_MSG_RESULT([VPATH=DIR1 DIR2 ...])
    break
  fi

  dnl The second most common method is like above except with the
  dnl directories separated by colons.
  cat >maketest <<EOF
VPATH=$srcdir/config:$srcdir/src:$srcdir/bin
.c.o:
	cp $< H5.o

foo: H5.o
	/bin/rm -f H5.o
	@echo works
EOF

  if (${MAKE-make} -f maketest foo) >/dev/null 2>&1; then
    SEARCH_RULE='VPATH='
    SEARCH_SEP=':'
    AC_MSG_RESULT([VPATH=DIR1:DIR2:...])
    break
  fi

  dnl pmake uses the construct `.PATH: DIR1 DIR2
  cat >maketest <<EOF
.PATH: $srcdir/config $srcdir/src $srcdir/bin
.c.o:
	cp $< H5.o

foo: H5.o
	/bin/rm -f H5.o
	@echo works
EOF

  if (MAKE= ${MAKE-make} -f maketest foo) >/dev/null 2>&1; then
    SEARCH_RULE='.PATH: '
    SEARCH_SEP=' '
    AC_MSG_RESULT([.PATH: DIR1 DIR2 ...])
    break
  fi

  dnl No way for make to search directories
  SEARCH_RULE='## SEARCH DISABLED: '
  SEARCH_SEP=' '
  AC_MSG_RESULT([it doesn't])
  if test ! -f configure; then
    AC_MSG_ERROR([${MAKE-make} requires the build and source directories to be the same])
  fi
  break
done
rm maketest

dnl ----------------------------------------------------------------------
dnl Production flags?  Save the value in $CONFIG_MODE so we have it for
dnl the record.
dnl
AC_MSG_CHECKING(for production mode)
AC_ARG_ENABLE(production,
              [AC_HELP_STRING([--enable-production],
                              [Determines how to run the compiler.])])

case "X-$enable_production" in
  X-yes)
    enable_production="yes"
    AC_MSG_RESULT([production])

    dnl Remove the "-g" flag from CFLAGS if it's in there.
    dnl
    CFLAGS_temp=""
    if test -n "$CFLAGS"; then
      for d in $CFLAGS ; do
        if test "X$d" != "X-g"; then
          CFLAGS_temp="$CFLAGS_temp $d"
        fi
      done
      CFLAGS=$CFLAGS_temp
    fi

    CONFIG_MODE=production
    CFLAGS="$CFLAGS $PROD_CFLAGS"
    CPPFLAGS="$CPPFLAGS $PROD_CPPFLAGS"
    ;;
  X-|X-no)
    enable_production="no"
    AC_MSG_RESULT([development])
    CONFIG_MODE=development
    CFLAGS="$CFLAGS $DEBUG_CFLAGS"
    CPPFLAGS="$CPPFLAGS $DEBUG_CPPFLAGS"
    ;;
  X-pg|X-profile)
    enable_production="profile"
    AC_MSG_RESULT([profile])
    CONFIG_MODE=profile
    CFLAGS="$CFLAGS $PROFILE_CFLAGS"
    CPPFLAGS="$CPPFLAGS $PROFILE_CPPFLAGS"
    ;;
  *)
    enable_production="user-defined"
    AC_MSG_RESULT([user-defined])
    CONFIG_MODE="$X-enableval"
    ;;
esac

dnl ----------------------------------------------------------------------
dnl Check for system libraries.
dnl
AC_CHECK_LIB([m], [ceil])

if test "`uname`" = "SunOS" -o "`uname -sr`" = "HP-UX B.11.00"; then
  dnl ...for Solaris
  AC_CHECK_LIB([nsl], [xdr_int])
fi

dnl AC_CHECK_LIB([coug], [main])		dnl ...for ASCI/Red

dnl ----------------------------------------------------------------------
dnl Check for system header files.
dnl
AC_HEADER_STDC
AC_HEADER_TIME

dnl ----------------------------------------------------------------------
dnl Check for these two functions before <sys/time.h> is checked for, otherwise
dnl they are not detected correctly on Solaris [2.6].
dnl
AC_CHECK_FUNCS(difftime gettimeofday)

dnl Unix
AC_CHECK_HEADERS([sys/resource.h sys/time.h unistd.h sys/ioctl.h sys/stat.h])
AC_CHECK_HEADERS([sys/socket.h sys/types.h])
AC_CHECK_HEADERS([stddef.h setjmp.h features.h])
AC_CHECK_HEADERS([stdint.h], [C9x=yes])

dnl Windows
AC_CHECK_HEADERS([io.h winsock.h sys/timeb.h])

case "$host" in
  alpha*-dec*-osf*)
    dnl The <sys/sysinfo.h> and <sys/proc.h> are needed on the DEC
    dnl Alpha to turn off UAC fixing. We do *not* attempt to
    dnl locate these files on other systems because there are too
    dnl many problems with including them.
    AC_CHECK_HEADERS([sys/sysinfo.h sys/proc.h])
    ;;
esac

dnl ----------------------------------------------------------------------
dnl Test for 64bit stuff before the data types and their sizes. The
dnl result could effect the outcome of the sizeof macros below.
dnl
case "$host_cpu-$host_vendor-$host_os" in
  *linux*)
    dnl ----------------------------------------------------------------------
    dnl Enable large file support on linux? Store the result in the LINUX_LFS
    dnl variable for posterity
    AC_ARG_ENABLE([linux-lfs],
                  [AC_HELP_STRING([--enable-linux-lfs],
                                  [Enable support for large (64-bit)
                                   files on Linux. [default=check]])])

    LINUX_LFS="no"
    case "X-$enable_linux_lfs" in
      X-yes)
        LINUX_LFS=yes
        ;;
      X-no)
        ;;
      X-|*)
        MAJOR_VER="`uname -r | cut -d '.' -f1`"
        MINOR_VER="`uname -r | cut -d '.' -f2`"

        if test ${MAJOR_VER} -gt 2 -o ${MAJOR_VER} -eq 2 -a ${MINOR_VER} -ge 4; then
          LINUX_LFS="yes"
        fi
        ;;
    esac

    AC_MSG_CHECKING([for large file support mode on Linux])
    if test "X$LINUX_LFS" = "Xyes"; then
      AC_MSG_RESULT([enabled])
      CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE $CPPFLAGS"
    else
      AC_MSG_RESULT([disabled])
    fi

    dnl Add POSIX support on Linux systems, so <features.h> defines
    dnl __USE_POSIX, which is required to get the prototype for fdopen
    dnl defined correctly in <stdio.h>
    CPPFLAGS="-D_POSIX_SOURCE $CPPFLAGS"

    dnl Also add BSD support on Linux systems, so <features.h> defines
    dnl __USE_BSD, which is required to get the prototype for strdup
    dnl defined correctly in <string.h> and snprintf & vsnprintf defined
    dnl correctly in <stdio.h>
    CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS"
    ;;
esac

AC_TRY_COMPILE([#include <sys/types.h>],
               [off64_t n = 0;],
               [AC_CHECK_FUNCS([lseek64 fseek64])],
               [AC_MSG_RESULT([skipping test for lseek64() and fseek64()])])

dnl ----------------------------------------------------------------------
dnl Data types and their sizes.
dnl
AC_TYPE_OFF_T
AC_CHECK_TYPE([size_t], [unsigned long])
AC_CHECK_TYPE([ssize_t], [long])
AC_C_BIGENDIAN
AC_CHECK_SIZEOF([char], [1])
AC_CHECK_SIZEOF([short], [2])
AC_CHECK_SIZEOF([int], [4])
AC_CHECK_SIZEOF([long], [4])
AC_CHECK_SIZEOF([long long], [8])
AC_CHECK_SIZEOF([__int64], [8])
AC_CHECK_SIZEOF([float], [4])
AC_CHECK_SIZEOF([double], [8])
AC_CHECK_SIZEOF([long double], [8])

dnl Checkpoint the cache
AC_CACHE_SAVE

dnl Posix.1g types (C9x)
cat >>confdefs.h <<\EOF
#include <sys/types.h>
EOF

if test "X$C9x" = "Xyes"; then
  cat >>confdefs.h <<\EOF
#include <stdint.h>
EOF
fi

AC_CHECK_SIZEOF(        int8_t, [1])
AC_CHECK_SIZEOF(       uint8_t, [1])
AC_CHECK_SIZEOF(  int_least8_t, [1])
AC_CHECK_SIZEOF( uint_least8_t, [1])
AC_CHECK_SIZEOF(   int_fast8_t, [1])
AC_CHECK_SIZEOF(  uint_fast8_t, [1])

AC_CHECK_SIZEOF(       int16_t, [2])
AC_CHECK_SIZEOF(      uint16_t, [2])
AC_CHECK_SIZEOF( int_least16_t, [2])
AC_CHECK_SIZEOF(uint_least16_t, [2])
AC_CHECK_SIZEOF(  int_fast16_t, [2])
AC_CHECK_SIZEOF( uint_fast16_t, [2])

AC_CHECK_SIZEOF(       int32_t, [4])
AC_CHECK_SIZEOF(      uint32_t, [4])
AC_CHECK_SIZEOF( int_least32_t, [4])
AC_CHECK_SIZEOF(uint_least32_t, [4])
AC_CHECK_SIZEOF(  int_fast32_t, [4])
AC_CHECK_SIZEOF( uint_fast32_t, [4])

AC_CHECK_SIZEOF(       int64_t, [8])
AC_CHECK_SIZEOF(      uint64_t, [8])
AC_CHECK_SIZEOF( int_least64_t, [8])
AC_CHECK_SIZEOF(uint_least64_t, [8])
AC_CHECK_SIZEOF(  int_fast64_t, [8])
AC_CHECK_SIZEOF( uint_fast64_t, [8])

AC_CHECK_SIZEOF([size_t], [4])
AC_CHECK_SIZEOF([ssize_t], [4])

cat >>confdefs.h <<\EOF
#include <sys/types.h> /*for off_t definition*/
EOF
AC_CHECK_SIZEOF([off_t], [4])

dnl Checkpoint the cache
AC_CACHE_SAVE

dnl ----------------------------------------------------------------------
dnl Check if the dev_t type is a scalar type (must come after the check for
dnl sys/types.h)
AC_MSG_CHECKING([if dev_t is scalar])
AC_TRY_COMPILE([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
  ],
  [dev_t d1, d2; if(d1==d2) return 0;],
  AC_DEFINE([DEV_T_IS_SCALAR], [1],
            [Define if \`dev_t' is a scalar])
  AC_MSG_RESULT(yes),
  AC_MSG_RESULT(no)
)

dnl ----------------------------------------------------------------------
dnl Fake --with-xxx option to allow us to create a help message for the
dnl following --with-xxx options which can take either a =DIR or =INC,LIB
dnl specifier.
dnl
AC_ARG_WITH([fnord],
  [
 For the following --with-xxx options, you can specify where the header
 files and libraries are in two different ways:

    --with-xxx=INC,LIB - Specify individually the include directory and
                         library directory separated by a comma
    --with-xxx=DIR     - Specify only the directory which contains the
                         include/ and lib/ subdirectories
  ])

dnl ----------------------------------------------------------------------
dnl Is the dmalloc present? It has a header file `dmalloc.h' and a library
dnl `-ldmalloc' and their locations might be specified with the `--with-dmalloc'
dnl command-line switch. The value is an include path and/or a library path.
dnl If the library path is specified then it must be preceded by a comma.
dnl
AC_ARG_WITH([dmalloc],
            [AC_HELP_STRING([--with-dmalloc=DIR],
                            [Use dmalloc memory debugging aid [default=no]])],,
            withval=no)

case $withval in
  yes)
    HAVE_DMALLOC="yes"
    AC_CHECK_HEADERS(dmalloc.h)
    AC_CHECK_LIB(dmalloc, dmalloc_shutdown,, unset HAVE_DMALLOC)

    if test -z "$HAVE_DMALLOC" -a -n "$HDF5_CONFIG_ABORT"; then
      AC_MSG_ERROR(couldn't find dmalloc library)
    fi
    ;;
  no)
    HAVE_DMALLOC="no"
    AC_MSG_CHECKING(for dmalloc library)
    AC_MSG_RESULT(suppressed)
    ;;
  *)
    HAVE_DMALLOC="yes"
    case "$withval" in
      *,*)
        dmalloc_inc="`echo $withval |cut -f1 -d,`"
        dmalloc_lib="`echo $withval |cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          dmalloc_inc="$withval/include"
          dmalloc_lib="$withval/lib"
        fi
        ;;
    esac

    dnl Trying to include -I/usr/include and -L/usr/lib is redundant and
    dnl can mess some compilers up.
    if test "X$dmalloc_inc" = "X/usr/include"; then
      dmalloc_inc=""
    fi
    if test "X$dmalloc_lib" = "X/usr/lib"; then
      dmalloc_lib=""
    fi

    saved_CPPFLAGS="$CPPFLAGS"
    saved_LDFLAGS="$LDFLAGS"

    if test -n "$dmalloc_inc"; then
      CPPFLAGS="$CPPFLAGS -I$dmalloc_inc"
    fi

    AC_CHECK_HEADERS(dmalloc.h,, CPPFLAGS="$saved_CPPFLAGS")

    if test -n "$dmalloc_lib"; then
      LDFLAGS="$LDFLAGS -L$dmalloc_lib"
    fi

    AC_CHECK_LIB(dmalloc, dmalloc_shutdown,, LDFLAGS="$saved_LDFLAGS"; unset HAVE_DMALLOC)

    if test -z "$HAVE_DMALLOC" -a -n "$HDF5_CONFIG_ABORT"; then
      AC_MSG_ERROR(couldn't find dmalloc library)
    fi
    ;;
esac

dnl ----------------------------------------------------------------------
dnl Is the GNU zlib present? It has a header file `zlib.h' and a library
dnl `-lz' and their locations might be specified with the `--with-zlib'
dnl command-line switch. The value is an include path and/or a library path.
dnl If the library path is specified then it must be preceded by a comma.
dnl
AC_ARG_WITH([zlib],
            [AC_HELP_STRING([--with-zlib=DIR],
                            [Use zlib library for external deflate I/O
                             filter [default=yes]])],,
            withval=yes)

case $withval in
  yes)
    HAVE_ZLIB="yes"
    AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H="yes"])
    AC_CHECK_LIB([z], [compress2],, [unset HAVE_ZLIB])
    AC_CHECK_FUNC([compress2], [HAVE_COMPRESS2="yes"])

    if test -z "$HAVE_ZLIB" -a -n "$HDF5_CONFIG_ABORT"; then
      AC_MSG_ERROR([couldn't find zlib library])
    fi
    ;;
  no)
    HAVE_ZLIB="no"
    AC_MSG_CHECKING([for GNU zlib])
    AC_MSG_RESULT([suppressed])
    ;;
  *)
    HAVE_ZLIB="yes"
    case "$withval" in
      *,*)
        zlib_inc="`echo $withval |cut -f1 -d,`"
        zlib_lib="`echo $withval |cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          zlib_inc="$withval/include"
          zlib_lib="$withval/lib"
        fi
        ;;
    esac

    dnl Trying to include -I/usr/include and -L/usr/lib is redundant and
    dnl can mess some compilers up.
    if test "X$zlib_inc" = "X/usr/include"; then
      zlib_inc=""
    fi
    if test "X$zlib_lib" = "X/usr/lib"; then
      zlib_lib=""
    fi

    saved_CPPFLAGS="$CPPFLAGS"
    saved_LDFLAGS="$LDFLAGS"

    if test -n "$zlib_inc"; then
      CPPFLAGS="$CPPFLAGS -I$zlib_inc"
    fi

    AC_CHECK_HEADERS([zlib.h],
                     [HAVE_ZLIB_H="yes"],
                     [CPPFLAGS="$saved_CPPFLAGS"])

    if test -n "$zlib_lib"; then
      LDFLAGS="$LDFLAGS -L$zlib_lib"
    fi

    AC_CHECK_LIB([z], [compress2],,
                 [LDFLAGS="$saved_LDFLAGS"; unset HAVE_ZLIB])
    AC_CHECK_FUNC([compress2], [HAVE_COMPRESS2="yes"])

    if test -z "$HAVE_ZLIB" -a -n "$HDF5_CONFIG_ABORT"; then
      AC_MSG_ERROR([couldn't find zlib library])
    fi
    ;;
esac

if test "x$HAVE_ZLIB" = "xyes" -a "x$HAVE_ZLIB_H" = "xyes" -a "x$HAVE_COMPRESS2" = "xyes"; then
    AC_DEFINE(HAVE_FILTER_DEFLATE, 1,
            [Define if support for deflate filter is enabled])

    dnl Add "deflate" to external filter list
    if test "X$EXTERNAL_FILTERS" != "X"; then
        EXTERNAL_FILTERS="${EXTERNAL_FILTERS},"
    fi
    EXTERNAL_FILTERS="${EXTERNAL_FILTERS}deflate"
fi


dnl ----------------------------------------------------------------------
dnl Is the szlib present? It has a header file `szlib.h' and a library
dnl `-lsz' and their locations might be specified with the `--with-szlib'
dnl command-line switch. The value is an include path and/or a library path.
dnl If the library path is specified then it must be preceded by a comma.
dnl
AC_ARG_WITH([szlib],
            [AC_HELP_STRING([--with-szlib=DIR],
                            [Use szlib library for external szlib I/O
                             filter [default=yes]])],,
            withval=yes)

case $withval in
  yes)
    HAVE_SZLIB="yes"
    AC_CHECK_HEADERS([szlib.h], [HAVE_SZLIB_H="yes"])
    AC_CHECK_LIB([sz], [SZ_BufftoBuffCompress],, [unset HAVE_SZLIB])

    if test -z "$HAVE_SZLIB" -a -n "$HDF5_CONFIG_ABORT"; then
      AC_MSG_ERROR([couldn't find szlib library])
    fi
    ;;
  no)
    HAVE_SZLIB="no"
    AC_MSG_CHECKING([for szlib])
    AC_MSG_RESULT([suppressed])
    ;;
  *)
    HAVE_SZLIB="yes"
    case "$withval" in
      *,*)
        szlib_inc="`echo $withval |cut -f1 -d,`"
        szlib_lib="`echo $withval |cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          szlib_inc="$withval/include"
          szlib_lib="$withval/lib"
        fi
        ;;
    esac

    dnl Trying to include -I/usr/include and -L/usr/lib is redundant and
    dnl can mess some compilers up.
    if test "X$szlib_inc" = "X/usr/include"; then
      szlib_inc=""
    fi
    if test "X$szlib_lib" = "X/usr/lib"; then
      szlib_lib=""
    fi

    saved_CPPFLAGS="$CPPFLAGS"
    saved_LDFLAGS="$LDFLAGS"

    if test -n "$szlib_inc"; then
      CPPFLAGS="$CPPFLAGS -I$szlib_inc"
    fi

    AC_CHECK_HEADERS([szlib.h],
                     [HAVE_SZLIB_H="yes"],
                     [CPPFLAGS="$saved_CPPFLAGS"])

    if test -n "$szlib_lib"; then
      LDFLAGS="$LDFLAGS -L$szlib_lib"
    fi

    AC_CHECK_LIB([sz], [SZ_BufftoBuffCompress],,
                 [LDFLAGS="$saved_LDFLAGS"; unset HAVE_SZLIB])

    if test -z "$HAVE_SZLIB" -a -n "$HDF5_CONFIG_ABORT"; then
      AC_MSG_ERROR([couldn't find szlib library])
    fi
    ;;
esac

if test "x$HAVE_SZLIB" = "xyes" -a "x$HAVE_SZLIB_H" = "xyes"; then
    AC_DEFINE(HAVE_FILTER_SZIP, 1,
            [Define if support for szip filter is enabled])

    dnl Add "szip" to external filter list
    if test "X$EXTERNAL_FILTERS" != "X"; then
        EXTERNAL_FILTERS="${EXTERNAL_FILTERS},"
    fi
    EXTERNAL_FILTERS="${EXTERNAL_FILTERS}szip"
fi

dnl ----------------------------------------------------------------------
dnl Pablo Configuration
dnl
AC_SUBST(PABLO) PABLO=""
AC_SUBST(HAVE_PABLO) HAVE_PABLO="no"
AC_ARG_WITH([pablo],
            [AC_HELP_STRING([--with-pablo=DIR],
                            [Use the Pablo library [default=no]])],,
            withval=no)

AC_MSG_CHECKING([for Pablo])

case "$withval" in
  yes)
    AC_MSG_RESULT(yes)
    HAVE_PABLO="yes"
    PABLO="pablo"
    ;;
  no)
    AC_MSG_RESULT(suppressed)
    ;;
  *)
    case "$withval" in
      *,*)
        pablo_inc="`echo $withval | cut -f1 -d,`"
        pablo_lib="`echo $withval | cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          pablo_inc="$withval/include"
          pablo_lib="$withval/lib"
        fi
        ;;
    esac

    dnl Trying to include -I/usr/include and -L/usr/lib is redundant and
    dnl can mess some compilers up.
    if test "X$pablo_inc" = "X/usr/include"; then
      pablo_inc=""
    fi
    if test "X$pablo_lib" = "X/usr/lib"; then
      pablo_lib=""
    fi

    saved_CPPFLAGS="$CPPFLAGS"
    saved_LDFLAGS="$LDFLAGS"
    if test -n "$pablo_inc"; then
      CPPFLAGS="$CPPFLAGS -I$pablo_inc"
    fi

    if test -n "$pablo_lib"; then
      LDFLAGS="$LDFLAGS -L$pablo_lib"
    fi

    failed="no"
    if test -f "$pablo_inc/PabloTrace.h"; then
      :
    else
      failed="yes"
    fi

    if test -f "$pablo_lib/libPabloTraceExt.a"; then
      :
    else
      failed="yes"
    fi

    if test "$failed" = "yes"; then
      dnl Reset flags if failed
      CPPFLAGS="$saved_CPPFLAGS"
      LDFLAGS="$saved_LDFLAGS"
    else
      HAVE_PABLO="yes"
      PABLO="pablo"
    fi

    if test "$HAVE_PABLO" = "yes"; then
      AC_MSG_RESULT(yes)
    else
      AC_MSG_RESULT(no)
    fi
    ;;
esac

dnl Is SSL library present?  It is needed by GLOBUS-GASS and Grid Storage
dnl driver.  SSL must be tested before them.
AC_SUBST(SSL) SSL=yes
AC_ARG_WITH([ssl],
            [AC_HELP_STRING([--with-ssl=LIB],
                            [Use the SSL library [default=no]])],,
            withval=no)

case "$withval" in
   yes)
      AC_CHECK_LIB(crypto,main,,unset SSL)
      AC_CHECK_LIB(ssl,SSL_get_version,,unset SSL)
      ;;
   no)
      AC_MSG_CHECKING(for SSL)
      AC_MSG_RESULT(suppressed)
      unset SSL
      ;;
   *)
      saved_LDFLAGS="$LDFLAGS"
      if test "X$with_ssl" != "X/usr/lib"; then
        LDFLAGS="$LDFLAGS -L$with_ssl"
      fi
      AC_CHECK_LIB(crypto,main,, LDFLAGS="$saved_LDFLAGS"; unset SSL)
      AC_CHECK_LIB(ssl,SSL_get_version,, LDFLAGS="$saved_LDFLAGS"; unset SSL)
      ;;
esac

dnl ----------------------------------------------------------------------
dnl Is GLOBUS-GASS(1.1.0 or 1.1.1) Library present? It is also needed by 
dnl the Grid Storage driver.
dnl
AC_SUBST(GASS) GASS="yes"
AC_SUBST(TESTGASS) TESTGASS='$(srcdir)/testgass'
AC_ARG_WITH([gass],
            [AC_HELP_STRING([--with-gass=DIR],
                            [Use the GASS library [default=no]])],,
            withval=no)

case "$withval" in
  yes)
    AC_CHECK_HEADERS(globus_common.h,,unset GASS TESTGASS)
    AC_CHECK_LIB(globus_common,globus_module_activate,,unset GASS TESTGASS)
    AC_CHECK_LIB(globus_gass_cache,main,,unset GASS TESTGASS)
    AC_CHECK_LIB(globus_gaa,main,,unset GASS TESTGASS)
    AC_CHECK_LIB(globus_gss,main,,unset GASS TESTGASS)
    AC_CHECK_LIB(globus_gss_assist,main,,unset GASS TESTGASS)
    AC_CHECK_LIB(globus_io,main,,unset GASS TESTGASS)
    AC_CHECK_LIB(globus_gass_transfer_assist,main,,unset GASS TESTGASS)
    AC_CHECK_LIB(globus_gass_transfer,main,,unset GASS TESTGASS)
    AC_CHECK_LIB(globus_gass_file,globus_gass_open,,unset GASS TESTGASS)
    ;;

  no)
    AC_MSG_CHECKING(for GASS)
    AC_MSG_RESULT(suppressed)
    unset GASS TESTGASS
    ;;

  *)
    case "$withval" in
      *,*)
        gass_inc="`echo $withval | cut -f1 -d,`"
        gass_lib="`echo $withval | cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          gass_inc="$withval/include"
          gass_lib="$withval/lib"
        fi
        ;;
    esac

    dnl Trying to include -I/usr/include and -L/usr/lib is redundant and
    dnl can mess some compilers up.
    if test "X$gass_inc" = "X/usr/include"; then
      gass_inc=""
    fi
    if test "X$gass_lib" = "X/usr/lib"; then
      gass_lib=""
    fi

    if test -n "$gass_inc"; then
      saved_CPPFLAGS="$CPPFLAGS"
      CPPFLAGS="$CPPFLAGS -I$gass_inc"
      AC_CHECK_HEADERS(globus_common.h,,
                       CPPFLAGS="$saved_CPPFLAGS"
                       unset GASS TESTGASS)
    else
      AC_CHECK_HEADERS(globus_common.h)
    fi

    if test -n "$gass_lib"; then
      saved_LDFLAGS="$LDFLAGS"
      LDFLAGS="$LDFLAGS -L$gass_lib"
      AC_CHECK_LIB(globus_common,globus_module_activate,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gass_cache,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gaa,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gss,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gss_assist,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_io,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gass_transfer_assist,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gass_transfer,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gass_file,globus_gass_open,,unset GASS TESTGASS)
    else
      AC_CHECK_LIB(globus_common,globus_module_activate,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gass_cache,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gaa,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gss,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gss_assist,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_io,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gass_transfer_assist,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gass_transfer,main,,unset GASS TESTGASS)
      AC_CHECK_LIB(globus_gass_file,globus_gass_open,,unset GASS TESTGASS)
    fi
    ;;
esac

if test -n "$GASS"; then
  AC_DEFINE([HAVE_GASS], [1],
            [Define if the Globus GASS is defined])
fi

dnl ----------------------------------------------------------------------
dnl Are SRB Client and other system libraries(socket, elf) present?  
dnl
AC_SUBST(SRB) SRB="yes"
AC_SUBST(TESTSRB) TESTSRB='$(srcdir)/testsrb'
AC_ARG_WITH([srb],
            [AC_HELP_STRING([--with-srb=DIR],
                            [Use the SRB library [default=no]])],,
            withval=no)

case "$withval" in
  yes)
    AC_CHECK_HEADERS(srbClient.h,,unset SRB TESTSRB)
    AC_CHECK_LIB(elf,main,,unset SRB TESTSRB)
    AC_CHECK_LIB(socket,main,,unset SRB TESTSRB)
    AC_CHECK_LIB(SrbClient,clConnect,,unset SRB TESTSRB)
    ;;
  no)
    AC_MSG_CHECKING(for SRB)
    AC_MSG_RESULT(suppressed)
    unset SRB TESTSRB
    ;;
  *)
    case "$withval" in
      *,*)
        srb_inc="`echo $withval | cut -f1 -d,`"
        srb_lib="`echo $withval | cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          srb_inc="$withval/include"
          srb_lib="$withval/lib"
        fi
        ;;
    esac

    dnl Trying to include -I/usr/include and -L/usr/lib is redundant and
    dnl can mess some compilers up.
    if test "X$srb_inc" = "X/usr/include"; then
      srb_inc=""
    fi
    if test "X$srb_lib" = "X/usr/lib"; then
      srb_lib=""
    fi

    if test -n "$srb_inc"; then
      saved_CPPFLAGS="$CPPFLAGS"
      CPPFLAGS="$CPPFLAGS -I$srb_inc"
      AC_CHECK_HEADERS(srbClient.h,,
                       CPPFLAGS="$saved_CPPFLAGS"
                       unset SRB TESTSRB)
    else
      AC_CHECK_HEADERS(srbClient.h)
    fi

    if test -n "$srb_lib"; then
      saved_LDFLAGS="$LDFLAGS"
      LDFLAGS="$LDFLAGS -L$srb_lib"
      AC_CHECK_LIB(elf,main,,unset SRB TESTSRB)
      AC_CHECK_LIB(socket,main,,unset SRB TESTSRB)
      AC_CHECK_LIB(SrbClient,clConnect,,unset SRB TESTSRB)
    else
      AC_CHECK_LIB(elf,main,,unset SRB TESTSRB)
      AC_CHECK_LIB(socket,main,,unset SRB TESTSRB)
      AC_CHECK_LIB(SrbClient,clConnect,,unset SRB TESTSRB)
    fi
    ;;
esac

if test -n "$SRB"; then
  AC_DEFINE(HAVE_SRB, 1,
            [Define if the SRB is defined])
fi

dnl ----------------------------------------------------------------------
dnl Is LLNL's PDB present? If so then we'll compile the PDB-to-HDF5
dnl translator.
dnl
AC_SUBST(PDB2HDF)
AC_CHECK_LIB(pdb, PD_open)
AC_CHECK_LIB(silo, lite_PD_open)
AC_CHECK_HEADERS(pdb.h, PDB2HDF=pdb2hdf)

dnl Checkpoint the cache
AC_CACHE_SAVE

dnl ----------------------------------------------------------------------
dnl Is the Pthreads library present?  It has a header file `pthread.h' and
dnl a library `-lpthread' and their locations might be specified with the
dnl `--with-pthread' command-line switch.  The value is an include path
dnl and/or a library path.  If the library path is specified then it must
dnl be preceded by a comma.
dnl
AC_SUBST(PTHREAD) PTHREAD=yes

AC_ARG_WITH([pthread],
            [AC_HELP_STRING([--with-pthread=DIR],
                            [Use the Pthreads library [default=no]])],,
            withval=no)

case "$withval" in
  yes)
    AC_CHECK_HEADERS(pthread.h)
    AC_CHECK_LIB(pthread, pthread_create,,unset PTHREAD)
    ;;
  no)
    AC_MSG_CHECKING(for pthread)
    AC_MSG_RESULT(suppressed)
    unset PTHREAD
    ;;
  *)
    case "$withval" in
      *,*)
        pthread_inc="`echo $withval | cut -f1 -d,`"
        pthread_lib="`echo $withval | cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          pthread_inc="$withval/include"
          pthread_lib="$withval/lib"
        fi
        ;;
    esac

    dnl Trying to include -I/usr/include and -L/usr/lib is redundant and
    dnl can mess some compilers up.
    if test "X$pthread_inc" = "X/usr/include"; then
      pthread_inc=""
    fi
    if test "X$pthread_lib" = "X/usr/lib"; then
      pthread_lib=""
    fi

    if test -n "$pthread_inc"; then
      saved_CPPFLAGS="$CPPFLAGS"
      CPPFLAGS="$CPPFLAGS -I$pthread_inc"
      AC_CHECK_HEADERS(pthread.h,,CPPFLAGS="$saved_CPPFLAGS"; unset PTHREAD)
    else
      AC_CHECK_HEADERS(pthread.h,,unset PTHREAD)
    fi

    if test -n "$pthread_lib"; then
      saved_LDFLAGS="$LDFLAGS"
      LDFLAGS="$LDFLAGS -L$pthread_lib"
      AC_CHECK_LIB(pthread, pthread_create,,
                   LDFLAGS="$saved_LDFLAGS"; unset PTHREAD)
    else
      AC_CHECK_LIB(pthread, pthread_create,,unset PTHREAD)
    fi
    ;;
esac

dnl ----------------------------------------------------------------------
dnl Enable thread-safe version of library.  It requires Pthreads support.
dnl
AC_MSG_CHECKING(for thread safe support)
AC_ARG_ENABLE([threadsafe],
              [AC_HELP_STRING([--enable-threadsafe],
                              [Enable thread safe capability])],
              THREADSAFE=$enableval)

case "X-$THREADSAFE" in
  X-|X-no)
    AC_MSG_RESULT(no)
    ;;
  X-yes)
    dnl Check that we can link a simple Pthread program.
    AC_TRY_LINK(,pthread_create(),
    AC_MSG_RESULT(yes); THREADSAFE=yes,
    AC_MSG_ERROR(needed pthread library not available))
    ;;
  *)
    AC_MSG_RESULT(error)
    AC_MSG_ERROR(\'$enableval\' is not a valid threadsafe type)
    ;;
esac

if test "X$THREADSAFE" = "Xyes"; then
  AC_DEFINE([HAVE_THREADSAFE], [1],
            [Define if we have thread safe support])
fi

dnl ----------------------------------------------------------------------
dnl Check if they would like the function stack support compiled in
dnl
AC_MSG_CHECKING([whether function stack tracking is enabled])
AC_ARG_ENABLE([funcstack],
              [AC_HELP_STRING([--enable-funcstack],
                              [Enable the function stack
                               tracing [default=yes]])],
              [FUNCSTACK=$enableval])

case "X-$FUNCSTACK" in
  X-|X-yes)
      FUNCSTACK="yes"
      AC_MSG_RESULT([yes])
      AC_DEFINE([HAVE_FUNCSTACK], [1],
                [Define if the function stack tracing code is to be compiled in])
    ;;
  *)
      AC_MSG_RESULT([no])
    ;;
esac

dnl ----------------------------------------------------------------------
dnl Check if they would like the HDF5 v1.4 compatibility functions
dnl compiled in
dnl
AC_MSG_CHECKING([whether HDF5 v1.4 compatibility functions enabled])
AC_ARG_ENABLE([hdf5v1_4],
              [AC_HELP_STRING([--enable-hdf5v1_4],
                              [Compile the HDF5 v1.4 compatibility
                               interface [default=no]])],
              [HDF5_V1_4_COMPAT=$enableval])

if test "$HDF5_V1_4_COMPAT" = "yes"; then
  AC_MSG_RESULT([yes])
  AC_DEFINE([WANT_H5_V1_4_COMPAT], [1],
            [Define if the HDF5 v1.4 compatibility functions are to be compiled in])
else
  AC_MSG_RESULT([no])
fi

dnl ----------------------------------------------------------------------
dnl Should the Stream Virtual File Driver be compiled in ?
dnl
AC_MSG_CHECKING([for Stream Virtual File Driver support])
AC_ARG_ENABLE([stream-vfd],
              [AC_HELP_STRING([--enable-stream-vfd],
                              [Build the Stream Virtual File Driver
                               [default=no]])],
              [STREAM_VFD=$enableval])

if test "$STREAM_VFD" = "yes"; then
  AC_MSG_RESULT([yes])
  AC_CHECK_HEADERS([netinet/tcp.h sys/filio.h])
  AC_DEFINE([HAVE_STREAM], [1],
            [Define if the stream virtual file driver should be compiled])

  dnl Check if 'socklen_t' available
  AC_MSG_CHECKING([if socklen_t is defined])
  AC_TRY_COMPILE([
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
  ],
    [socklen_t foo; return 0;],
    AC_DEFINE([HAVE_SOCKLEN_T], 1,
              [Define if \`socklen_t' is defined])
    AC_MSG_RESULT([yes]),
    AC_MSG_RESULT([no])
  )
else
  AC_MSG_RESULT([not configured])
fi

dnl ----------------------------------------------------------------------
dnl How does one figure out the local time zone?  Anyone know of a
dnl Posix way to do this?
dnl

dnl First check if `struct tm' has a `tm_gmtoff' member.
AC_MSG_CHECKING(for tm_gmtoff in struct tm)
AC_TRY_COMPILE([
#include <sys/time.h>
#include <time.h>],[struct tm tm; tm.tm_gmtoff=0;],
AC_DEFINE(HAVE_TM_GMTOFF, 1,
          [Define if \`tm_gmtoff' is a member of \`struct tm'])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

dnl check if `struct tm' has a `__tm_gmtoff' member.
AC_MSG_CHECKING(for __tm_gmtoff in struct tm)
AC_TRY_COMPILE([
#include <sys/time.h>
#include <time.h>],[struct tm tm; tm.__tm_gmtoff=0;],
AC_DEFINE(HAVE___TM_GMTOFF, 1,
          [Define if \`__tm_gmtoff' is a member of \`struct tm'])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

dnl Check whether the global variable `timezone' is defined.
AC_MSG_CHECKING(for global timezone variable)
AC_TRY_LINK([
#include <sys/time.h>
#include <time.h>], [timezone=0;],
AC_DEFINE(HAVE_TIMEZONE, 1,
          [Define if \`timezone' is a global variable])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

dnl Check whether `struct timezone' is defined.
AC_STRUCT_TIMEZONE
AC_MSG_CHECKING(for struct timezone)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>],[struct timezone tz; tz.tz_minuteswest=0;],
AC_DEFINE(HAVE_STRUCT_TIMEZONE, 1,
          [Define if \`struct timezone' is defined])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

dnl ----------------------------------------------------------------------
dnl Does the struct stat have the st_blocks field?  This field is not Posix.
dnl
AC_MSG_CHECKING(for st_blocks in struct stat)
AC_TRY_COMPILE([
#include <sys/stat.h>],[struct stat sb; sb.st_blocks=0;],
AC_DEFINE(HAVE_STAT_ST_BLOCKS, 1,
          [Define if \`struct stat' has the \`st_blocks' field])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

dnl ----------------------------------------------------------------------
dnl How do we figure out the width of a tty in characters?
dnl
AC_CHECK_FUNCS(_getvideoconfig gettextinfo GetConsoleScreenBufferInfo)
AC_CHECK_FUNCS(_scrsize ioctl)

AC_MSG_CHECKING(for struct videoconfig)
AC_TRY_COMPILE(,[struct videoconfig w; w.numtextcols=0;],
AC_DEFINE(HAVE_STRUCT_VIDEOCONFIG, 1,
          [Define if \`struct videoconfig' is defined])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct text_info)
AC_TRY_COMPILE(,[struct text_info w; w.screenwidth=0;],
AC_DEFINE(HAVE_STRUCT_TEXT_INFO, 1,
          [Define if \`struct text_info' is defined])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for TIOCGWINSZ)
AC_TRY_COMPILE([#include <sys/ioctl.h>],[int w=TIOCGWINSZ;],
AC_DEFINE(HAVE_TIOCGWINSZ, 1,
          [Define if the ioctl TIOGWINSZ is defined])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for TIOCGGETD)
AC_TRY_COMPILE([#include <sys/ioctl.h>],[int w=TIOCGETD;],
AC_DEFINE(HAVE_TIOCGETD, 1,
          [Define if the ioctl TIOCGETD is defined])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))


dnl ----------------------------------------------------------------------
dnl Check for functions.
dnl
AC_CHECK_FUNCS(fork gethostname getpwuid getrusage)
AC_CHECK_FUNCS(BSDgettimeofday longjmp setsysinfo sigaction)
AC_CHECK_FUNCS(signal snprintf vsnprintf strdup system waitpid)

dnl ----------------------------------------------------------------------
dnl Check compiler characteristics
dnl
AC_C_CONST
AC_C_INLINE

AC_MSG_CHECKING([for __attribute__ extension])
AC_TRY_COMPILE(,[int __attribute__((unused)) x],
               AC_DEFINE(HAVE_ATTRIBUTE, 1,
                         [Define if the __attribute__(()) extension is present])
               AC_MSG_RESULT(yes),
               AC_MSG_RESULT(no))

AC_MSG_CHECKING([for __FUNCTION__ extension])
AC_TRY_COMPILE(,[(void)__FUNCTION__],
               AC_DEFINE(HAVE_FUNCTION, 1,
                         [Define if the compiler understand the __FUNCTION__ keyword])
               AC_MSG_RESULT(yes),
               AC_MSG_RESULT(no))

dnl ----------------------------------------------------------------------
dnl Try to figure out how to print `long long'.  Some machines use `%lld'
dnl and others use `%qd'.  There may be more!  The final `l' is a
dnl default in case none of the others work.
dnl Need to patch up LD_LIBRARY_PATH so that the execution can find all
dnl the dynamic library.  The correct way to do it should be updating
dnl LD_LIBRARY_PATH along with LDFLAGS or do it with the AC_TRY_RUN macro.
dnl
AC_MSG_CHECKING(how to print long long)
AC_CACHE_VAL([hdf5_cv_printf_ll],
LD_LIBRARY_PATH="$LD_LIBRARY_PATH`echo $LDFLAGS | sed -e 's/-L/:/g' -e 's/ //g'`"
export LD_LIBRARY_PATH

for hdf5_cv_printf_ll in l L q ll unknown; do
   AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
	char *s = malloc(128);
	long long x = (long long)1048576 * (long long)1048576;
	sprintf(s,"%${hdf5_cv_printf_ll}d",x);
	exit(strcmp(s,"1099511627776"));
}
   ], break,,continue)
done)dnl

AC_MSG_RESULT(%${hdf5_cv_printf_ll}d and %${hdf5_cv_printf_ll}u)
AC_DEFINE_UNQUOTED(PRINTF_LL_WIDTH, "$hdf5_cv_printf_ll", 
                   [Width for printf() for type \`long long' or \`__int64', us. \`ll'])

dnl ----------------------------------------------------------------------
dnl Check if malloc(0) returns valid pointer
dnl
AC_MSG_CHECKING([if malloc of zero bytes returns valid pointer])
AC_CACHE_VAL(hdf5_cv_malloc_works,
AC_TRY_RUN([
#if STDC_HEADERS
#include <stdlib.h>
#endif

int main(void)
{
    exit(malloc (0) ? 0 : 1);
}
], hdf5_cv_malloc_works=yes, hdf5_cv_malloc_works=no,))

if test ${hdf5_cv_malloc_works} = "yes"; then
  AC_DEFINE(MALLOC_WORKS, 1,
            [Define if your system has a working \`malloc' function.])
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

dnl ----------------------------------------------------------------------
dnl Check if pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM)
dnl is supported on this system
dnl
AC_MSG_CHECKING([Threads support system scope])
AC_CACHE_VAL(hdf5_cv_system_scope_threads,
AC_TRY_RUN([
#if STDC_HEADERS
#include <stdlib.h>
#include <pthread.h>
#endif

int main(void)
{
    pthread_attr_t attribute;
    int ret;

    pthread_attr_init(&attribute);
    ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
    exit(ret==0 ? 0 : 1);
}
], hdf5_cv_system_scope_threads=yes, hdf5_cv_system_scope_threads=no,))

if test ${hdf5_cv_system_scope_threads} = "yes"; then
  AC_DEFINE(SYSTEM_SCOPE_THREADS, 1,
            [Define if your system supports pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM) call.])
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

dnl ----------------------------------------------------------------------
dnl Checking to see if GPFS is available on this filesystem
dnl
AC_CHECK_HEADERS([gpfs.h],
                 AC_MSG_CHECKING([for GPFS support])
                 AC_TRY_COMPILE([#include <gpfs.h>],
                                [int fd = 0; gpfs_fcntl(fd, (void *)0);],
                                AC_DEFINE(HAVE_GPFS, 1,
                                          [Define if we have GPFS support])
                                AC_MSG_RESULT(yes)
                                LIBS="$LIBS -lgpfs"
                                GPFS="yes",
                                AC_MSG_RESULT(no)
                                GPFS="no"))
   
dnl ----------------------------------------------------------------------
dnl Turn on debugging by setting compiler flags
dnl
AC_MSG_CHECKING(for debug flags)
AC_ARG_ENABLE([debug],
              [AC_HELP_STRING([--enable-debug=all],
                              [Turn on debugging in all packages. One may
                               also specify a comma-separated list of
                               package names without the leading H5 or
                               the word no. The default is most
                               packages.])],
              [DEBUG_PKG=$enableval])

AC_SUBST([DEBUG_PKG])
all_packages="ac,b,d,e,f,g,hg,hl,i,mf,mm,o,p,s,t,v,z"
case "X-$DEBUG_PKG" in
  X-|X-yes)
    DEBUG_PKG="d,e,f,g,hg,i,mm,o,p,s,t,v,z"
    CPPFLAGS="$CPPFLAGS -UNDEBUG"
    AC_MSG_RESULT(default ($DEBUG_PKG))
    ;;
  X-all)
    DEBUG_PKG=$all_packages
    CPPFLAGS="$CPPFLAGS -UNDEBUG"
    AC_MSG_RESULT(all ($DEBUG_PKG))
    ;;
  X-no|X-none)
    AC_MSG_RESULT(none)
    DEBUG_PKG=
    CPPFLAGS="$CPPFLAGS -DNDEBUG"
    ;;
  *)
    AC_MSG_RESULT($DEBUG_PKG)
    ;;
esac

if test -n "$DEBUG_PKG"; then
  for pkg in `echo $DEBUG_PKG | tr 'a-z,' 'A-Z '`; do
    CPPFLAGS="$CPPFLAGS -DH5${pkg}_DEBUG"
  done
fi

dnl ----------------------------------------------------------------------
dnl Enable tracing of the API
dnl This must come after the enable-debug since it depends on debug.
dnl
AC_MSG_CHECKING(for API tracing);
AC_ARG_ENABLE([trace],
              [AC_HELP_STRING([--enable-trace],
                              [Enable API tracing capability.
			       Default=no if debug is disabled.])],
              TRACE=$enableval)

AC_SUBST(TRACE_API)
dnl Default to no if debug is disabled
if test "X-$TRACE" = X- ; then
  if test -z "$DEBUG_PKG" ; then
    TRACE=no
  else
    TRACE=yes
  fi
fi
case "X-$TRACE" in
  X-yes)
    AC_MSG_RESULT(yes)
    TRACE_API=yes
    CPPFLAGS="$CPPFLAGS -DH5_DEBUG_API"
    ;;
  X-no|*)
    AC_MSG_RESULT(no)
    TRACE_API=no
    CPPFLAGS="$CPPFLAGS -UH5_DEBUG_API"
    ;;
esac

dnl Checkpoint the cache
AC_CACHE_SAVE

dnl ----------------------------------------------------------------------
dnl The following variables are used to distinguish between building a
dnl serial and parallel library.
dnl
dnl    HAVE_PARALLEL	-- defined in H5config.h if we are building
dnl			   a parallel library even if configure wasn't
dnl			   able to find some header file or library that
dnl			   might be required. This is defined if the
dnl			   compiler looks like a parallel compiler (e.g.,
dnl			   mpicc or mpcc) or if the user explicitly states
dnl			   that a parallel library is being built by supplying
dnl			   the `--enable-parallel' configure switch.
dnl
dnl    PARALLEL		-- This variable is set to a non-null value if
dnl			   configure thinks we're compiling a parallel
dnl			   version of the library.
dnl
dnl    RUNSERIAL	-- This is a command which will be prepended to
dnl			   the executable name to run the executable using
dnl			   a single process. For serial versions of the
dnl			   library this will normally be empty. For parallel
dnl			   versions it might be something like `mpirun -np 1'.
dnl			   The value of this variable is substituted in *.in
dnl			   files.
dnl
dnl    RUNPARALLEL	-- This is a command which will be prepended to
dnl			   the executable name to run the executable on
dnl			   multiple processors. For the serial library the
dnl			   value will normally be the empty string. For
dnl			   parallel library it should be something like
dnl			   `mpi -np $$NPROCS' where NPROCS will eventually
dnl			   contain the number of processors on which to run
dnl			   the executable (the double dollarsigns are to
dnl			   protect the expansion until make executes the
dnl			   command).  The value of this variable is
dnl			   substituted in *.in files.
dnl
AC_SUBST(PARALLEL)
AC_SUBST(RUNSERIAL)
AC_SUBST(RUNPARALLEL)
AC_SUBST(TESTPARALLEL)

dnl ----------------------------------------------------------------------
dnl If the compiler is obviously a parallel compiler then we're building
dnl a parallel version of hdf5 and should define HAVE_PARALLEL. Furthermore,
dnl the name of the compiler might tell us how to run the resulting
dnl executable. For `mpicc' the executable should be run with `mpirun' from
dnl the same directory as mpicc if it exists.
dnl
case "$CC_BASENAME" in
  mpicc)
    dnl The mpich compiler. Use mpirun from the same directory if it
    dnl exists.
    PARALLEL=mpicc
    AC_MSG_CHECKING([for mpirun])

    dnl Find the path where mpicc is located.
    cmd="`echo $CC | cut -f1 -d' '`"
    if (echo $cmd | grep / >/dev/null); then
      path="`echo $cmd | sed 's/\(.*\)\/.*$/\1/'`"
    else
      for path in `echo $PATH | tr : ' '`; do
        if test -x $path/$cmd; then
          break
        fi
      done
    fi

    dnl Is there an mpirun at that path?
    if test -x $path/mpirun; then
      AC_MSG_RESULT([$path/mpirun])
      RUNSERIAL="${RUNSERIAL:-none}"

      if test -z "$RUNPARALLEL"; then
        RUNPARALLEL="$path/mpirun -np \$\${NPROCS:=3}"
      fi
    else
      AC_MSG_RESULT([none])
    fi
    ;;

  hcc)
    dnl The LAM compiler. Use mpirun_lam or mpirun from the same directory
    dnl if it exists.
    PARALLEL=hcc
    AC_MSG_CHECKING([for mpirun_lam or mpirun])

    dnl Find the path where hcc is located
    cmd="`echo $CC | cut -f1 -d' '`"
    if (echo $cmd | grep / >/dev/null); then
      path="`echo $cmd | sed 's/\(.*\)\/.*$/\1/'`"
    else
      for path in `echo $PATH | tr : ' '`; do
        if test -x $path/$cmd; then
          break
        fi
      done
    fi

    dnl Is there an mpirun_lam or mpirun at that path?
    if test -x $path/mpirun_lam -o -x $path/mpirun; then
      if test -x $path/mpirun_lam; then
        cmd=mpirun_lam
      else
        cmd=mpirun
      fi
      AC_MSG_RESULT([$path/$cmd])
      RUNSERIAL="${RUNSERIAL:-none}"
      if test -z "$RUNPARALLEL"; then
        RUNPARALLEL="$path/$cmd -np \$\${NPROCS:=3}"
      fi
    else
      AC_MSG_RESULT([none])
    fi
    ;;

  mpcc|mpcc_r)
    dnl The IBM compiler
    PARALLEL="$CC_BASENAME"
    ;;

  *)
    dnl Probably not a parallel compiler, but if `--enable-parallel'
    dnl is defined below then we're still building a parallel hdf5.
    ;;
esac

dnl ----------------------------------------------------------------------
dnl What header files and libraries do we have to look for for parallel
dnl support?  For the most part, search paths are already specified with
dnl CPPFLAGS and LDFLAGS or are known to the compiler.  If the user says
dnl `--disable-parallel' but specifies a known parallel compiler (like mpicc
dnl or mpcc) then parallel support is enabled but configure doesn't search
dnl for any parallel header files or libraries.
dnl
AC_ARG_ENABLE([parallel],
              [AC_HELP_STRING([--enable-parallel],
                              [Search for MPI-IO and MPI support files])])

AC_MSG_CHECKING([for parallel support files])
case "X-$enable_parallel" in
  X-|X-no|X-none)
    dnl Either we are not compiling for parallel or the header and
    dnl library files and locations are known to the compiler (this is
    dnl the case for a correct installation of mpicc for instance).
    AC_MSG_RESULT(skipped)
    ;;

  X-yes)
    dnl We want to compile a parallel library with a compiler that
    dnl may already know how to link with MPI and MPI-IO.
    AC_MSG_RESULT(provided by compiler)
    PARALLEL=yes

    dnl Try link a simple MPI program.  If fail, try again with -lmpi.
    AC_TRY_LINK(,MPI_Init(),,AC_CHECK_LIB(mpi,MPI_Init,,PARALLEL=no))

    dnl Then try link a simple MPI-IO program. If fail, try again with
    dnl -lmpio.
    if test "X$PARALLEL" = "Xyes"; then
      AC_TRY_LINK(,MPI_File_open(),,
                  AC_CHECK_LIB(mpio,MPI_File_open,,PARALLEL=no))
    fi

    dnl Set RUNPARALLEL to mpirun if not set yet.
    if test "X$PARALLEL" = "Xyes" -a -z "$RUNPARALLEL"; then
      RUNPARALLEL="mpirun -np \$\${NPROCS:=3}"
    fi
    ;;

  *)
    AC_MSG_RESULT(error)
    AC_MSG_ERROR(\'$enable_parallel\' is not a valid parallel search type)
    ;;
esac

dnl ----------------------------------------------------------------------
dnl Should the 'testpar' directory participate in the build?
dnl
if test -n "$PARALLEL"; then
  TESTPARALLEL=testpar
fi

dnl ----------------------------------------------------------------------
dnl Print some other parallel information and do some sanity checks.
dnl
if test -n "$PARALLEL"; then
  dnl We are building a parallel library
  AC_DEFINE(HAVE_PARALLEL, 1,
            [Define if we have parallel support])

  dnl Display what we found about running programs
  AC_MSG_CHECKING(prefix for running on one processor)
  AC_MSG_RESULT($RUNSERIAL)
  AC_MSG_CHECKING(prefix for running in parallel)
  AC_MSG_RESULT($RUNPARALLEL)

  dnl Check that we can link a simple MPI and MPI-IO application
  AC_MSG_CHECKING(whether a simple MPI-IO program can be linked)
  AC_TRY_LINK(,[MPI_Init();MPI_File_open();],
              AC_MSG_RESULT(yes),
              AC_MSG_RESULT(no)
              AC_MSG_ERROR('unable to link a simple MPI-IO application'))

  dnl There *must* be some way to run in parallel even if it's just the
  dnl word `none'.
  if test -z "$RUNPARALLEL"; then
    AC_MSG_ERROR(no way to run a parallel program)
  fi

  dnl If RUNSERIAL or RUNPARALLEL is the word `none' then replace it with
  dnl the empty string.
  if test "X$RUNSERIAL" = "Xnone"; then
    RUNSERIAL=""
  fi
  if test "X$RUNPARALLEL" = "Xnone"; then
    RUNPARALLEL=""
  fi

  dnl Check whether MPI_Get_count actually works correctly on this
  dnl platform.
  AC_MSG_CHECKING(whether a MPI_Get_count works correctly)
  AC_TRY_RUN([
#include <mpi.h>

int main(int argc, char **argv)
{
    MPI_Status mpi_stat;
    int bytes_read = 0, ret;

    MPI_Init(&argc, &argv);
    memset(&mpi_stat, 0, sizeof(MPI_Status)); /* zero out status */
    ret = MPI_Get_count(&mpi_stat, MPI_BYTE, &bytes_read);
    MPI_Finalize();

    /* this returns TRUE if bytes_read is 0...the shell thinks that the
     * program fails, but we want it to fail of course so switch the
     * "true"/"false" parts of the TRY_RUN macro */
    return bytes_read == 0;
}
  ],
  AC_MSG_RESULT(no),
  AC_MSG_RESULT(yes)
  CPPFLAGS="$CPPFLAGS -DMPI_GET_COUNT_WORKS",AC_MSG_RESULT(no))

dnl ----------------------------------------------------------------------
dnl Check if they would like the "Flexible parallel" functions compiled in
dnl
dnl  AC_MSG_CHECKING([if Flexible Parallel HDF5 interface enabled])
dnl  AC_ARG_ENABLE([fphdf5],
dnl                [AC_HELP_STRING([--enable-fphdf5],
dnl                                [Enable the Flexible Parallel HDF5
dnl                                 interface])],
dnl                [FPHDF5=$enableval])
dnl  if test "X$FPHDF5" = "Xyes"; then
dnl    AC_DEFINE(HAVE_FPHDF5, 1,
dnl              [Define if we want flexible parallel HDF5 support])
dnl    AC_MSG_RESULT(yes)
dnl  else
dnl    AC_MSG_RESULT(no)
dnl  fi
fi

dnl ----------------------------------------------------------------------
dnl Do we want MPE instrumentation feature on?
dnl This must be done after enable-parallel is checked since it depends on
dnl a mpich compiler.
dnl
AC_SUBST(MPE) MPE=yes
AC_ARG_ENABLE([mpe],
              [AC_HELP_STRING([--enable-mpe],
                              [Enable MPE instrumentation [default=no]])],,
	      enableval=no)

AC_MSG_CHECKING([for MPE instrumentation])
case "X-$enableval" in
  X-|X-no|X-none)
    AC_MSG_RESULT(no)
    unset MPE
    ;;

  X-yes)
    AC_MSG_RESULT(yes)

    dnl Check if MPE library is available
    AC_CHECK_LIB(mpe,main,, unset MPE)
    ;;

  *)
    AC_MSG_RESULT(error)
    AC_MSG_ERROR(\'$enableval\' is not a valid MPE value)
    unset MPE
    ;;
esac

if test "X-$MPE" = "X-yes"; then
    AC_DEFINE(HAVE_MPE, 1, [Define if we have MPE support])
fi

dnl ----------------------------------------------------------------------
dnl Turn on internal I/O filters by setting macros in header files
dnl Internal I/O filters are contained entirely within the library and do
dnl not depend on external headers or libraries.  The shuffle filter is
dnl an example of an internal filter, while the gzip filter is an example of
dnl an external filter.  Each external filter is controlled with an
dnl "--with-foo=" configure flag.
dnl
AC_MSG_CHECKING(for I/O filters)
AC_ARG_ENABLE([filters],
              [AC_HELP_STRING([--enable-filters=all],
                              [Turn on all internal I/O filters. One may
                               also specify a comma-separated list of filters
                               or the word no.  The default is all internal
                               I/O filters.])],
              [FILTERS=$enableval])

AC_SUBST([FILTERS])
dnl Eventually: all_filters="shuffle,foo,bar,baz"
all_filters="shuffle,fletcher32"
case "X-$FILTERS" in
  X-|X-all)
    FILTERS=$all_filters
    AC_MSG_RESULT(all ($FILTERS))
    ;;
  X-no|X-none)
    AC_MSG_RESULT(none)
    FILTERS="none"
    ;;
  *)
    AC_MSG_RESULT($FILTERS)
    ;;
esac

if test -n "$FILTERS"; then
  for filter in `echo $FILTERS | tr 'a-z,' 'A-Z '`; do
dnl ----------------------------------------------------------------------
dnl Have to use separate 'if' construct for each filter, so that autoheader
dnl can detect the AC_DEFINE for each one...
dnl
    if test $filter = "SHUFFLE"; then
        AC_DEFINE(HAVE_FILTER_SHUFFLE, 1,
                [Define if support for shuffle filter is enabled])
    fi
    if test $filter = "FLETCHER32"; then
        AC_DEFINE(HAVE_FILTER_FLETCHER32, 1,
                [Define if support for Fletcher32 checksum is enabled])
    fi
  done
fi

dnl ----------------------------------------------------------------------
dnl This is defined only when we're using CodeWarrior, since it has a
dnl broken "open()" call.
dnl
if test 1 = 2; then
  AC_DEFINE(NO_SHARED_WRITING, 1,
            [Define if shared writing must be disabled (CodeWarrior only)])
fi

dnl ----------------------------------------------------------------------
dnl Set some variables for general configuration information to be saved
dnl and installed with the libraries.
dnl

dnl HDF5 version from the first line of the README.txt file.
H5_VERSION="`cut -d' ' -f3 $srcdir/README.txt | head -1`"
AC_SUBST(H5_VERSION)

dnl Configuration date
AC_SUBST(CONFIG_DATE) CONFIG_DATE="`date`"

dnl User doing the configuration
AC_SUBST(CONFIG_USER) CONFIG_USER="`whoami`@`hostname`"
if test -n "$ORGANIZATION"; then
  CONFIG_USER="$CONFIG_USER at $ORGANIZATION"
fi

dnl Configuration mode (production, development, profile, etc) saved above.
AC_SUBST(CONFIG_MODE)

dnl Byte sex from the AC_C_BIGENDIAN macro.
AC_SUBST(BYTESEX)
if test "X$ac_cv_c_bigendian" = "Xyes"; then
  BYTESEX="big-endian"
else
  BYTESEX="little-endian"
fi

dnl Are we compiling static libraries, shared libraries, or both?  This
dnl is only used for the libhdf5.settings file. We can't just look at
dnl $enable_static and $enable_shared because if they're yes the ltconfig
dnl might have decided that one or the other is simply not possible.
dnl Therefore we have to look in the generated `libtool' shell script for
dnl lines that set the value of `build_libtool_libs' (shared) and
dnl `build_old_libs' (static).
AC_SUBST(STATIC_SHARED)
if (grep '^build_libtool_libs=yes' libtool >/dev/null); then
  enable_shared=yes
else
  enable_shared=no
fi
if (grep '^build_old_libs=yes' libtool >/dev/null); then
  enable_static=yes
else
  enable_static=no
fi
if test "X$enable_static" = "Xyes" && test "X$enable_shared" = "Xyes"; then
  STATIC_SHARED="static, shared"
elif test "X$enable_static" = "Xyes"; then
  STATIC_SHARED="static"
elif test "X$enable_shared" = "Xyes"; then
  STATIC_SHARED="shared"
else
  STATIC_SHARED="none"
fi

dnl Parallel support? (set above except empty if none)
PARALLEL=${PARALLEL:-no}

dnl Compiler with version information. This consists of the full path
dnl name of the compiler and the reported version number.
AC_SUBST(CC_VERSION)
if `echo $CC | grep / 2>&1 /dev/null`; then
  CC_VERSION="$CC"	
else
  CC_VERSION="$CC";
  for x in `echo $PATH | sed -e 's/:/ /g'`; do
    if test -x $x/$CC; then
      CC_VERSION="$x/$CC"
      break
    fi
  done
fi
if test -n "$cc_vendor" && test -n "$cc_version"; then
  CC_VERSION="$CC_VERSION ($cc_vendor-$cc_version)"
fi

dnl ----------------------------------------------------------------------
dnl Where is the root of the source tree. Give an absolute address so
dnl we can find it no matter which directory of the distribution is our
dnl current directory. The built-in pwd fails on some systems, but the
dnl /bin/pwd version works OK.
dnl
if test -x /bin/pwd; then
  pwd=/bin/pwd
else
  pwd=pwd
fi
AC_SUBST(ROOT) ROOT="`$pwd`"

dnl ----------------------------------------------------------------------
dnl Determine the runtime libraries we may need to include in the
dnl libtools command so that executables will find the correct dynamic
dnl libraries.
dnl 
DYNAMIC_DIRS=""
if test -n "$LDFLAGS"; then
  for d in $LDFLAGS ; do
    case "$d" in
      -L*)
        d="`echo $d | sed -e 's/-L//g'`"
        case "$d" in
          .*)
            dnl If the path isn't absolute, make it so by
            dnl prepending the ROOT directory to it.
            d=${ROOT}/$d
            ;;
        esac
        DYNAMIC_DIRS="-R${d} $DYNAMIC_DIRS"
        ;;
    esac
  done
fi
AC_SUBST(DYNAMIC_DIRS)

if test -n "$CPPFLAGS"; then
  TEMP_CPPFLAGS=""
  for d in $CPPFLAGS ; do
    case "$d" in
      -I.*)
        dnl If the path isn't absolute, make it so by prepending
        dnl the ROOT directory to it.
        d="`echo $d | sed -e 's/-I//g'`"
        d="-I${ROOT}/${d}"
        ;;
    esac
    TEMP_CPPFLAGS="$d $TEMP_CPPFLAGS"
  done
  CPPFLAGS=$TEMP_CPPFLAGS
fi

dnl ----------------------------------------------------------------------
dnl Build the Makefiles.  Almost every Makefile.in will begin with the line
dnl `@COMMENCE@' and end with the line `@CONCLUDE@'.  These lines insert
dnl various files from the config directory into the Makefile.
dnl
AC_SUBST_FILE(COMMENCE) COMMENCE=config/commence
AC_SUBST_FILE(CONCLUDE) CONCLUDE=config/conclude

dnl The directory search list
AC_SUBST(SEARCH) SEARCH='$(srcdir) $(top_builddir)/src $(top_srcdir)/src'
cmd='echo $SEARCH |sed "s/ /'$SEARCH_SEP'/g"'
SEARCH="$SEARCH_RULE`eval $cmd`"
export SEARCH

dnl We don't need to say when we're entering directories if we're using
dnl GNU make becuase make does it for us.
if test "X$GMAKE" = "Xyes"; then
  AC_SUBST(SETX) SETX=":"
else
  AC_SUBST(SETX) SETX="set -x"
fi

dnl Some cleanup stuff
rm -f conftest conftest.o conftest.c dummy.o

dnl Build config.status, touch the stamp files, and build all the Makefiles.
dnl The order is such that the first `make' does not need to update any
dnl configuration information. See config/commence.in for the order in which
dnl things need to be done.

# First the stamp1 file for H5config.h.in
mkdir ./config >/dev/null 2>&1
touch ./config/stamp1

# Then the config.status file (but not makefiles)
saved_no_create=$no_create
no_create=yes

PARALLEL_MAKE=""

if test -n "$TESTPARALLEL"; then
  PARALLEL_MAKE="$TESTPARALLEL/Makefile $TESTPARALLEL/testph5.sh"
fi

PABLO_MAKE=""

AC_SUBST(PARALLEL_PABLO) PARALLEL_PABLO=""

if test "$HAVE_PABLO" = "yes"; then
  PABLO_MAKE="pablo/Makefile"

  if test -n "$TESTPARALLEL"; then
    PARALLEL_PABLO="yes"
  fi
fi

AC_CONFIG_FILES([src/libhdf5.settings
                 config/depend1
                 config/depend2
                 config/depend3
                 config/depend4
                 config/dependN
                 config/commence
                 config/conclude
                 Makefile
                 src/Makefile
                 $PABLO_MAKE
                 test/Makefile
                 $PARALLEL_MAKE
                 perform/Makefile
                 tools/Makefile
                 tools/h5dump/Makefile
                 tools/h5import/Makefile
                 tools/h5diff/Makefile
                 tools/h5ls/Makefile
                 tools/lib/Makefile
                 tools/misc/Makefile
                 tools/misc/h5cc
                 tools/gifconv/Makefile
                 examples/Makefile
                 doc/Makefile
                 doc/html/Makefile
                 doc/html/ed_libs/Makefile
                 doc/html/ed_styles/Makefile
                 doc/html/ADGuide/Makefile
                 doc/html/Graphics/Makefile
                 doc/html/Intro/Makefile
                 doc/html/PSandPDF/Makefile
                 doc/html/TechNotes/Makefile
                 doc/html/Tutor/Makefile
                 doc/html/Tutor/Graphics/Makefile
                 doc/html/Tutor/examples/Makefile
                 doc/html/cpplus/Makefile
                 doc/html/fortran/Makefile])

AC_OUTPUT
no_create=$saved_no_create

# Then the stamp2 file for H5config.h
touch ./config/stamp2

# Finally the makefiles
test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1

chmod 755 tools/misc/h5cc

dnl We don't want inline defined for C++ compilers
dnl Don't worry about the C++ ifdef wrappers in the H5pubconf file, since
dnl 'H5_inline' isn't a C++ keyword.
cat >> src/H5config.h <<EOF

#if defined(__cplusplus) && defined(inline)
#undef inline
#endif
EOF

dnl ----------------------------------------------------------------------
dnl Print out a summary of what we are going to build.
dnl
if test -z "$ECHO_N" -o -z "$ECHO_C"; then
  if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
    if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
      ECHO_N=''
      ECHO_C='
'
    else
      ECHO_N=-n
      ECHO_C=''
    fi
  else
    ECHO_N=''
    ECHO_C='\c'
  fi
fi

PRINT_PLAIN() {
  echo $ECHO_N "$1$ECHO_C"
  echo $ECHO_N "$1$ECHO_C" 1>>src/libhdf5.settings
}

PRINT_N() {
  echo $ECHO_N "$1:  $ECHO_C"
  echo $ECHO_N "$1:  $ECHO_C" 1>>src/libhdf5.settings
}

PRINT() {
  echo "$1"
  echo "$1" 1>>src/libhdf5.settings
}

dnl ----------------------------------------------------------------------
dnl Print "Yes" if all arguments are "yes", otherwise "No"
dnl
IF_YES_NO() {
  if test $# -lt 1; then
    PRINT "No"
    return
  else
    while test $# -gt 0; do
      if test "$1" != "yes"; then
        PRINT "No"
        return
      fi
      shift
    done
  fi
  PRINT "Yes"
}

IF_ENABLED_DISABLED() {
  if test "$1" = "yes"; then
    PRINT "Enabled"
  else
    PRINT "Disabled"
  fi
}

PRINT "Configure Summary"
PRINT "Compiling Options:"

PRINT_N "               Compilation Mode"
case "X-$enable_production" in
  X-yes)        PRINT "Production" ;;
  X-no)         PRINT "Development" ;;
  X-profile)    PRINT "Profile" ;;
  *)            PRINT "$enable_production" ;;
esac

PRINT_N "                     C Compiler"
PRINT "$CC"

PRINT_N "                         CFLAGS"
PRINT "$CFLAGS"

PRINT_N "                       CPPFLAGS"
PRINT "$CPPFLAGS"

PRINT_N "                        LDFLAGS"
PRINT "$LDFLAGS"

PRINT_N "                     Debug Mode"

if test "X$DEBUG_PKG" = "X$all_packages"; then
  PRINT "All"
elif test "X$DEBUG_PKG" = "X"; then
  PRINT "None"
else
  PRINT $DEBUG_PKG
fi

PRINT_N "               Shared Libraries"
IF_YES_NO "$enable_shared"

PRINT_N "               Static Libraries"
IF_YES_NO "$enable_static"

PRINT_N "  Statically Linked Executables"
IF_YES_NO "$STATIC_EXEC"

PRINT_N "                        Tracing"
IF_YES_NO "$TRACE_API"

PRINT "Languages:"

PRINT_N "                            C++"
IF_YES_NO "$HDF_CXX"

PRINT_N "                        Fortran"
IF_YES_NO "$HDF_FORTRAN"

PRINT "Features:"

PRINT_N "                        dmalloc"
IF_YES_NO "$HAVE_DMALLOC"

dnl
dnl PRINT_N "          Flexible Parallel HDF"
dnl IF_YES_NO "$FPHDF5"
dnl

PRINT_N "         Function Stack Tracing"
IF_ENABLED_DISABLED "$FUNCSTACK"

PRINT_N "                           GASS"
IF_YES_NO "$GASS"

PRINT_N "                           GPFS"
IF_YES_NO "$GPFS"

PRINT_N "        HDF5 v1.4 Compatibility"
IF_YES_NO "$HDF5_V1_4_COMPAT"

PRINT_N "                        hsize_t"
case "$HSIZET" in
  no|small)  PRINT "Small" ;;
  *)         PRINT "Large" ;;
esac

PRINT_N "         I/O filters (external)"
PRINT "$EXTERNAL_FILTERS"

PRINT_N "         I/O filters (internal)"
PRINT "$FILTERS"

PRINT_N " Linux Large File Support (LFS)"
IF_ENABLED_DISABLED "$LINUX_LFS"

PRINT_N "                            MPE"
IF_YES_NO "$MPE"

PRINT_N "                          Pablo"
IF_YES_NO "$HAVE_PABLO"

PRINT_N "                  Parallel HDF5"
if test "$PARALLEL" != "no"; then
  PRINT "Yes"
else
  PRINT "No"
fi

PRINT_N "                            SRB"
IF_YES_NO "$SRB"

PRINT_N "                     Stream VFD"
IF_ENABLED_DISABLED "$STREAM_VFD"

PRINT_N "                   Threadsafety"
IF_ENABLED_DISABLED "$THREADSAFE"
0'>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 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
 * access to either file, you may request a copy from help@hdfgroup.org.     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/***********************************************************
*
* Test program:	 tselect
*
* Test the Dataspace selection functionality
*
*************************************************************/

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

/* Define this macro to indicate that the testing APIs should be available */
#define H5S_TESTING

#include "testhdf5.h"
#include "hdf5.h"
#include "H5Spkg.h"		/* Dataspaces				*/

#define FILENAME   "tselect.h5"

/* 3-D dataset with fixed dimensions */
#define SPACE1_NAME  "Space1"
#define SPACE1_RANK	3
#define SPACE1_DIM1	3
#define SPACE1_DIM2	15
#define SPACE1_DIM3	13

/* 2-D dataset with fixed dimensions */
#define SPACE2_NAME  "Space2"
#define SPACE2_RANK	2
#define SPACE2_DIM1	30
#define SPACE2_DIM2	26
#define SPACE2A_RANK	1
#define SPACE2A_DIM1	(SPACE2_DIM1*SPACE2_DIM2)

/* 2-D dataset with fixed dimensions */
#define SPACE3_NAME  "Space3"
#define SPACE3_RANK	2
#define SPACE3_DIM1	15
#define SPACE3_DIM2	26

/* 3-D dataset with fixed dimensions */
#define SPACE4_NAME  "Space4"
#define SPACE4_RANK	3
#define SPACE4_DIM1	11
#define SPACE4_DIM2	13
#define SPACE4_DIM3	17

/* Number of random hyperslabs to test */
#define NHYPERSLABS 10

/* Number of random hyperslab tests performed */
#define NRAND_HYPER 100

/* 5-D dataset with fixed dimensions */
#define SPACE5_NAME  "Space5"
#define SPACE5_RANK	5
#define SPACE5_DIM1	10
#define SPACE5_DIM2	10
#define SPACE5_DIM3	10
#define SPACE5_DIM4	10
#define SPACE5_DIM5	10

/* 1-D dataset with same size as 5-D dataset */
#define SPACE6_RANK	1
#define SPACE6_DIM1	(SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5)

/* 2-D dataset with easy dimension sizes */
#define SPACE7_NAME  "Space7"
#define SPACE7_RANK	2
#define SPACE7_DIM1	10
#define SPACE7_DIM2	10
#define SPACE7_FILL     254
#define SPACE7_CHUNK_DIM1 5
#define SPACE7_CHUNK_DIM2 5
#define SPACE7_NPOINTS  8

/* 4-D dataset with fixed dimensions */
#define SPACE8_NAME  "Space8"
#define SPACE8_RANK	4
#define SPACE8_DIM1	11
#define SPACE8_DIM2	13
#define SPACE8_DIM3	17
#define SPACE8_DIM4	19

/* Another 2-D dataset with easy dimension sizes */
#define SPACE9_RANK	2
#define SPACE9_DIM1	12
#define SPACE9_DIM2	12

/* Element selection information */
#define POINT1_NPOINTS 10

/* Chunked dataset information */
#define DATASETNAME "ChunkArray"
#define NX_SUB   87                     /* hyperslab dimensions */
#define NY_SUB   61
#define NZ_SUB  181
#define NX       87                     /* output buffer dimensions */
#define NY       61
#define NZ      181
#define RANK_F     3                    /* File dataspace rank */
#define RANK_M     3                    /* Memory dataspace rank */
#define X    87                         /* dataset dimensions */
#define Y    61
#define Z   181
#define CHUNK_X   87                    /* chunk dimensions */
#define CHUNK_Y   61
#define CHUNK_Z  181

/* Basic chunk size */
#define SPACE10_DIM1    180
#define SPACE10_CHUNK_SIZE 12

/* Information for bounds checking test */
#define SPACE11_RANK	2
#define SPACE11_DIM1    100
#define SPACE11_DIM2    100
#define SPACE11_NPOINTS 4

/* Information for offsets w/chunks test #2 */
#define SPACE12_RANK	        1
#define SPACE12_DIM0            25
#define SPACE12_CHUNK_DIM0      5

/* Information for Space rebuild test */
#define SPACERE1_RANK            1
#define SPACERE1_DIM0            20
#define SPACERE2_RANK            2
#define SPACERE2_DIM0            8
#define SPACERE2_DIM1            12
#define SPACERE3_RANK            3
#define SPACERE3_DIM0            8
#define SPACERE3_DIM1            12
#define SPACERE3_DIM2            8
#define SPACERE4_RANK            4
#define SPACERE4_DIM0            8
#define SPACERE4_DIM1            12
#define SPACERE4_DIM2            8
#define SPACERE4_DIM3            12
#define SPACERE5_RANK            5
#define SPACERE5_DIM0            8
#define SPACERE5_DIM1            12
#define SPACERE5_DIM2            8
#define SPACERE5_DIM3            12
#define SPACERE5_DIM4            8

/* #defines for shape same / different rank tests */
#define SS_DR_MAX_RANK		5



/* Location comparison function */
static int compare_size_t(const void *s1, const void *s2);

static herr_t test_select_hyper_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
static herr_t test_select_point_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
static herr_t test_select_all_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
static herr_t test_select_none_iter1(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);
static herr_t test_select_hyper_iter2(void *_elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *_operator_data);
static herr_t test_select_hyper_iter3(void *elem,hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data);

/****************************************************************
**
**  test_select_hyper_iter1(): Iterator for checking hyperslab iteration
**
****************************************************************/
static herr_t
test_select_hyper_iter1(void *_elem, hid_t UNUSED type_id, unsigned UNUSED ndim, const hsize_t UNUSED *point, void *_operator_data)
{
    uint8_t *tbuf=(uint8_t *)_elem,     /* temporary buffer pointer */
            **tbuf2=(uint8_t **)_operator_data; /* temporary buffer handle */

    if(*tbuf!=**tbuf2)
        return(-1);
    else {
        (*tbuf2)++;
        return(0);
    }
}   /* end test_select_hyper_iter1() */

/****************************************************************
**
**  test_select_hyper(): Test basic H5S (dataspace) selection code.
**      Tests hyperslabs of various sizes and dimensionalities.
**
****************************************************************/
static void
test_select_hyper(hid_t xfer_plist)
{
    hid_t	fid1;		/* HDF5 File IDs		*/
    hid_t	dataset;	/* Dataset ID			*/
    hid_t	sid1,sid2;	/* Dataspace ID			*/
    hsize_t	dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
    hsize_t	dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
    hsize_t	dims3[] = {SPACE3_DIM1, SPACE3_DIM2};
    hsize_t	start[SPACE1_RANK];     /* Starting location of hyperslab */
    hsize_t	stride[SPACE1_RANK];    /* Stride of hyperslab */
    hsize_t	count[SPACE1_RANK];     /* Element count of hyperslab */
    hsize_t	block[SPACE1_RANK];     /* Block size of hyperslab */
    uint8_t    *wbuf,       /* buffer to write to disk */
               *rbuf,       /* buffer read from disk */
               *tbuf;       /* temporary buffer pointer */
    int        i,j;        /* Counters */
    herr_t		ret;		/* Generic return value		*/
    H5S_class_t ext_type;   /* Extent type */

    /* Output message about test being performed */
    MESSAGE(5, ("Testing Hyperslab Selection Functions\n"));

    /* Allocate write & read buffers */
    wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
    CHECK(wbuf, NULL, "HDmalloc");
    rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2));
    CHECK(rbuf, NULL, "HDcalloc");

    /* Initialize write buffer */
    for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
        for(j=0; j<SPACE2_DIM2; j++)
            *tbuf++=(uint8_t)((i*SPACE2_DIM2)+j);

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Create dataspace for dataset */
    sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
    CHECK(sid1, FAIL, "H5Screate_simple");

    /* Create dataspace for writing buffer */
    sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Verify extent type */
    ext_type = H5Sget_simple_extent_type(sid1);
    VERIFY(ext_type, H5S_SIMPLE, "H5Sget_simple_extent_type");

    /* Test selecting stride==0 to verify failure */
    start[0]=1; start[1]=0; start[2]=0;
    stride[0]=0; stride[1]=0; stride[2]=0;
    count[0]=2; count[1]=15; count[2]=13;
    block[0]=1; block[1]=1; block[2]=1;
    H5E_BEGIN_TRY {
        ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,stride,count,block);
    } H5E_END_TRY;
    VERIFY(ret, FAIL, "H5Sselect_hyperslab");

    /* Test selecting stride<block to verify failure */
    start[0]=1; start[1]=0; start[2]=0;
    stride[0]=1; stride[1]=1; stride[2]=1;
    count[0]=2; count[1]=15; count[2]=13;
    block[0]=2; block[1]=2; block[2]=2;
    H5E_BEGIN_TRY {
        ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,stride,count,block);
    } H5E_END_TRY;
    VERIFY(ret, FAIL, "H5Sselect_hyperslab");

    /* Select 2x15x13 hyperslab for disk dataset */
    start[0]=1; start[1]=0; start[2]=0;
    stride[0]=1; stride[1]=1; stride[2]=1;
    count[0]=2; count[1]=15; count[2]=13;
    block[0]=1; block[1]=1; block[2]=1;
    ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,stride,count,block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select 15x26 hyperslab for memory dataset */
    start[0]=15; start[1]=0;
    stride[0]=1; stride[1]=1;
    count[0]=15; count[1]=26;
    block[0]=1; block[1]=1;
    ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Create a dataset */
    dataset=H5Dcreate2(fid1,SPACE2_NAME,H5T_NATIVE_UCHAR,sid1,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    /* Write selection to disk */
    ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,wbuf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* Exercise check for NULL buffer and valid selection */
    H5E_BEGIN_TRY {
        ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,NULL);
    } H5E_END_TRY;
    VERIFY(ret, FAIL, "H5Dwrite");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Create dataspace for reading buffer */
    sid2 = H5Screate_simple(SPACE3_RANK, dims3, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select 15x26 hyperslab for reading memory dataset */
    start[0]=0; start[1]=0;
    stride[0]=1; stride[1]=1;
    count[0]=15; count[1]=26;
    block[0]=1; block[1]=1;
    ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select 0x26 hyperslab to OR into current selection (should be a NOOP) */
    start[0]=0; start[1]=0;
    stride[0]=1; stride[1]=1;
    count[0]=0; count[1]=26;
    block[0]=1; block[1]=1;
    ret = H5Sselect_hyperslab(sid2,H5S_SELECT_OR,start,stride,count,block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Read selection from disk */
    ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,rbuf);
    CHECK(ret, FAIL, "H5Dread");

    /* Exercise check for NULL buffer and valid selection */
    H5E_BEGIN_TRY {
        ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,NULL);
    } H5E_END_TRY;
    VERIFY(ret, FAIL, "H5Dread");

    /* Check that the values match with a dataset iterator */
    tbuf=wbuf+(15*SPACE2_DIM2);
    ret = H5Diterate(rbuf,H5T_NATIVE_UCHAR,sid2,test_select_hyper_iter1,&tbuf);
    CHECK(ret, FAIL, "H5Diterate");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close disk dataspace */
    ret = H5Sclose(sid1);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close Dataset */
    ret = H5Dclose(dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(wbuf);
    HDfree(rbuf);
}   /* test_select_hyper() */

struct pnt_iter {
    hsize_t	coord[POINT1_NPOINTS*2][SPACE2_RANK]; /* Coordinates for point selection */
    uint8_t *buf;           /* Buffer the points are in */
    int offset;            /* Which point we are looking at */
};

/****************************************************************
**
**  test_select_point_iter1(): Iterator for checking point iteration
**  (This is really ugly code, not a very good example of correct usage - QAK)
**
****************************************************************/
static herr_t
test_select_point_iter1(void *_elem, hid_t UNUSED type_id, unsigned UNUSED ndim, const hsize_t UNUSED *point, void *_operator_data)
{
    uint8_t *elem=(uint8_t *)_elem;  /* Pointer to the element to examine */
    uint8_t *tmp;                       /* temporary ptr to element in operator data */
    struct pnt_iter *pnt_info=(struct pnt_iter *)_operator_data;

    tmp=pnt_info->buf+(pnt_info->coord[pnt_info->offset][0]*SPACE2_DIM2)+pnt_info->coord[pnt_info->offset][1];
    if(*elem!=*tmp)
        return(-1);
    else {
        pnt_info->offset++;
        return(0);
    }
}   /* end test_select_point_iter1() */

/****************************************************************
**
**  test_select_point(): Test basic H5S (dataspace) selection code.
**      Tests element selections between dataspaces of various sizes
**      and dimensionalities.
**
****************************************************************/
static void
test_select_point(hid_t xfer_plist)
{
    hid_t		fid1;		/* HDF5 File IDs		*/
    hid_t		dataset;	/* Dataset ID			*/
    hid_t		sid1,sid2;	/* Dataspace ID			*/
    hsize_t		dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
    hsize_t		dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
    hsize_t		dims3[] = {SPACE3_DIM1, SPACE3_DIM2};
    hsize_t	coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */
    hsize_t	temp_coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */
    hsize_t	coord2[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */
    hsize_t	temp_coord2[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */
    hsize_t	coord3[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */
    hsize_t	temp_coord3[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */
    uint8_t    *wbuf,       /* buffer to write to disk */
               *rbuf,       /* buffer read from disk */
               *tbuf;       /* temporary buffer pointer */
    int        i,j;        /* Counters */
    struct pnt_iter pi;     /* Custom Pointer iterator struct */
    herr_t		ret;		/* Generic return value		*/

    /* Output message about test being performed */
    MESSAGE(5, ("Testing Element Selection Functions\n"));

    /* Allocate write & read buffers */
    wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
    CHECK(wbuf, NULL, "HDmalloc");
    rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2));
    CHECK(rbuf, NULL, "HDcalloc");

    /* Initialize write buffer */
    for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
        for(j=0; j<SPACE2_DIM2; j++)
            *tbuf++=(uint8_t)((i*SPACE2_DIM2)+j);

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Create dataspace for dataset */
    sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
    CHECK(sid1, FAIL, "H5Screate_simple");

    /* Create dataspace for write buffer */
    sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select sequence of ten points for disk dataset */
    coord1[0][0]=0; coord1[0][1]=10; coord1[0][2]= 5;
    coord1[1][0]=1; coord1[1][1]= 2; coord1[1][2]= 7;
    coord1[2][0]=2; coord1[2][1]= 4; coord1[2][2]= 9;
    coord1[3][0]=0; coord1[3][1]= 6; coord1[3][2]=11;
    coord1[4][0]=1; coord1[4][1]= 8; coord1[4][2]=13;
    coord1[5][0]=2; coord1[5][1]=12; coord1[5][2]= 0;
    coord1[6][0]=0; coord1[6][1]=14; coord1[6][2]= 2;
    coord1[7][0]=1; coord1[7][1]= 0; coord1[7][2]= 4;
    coord1[8][0]=2; coord1[8][1]= 1; coord1[8][2]= 6;
    coord1[9][0]=0; coord1[9][1]= 3; coord1[9][2]= 8;
    ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
    CHECK(ret, FAIL, "H5Sselect_elements");

    /* Verify correct elements selected */
    H5Sget_select_elem_pointlist(sid1,(hsize_t)0,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord1);
    for(i=0; i<POINT1_NPOINTS; i++) {
        VERIFY(temp_coord1[i][0],coord1[i][0],"H5Sget_select_elem_pointlist");
        VERIFY(temp_coord1[i][1],coord1[i][1],"H5Sget_select_elem_pointlist");
        VERIFY(temp_coord1[i][2],coord1[i][2],"H5Sget_select_elem_pointlist");
    } /* end for */

    ret = (int)H5Sget_select_npoints(sid1);
    VERIFY(ret, 10, "H5Sget_select_npoints");

    /* Append another sequence of ten points to disk dataset */
    coord1[0][0]=0; coord1[0][1]= 2; coord1[0][2]= 0;
    coord1[1][0]=1; coord1[1][1]=10; coord1[1][2]= 8;
    coord1[2][0]=2; coord1[2][1]= 8; coord1[2][2]=10;
    coord1[3][0]=0; coord1[3][1]= 7; coord1[3][2]=12;
    coord1[4][0]=1; coord1[4][1]= 3; coord1[4][2]=11;
    coord1[5][0]=2; coord1[5][1]= 1; coord1[5][2]= 1;
    coord1[6][0]=0; coord1[6][1]=13; coord1[6][2]= 7;
    coord1[7][0]=1; coord1[7][1]=14; coord1[7][2]= 6;
    coord1[8][0]=2; coord1[8][1]= 2; coord1[8][2]= 5;
    coord1[9][0]=0; coord1[9][1]= 6; coord1[9][2]=13;
    ret = H5Sselect_elements(sid1, H5S_SELECT_APPEND, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
    CHECK(ret, FAIL, "H5Sselect_elements");

    /* Verify correct elements selected */
    H5Sget_select_elem_pointlist(sid1,(hsize_t)POINT1_NPOINTS,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord1);
    for(i=0; i<POINT1_NPOINTS; i++) {
        VERIFY(temp_coord1[i][0],coord1[i][0],"H5Sget_select_elem_pointlist");
        VERIFY(temp_coord1[i][1],coord1[i][1],"H5Sget_select_elem_pointlist");
        VERIFY(temp_coord1[i][2],coord1[i][2],"H5Sget_select_elem_pointlist");
    } /* end for */

    ret = (int)H5Sget_select_npoints(sid1);
    VERIFY(ret, 20, "H5Sget_select_npoints");

    /* Select sequence of ten points for memory dataset */
    coord2[0][0]=12; coord2[0][1]= 3;
    coord2[1][0]=15; coord2[1][1]=13;
    coord2[2][0]= 7; coord2[2][1]=25;
    coord2[3][0]= 0; coord2[3][1]= 6;
    coord2[4][0]=13; coord2[4][1]= 0;
    coord2[5][0]=24; coord2[5][1]=11;
    coord2[6][0]=12; coord2[6][1]=21;
    coord2[7][0]=29; coord2[7][1]= 4;
    coord2[8][0]= 8; coord2[8][1]= 8;
    coord2[9][0]=19; coord2[9][1]=17;
    ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord2);
    CHECK(ret, FAIL, "H5Sselect_elements");

    /* Verify correct elements selected */
    H5Sget_select_elem_pointlist(sid2,(hsize_t)0,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord2);
    for(i=0; i<POINT1_NPOINTS; i++) {
        VERIFY(temp_coord2[i][0],coord2[i][0],"H5Sget_select_elem_pointlist");
        VERIFY(temp_coord2[i][1],coord2[i][1],"H5Sget_select_elem_pointlist");
    } /* end for */

    /* Save points for later iteration */
    /* (these are in the second half of the buffer, because we are prepending */
    /*  the next list of points to the beginning of the point selection list) */
    HDmemcpy(((char *)pi.coord)+sizeof(coord2),coord2,sizeof(coord2));

    ret = (int)H5Sget_select_npoints(sid2);
    VERIFY(ret, 10, "H5Sget_select_npoints");

    /* Append another sequence of ten points to memory dataset */
    coord2[0][0]=24; coord2[0][1]= 0;
    coord2[1][0]= 2; coord2[1][1]=25;
    coord2[2][0]=13; coord2[2][1]=17;
    coord2[3][0]= 8; coord2[3][1]= 3;
    coord2[4][0]=29; coord2[4][1]= 4;
    coord2[5][0]=11; coord2[5][1]=14;
    coord2[6][0]= 5; coord2[6][1]=22;
    coord2[7][0]=12; coord2[7][1]= 2;
    coord2[8][0]=21; coord2[8][1]=12;
    coord2[9][0]= 9; coord2[9][1]=18;
    ret = H5Sselect_elements(sid2, H5S_SELECT_PREPEND, (size_t)POINT1_NPOINTS, (const hsize_t *)coord2);
    CHECK(ret, FAIL, "H5Sselect_elements");

    /* Verify correct elements selected */
    H5Sget_select_elem_pointlist(sid2,(hsize_t)0,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord2);
    for(i=0; i<POINT1_NPOINTS; i++) {
        VERIFY(temp_coord2[i][0],coord2[i][0],"H5Sget_select_elem_pointlist");
        VERIFY(temp_coord2[i][1],coord2[i][1],"H5Sget_select_elem_pointlist");
    } /* end for */

    ret = (int)H5Sget_select_npoints(sid2);
    VERIFY(ret, 20, "H5Sget_select_npoints");

    /* Save points for later iteration */
    HDmemcpy(pi.coord, coord2, sizeof(coord2));

    /* Create a dataset */
    dataset = H5Dcreate2(fid1, SPACE1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(dataset, FAIL, "H5Dcreate2");

    /* Write selection to disk */
    ret = H5Dwrite(dataset, H5T_NATIVE_UCHAR, sid2, sid1, xfer_plist, wbuf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Create dataspace for reading buffer */
    sid2 = H5Screate_simple(SPACE3_RANK, dims3, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select sequence of points for read dataset */
    coord3[0][0]= 0; coord3[0][1]= 2;
    coord3[1][0]= 4; coord3[1][1]= 8;
    coord3[2][0]=13; coord3[2][1]=13;
    coord3[3][0]=14; coord3[3][1]=20;
    coord3[4][0]= 7; coord3[4][1]= 9;
    coord3[5][0]= 2; coord3[5][1]= 0;
    coord3[6][0]= 9; coord3[6][1]=19;
    coord3[7][0]= 1; coord3[7][1]=22;
    coord3[8][0]=12; coord3[8][1]=21;
    coord3[9][0]=11; coord3[9][1]= 6;
    ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord3);
    CHECK(ret, FAIL, "H5Sselect_elements");

    /* Verify correct elements selected */
    H5Sget_select_elem_pointlist(sid2,(hsize_t)0,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord3);
    for(i=0; i<POINT1_NPOINTS; i++) {
        VERIFY(temp_coord3[i][0],coord3[i][0],"H5Sget_select_elem_pointlist");
        VERIFY(temp_coord3[i][1],coord3[i][1],"H5Sget_select_elem_pointlist");
    } /* end for */

    ret = (int)H5Sget_select_npoints(sid2);
    VERIFY(ret, 10, "H5Sget_select_npoints");

    /* Append another sequence of ten points to disk dataset */
    coord3[0][0]=14; coord3[0][1]=25;
    coord3[1][0]= 0; coord3[1][1]= 0;
    coord3[2][0]=11; coord3[2][1]=11;
    coord3[3][0]= 5; coord3[3][1]=14;
    coord3[4][0]= 3; coord3[4][1]= 5;
    coord3[5][0]= 2; coord3[5][1]= 2;
    coord3[6][0]= 7; coord3[6][1]=13;
    coord3[7][0]= 9; coord3[7][1]=16;
    coord3[8][0]=12; coord3[8][1]=22;
    coord3[9][0]=13; coord3[9][1]= 9;
    ret = H5Sselect_elements(sid2, H5S_SELECT_APPEND, (size_t)POINT1_NPOINTS, (const hsize_t *)coord3);
    CHECK(ret, FAIL, "H5Sselect_elements");

    /* Verify correct elements selected */
    H5Sget_select_elem_pointlist(sid2,(hsize_t)POINT1_NPOINTS,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord3);
    for(i=0; i<POINT1_NPOINTS; i++) {
        VERIFY(temp_coord3[i][0],coord3[i][0],"H5Sget_select_elem_pointlist");
        VERIFY(temp_coord3[i][1],coord3[i][1],"H5Sget_select_elem_pointlist");
    } /* end for */
    ret = (int)H5Sget_select_npoints(sid2);
    VERIFY(ret, 20, "H5Sget_select_npoints");

    /* Read selection from disk */
    ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,rbuf);
    CHECK(ret, FAIL, "H5Dread");

    /* Check that the values match with a dataset iterator */
    pi.buf=wbuf;
    pi.offset=0;
    ret = H5Diterate(rbuf,H5T_NATIVE_UCHAR,sid2,test_select_point_iter1,&pi);
    CHECK(ret, FAIL, "H5Diterate");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close disk dataspace */
    ret = H5Sclose(sid1);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close Dataset */
    ret = H5Dclose(dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(wbuf);
    HDfree(rbuf);
}   /* test_select_point() */

/****************************************************************
**
**  test_select_all_iter1(): Iterator for checking all iteration
**
**
****************************************************************/
static herr_t
test_select_all_iter1(void *_elem, hid_t UNUSED type_id, unsigned UNUSED ndim, const hsize_t UNUSED *point, void *_operator_data)
{
    uint8_t *tbuf=(uint8_t *)_elem,     /* temporary buffer pointer */
            **tbuf2=(uint8_t **)_operator_data; /* temporary buffer handle */

    if(*tbuf!=**tbuf2)
        return(-1);
    else {
        (*tbuf2)++;
        return(0);
    }
}   /* end test_select_all_iter1() */

/****************************************************************
**
**  test_select_none_iter1(): Iterator for checking none iteration
**      (This is never supposed to be called, so it always returns -1)
**
****************************************************************/
static herr_t
test_select_none_iter1(void UNUSED *_elem, hid_t UNUSED type_id, unsigned UNUSED ndim, const hsize_t UNUSED *point, void UNUSED *_operator_data)
{
    return(-1);
}   /* end test_select_none_iter1() */

/****************************************************************
**
**  test_select_all(): Test basic H5S (dataspace) selection code.
**      Tests "all" selections.
**
****************************************************************/
static void
test_select_all(hid_t xfer_plist)
{
    hid_t		fid1;		/* HDF5 File IDs		*/
    hid_t		dataset;	/* Dataset ID			*/
    hid_t		sid1;	        /* Dataspace ID			*/
    hsize_t		dims1[] = {SPACE4_DIM1, SPACE4_DIM2, SPACE4_DIM3};
    uint8_t    *wbuf,       /* buffer to write to disk */
               *rbuf,       /* buffer read from disk */
               *tbuf;       /* temporary buffer pointer */
    int        i,j,k;      /* Counters */
    herr_t		ret;		/* Generic return value		*/
    H5S_class_t ext_type;   /* Extent type */

    /* Output message about test being performed */
    MESSAGE(5, ("Testing 'All' Selection Functions\n"));

    /* Allocate write & read buffers */
    wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE4_DIM1 * SPACE4_DIM2 * SPACE4_DIM3);
    CHECK(wbuf, NULL, "HDmalloc");
    rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE4_DIM1 * SPACE4_DIM2 * SPACE4_DIM3));
    CHECK(rbuf, NULL, "HDcalloc");

    /* Initialize write buffer */
    for(i=0, tbuf=wbuf; i<SPACE4_DIM1; i++)
        for(j=0; j<SPACE4_DIM2; j++)
            for(k=0; k<SPACE4_DIM3; k++)
                *tbuf++ = (uint8_t)(((i * SPACE4_DIM2) + j) * SPACE4_DIM3) + k;

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Create dataspace for dataset */
    sid1 = H5Screate_simple(SPACE4_RANK, dims1, NULL);
    CHECK(sid1, FAIL, "H5Screate_simple");

    /* Verify extent type */
    ext_type = H5Sget_simple_extent_type(sid1);
    VERIFY(ext_type, H5S_SIMPLE, "H5Sget_simple_extent_type");

    /* Create a dataset */
    dataset = H5Dcreate2(fid1, SPACE4_NAME, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(dataset, FAIL, "H5Dcreate2");

    /* Write selection to disk */
    ret = H5Dwrite(dataset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, xfer_plist, wbuf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* Read selection from disk */
    ret = H5Dread(dataset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, xfer_plist, rbuf);
    CHECK(ret, FAIL, "H5Dread");

    /* Check that the values match with a dataset iterator */
    tbuf = wbuf;
    ret = H5Diterate(rbuf, H5T_NATIVE_UCHAR, sid1, test_select_all_iter1, &tbuf);
    CHECK(ret, FAIL, "H5Diterate");

    /* Close disk dataspace */
    ret = H5Sclose(sid1);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close Dataset */
    ret = H5Dclose(dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(wbuf);
    HDfree(rbuf);
}   /* test_select_all() */

/****************************************************************
**
**  test_select_all_hyper(): Test basic H5S (dataspace) selection code.
**      Tests "all" and hyperslab selections.
**
****************************************************************/
static void
test_select_all_hyper(hid_t xfer_plist)
{
    hid_t		fid1;		/* HDF5 File IDs		*/
    hid_t		dataset;	/* Dataset ID			*/
    hid_t		sid1,sid2;	/* Dataspace ID			*/
    hsize_t		dims1[] = {SPACE3_DIM1, SPACE3_DIM2};
    hsize_t		dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
    hsize_t		dims3[] = {SPACE3_DIM1, SPACE3_DIM2};
    hsize_t		start[SPACE1_RANK];     /* Starting location of hyperslab */
    hsize_t		stride[SPACE1_RANK];    /* Stride of hyperslab */
    hsize_t		count[SPACE1_RANK];     /* Element count of hyperslab */
    hsize_t		block[SPACE1_RANK];     /* Block size of hyperslab */
    uint8_t    *wbuf,       /* buffer to write to disk */
               *rbuf,       /* buffer read from disk */
               *tbuf;       /* temporary buffer pointer */
    int        i,j;        /* Counters */
    herr_t		ret;		/* Generic return value		*/
    H5S_class_t ext_type;   /* Extent type */

    /* Output message about test being performed */
    MESSAGE(5, ("Testing 'All' Selection Functions\n"));

    /* Allocate write & read buffers */
    wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
    CHECK(wbuf, NULL, "HDmalloc");
    rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2));
    CHECK(rbuf, NULL, "HDcalloc");

    /* Initialize write buffer */
    for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
        for(j=0; j<SPACE2_DIM2; j++)
            *tbuf++=(uint8_t)((i*SPACE2_DIM2)+j);

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Create dataspace for dataset */
    sid1 = H5Screate_simple(SPACE3_RANK, dims1, NULL);
    CHECK(sid1, FAIL, "H5Screate_simple");

    /* Create dataspace for writing buffer */
    sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Verify extent type */
    ext_type = H5Sget_simple_extent_type(sid1);
    VERIFY(ext_type, H5S_SIMPLE, "H5Sget_simple_extent_type");

    /* Select entire 15x26 extent for disk dataset */
    ret = H5Sselect_all(sid1);
    CHECK(ret, FAIL, "H5Sselect_all");

    /* Select 15x26 hyperslab for memory dataset */
    start[0] = 15; start[1] = 0;
    stride[0] = 1; stride[1] = 1;
    count[0] = 15; count[1] = 26;
    block[0] = 1; block[1] = 1;
    ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Create a dataset */
    dataset = H5Dcreate2(fid1, SPACE3_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(dataset, FAIL, "H5Dcreate2");

    /* Write selection to disk */
    ret = H5Dwrite(dataset, H5T_NATIVE_UCHAR, sid2, sid1, xfer_plist, wbuf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Create dataspace for reading buffer */
    sid2 = H5Screate_simple(SPACE3_RANK, dims3, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select 15x26 hyperslab for reading memory dataset */
    start[0]=0; start[1]=0;
    stride[0]=1; stride[1]=1;
    count[0]=15; count[1]=26;
    block[0]=1; block[1]=1;
    ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select no extent for disk dataset */
    ret = H5Sselect_none(sid1);
    CHECK(ret, FAIL, "H5Sselect_all");

    /* Read selection from disk (should fail with no selection defined) */
    ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,rbuf);
    VERIFY(ret, FAIL, "H5Dread");

    /* Select entire 15x26 extent for disk dataset */
    ret = H5Sselect_all(sid1);
    CHECK(ret, FAIL, "H5Sselect_all");

    /* Read selection from disk (should work now) */
    ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,rbuf);
    CHECK(ret, FAIL, "H5Dread");

    /* Check that the values match with a dataset iterator */
    tbuf=wbuf+(15*SPACE2_DIM2);
    ret = H5Diterate(rbuf,H5T_NATIVE_UCHAR,sid2,test_select_all_iter1,&tbuf);
    CHECK(ret, FAIL, "H5Diterate");

    /* A quick check to make certain that iterating through a "none" selection works */
    ret = H5Sselect_none(sid2);
    CHECK(ret, FAIL, "H5Sselect_all");
    ret = H5Diterate(rbuf,H5T_NATIVE_UCHAR,sid2,test_select_none_iter1,&tbuf);
    CHECK(ret, FAIL, "H5Diterate");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close disk dataspace */
    ret = H5Sclose(sid1);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close Dataset */
    ret = H5Dclose(dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(wbuf);
    HDfree(rbuf);
}   /* test_select_all_hyper() */

/****************************************************************
**
**  test_select_combo(): Test basic H5S (dataspace) selection code.
**      Tests combinations of element and hyperslab selections between
**      dataspaces of various sizes and dimensionalities.
**
****************************************************************/
static void
test_select_combo(void)
{
    hid_t		fid1;		/* HDF5 File IDs		*/
    hid_t		dataset;	/* Dataset ID			*/
    hid_t		sid1,sid2;	/* Dataspace ID			*/
    hsize_t		dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
    hsize_t		dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
    hsize_t		dims3[] = {SPACE3_DIM1, SPACE3_DIM2};
    hsize_t		coord1[POINT1_NPOINTS][SPACE1_RANK]; /* Coordinates for point selection */
    hsize_t		start[SPACE1_RANK];     /* Starting location of hyperslab */
    hsize_t		stride[SPACE1_RANK];    /* Stride of hyperslab */
    hsize_t		count[SPACE1_RANK];     /* Element count of hyperslab */
    hsize_t		block[SPACE1_RANK];     /* Block size of hyperslab */
    uint8_t    *wbuf,       /* buffer to write to disk */
               *rbuf,       /* buffer read from disk */
               *tbuf,       /* temporary buffer pointer */
               *tbuf2;      /* temporary buffer pointer */
    int        i,j;        /* Counters */
    herr_t		ret;		/* Generic return value		*/

    /* Output message about test being performed */
    MESSAGE(5, ("Testing Combination of Hyperslab & Element Selection Functions\n"));

    /* Allocate write & read buffers */
    wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
    CHECK(wbuf, NULL, "HDmalloc");
    rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2));
    CHECK(rbuf, NULL, "HDcalloc");

    /* Initialize write buffer */
    for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
        for(j=0; j<SPACE2_DIM2; j++)
            *tbuf++=(uint8_t)((i*SPACE2_DIM2)+j);

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Create dataspace for dataset */
    sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
    CHECK(sid1, FAIL, "H5Screate_simple");

    /* Create dataspace for write buffer */
    sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select sequence of ten points for disk dataset */
    coord1[0][0]=0; coord1[0][1]=10; coord1[0][2]= 5;
    coord1[1][0]=1; coord1[1][1]= 2; coord1[1][2]= 7;
    coord1[2][0]=2; coord1[2][1]= 4; coord1[2][2]= 9;
    coord1[3][0]=0; coord1[3][1]= 6; coord1[3][2]=11;
    coord1[4][0]=1; coord1[4][1]= 8; coord1[4][2]=13;
    coord1[5][0]=2; coord1[5][1]=12; coord1[5][2]= 0;
    coord1[6][0]=0; coord1[6][1]=14; coord1[6][2]= 2;
    coord1[7][0]=1; coord1[7][1]= 0; coord1[7][2]= 4;
    coord1[8][0]=2; coord1[8][1]= 1; coord1[8][2]= 6;
    coord1[9][0]=0; coord1[9][1]= 3; coord1[9][2]= 8;
    ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
    CHECK(ret, FAIL, "H5Sselect_elements");

    /* Select 1x10 hyperslab for writing memory dataset */
    start[0]=0; start[1]=0;
    stride[0]=1; stride[1]=1;
    count[0]=1; count[1]=10;
    block[0]=1; block[1]=1;
    ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Create a dataset */
    dataset = H5Dcreate2(fid1, SPACE1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(dataset, FAIL, "H5Dcreate2");

    /* Write selection to disk */
    ret = H5Dwrite(dataset, H5T_NATIVE_UCHAR, sid2, sid1, H5P_DEFAULT, wbuf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Create dataspace for reading buffer */
    sid2 = H5Screate_simple(SPACE3_RANK, dims3, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select 10x1 hyperslab for reading memory dataset */
    start[0]=0; start[1]=0;
    stride[0]=1; stride[1]=1;
    count[0]=10; count[1]=1;
    block[0]=1; block[1]=1;
    ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Read selection from disk */
    ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,rbuf);
    CHECK(ret, FAIL, "H5Dread");

    /* Compare data read with data written out */
    for(i=0; i<POINT1_NPOINTS; i++) {
        tbuf=wbuf+i;
        tbuf2=rbuf+(i*SPACE3_DIM2);
        if(*tbuf!=*tbuf2)
            TestErrPrintf("element values don't match!, i=%d\n",i);
    } /* end for */

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close disk dataspace */
    ret = H5Sclose(sid1);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close Dataset */
    ret = H5Dclose(dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(wbuf);
    HDfree(rbuf);
}   /* test_select_combo() */

static int
compare_size_t(const void *s1, const void *s2)
{
    if(*(const size_t *)s1<*(const size_t *)s2)
        return(-1);
    else
        if(*(const size_t *)s1>*(const size_t *)s2)
            return(1);
        else
            return(0);
}

/****************************************************************
**
**  test_select_hyper_stride(): Test H5S (dataspace) selection code.
**      Tests strided hyperslabs of various sizes and dimensionalities.
**
****************************************************************/
static void
test_select_hyper_stride(hid_t xfer_plist)
{
    hid_t		fid1;		/* HDF5 File IDs		*/
    hid_t		dataset;	/* Dataset ID			*/
    hid_t		sid1,sid2;	/* Dataspace ID			*/
    hsize_t		dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
    hsize_t		dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
    hsize_t		dims3[] = {SPACE3_DIM1, SPACE3_DIM2};
    hsize_t		start[SPACE1_RANK];     /* Starting location of hyperslab */
    hsize_t		stride[SPACE1_RANK];    /* Stride of hyperslab */
    hsize_t		count[SPACE1_RANK];     /* Element count of hyperslab */
    hsize_t		block[SPACE1_RANK];     /* Block size of hyperslab */
    uint16_t   *wbuf,       /* buffer to write to disk */
               *rbuf,       /* buffer read from disk */
               *tbuf,       /* temporary buffer pointer */
               *tbuf2;      /* temporary buffer pointer */
    size_t      loc1[72]={  /* Gruesomely ugly way to make certain hyperslab locations are checked correctly */
       27, 28, 29, 53, 54, 55, 79, 80, 81,   /* Block #1 */
       32, 33, 34, 58, 59, 60, 84, 85, 86,   /* Block #2 */
      157,158,159,183,184,185,209,210,211,   /* Block #3 */
      162,163,164,188,189,190,214,215,216,   /* Block #4 */
      287,288,289,313,314,315,339,340,341,   /* Block #5 */
      292,293,294,318,319,320,344,345,346,   /* Block #6 */
      417,418,419,443,444,445,469,470,471,   /* Block #7 */
      422,423,424,448,449,450,474,475,476,   /* Block #8 */
            };
    size_t      loc2[72]={
        0,  1,  2, 26, 27, 28,    /* Block #1 */
        4,  5,  6, 30, 31, 32,    /* Block #2 */
        8,  9, 10, 34, 35, 36,    /* Block #3 */
       12, 13, 14, 38, 39, 40,    /* Block #4 */
      104,105,106,130,131,132,    /* Block #5 */
      108,109,110,134,135,136,    /* Block #6 */
      112,113,114,138,139,140,    /* Block #7 */
      116,117,118,142,143,144,    /* Block #8 */
      208,209,210,234,235,236,    /* Block #9 */
      212,213,214,238,239,240,    /* Block #10 */
      216,217,218,242,243,244,    /* Block #11 */
      220,221,222,246,247,248,    /* Block #12 */
            };
    int        i,j;        /* Counters */
    herr_t		ret;		/* Generic return value		*/

    /* Output message about test being performed */
    MESSAGE(5, ("Testing Hyperslabs with Strides Functionality\n"));

    /* Allocate write & read buffers */
    wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2);
    CHECK(wbuf, NULL, "HDmalloc");
    rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2));
    CHECK(rbuf, NULL, "HDcalloc");

    /* Initialize write buffer */
    for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
        for(j=0; j<SPACE2_DIM2; j++)
            *tbuf++=(uint16_t)((i*SPACE2_DIM2)+j);

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Create dataspace for dataset */
    sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
    CHECK(sid1, FAIL, "H5Screate_simple");

    /* Create dataspace for writing buffer */
    sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select 2x3x3 count with a stride of 2x4x3 & 1x2x2 block hyperslab for disk dataset */
    start[0] = 0; start[1] = 0; start[2] = 0;
    stride[0] = 2; stride[1] = 4; stride[2] = 3;
    count[0] = 2; count[1] = 3; count[2] = 3;
    block[0] = 1; block[1] = 2; block[2] = 2;
    ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select 4x2 count with a stride of 5x5 & 3x3 block hyperslab for memory dataset */
    start[0] = 1; start[1] = 1;
    stride[0] = 5; stride[1] = 5;
    count[0] = 4; count[1] = 2;
    block[0] = 3; block[1] = 3;
    ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Create a dataset */
    dataset = H5Dcreate2(fid1, SPACE2_NAME, H5T_STD_U16LE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(dataset, FAIL, "H5Dcreate2");

    /* Write selection to disk */
    ret = H5Dwrite(dataset, H5T_NATIVE_USHORT, sid2, sid1, xfer_plist, wbuf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Create dataspace for reading buffer */
    sid2 = H5Screate_simple(SPACE3_RANK, dims3, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select 3x4 count with a stride of 4x4 & 2x3 block hyperslab for memory dataset */
    start[0]=0; start[1]=0;
    stride[0]=4; stride[1]=4;
    count[0]=3; count[1]=4;
    block[0]=2; block[1]=3;
    ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Read selection from disk */
    ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid2,sid1,xfer_plist,rbuf);
    CHECK(ret, FAIL, "H5Dread");

    /* Sort the locations into the proper order */
    HDqsort(loc1, (size_t)72, sizeof(size_t), compare_size_t);
    HDqsort(loc2, (size_t)72, sizeof(size_t), compare_size_t);
    /* Compare data read with data written out */
    for(i=0; i<72; i++) {
        tbuf=wbuf+loc1[i];
        tbuf2=rbuf+loc2[i];
        if(*tbuf!=*tbuf2) {
            printf("%d: hyperslab values don't match!, loc1[%d]=%d, loc2[%d]=%d\n",__LINE__,i,(int)loc1[i],i,(int)loc2[i]);
            printf("wbuf=%p, tbuf=%p, rbuf=%p, tbuf2=%p\n",(void *)wbuf,(void *)tbuf,(void *)rbuf,(void *)tbuf2);
            TestErrPrintf("*tbuf=%u, *tbuf2=%u\n",(unsigned)*tbuf,(unsigned)*tbuf2);
        } /* end if */
    } /* end for */

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close disk dataspace */
    ret = H5Sclose(sid1);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close Dataset */
    ret = H5Dclose(dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(wbuf);
    HDfree(rbuf);
}   /* test_select_hyper_stride() */

/****************************************************************
**
**  test_select_hyper_contig(): Test H5S (dataspace) selection code.
**      Tests contiguous hyperslabs of various sizes and dimensionalities.
**
****************************************************************/
static void
test_select_hyper_contig(hid_t dset_type, hid_t xfer_plist)
{
    hid_t		fid1;		/* HDF5 File IDs		*/
    hid_t		dataset;	/* Dataset ID			*/
    hid_t		sid1,sid2;	/* Dataspace ID			*/
    hsize_t		dims2[] = {SPACE2_DIM2, SPACE2_DIM1};
    hsize_t		start[SPACE1_RANK];     /* Starting location of hyperslab */
    hsize_t		stride[SPACE1_RANK];    /* Stride of hyperslab */
    hsize_t		count[SPACE1_RANK];     /* Element count of hyperslab */
    hsize_t		block[SPACE1_RANK];     /* Block size of hyperslab */
    uint16_t   *wbuf,       /* buffer to write to disk */
               *rbuf,       /* buffer read from disk */
               *tbuf;       /* temporary buffer pointer */
    int        i,j;        /* Counters */
    herr_t		ret;		/* Generic return value		*/

    /* Output message about test being performed */
    MESSAGE(5, ("Testing Contiguous Hyperslabs Functionality\n"));

    /* Allocate write & read buffers */
    wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2);
    CHECK(wbuf, NULL, "HDmalloc");
    rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2));
    CHECK(rbuf, NULL, "HDcalloc");

    /* Initialize write buffer */
    for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
        for(j=0; j<SPACE2_DIM2; j++)
            *tbuf++=(uint16_t)((i*SPACE2_DIM2)+j);

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Create dataspace for dataset */
    sid1 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
    CHECK(sid1, FAIL, "H5Screate_simple");

    /* Create dataspace for writing buffer */
    sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select 12x10 count with a stride of 1x3 & 3x3 block hyperslab for disk dataset */
    start[0] = 0; start[1] = 0;
    stride[0] = 1; stride[1] = 3;
    count[0] = 12; count[1] = 10;
    block[0] = 1; block[1] = 3;
    ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select 4x5 count with a stride of 3x6 & 3x6 block hyperslab for memory dataset */
    start[0] = 0; start[1] = 0;
    stride[0] = 3; stride[1] = 6;
    count[0] = 4; count[1] = 5;
    block[0] = 3; block[1] = 6;
    ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Create a dataset */
    dataset = H5Dcreate2(fid1, SPACE2_NAME, dset_type, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(dataset, FAIL, "H5Dcreate2");

    /* Write selection to disk */
    ret = H5Dwrite(dataset, H5T_NATIVE_USHORT, sid2, sid1, xfer_plist, wbuf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Create dataspace for reading buffer */
    sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select 6x5 count with a stride of 2x6 & 2x6 block hyperslab for disk dataset */
    start[0] = 0; start[1] = 0;
    stride[0] = 2; stride[1] = 6;
    count[0] = 6; count[1] = 5;
    block[0] = 2; block[1] = 6;
    ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select 3x15 count with a stride of 4x2 & 4x2 block hyperslab for memory dataset */
    start[0] = 0; start[1] = 0;
    stride[0] = 4; stride[1] = 2;
    count[0] = 3; count[1] = 15;
    block[0] = 4; block[1] = 2;
    ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Read selection from disk */
    ret = H5Dread(dataset, H5T_NATIVE_USHORT, sid2, sid1, xfer_plist, rbuf);
    CHECK(ret, FAIL, "H5Dread");

    /* Compare data read with data written out */
    if(HDmemcmp(rbuf, wbuf, sizeof(uint16_t) * 30 * 12)) {
        TestErrPrintf("hyperslab values don't match! Line=%d\n",__LINE__);
#ifdef QAK
        for(i=0, tbuf=wbuf; i<12; i++)
            for(j=0; j<30; j++)
                printf("i=%d, j=%d, *wbuf=%u, *rbuf=%u\n",i,j,(unsigned)*(wbuf+i*30+j),(unsigned)*(rbuf+i*30+j));
#endif /* QAK */
    } /* end if */

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close disk dataspace */
    ret = H5Sclose(sid1);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close Dataset */
    ret = H5Dclose(dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(wbuf);
    HDfree(rbuf);
}   /* test_select_hyper_contig() */

/****************************************************************
**
**  test_select_hyper_contig2(): Test H5S (dataspace) selection code.
**      Tests more contiguous hyperslabs of various sizes and dimensionalities.
**
****************************************************************/
static void
test_select_hyper_contig2(hid_t dset_type, hid_t xfer_plist)
{
    hid_t		fid1;		/* HDF5 File IDs		*/
    hid_t		dataset;	/* Dataset ID			*/
    hid_t		sid1,sid2;	/* Dataspace ID			*/
    hsize_t		dims2[] = {SPACE8_DIM4, SPACE8_DIM3, SPACE8_DIM2, SPACE8_DIM1};
    hsize_t	        start[SPACE8_RANK];     /* Starting location of hyperslab */
    hsize_t		count[SPACE8_RANK];     /* Element count of hyperslab */
    uint16_t   *wbuf,       /* buffer to write to disk */
               *rbuf,       /* buffer read from disk */
               *tbuf;       /* temporary buffer pointer */
    int        i,j,k,l;     /* Counters */
    herr_t		ret;		/* Generic return value		*/

    /* Output message about test being performed */
    MESSAGE(5, ("Testing More Contiguous Hyperslabs Functionality\n"));

    /* Allocate write & read buffers */
    wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4);
    CHECK(wbuf, NULL, "HDmalloc");
    rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4));
    CHECK(rbuf, NULL, "HDcalloc");

    /* Initialize write buffer */
    for(i=0, tbuf=wbuf; i<SPACE8_DIM1; i++)
        for(j=0; j<SPACE8_DIM2; j++)
            for(k=0; k<SPACE8_DIM3; k++)
                for(l=0; l<SPACE8_DIM4; l++)
                    *tbuf++=(uint16_t)((i*SPACE8_DIM2)+j);

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Create dataspace for dataset */
    sid1 = H5Screate_simple(SPACE8_RANK, dims2, NULL);
    CHECK(sid1, FAIL, "H5Screate_simple");

    /* Create dataspace for writing buffer */
    sid2 = H5Screate_simple(SPACE8_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select contiguous hyperslab for disk dataset */
    start[0]=0; start[1]=0; start[2]=0; start[3]=0;
    count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2; count[3]=SPACE8_DIM1;
    ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select contiguous hyperslab in memory */
    start[0]=0; start[1]=0; start[2]=0; start[3]=0;
    count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2; count[3]=SPACE8_DIM1;
    ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, NULL, count, NULL);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Create a dataset */
    dataset = H5Dcreate2(fid1, SPACE8_NAME, dset_type, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(dataset, FAIL, "H5Dcreate2");

    /* Write selection to disk */
    ret = H5Dwrite(dataset, H5T_NATIVE_USHORT, sid2, sid1, xfer_plist, wbuf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Create dataspace for reading buffer */
    sid2 = H5Screate_simple(SPACE8_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select contiguous hyperslab in memory */
    start[0]=0; start[1]=0; start[2]=0; start[3]=0;
    count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2; count[3]=SPACE8_DIM1;
    ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select contiguous hyperslab in memory */
    start[0]=0; start[1]=0; start[2]=0; start[3]=0;
    count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2; count[3]=SPACE8_DIM1;
    ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,NULL,count,NULL);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Read selection from disk */
    ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid2,sid1,xfer_plist,rbuf);
    CHECK(ret, FAIL, "H5Dread");

    /* Compare data read with data written out */
    if(HDmemcmp(rbuf,wbuf,sizeof(uint16_t)*2*SPACE8_DIM3*SPACE8_DIM2*SPACE8_DIM1)) {
        TestErrPrintf("Error: hyperslab values don't match!\n");
#ifdef QAK
        for(i=0, tbuf=wbuf; i<12; i++)
            for(j=0; j<30; j++)
                printf("i=%d, j=%d, *wbuf=%u, *rbuf=%u\n",i,j,(unsigned)*(wbuf+i*30+j),(unsigned)*(rbuf+i*30+j));
#endif /* QAK */
    } /* end if */

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close disk dataspace */
    ret = H5Sclose(sid1);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close Dataset */
    ret = H5Dclose(dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(wbuf);
    HDfree(rbuf);
}   /* test_select_hyper_contig2() */

/****************************************************************
**
**  test_select_hyper_contig3(): Test H5S (dataspace) selection code.
**      Tests contiguous hyperslabs of various sizes and dimensionalities.
**  This test uses a hyperslab that is contiguous in the lowest dimension,
**  not contiguous in a dimension, then has a selection across the entire next
**  dimension (which should be "flattened" out also).
**
****************************************************************/
static void
test_select_hyper_contig3(hid_t dset_type, hid_t xfer_plist)
{
    hid_t		fid1;		/* HDF5 File IDs		*/
    hid_t		dataset;	/* Dataset ID			*/
    hid_t		sid1,sid2;	/* Dataspace ID			*/
    hsize_t		dims2[] = {SPACE8_DIM4, SPACE8_DIM3, SPACE8_DIM2, SPACE8_DIM1};
    hsize_t	        start[SPACE8_RANK];     /* Starting location of hyperslab */
    hsize_t		count[SPACE8_RANK];     /* Element count of hyperslab */
    uint16_t   *wbuf,           /* Buffer to write to disk */
               *rbuf,           /* Buffer read from disk */
               *tbuf, *tbuf2;   /* Temporary buffer pointers */
    unsigned   i,j,k,l;     /* Counters */
    herr_t		ret;		/* Generic return value		*/

    /* Output message about test being performed */
    MESSAGE(5, ("Testing Yet More Contiguous Hyperslabs Functionality\n"));

    /* Allocate write & read buffers */
    wbuf = (uint16_t *)HDmalloc(sizeof(uint16_t) * SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4);
    CHECK(wbuf, NULL, "HDmalloc");
    rbuf = (uint16_t *)HDcalloc(sizeof(uint16_t), (size_t)(SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4));
    CHECK(rbuf, NULL, "HDcalloc");

    /* Initialize write buffer */
    for(i=0, tbuf=wbuf; i<SPACE8_DIM4; i++)
        for(j=0; j<SPACE8_DIM3; j++)
            for(k=0; k<SPACE8_DIM2; k++)
                for(l=0; l<SPACE8_DIM1; l++)
                    *tbuf++=(uint16_t)((k*SPACE8_DIM2)+l);

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Create dataspace for dataset */
    sid1 = H5Screate_simple(SPACE8_RANK, dims2, NULL);
    CHECK(sid1, FAIL, "H5Screate_simple");

    /* Create dataspace for writing buffer */
    sid2 = H5Screate_simple(SPACE8_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select semi-contiguous hyperslab for disk dataset */
    start[0] = 0; start[1] = 0; start[2] = SPACE8_DIM2/2; start[3] = 0;
    count[0] = 2; count[1] = SPACE8_DIM3; count[2] = SPACE8_DIM2 / 2; count[3] = SPACE8_DIM1;
    ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select semi-contiguous hyperslab in memory */
    start[0] = 0; start[1] = 0; start[2] = SPACE8_DIM2 / 2; start[3] = 0;
    count[0] = 2; count[1] = SPACE8_DIM3; count[2] = SPACE8_DIM2 / 2; count[3] = SPACE8_DIM1;
    ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, NULL, count, NULL);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Create a dataset */
    dataset = H5Dcreate2(fid1, SPACE8_NAME, dset_type, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    CHECK(dataset, FAIL, "H5Dcreate2");

    /* Write selection to disk */
    ret = H5Dwrite(dataset, H5T_NATIVE_USHORT, sid2, sid1, xfer_plist, wbuf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Create dataspace for reading buffer */
    sid2 = H5Screate_simple(SPACE8_RANK, dims2, NULL);
    CHECK(sid2, FAIL, "H5Screate_simple");

    /* Select semi-contiguous hyperslab in memory */
    start[0]=0; start[1]=0; start[2]=SPACE8_DIM2/2; start[3]=0;
    count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2/2; count[3]=SPACE8_DIM1;
    ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Select semi-contiguous hyperslab in memory */
    start[0]=0; start[1]=0; start[2]=SPACE8_DIM2/2; start[3]=0;
    count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2/2; count[3]=SPACE8_DIM1;
    ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,NULL,count,NULL);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");

    /* Read selection from disk */
    ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid2,sid1,xfer_plist,rbuf);
    CHECK(ret, FAIL, "H5Dread");

    /* Compare data read with data written out */
    for(i=0, tbuf=wbuf,tbuf2=rbuf; i<SPACE8_DIM4; i++)
        for(j=0; j<SPACE8_DIM3; j++)
            for(k=0; k<SPACE8_DIM2; k++)
                for(l=0; l<SPACE8_DIM1; l++,tbuf++,tbuf2++)
                    if( (i>=start[0] && i<(start[0]+count[0])) &&
                            (j>=start[1] && j<(start[1]+count[1])) &&
                            (k>=start[2] && k<(start[2]+count[2])) &&
                            (l>=start[3] && l<(start[3]+count[3])) ) {
                        if(*tbuf!=*tbuf2) {
                            printf("Error: hyperslab values don't match!\n");
                            TestErrPrintf("Line: %d, i=%u, j=%u, k=%u, l=%u, *tbuf=%u,*tbuf2=%u\n",__LINE__,i,j,k,l,(unsigned)*tbuf,(unsigned)*tbuf2);
                        } /* end if */
                    } /* end if */
                    else {
                        if(*tbuf2!=0) {
                            printf("Error: invalid data in read buffer!\n");
                            TestErrPrintf("Line: %d, i=%u, j=%u, k=%u, l=%u, *tbuf=%u,*tbuf2=%u\n",__LINE__,i,j,k,l,(unsigned)*tbuf,(unsigned)*tbuf2);
                        } /* end if */
                    } /* end else */

    /* Close memory dataspace */
    ret = H5Sclose(sid2);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close disk dataspace */
    ret = H5Sclose(sid1);
    CHECK(ret, FAIL, "H5Sclose");

    /* Close Dataset */
    ret = H5Dclose(dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(wbuf);
    HDfree(rbuf);
}   /* test_select_hyper_contig3() */


/****************************************************************
**
**  verify_select_hyper_contig_dr__run_test(): Verify data from
**      test_select_hyper_contig_dr__run_test()
**
****************************************************************/
static void
verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf,
    size_t cube_size, unsigned edge_size, unsigned cube_rank)
{
    const uint16_t     *cube_ptr;           /* Pointer into the cube buffer */
    uint16_t		expected_value;     /* Expected value in dataset */
    unsigned            i, j, k, l, m;      /* Local index variables */
    size_t              s;                  /* Local index variable */
    hbool_t		mis_match;          /* Flag to indicate mis-match in expected value */

    HDassert(cube_buf);
    HDassert(cube_size > 0);

    expected_value = 0;
    mis_match = FALSE;
    cube_ptr = cube_buf;
    s = 0;
    i = 0;
    do {
        j = 0;
        do {
            k = 0;
            do {
                l = 0;
                do {
                    m = 0;
                    do {
                        /* Sanity check */
                        HDassert(s < cube_size);

                        /* Check for correct value */
                        if(*cube_ptr != expected_value)
                            mis_match = TRUE;

                        /* Advance to next element */
                        cube_ptr++;
                        expected_value++;
                        s++;       
                        m++;       
                    } while((cube_rank > 0) && (m < edge_size));
                    l++;
                } while((cube_rank > 1) && (l < edge_size));
                k++;
            } while((cube_rank > 2) && (k < edge_size));
            j++;
        } while((cube_rank > 3) && (j < edge_size));
        i++;
    } while((cube_rank > 4) && (i < edge_size));
    if(mis_match)
        TestErrPrintf("Initial cube data don't match! Line = %d\n", __LINE__);
}   /* verify_select_hyper_contig_dr__run_test() */


/****************************************************************
**
**  test_select_hyper_contig_dr__run_test(): Test H5S (dataspace) 
**	selection code with contiguous source and target having 
**	different ranks but the same shape.  We have already
**	tested H5S_shape_same in isolation, so now we try to do 
**	I/O.
**
****************************************************************/
static void
test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf,
    const uint16_t *zero_buf, unsigned edge_size, unsigned chunk_edge_size,
    unsigned small_rank, unsigned large_rank, hid_t dset_type, hid_t xfer_plist)
{
    hbool_t		mis_match;              /* Flag indicating a value read in wasn't what was expected */
    hid_t               fapl;                   /* File access property list */
    hid_t		fid1;		        /* File ID */
    hid_t		small_cube_sid;         /* Dataspace ID for small cube in memory & file */
    hid_t		mem_large_cube_sid;     /* Dataspace ID for large cube in memory */
    hid_t		file_large_cube_sid;    /* Dataspace ID for large cube in file */
    hid_t		small_cube_dcpl_id = H5P_DEFAULT;   /* DCPL for small cube dataset */
    hid_t		large_cube_dcpl_id = H5P_DEFAULT;   /* DCPL for large cube dataset */
    hid_t		small_cube_dataset;	/* Dataset ID */
    hid_t		large_cube_dataset;	/* Dataset ID */
    size_t              start_index;            /* Offset within buffer to begin inspecting */
    size_t              stop_index;             /* Offset within buffer to end inspecting */
    uint16_t		expected_value;         /* Expected value in dataset */
    uint16_t	      * small_cube_buf_1;       /* Buffer for small cube data */
    uint16_t	      * large_cube_buf_1;       /* Buffer for large cube data */
    uint16_t	      * ptr_1;                  /* Temporary pointer into cube data */
    hsize_t		dims[SS_DR_MAX_RANK];   /* Dataspace dimensions */
    hsize_t     	start[SS_DR_MAX_RANK];  /* Shared hyperslab start offset */
    hsize_t     	stride[SS_DR_MAX_RANK]; /* Shared hyperslab stride */
    hsize_t     	count[SS_DR_MAX_RANK];  /* Shared hyperslab count */
    hsize_t     	block[SS_DR_MAX_RANK];  /* Shared hyperslab block size */
    hsize_t	      * start_ptr;          /* Actual hyperslab start offset */
    hsize_t	      * stride_ptr;         /* Actual hyperslab stride */
    hsize_t	      * count_ptr;          /* Actual hyperslab count */
    hsize_t	      * block_ptr;          /* Actual hyperslab block size */
    size_t              small_cube_size;    /* Number of elements in small cube */
    size_t              large_cube_size;    /* Number of elements in large cube */
    unsigned            u, v, w, x;     /* Local index variables */
    size_t              s;              /* Local index variable */
    htri_t      	check;          /* Shape comparison return value */
    herr_t      	ret;            /* Generic return value */

    MESSAGE(7, ("\tn-cube slice through m-cube I/O test %d.\n", test_num));
    MESSAGE(7, ("\tranks = %u/%u, edge_size = %u, chunk_edge_size = %u.\n", small_rank, large_rank, edge_size, chunk_edge_size));

    HDassert(edge_size >= 6);
    HDassert(edge_size >= chunk_edge_size);
    HDassert((chunk_edge_size == 0) || (chunk_edge_size >= 3));
    HDassert(small_rank > 0);
    HDassert(small_rank < large_rank);
    HDassert(large_rank <= SS_DR_MAX_RANK);

    /* Compute cube sizes */
    small_cube_size = large_cube_size = (size_t)1;
    for(u = 0; u < large_rank; u++) {
        if(u < small_rank)
            small_cube_size *= (size_t)edge_size;

        large_cube_size *= (size_t)edge_size;
    } /* end for */

    HDassert(large_cube_size < (size_t)UINT_MAX);

    /* set up the start, stride, count, and block pointers */
    start_ptr  = &(start[SS_DR_MAX_RANK - large_rank]);
    stride_ptr = &(stride[SS_DR_MAX_RANK - large_rank]);
    count_ptr  = &(count[SS_DR_MAX_RANK - large_rank]);
    block_ptr  = &(block[SS_DR_MAX_RANK - large_rank]);

    /* Allocate buffers */
    small_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), small_cube_size);
    CHECK(small_cube_buf_1, NULL, "HDcalloc");
    large_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), large_cube_size);
    CHECK(large_cube_buf_1, NULL, "HDcalloc");

    /* Create a dataset transfer property list */
    fapl = H5Pcreate(H5P_FILE_ACCESS);
    CHECK(fapl, FAIL, "H5Pcreate");

    /* Use the 'core' VFD for this test */
    ret = H5Pset_fapl_core(fapl, (size_t)(1024 * 1024), FALSE);
    CHECK(ret, FAIL, "H5Pset_fapl_core");

    /* Create file */
    fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
    CHECK(fid1, FAIL, "H5Fcreate");

    /* Close file access property list */
    ret = H5Pclose(fapl);
    CHECK(ret, FAIL, "H5Pclose");

    /* setup dims: */
    dims[0] = dims[1] = dims[2] = dims[3] = dims[4] = (hsize_t)edge_size;

    /* Create small cube dataspaces */
    small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL);
    CHECK(small_cube_sid, FAIL, "H5Screate_simple");

    /* Create large cube dataspace */
    mem_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
    CHECK(mem_large_cube_sid, FAIL, "H5Screate_simple");
    file_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
    CHECK(file_large_cube_sid, FAIL, "H5Screate_simple");

    /* if chunk edge size is greater than zero, set up the small and
     * large data set creation property lists to specify chunked 
     * datasets.
     */
    if(chunk_edge_size > 0) {
        hsize_t		chunk_dims[SS_DR_MAX_RANK];     /* Chunk dimensions */

        chunk_dims[0] = chunk_dims[1] = 
		chunk_dims[2] = chunk_dims[3] = chunk_dims[4] = (hsize_t)chunk_edge_size;

        small_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
        CHECK(small_cube_dcpl_id, FAIL, "H5Pcreate");

        ret = H5Pset_layout(small_cube_dcpl_id, H5D_CHUNKED);
        CHECK(ret, FAIL, "H5Pset_layout");

        ret = H5Pset_chunk(small_cube_dcpl_id, (int)small_rank, chunk_dims);
        CHECK(ret, FAIL, "H5Pset_chunk");


        large_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
        CHECK(large_cube_dcpl_id, FAIL, "H5Pcreate");

        ret = H5Pset_layout(large_cube_dcpl_id, H5D_CHUNKED);
        CHECK(ret, FAIL, "H5Pset_layout");

        ret = H5Pset_chunk(large_cube_dcpl_id, (int)large_rank, chunk_dims);
        CHECK(ret, FAIL, "H5Pset_chunk");
    } /* end if */

    /* create the small cube dataset */
    small_cube_dataset = H5Dcreate2(fid1, "small_cube_dataset", dset_type, 
            small_cube_sid, H5P_DEFAULT, small_cube_dcpl_id, H5P_DEFAULT);
    CHECK(small_cube_dataset, FAIL, "H5Dcreate2");

    /* Close non-default small dataset DCPL */
    if(small_cube_dcpl_id != H5P_DEFAULT) {
        ret = H5Pclose(small_cube_dcpl_id);
        CHECK(ret, FAIL, "H5Pclose");
    } /* end if */

    /* create the large cube dataset */
    large_cube_dataset = H5Dcreate2(fid1, "large_cube_dataset", dset_type, 
            file_large_cube_sid, H5P_DEFAULT, large_cube_dcpl_id, H5P_DEFAULT);
    CHECK(large_cube_dataset, FAIL, "H5Dcreate2");

    /* Close non-default large dataset DCPL */
    if(large_cube_dcpl_id != H5P_DEFAULT) {
        ret = H5Pclose(large_cube_dcpl_id);
        CHECK(ret, FAIL, "H5Pclose");
    } /* end if */


    /* write initial data to the on disk datasets */
    ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, 
            small_cube_sid, xfer_plist, cube_buf);
    CHECK(ret, FAIL, "H5Dwrite");

    ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, 
            file_large_cube_sid, xfer_plist, cube_buf);
    CHECK(ret, FAIL, "H5Dwrite");

    /* read initial data from disk and verify that it is as expected. */
    ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, small_cube_sid, 
        small_cube_sid, xfer_plist, small_cube_buf_1);
    CHECK(ret, FAIL, "H5Dread");

    /* Check that the data is valid */
    verify_select_hyper_contig_dr__run_test(small_cube_buf_1, small_cube_size,
        edge_size, small_rank);

    ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, mem_large_cube_sid, 
        file_large_cube_sid, xfer_plist, large_cube_buf_1);
    CHECK(ret, FAIL, "H5Dread");

    /* Check that the data is valid */
    verify_select_hyper_contig_dr__run_test(large_cube_buf_1, large_cube_size,
        edge_size, large_rank);


    /* first, verify that we can read from disk correctly using selections
     * of different rank that H5S_select_shape_same() views as being of the
     * same shape.
     *
     * Start by reading small_rank-D slice from the on disk large cube, and 
     * verifying that the data read is correct.  Verify that H5S_select_shape_same() 
     * returns true on the memory and file selections.
     */

    
    /* set up start, stride, count, and block -- note that we will
     * change start[] so as to read slices of the large cube.
     */
    for(u = 0; u < SS_DR_MAX_RANK; u++) {
        start[u] = 0;
        stride[u] = 1;
        count[u] = 1;
        if((SS_DR_MAX_RANK - u) > small_rank)
            block[u] = 1;
        else
            block[u] = (hsize_t)edge_size;
    } /* end for */

    u = 0;
    do {
        v = 0;
        do {
            w = 0;
            do {
                x = 0;
                do {
                    /* we know that small_rank >= 1 and that large_rank > small_rank
                     * by the assertions at the head of this function.  Thus no
                     * need for another inner loop.
                     */
                    start[0] = (hsize_t)u;
                    start[1] = (hsize_t)v;
                    start[2] = (hsize_t)w;
                    start[3] = (hsize_t)x;
                    start[4] = (hsize_t)0;

                    ret = H5Sselect_hyperslab(file_large_cube_sid, 
                                              H5S_SELECT_SET,
                                              start_ptr, 
                                              stride_ptr, 
                                              count_ptr, 
                                              block_ptr);
                    CHECK(ret, FAIL, "H5Sselect_hyperslab");

                    /* verify that H5S_select_shape_same() reports the two 
                     * selections as having the same shape.
                     */
                    check = H5S_select_shape_same_test(small_cube_sid, 
                                                       file_large_cube_sid);
                    VERIFY(check, TRUE, "H5S_select_shape_same_test");

                    /* Read selection from disk */
                    ret = H5Dread(large_cube_dataset,
                                  H5T_NATIVE_UINT16,
                                  small_cube_sid,
                                  file_large_cube_sid,
                                  xfer_plist,
                                  small_cube_buf_1);
                    CHECK(ret, FAIL, "H5Dread");

                    /* verify that expected data is retrieved */
                    mis_match = FALSE;
                    ptr_1 = small_cube_buf_1;
                    expected_value = (uint16_t)((u * edge_size * edge_size * edge_size * edge_size) +
                                     (v * edge_size * edge_size * edge_size) +
                                     (w * edge_size * edge_size) +
                                     (x * edge_size));
                    for(s = 0; s < small_cube_size; s++ ) {
                        if(*ptr_1 != expected_value )
                            mis_match = TRUE;
                        ptr_1++;
                        expected_value++;
                    } /* end for */
                    if(mis_match)
                        TestErrPrintf("small cube read from largecube has bad data! Line=%d\n",__LINE__);

                    x++;
                } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size));
                w++;
            } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size));
            v++;
        } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size));
        u++;
    } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size));
        

    /* similarly, read the on disk small cube into slices through the in memory
     * large cube, and verify that the correct data (and only the correct data)
     * is read.
     */

    /* zero out the in-memory large cube */
    HDmemset(large_cube_buf_1, 0, large_cube_size * sizeof(uint16_t));

    u = 0;
    do {
        v = 0;
        do {
            w = 0;
            do {
                x = 0;
                do {
                    /* we know that small_rank >= 1 and that large_rank > small_rank
                     * by the assertions at the head of this function.  Thus no
                     * need for another inner loop.
                     */
                    start[0] = (hsize_t)u;
                    start[1] = (hsize_t)v;
                    start[2] = (hsize_t)w;
                    start[3] = (hsize_t)x;
                    start[4] = (hsize_t)0;

                    ret = H5Sselect_hyperslab(mem_large_cube_sid, 
                                              H5S_SELECT_SET,
                                              start_ptr, 
                                              stride_ptr, 
                                              count_ptr, 
                                              block_ptr);
                    CHECK(ret, FAIL, "H5Sselect_hyperslab");


                    /* verify that H5S_select_shape_same() reports the two 
                     * selections as having the same shape.
                     */
                    check = H5S_select_shape_same_test(small_cube_sid, 
                                                       mem_large_cube_sid);
                    VERIFY(check, TRUE, "H5S_select_shape_same_test");


                    /* Read selection from disk */
                    ret = H5Dread(small_cube_dataset,
                                  H5T_NATIVE_UINT16,
                                  mem_large_cube_sid,
                                  small_cube_sid,
                                  xfer_plist,
                                  large_cube_buf_1);
                    CHECK(ret, FAIL, "H5Dread");


                    /* verify that the expected data and only the 
                     * expected data was read.
                     */
                    start_index = (u * edge_size * edge_size * edge_size * edge_size) +
                                  (v * edge_size * edge_size * edge_size) +
                                  (w * edge_size * edge_size) +
                                  (x * edge_size);
                    stop_index = start_index + small_cube_size - 1;

                    HDassert(start_index < stop_index);
                    HDassert(stop_index <= large_cube_size);

                    mis_match = FALSE;
                    ptr_1 = large_cube_buf_1;
                    expected_value = 0;
                    for(s = 0; s < start_index; s++) {
                        if(*ptr_1 != 0)
                            mis_match = TRUE;
                        ptr_1++;
                    } /* end for */
                    for(; s <= stop_index; s++) {
                        if(*ptr_1 != expected_value)
                            mis_match = TRUE;
                        expected_value++;
                        ptr_1++;
                    } /* end for */
                    for(; s < large_cube_size; s++) {
                        if(*ptr_1 != 0)
                            mis_match = TRUE;
                        ptr_1++;
                    } /* end for */
                    if(mis_match)
                        TestErrPrintf("large cube read from small cube has bad data! Line=%u\n", __LINE__);

                    /* Zero out the buffer for the next pass */
                    HDmemset(large_cube_buf_1 + start_index, 0, small_cube_size * sizeof(uint16_t));
                    
                    x++;
                } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size));
                w++;
            } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size));
            v++;
        } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size));
        u++;
    } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size));


    /* now we go in the opposite direction, verifying that we can write 
     * from memory to file using selections of different rank that 
     * H5S_select_shape_same() views as being of the same shape.
     *
     * Start by writing small_rank D slices from the in memory large cube, to 
     * the the on disk small cube dataset.  After each write, read the small
     * cube dataset back from disk, and verify that it contains the expected
     * data. Verify that H5S_select_shape_same() returns true on the 
     * memory and file selections.
     */ 

    u = 0;
    do {
        v = 0;
        do {
            w = 0;
            do {
                x = 0;
                do {
                    /* we know that small_rank >= 1 and that large_rank > small_rank
                     * by the assertions at the head of this function.  Thus no
                     * need for another inner loop.
                     */

                    /* zero out the on disk small cube */
                    ret = H5Dwrite(small_cube_dataset, 
                                   H5T_NATIVE_UINT16, 
                                   small_cube_sid, 
                                   small_cube_sid, 
                                   xfer_plist, 
                                   zero_buf);
                    CHECK(ret, FAIL, "H5Dwrite");

                    /* select the portion of the in memory large cube from which we 
                     * are going to write data.
                     */
                    start[0] = (hsize_t)u;
                    start[1] = (hsize_t)v;
                    start[2] = (hsize_t)w;
                    start[3] = (hsize_t)x;
                    start[4] = (hsize_t)0;

                    ret = H5Sselect_hyperslab(mem_large_cube_sid, 
                                              H5S_SELECT_SET,
                                              start_ptr, 
                                              stride_ptr, 
                                              count_ptr, 
                                              block_ptr);
                    CHECK(ret, FAIL, "H5Sselect_hyperslab");


                    /* verify that H5S_select_shape_same() reports the in 
                     * memory slice through the cube selection and the 
                     * on disk full small cube selections as having the same shape.
                     */
                    check = H5S_select_shape_same_test(small_cube_sid, 
                                                       mem_large_cube_sid);
                    VERIFY(check, TRUE, "H5S_select_shape_same_test");


	            /* write the slice from the in memory large cube to the on disk small cube */
                    ret = H5Dwrite(small_cube_dataset, 
                                   H5T_NATIVE_UINT16, 
                                   mem_large_cube_sid, 
                                   small_cube_sid, 
                                   xfer_plist, 
                                   cube_buf);
                    CHECK(ret, FAIL, "H5Dwrite");


                    /* read the on disk small cube into memory */
                    ret = H5Dread(small_cube_dataset, 
                                  H5T_NATIVE_UINT16,
                                  small_cube_sid,
                                  small_cube_sid, 
                                  xfer_plist, 
                                  small_cube_buf_1);
                    CHECK(ret, FAIL, "H5Dread");


                    /* verify that expected data is retrieved */
                    mis_match = FALSE;
                    ptr_1 = small_cube_buf_1;
                    expected_value = (uint16_t)((u * edge_size * edge_size * edge_size * edge_size) +
                                     (v * edge_size * edge_size * edge_size) +
                                     (w * edge_size * edge_size) +
                                     (x * edge_size));
                    for(s = 0; s < small_cube_size; s++) {
                        if(*ptr_1 != expected_value)
                            mis_match = TRUE;
                        expected_value++;
                        ptr_1++;
                    } /* end for */
                    if(mis_match )
                        TestErrPrintf("small cube data don't match! Line=%d\n",__LINE__);
                    
                    x++;
                } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size));
                w++;
            } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size));
            v++;
        } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size));
        u++;
    } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size));


    /* Now write the contents of the in memory small cube to slices of 
     * the on disk cube.  After each write, read the on disk cube
     * into memeory, and verify that it contains the expected 
     * data.  Verify that H5S_select_shape_same() returns true on 
     * the memory and file selections.
     */

    /* select the entire memory and file cube dataspaces */
    ret = H5Sselect_all(mem_large_cube_sid);
    CHECK(ret, FAIL, "H5Sselect_all");

    ret = H5Sselect_all(file_large_cube_sid);
    CHECK(ret, FAIL, "H5Sselect_all");

    u = 0;
    do {
        v = 0;
        do {
            w = 0;
            do {
                x = 0;
                do {
                    /* we know that small_rank >= 1 and that large_rank > small_rank
                     * by the assertions at the head of this function.  Thus no
                     * need for another inner loop.
                     */

                    /* zero out the on disk cube */
                    ret = H5Dwrite(large_cube_dataset, 
                                   H5T_NATIVE_USHORT, 
                                   mem_large_cube_sid, 
                                   file_large_cube_sid, 
                                   xfer_plist, 
                                   zero_buf);
                    CHECK(ret, FAIL, "H5Dwrite");


                    /* select the portion of the in memory large cube to which we 
                     * are going to write data.
                     */
                    start[0] = (hsize_t)u;
                    start[1] = (hsize_t)v;
                    start[2] = (hsize_t)w;
                    start[3] = (hsize_t)x;
                    start[4] = (hsize_t)0;

                    ret = H5Sselect_hyperslab(file_large_cube_sid, 
                                              H5S_SELECT_SET,
                                              start_ptr, 
                                              stride_ptr, 
                                              count_ptr, 
                                              block_ptr);
                    CHECK(ret, FAIL, "H5Sselect_hyperslab");


                    /* verify that H5S_select_shape_same() reports the in 
                     * memory full selection of the small cube and the 
                     * on disk slice through the large cube selection 
                     * as having the same shape.
                     */
                    check = H5S_select_shape_same_test(small_cube_sid, 
                                                       file_large_cube_sid);
                    VERIFY(check, TRUE, "H5S_select_shape_same_test");


	            /* write the cube from memory to the target slice of the disk cube */
                    ret = H5Dwrite(large_cube_dataset, 
                                   H5T_NATIVE_UINT16, 
                                   small_cube_sid, 
                                   file_large_cube_sid, 
                                   xfer_plist, 
                                   cube_buf);
                    CHECK(ret, FAIL, "H5Dwrite");


                    /* read the on disk cube into memory */
                    ret = H5Sselect_all(file_large_cube_sid);
                    CHECK(ret, FAIL, "H5Sselect_all");

                    ret = H5Dread(large_cube_dataset, 
                                  H5T_NATIVE_UINT16,
                                  mem_large_cube_sid,
                                  file_large_cube_sid, 
                                  xfer_plist, 
                                  large_cube_buf_1);
                    CHECK(ret, FAIL, "H5Dread");


                    /* verify that the expected data and only the 
                     * expected data was read.
                     */
                    start_index = (u * edge_size * edge_size * edge_size * edge_size) +
                                  (v * edge_size * edge_size * edge_size) +
                                  (w * edge_size * edge_size) +
                                  (x * edge_size);
                    stop_index = start_index + small_cube_size - 1;

                    HDassert(start_index < stop_index);
                    HDassert(stop_index <= large_cube_size);

                    mis_match = FALSE;
                    ptr_1 = large_cube_buf_1;
                    expected_value = 0;
                    for(s = 0; s < start_index; s++) {
                        if(*ptr_1 != 0)
                            mis_match = TRUE;
                        ptr_1++;
                    } /* end for */
                    for(; s <= stop_index; s++) {
                        if(*ptr_1 != expected_value)
                            mis_match = TRUE;
                        expected_value++;
                        ptr_1++;
                    } /* end for */
                    for(; s < large_cube_size; s++) {
                        if(*ptr_1 != 0)
                            mis_match = TRUE;
                        ptr_1++;
                    } /* end for */
                    if(mis_match)
                        TestErrPrintf("large cube written from small cube has bad data! Line=%d\n", __LINE__);
                    
                    x++;
                } while((large_rank >= 2) && (small_rank <= 1) && (x < edge_size));
                w++;
            } while((large_rank >= 3) && (small_rank <= 2) && (w < edge_size));
            v++;
        } while((large_rank >= 4) && (small_rank <= 3) && (v < edge_size));
        u++;
    } while((large_rank >= 5) && (small_rank <= 4) && (u < edge_size));

    /* Close memory dataspaces */
    ret = H5Sclose(small_cube_sid);
    CHECK(ret, FAIL, "H5Sclose");

    ret = H5Sclose(mem_large_cube_sid);
    CHECK(ret, FAIL, "H5Sclose");


    /* Close disk dataspace */
    ret = H5Sclose(file_large_cube_sid);
    CHECK(ret, FAIL, "H5Sclose");


    /* Close Datasets */
    ret = H5Dclose(small_cube_dataset);
    CHECK(ret, FAIL, "H5Dclose");

    ret = H5Dclose(large_cube_dataset);
    CHECK(ret, FAIL, "H5Dclose");

    /* Close file */
    ret = H5Fclose(fid1);
    CHECK(ret, FAIL, "H5Fclose");

    /* Free memory buffers */
    HDfree(small_cube_buf_1);
    HDfree(large_cube_buf_1);

}   /* test_select_hyper_contig_dr__run_test() */


/****************************************************************
**
**  test_select_hyper_contig_dr(): Test H5S (dataspace) 
**	selection code with contiguous source and target having 
**	different ranks but the same shape.  We have already
**	tested H5S_shape_same in isolation, so now we try to do 
**	I/O.
**
****************************************************************/
static void
test_select_hyper_contig_dr(hid_t dset_type, hid_t xfer_plist)
{
    int test_num = 0;
    unsigned chunk_edge_size;   /* Size of chunk's dataspace dimensions */
    unsigned edge_size = 6;     /* Size of dataset's dataspace dimensions */
    unsigned small_rank;        /* Current rank of small dataset */
    unsigned large_rank;        /* Current rank of large dataset */
    uint16_t *cube_buf;         /* Buffer for writing cube data */
    uint16_t *zero_buf;         /* Buffer for writing zeroed cube data */
    uint16_t *cube_ptr;         /* Temporary pointer into cube data */
    unsigned max_rank = 5;      /* Max. rank to use */
    size_t max_cube_size;       /* Max. number of elements in largest cube */
    size_t s;                   /* Local index variable */
    unsigned u;                 /* Local index variable */

    /* Output message about test being performed */
    MESSAGE(5, ("Testing Contiguous Hyperslabs With Different Rank I/O Functionality\n"));

    /* Compute max. cube size */
    max_cube_size = (size_t)1;
    for(u = 0; u < max_rank; u++)
        max_cube_size *= (size_t)edge_size;

    /* Allocate cube buffer for writing values */
    cube_buf = (uint16_t *)HDmalloc(sizeof(uint16_t) * max_cube_size);
    CHECK(cube_buf, NULL, "HDmalloc");

    /* Initialize the cube buffer */
    cube_ptr = cube_buf;
    for(s = 0; s < max_cube_size; s++)
        *cube_ptr++ = (uint16_t)s;

    /* Allocate cube buffer for zeroing values on disk */
    zero_buf = (uint16_t *)HDcalloc(sizeof(uint16_t), max_cube_size);
    CHECK(zero_buf, NULL, "HDcalloc");

    for(large_rank = 1; large_rank <= max_rank; large_rank++) {
        for(small_rank = 1; small_rank < large_rank; small_rank++) {
            chunk_edge_size = 0;
            test_select_hyper_contig_dr__run_test(test_num, cube_buf, zero_buf,
                    edge_size, chunk_edge_size, small_rank, large_rank,
                    dset_type, xfer_plist);
            test_num++;

            chunk_edge_size = 3;
            test_select_hyper_contig_dr__run_test(test_num, cube_buf, zero_buf,
                    edge_size, chunk_edge_size, small_rank, large_rank,
                    dset_type, xfer_plist);
            test_num++;
        } /* for loop on small rank */
    } /* for loop on large rank */

    HDfree(cube_buf);
    HDfree(zero_buf);

}   /* test_select_hyper_contig_dr() */


/****************************************************************
**
**  test_select_hyper_checker_board_dr__select_checker_board():  
**	Given an n-cube data space with each edge of length 
**	edge_size, and a checker_edge_size either select a checker
**	board selection of the entire cube(if sel_rank == n),
**	or select a checker board selection of a
**	sel_rank dimensional slice through n-cube parallel to the 
**      sel_rank fastest changing indices, with origin (in the
**	higher indices) as indicated by the start array.
**
**	Note that this function, like all its relatives, is
**	hard coded to presume a maximum n-cube rank of 5.
**	While this maximum is declared as a constant, increasing
**	it will require extensive coding in addition to changing
**      the value of the constant.
**
**					JRM -- 9/9/09
**
****************************************************************/
static void
test_select_hyper_checker_board_dr__select_checker_board(hid_t tgt_n_cube_sid,
    unsigned tgt_n_cube_rank, unsigned edge_size, unsigned checker_edge_size,
    unsigned sel_rank, hsize_t sel_start[])
{
    hbool_t		first_selection = TRUE;
    unsigned		n_cube_offset;
    unsigned		sel_offset;
    hsize_t		base_count;
    hsize_t             offset_count;
    hsize_t     	start[SS_DR_MAX_RANK];  /* Offset of hyperslab selection */
    hsize_t     	stride[SS_DR_MAX_RANK]; /* Stride of hyperslab selection */
    hsize_t     	count[SS_DR_MAX_RANK];  /* Count of hyperslab selection */
    hsize_t     	block[SS_DR_MAX_RANK];  /* Block size of hyperslab selection */
    unsigned            i, j, k, l, m;  /* Local index variable */
    unsigned            u;              /* Local index variables */
    herr_t      	ret;            /* Generic return value */

    HDassert(edge_size >= 6);
    HDassert(0 < checker_edge_size);
    HDassert(checker_edge_size <= edge_size);
    HDassert(0 < sel_rank);
    HDassert(sel_rank <= tgt_n_cube_rank);
    HDassert(tgt_n_cube_rank <= SS_DR_MAX_RANK);

    sel_offset = SS_DR_MAX_RANK - sel_rank;
    n_cube_offset = SS_DR_MAX_RANK - tgt_n_cube_rank;
    HDassert(n_cube_offset <= sel_offset);

    /* First, compute the base count (which assumes start == 0
     * for the associated offset) and offset_count (which
     * assumes start == checker_edge_size for the associated
     * offset).
     */
    base_count = edge_size / (checker_edge_size * 2);
    if((edge_size % (checker_edge_size * 2)) > 0)
        base_count++;

    offset_count = (edge_size - checker_edge_size) / (checker_edge_size * 2);
    if(((edge_size - checker_edge_size) % (checker_edge_size * 2)) > 0)
        offset_count++;

    /* Now set up the stride and block arrays, and portions of the start
     * and count arrays that will not be altered during the selection of 
     * the checker board.
     */
    u = 0;
    while(u < n_cube_offset) {
        /* these values should never be used */
        start[u] = 0;
        stride[u] = 0;
        count[u] = 0;
        block[u] = 0;

        u++;
    } /* end while */

    while(u < sel_offset) {
        start[u] = sel_start[u];
        stride[u] = 2 * edge_size;
        count[u] = 1;
        block[u] = 1;

        u++;
    } /* end while */

    while(u < SS_DR_MAX_RANK) {
        stride[u] = 2 * checker_edge_size;
        block[u] = checker_edge_size;

        u++;
    } /* end while */
   
    i = 0;
    do {
        if(0 >= sel_offset) {
            if(i == 0) {
                start[0] = 0;
                count[0] = base_count;
            } /* end if */
            else {
                start[0] = checker_edge_size;
                count[0] = offset_count;
            } /* end else */
        } /* end if */

        j = 0;
        do { 
            if(1 >= sel_offset) {
                if(j == 0 ) {
                    start[1] = 0;
                    count[1] = base_count;
                } /* end if */
                else {
                    start[1] = checker_edge_size;
                    count[1] = offset_count;
                } /* end else */
            } /* end if */

            k = 0;
            do {
                if(2 >= sel_offset) {
                    if(k == 0) {
                        start[2] = 0;
                        count[2] = base_count;
                    } /* end if */
                    else {
                        start[2] = checker_edge_size;
                        count[2] = offset_count;
                    } /* end else */
                } /* end if */

                l = 0;
                do {
                    if(3 >= sel_offset) {
                        if(l == 0) {
                            start[3] = 0;
                            count[3] = base_count;
                        } /* end if */
                        else {
                            start[3] = checker_edge_size;
                            count[3] = offset_count;
                        } /* end else */
                    } /* end if */

                    m = 0;
                    do {
                        if(4 >= sel_offset) {
                            if(m == 0) {
                                start[4] = 0;
                                count[4] = base_count;
                            } /* end if */
                            else {
                                start[4] = checker_edge_size;
                                count[4] = offset_count;
                            } /* end else */
                        } /* end if */

                        if(((i + j + k + l + m) % 2) == 0) {
                            if(first_selection) {
                                first_selection = FALSE; 

                                ret = H5Sselect_hyperslab(tgt_n_cube_sid, 
                                        H5S_SELECT_SET,
                                        &(start[n_cube_offset]), 
                                        &(stride[n_cube_offset]), 
                                        &(count[n_cube_offset]), 
                                        &(block[n_cube_offset]));
                                CHECK(ret, FAIL, "H5Sselect_hyperslab");
                            } /* end if */
                            else {
                                ret = H5Sselect_hyperslab(tgt_n_cube_sid, 
                                        H5S_SELECT_OR,
                                        &(start[n_cube_offset]), 
                                        &(stride[n_cube_offset]), 
                                        &(count[n_cube_offset]), 
                                        &(block[n_cube_offset]));
                                CHECK(ret, FAIL, "H5Sselect_hyperslab");
                            } /* end else */
                        } /* end if */

                        m++;
                    } while((m <= 1) && (4 >= sel_offset));
                    l++;
                } while((l <= 1) && (3 >= sel_offset));
                k++;
            } while((k <= 1) && (2 >= sel_offset));
            j++;
        } while((j <= 1) && (1 >= sel_offset));
        i++;
    } while((i <= 1) && (0 >= sel_offset));

    /* Wierdness alert:
     *
     * Some how, it seems that selections can extend beyond the
     * boundaries of the target data space -- hence the following
     * code to manually clip the selection back to the data space
     * proper.
     */
    for(u = 0; u < SS_DR_MAX_RANK; u++) {
        start[u]  = 0;
        stride[u] = edge_size;
        count[u]  = 1;
        block[u]  = edge_size;
    } /* end for */

    ret = H5Sselect_hyperslab(tgt_n_cube_sid, H5S_SELECT_AND, start, stride, count, block);
    CHECK(ret, FAIL, "H5Sselect_hyperslab");
} /* test_select_hyper_checker_board_dr__select_checker_board() */


/****************************************************************
**
**  test_select_hyper_checker_board_dr__verify_data(): 
**
**	Examine the supplied buffer to see if it contains the 
**	expected data.  Return TRUE if it does, and FALSE 
**      otherwise.
**
**	The supplied buffer is presumed to contain the results
**	of read or writing a checkerboard selection of an 
**	n-cube, or a checkerboard selection of an m (1 <= m < n)
**	dimensional slice through an n-cube parallel to the 
**      fastest changing indices.  
**
**	It is further presumed that the buffer was zeroed before
**	the read, and that the n-cube was initialize with the 
**      natural numbers listed in order from the origin along 
**      the fastest changing axis.
**
**      Thus for a 10x10x10 3-cube, the value stored in location
**	(x, y, z) (assuming that z is the fastest changing index
**	and x the slowest) is assumed to be:
**
**		(10 * 10 * x) + (10 * y) + z
**
**	Thus, if the buffer contains the result of reading a 
**	checker board selection of a 10x10x10 3-cube, location
**	(x, y, z) will contain zero if it is not in a checker,
**	and 100x + 10y + z if (x, y, z) is in a checker.
**
**	If the buffer contains the result of reading a 3 
**	dimensional slice (parallel to the three fastest changing
**	indices) through an n cube (n > 3), then the expected 
**	values in the buffer will be the same, save that we will
**	add a constant determined by the origin of the 3-cube 
**	in the n-cube.
**
**	Finally, the function presumes that the first element 
**	of the buffer resides either at the origin of either
**	a selected or an unselected checker.
**
****************************************************************/
static hbool_t
test_select_hyper_checker_board_dr__verify_data(uint16_t * buf_ptr,
    unsigned rank, unsigned edge_size, unsigned checker_edge_size,
    uint16_t first_expected_val, hbool_t buf_starts_in_checker)
{
    hbool_t good_data = TRUE;
    hbool_t in_checker;
    hbool_t start_in_checker[5];
    uint16_t expected_value;
    uint16_t * val_ptr;
    unsigned i, j, k, l, m;              /* to track position in n-cube */
    unsigned v, w, x, y, z;              /* to track position in checker */
    const unsigned test_max_rank = 5;    /* code changes needed if this is increased */

    HDassert(buf_ptr != NULL);
    HDassert(0 < rank);
    HDassert(rank <= test_max_rank);
    HDassert(edge_size >= 6);
    HDassert(0 < checker_edge_size);
    HDassert(checker_edge_size <= edge_size);
    HDassert(test_max_rank <= SS_DR_MAX_RANK);

    val_ptr = buf_ptr;
    expected_value = first_expected_val;

    i = 0;
    v = 0;
    start_in_checker[0] = buf_starts_in_checker;
    do {
        if(v >= checker_edge_size) {
            start_in_checker[0] = !start_in_checker[0];
            v = 0;
        } /* end if */

        j = 0;
        w = 0;
        start_in_checker[1] = start_in_checker[0];
        do {
            if(w >= checker_edge_size) {
                start_in_checker[1] = !start_in_checker[1];
                w = 0;
            } /* end if */

            k = 0;
            x = 0;
            start_in_checker[2] = start_in_checker[1];
            do {
                if(x >= checker_edge_size) {
                    start_in_checker[2] = !start_in_checker[2];
                    x = 0;
                } /* end if */

                l = 0;
                y = 0;
                start_in_checker[3] = start_in_checker[2];
                do { 
                    if(y >= checker_edge_size) {
                        start_in_checker[3] = ! start_in_checker[3];
                        y = 0;
                    } /* end if */

                    m = 0;
                    z = 0;
                    in_checker = start_in_checker[3];
                    do {
                        if(z >= checker_edge_size) {
                            in_checker = ! in_checker;
                            z = 0;
                        } /* end if */
         
                        if(in_checker) {
                            if(*val_ptr != expected_value)
                                good_data = FALSE;
                        } /* end if */
                        else {
                            if(*val_ptr != 0)
                                good_data = FALSE;
                        } /* end else */
 
                        val_ptr++;
                        expected_value++;
 
                        m++;
                        z++;
                    } while((rank >= (test_max_rank - 4)) && (m < edge_size));
                    l++;
                    y++;
                } while((rank >= (test_max_rank - 3)) && (l < edge_size));
                k++;
                x++;
            } while((rank >= (test_max_rank - 2)) && (k < edge_size));
            j++;
            w++;
        } while((rank >= (test_max_rank - 1)) && (j < edge_size));
        i++;
        v++;
    } while((rank >= test_max_rank) && (i < edge_size));

    return(good_data);
} /* test_select_hyper_checker_board_dr__verify_data() */


/****************************************************************
**
**  test_select_hyper_checker_board_dr__run_test(): Test H5S 
**      (dataspace) selection code with checker board source and 
**	target selections having different ranks but the same 
**	shape.  We have already tested H5S_shape_same in 
**	isolation, so now we try to do I/O.
**
****************************************************************/
static void
test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_buf,
    const uint16_t *zero_buf, unsigned edge_size, unsigned checker_edge_size,
    unsigned chunk_edge_size, unsigned small_rank, unsigned large_rank,
    hid_t dset_type, hid_t xfer_plist)
{
    hbool_t		data_ok;
    hbool_t		start_in_checker[5];
    hid_t               fapl;                   /* File access property list */
    hid_t		fid;			/* HDF5 File IDs		*/
    hid_t		full_small_cube_sid;    /* Dataspace for small cube w/all selection */
    hid_t		mem_small_cube_sid;
    hid_t		file_small_cube_sid;
    hid_t		full_large_cube_sid;    /* Dataspace for large cube w/all selection */
    hid_t		mem_large_cube_sid;
    hid_t		file_large_cube_sid;
    hid_t		small_cube_dcpl_id = H5P_DEFAULT;   /* DCPL for small cube dataset */
    hid_t		large_cube_dcpl_id = H5P_DEFAULT;   /* DCPL for large cube dataset */
    hid_t		small_cube_dataset;	/* Dataset ID			*/
    hid_t		large_cube_dataset;	/* Dataset ID			*/
    unsigned		small_rank_offset;      /* Rank offset of slice */
    const unsigned	test_max_rank = 5;  /* must update code if this changes */
    size_t              start_index;            /* Offset within buffer to begin inspecting */
    size_t              stop_index;             /* Offset within buffer to end inspecting */
    uint16_t		expected_value;
    uint16_t	      * small_cube_buf_1;
    uint16_t	      * large_cube_buf_1;
    uint16_t	      * ptr_1;
    size_t              small_cube_size;    /* Number of elements in small cube */
    size_t              large_cube_size;    /* Number of elements in large cube */
    hsize_t		dims[SS_DR_MAX_RANK];
    hsize_t		chunk_dims[SS_DR_MAX_RANK];
    hsize_t     	sel_start[SS_DR_MAX_RANK];
    unsigned            u, v, w, x;     /* Local index variables */
    size_t              s;              /* Local index variable */
    htri_t      	check;          /* Shape comparison return value */
    herr_t      	ret;            /* Generic return value */

    MESSAGE(7, ("\tn-cube slice through m-cube I/O test %d.\n", test_num));
    MESSAGE(7, ("\tranks = %d/%d, edge_size = %d, checker_edge_size = %d, chunk_edge_size = %d.\n", small_rank, large_rank, edge_size, checker_edge_size, chunk_edge_size));

    HDassert(edge_size >= 6);
    HDassert(checker_edge_size > 0);
    HDassert(checker_edge_size <= edge_size);
    HDassert(edge_size >= chunk_edge_size);
    HDassert((chunk_edge_size == 0) || (chunk_edge_size >= 3));
    HDassert(small_rank > 0);
    HDassert(small_rank < large_rank);
    HDassert(large_rank <= test_max_rank);
    HDassert(test_max_rank <= SS_DR_MAX_RANK);

    /* Compute cube sizes */
    small_cube_size = large_cube_size = (size_t)1;
    for(u = 0; u < large_rank; u++) {
        if(u < small_rank)
            small_cube_size *= (size_t)edge_size;

        large_cube_size *= (size_t)edge_size;
    } /* end for */
    HDassert(large_cube_size < (size_t)(UINT_MAX));

    small_rank_offset = test_max_rank - small_rank;
    HDassert(small_rank_offset >= 1);

    /* also, at present, we use 16 bit values in this test --
     * hence the following assertion.  Delete it if we convert
     * to 32 bit values.
     */
    HDassert(large_cube_size < (size_t)(64 * 1024));


    /* Allocate & initialize buffers */
    small_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), small_cube_size);
    CHECK(small_cube_buf_1, NULL, "HDcalloc");
    large_cube_buf_1 = (uint16_t *)HDcalloc(sizeof(uint16_t), large_cube_size);
    CHECK(large_cube_buf_1, NULL, "HDcalloc");


    /* Create a dataset transfer property list */
    fapl = H5Pcreate(H5P_FILE_ACCESS);
    CHECK(fapl, FAIL, "H5Pcreate");

    /* Use the 'core' VFD for this test */
    ret = H5Pset_fapl_core(fapl, (size_t)(1024 * 1024), FALSE);
    CHECK(ret, FAIL, "H5Pset_fapl_core");

    /* Create file */
    fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
    CHECK(fid, FAIL, "H5Fcreate");

    /* Close file access property list */
    ret = H5Pclose(fapl);
    CHECK(ret, FAIL, "H5Pclose");


    /* setup dims: */
    dims[0] = dims[1] = dims[2] = dims[3] = dims[4] = edge_size;


    /* Create small cube dataspaces */
    full_small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL);
    CHECK(full_small_cube_sid, FAIL, "H5Screate_simple");

    mem_small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL);
    CHECK(mem_small_cube_sid, FAIL, "H5Screate_simple");

    file_small_cube_sid = H5Screate_simple((int)small_rank, dims, NULL);
    CHECK(file_small_cube_sid, FAIL, "H5Screate_simple");


    /* Create large cube dataspace */
    full_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
    CHECK(full_large_cube_sid, FAIL, "H5Screate_simple");

    mem_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
    CHECK(mem_large_cube_sid, FAIL, "H5Screate_simple");

    file_large_cube_sid = H5Screate_simple((int)large_rank, dims, NULL);
    CHECK(file_large_cube_sid, FAIL, "H5Screate_simple");


    /* if chunk edge size is greater than zero, set up the small and
     * large data set creation property lists to specify chunked 
     * datasets.
     */
    if(chunk_edge_size > 0) {
        chunk_dims[0] = chunk_dims[1] = 
		chunk_dims[2] = chunk_dims[3] = chunk_dims[4] = chunk_edge_size;

        small_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
        CHECK(small_cube_dcpl_id, FAIL, "H5Pcreate");

        ret = H5Pset_layout(small_cube_dcpl_id, H5D_CHUNKED);
        CHECK(ret, FAIL, "H5Pset_layout");

        ret = H5Pset_chunk(small_cube_dcpl_id, (int)small_rank, chunk_dims);
        CHECK(ret, FAIL, "H5Pset_chunk");


        large_cube_dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
        CHECK(large_cube_dcpl_id, FAIL, "H5Pcreate");

        ret = H5Pset_layout(large_cube_dcpl_id, H5D_CHUNKED);
        CHECK(ret, FAIL, "H5Pset_layout");

        ret = H5Pset_chunk(large_cube_dcpl_id, (int)large_rank, chunk_dims);
        CHECK(ret, FAIL, "H5Pset_chunk");
    } /* end if */


    /* create the small cube dataset */
    small_cube_dataset = H5Dcreate2(fid, "small_cube_dataset", dset_type, 
            file_small_cube_sid, H5P_DEFAULT, small_cube_dcpl_id, H5P_DEFAULT);
    CHECK(small_cube_dataset, FAIL, "H5Dcreate2");

    /* Close non-default small dataset DCPL */
    if(small_cube_dcpl_id != H5P_DEFAULT) {
        ret = H5Pclose(small_cube_dcpl_id);
        CHECK(ret, FAIL, "H5Pclose");
    } /* end if */

    /* create the large cube dataset */
    large_cube_dataset = H5Dcreate2(fid, "large_cube_dataset", dset_type, 
            file_large_cube_sid, H5P_DEFAULT, large_cube_dcpl_id, H5P_DEFAULT);
    CHECK(large_cube_dataset, FAIL, "H5Dcreate2");

    /* Close non-default large dataset DCPL */
    if(large_cube_dcpl_id != H5P_DEFAULT) {
        ret = H5Pclose(large_cube_dcpl_id);
        CHECK(ret, FAIL, "H5Pclose");
    } /* end if */


    /* write initial data to the on disk datasets */
    ret = H5Dwrite(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid, 
            full_small_cube_sid, xfer_plist, cube_buf);
    CHECK(ret, FAIL, "H5Dwrite");

    ret = H5Dwrite(large_cube_dataset, H5T_NATIVE_UINT16, full_large_cube_sid, 
            full_large_cube_sid, xfer_plist, cube_buf);
    CHECK(ret, FAIL, "H5Dwrite");


    /* read initial small cube data from disk and verify that it is as expected. */
    ret = H5Dread(small_cube_dataset, H5T_NATIVE_UINT16, full_small_cube_sid, 
            full_small_cube_sid, xfer_plist, small_cube_buf_1);
    CHECK(ret, FAIL, "H5Dread");

    /* Check that the data is valid */
    verify_select_hyper_contig_dr__run_test(small_cube_buf_1, small_cube_size,
        edge_size, small_rank);

    /* read initial large cube data from disk and verify that it is as expected. */
    ret = H5Dread(large_cube_dataset, H5T_NATIVE_UINT16, full_large_cube_sid, 
            full_large_cube_sid, xfer_plist, large_cube_buf_1);
    CHECK(ret, FAIL, "H5Dread");

    /* Check that the data is valid */
    verify_select_hyper_contig_dr__run_test(large_cube_buf_1, large_cube_size,
        edge_size, large_rank);


    /* first, verify that we can read from disk correctly using selections
     * of different rank that H5S_select_shape_same() views as being of the
     * same shape.
     *
     * Start by reading small_rank-D slice from the on disk large cube, and 
     * verifying that the data read is correct.  Verify that H5S_select_shape_same() 
     * returns true on the memory and file selections.
     *
     * The first step is to set up the needed checker board selection in the 
     * in memory small small cube
     */

    sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0;

    test_select_hyper_checker_board_dr__select_checker_board(mem_small_cube_sid,
                                                             small_rank,
                                                             edge_size,
                                                             checker_edge_size,
                                                             small_rank,
                                                             sel_start);

    /* now read slices from the large, on-disk cube into the small cube. 
     * Note how we adjust sel_start only in the dimensions peculiar to the 
     * large cube.
     */

    start_in_checker[0] = TRUE;
    u = 0;
    do {
        if(small_rank_offset > 0)
            sel_start[0] = u;

        v = 0;
        do {
            if(small_rank_offset > 1)
                sel_start[1] = v;

            w = 0;
            do {
                if(small_rank_offset > 2)
                    sel_start[2] = w;

                x = 0;
                do {
                    if(small_rank_offset > 3)
                        sel_start[3] = x;

                    /* we know that small_rank >= 1 and that large_rank > small_rank
                     * by the assertions at the head of this function.  Thus no
                     * need for another inner loop.
                     */

                    HDassert((sel_start[0] == 0) || (0 < small_rank_offset));
                    HDassert((sel_start[1] == 0) || (1 < small_rank_offset));
                    HDassert((sel_start[2] == 0) || (2 < small_rank_offset));
                    HDassert((sel_start[3] == 0) || (3 < small_rank_offset));
                    HDassert((sel_start[4] == 0) || (4 < small_rank_offset));

                    test_select_hyper_checker_board_dr__select_checker_board
                    (
                      file_large_cube_sid,
                      large_rank,
                      edge_size,
                      checker_edge_size,
                      small_rank,
                      sel_start
                    );

                    /* verify that H5S_select_shape_same() reports the two 
                     * selections as having the same shape.
                     */
                    check = H5S_select_shape_same_test(mem_small_cube_sid, 
                                                       file_large_cube_sid);
                    VERIFY(check, TRUE, "H5S_select_shape_same_test");

                    /* zero the buffer that we will be using for reading */
                    HDmemset(small_cube_buf_1, 0, sizeof(*small_cube_buf_1) * small_cube_size);

                    /* Read selection from disk */
                    ret = H5Dread(large_cube_dataset,
                                  H5T_NATIVE_UINT16,
                                  mem_small_cube_sid,
                                  file_large_cube_sid,
                                  xfer_plist,
                                  small_cube_buf_1);
                    CHECK(ret, FAIL, "H5Dread");

                    expected_value = (uint16_t)
                                     ((u * edge_size * edge_size * edge_size * edge_size) +
                                      (v * edge_size * edge_size * edge_size) +
                                      (w * edge_size * edge_size) +
                                      (x * edge_size));

                    data_ok = test_select_hyper_checker_board_dr__verify_data
                              (
                                small_cube_buf_1,
                                small_rank,
                                edge_size,
                                checker_edge_size,
                                expected_value,
                                (hbool_t)TRUE
                              );
                    if(!data_ok)
                        TestErrPrintf("small cube read from largecube has bad data! Line=%d\n",__LINE__);

                    x++;
                } while((large_rank >= (test_max_rank - 3)) && 
                        (small_rank <= (test_max_rank - 4)) && (x < edge_size));
                w++;
            } while((large_rank >= (test_max_rank - 2)) && 
                    (small_rank <= (test_max_rank - 3)) && (w < edge_size));
            v++;
        } while((large_rank >= (test_max_rank - 1)) && 
                (small_rank <= (test_max_rank - 2)) && (v < edge_size));
        u++;
    } while((large_rank >= test_max_rank) && 
            (small_rank <= (test_max_rank - 1)) && (u < edge_size));
        

    /* similarly, read the on disk small cube into slices through the in memory
     * large cube, and verify that the correct data (and only the correct data)
     * is read.
     */

    /* select a checker board in the file small cube dataspace */
    sel_start[0] = sel_start[1] = sel_start[2] = sel_start[3] = sel_start[4] = 0;
    test_select_hyper_checker_board_dr__select_checker_board(file_small_cube_sid,
                                                             small_rank,
                                                             edge_size,
                                                             checker_edge_size,
                                                             small_rank,
                                                             sel_start);


    start_in_checker[0] = TRUE;
    u = 0;
    do {
        if(0 < small_rank_offset)
            sel_start[0] = u;

        v = 0;
        do {
            if(1 < small_rank_offset)
                sel_start[1] = v;

            w = 0;
            do {
                if(2 < small_rank_offset)
                    sel_start[2] = w;

                x = 0;
                do {
                    if(3 < small_rank_offset)
                        sel_start[3] = x;

                    /* we know that small_rank >= 1 and that large_rank > small_rank
                     * by the assertions at the head of this function.  Thus no
                     * need for another inner loop.
                     */

                    HDassert((sel_start[0] == 0) || (0 < small_rank_offset));
                    HDassert((sel_start[1] == 0) || (1 < small_rank_offset));
                    HDassert((sel_start[2] == 0) || (2 < small_rank_offset));
                    HDassert((sel_start[3] == 0) || (3 < small_rank_offset));
                    HDassert((sel_start[4] == 0) || (4 < small_rank_offset));

                    test_select_hyper_checker_board_dr__select_checker_board
                    (
                      mem_large_cube_sid,
                      large_rank,
                      edge_size,
                      checker_edge_size,
                      small_rank,
                      sel_start
                    );

                    /* verify that H5S_select_shape_same() reports the two 
                     * selections as having the same shape.
                     */
                    check = H5S_select_shape_same_test(file_small_cube_sid, 
                                                       mem_large_cube_sid);
                    VERIFY(check, TRUE, "H5S_select_shape_same_test");


                    /* zero out the in memory large cube */
                    HDmemset(large_cube_buf_1, 0, sizeof(*large_cube_buf_1) * large_cube_size);

                    /* Read selection from disk */
                    ret = H5Dread(small_cube_dataset,
                                  H5T_NATIVE_UINT16,
                                  mem_large_cube_sid,
                                  file_small_cube_sid,
                                  xfer_plist,
                                  large_cube_buf_1);
                    CHECK(ret, FAIL, "H5Dread");


                    /* verify that the expected data and only the 
                     * expected data was read.
                     */
                    data_ok = TRUE;
                    ptr_1 = large_cube_buf_1;
                    expected_value = 0;
                    start_index = (u * edge_size * edge_size * edge_size * edge_size) +
                                  (v * edge_size * edge_size * edge_size) +
                                  (w * edge_size * edge_size) +
                                  (x * edge_size);
                    stop_index = start_index + small_cube_size - 1;

                    HDassert( start_index < stop_index );
                    HDassert( stop_index <= large_cube_size );

                    /* verify that the large cube contains only zeros before the slice */
                    for(s = 0; s < start_index; s++) {
                        if(*ptr_1 != 0)
                            data_ok = FALSE;
                        ptr_1++;
                    } /* end for */
                    HDassert(s == start_index);

                    data_ok &= test_select_hyper_checker_board_dr__verify_data
                               (
                                 ptr_1,
                                 small_rank,
                                 edge_size,
                                 checker_edge_size,
                                 (uint16_t)0,
                                 (hbool_t)TRUE
                              );

                    ptr_1 += small_cube_size;
                    s += small_cube_size;

                    HDassert(s == stop_index + 1);

                    /* verify that the large cube contains only zeros after the slice */
                    for(s = stop_index + 1; s < large_cube_size; s++) {
                        if(*ptr_1 != 0)
                            data_ok = FALSE;
                        ptr_1++;
                    } /* end for */
                    if(!data_ok)
                        TestErrPrintf("large cube read from small cube has bad data! Line=%d\n",__LINE__);

                    x++;