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
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#define H5P_PACKAGE /*suppress error about including H5Ppkg */
/* Private header files */
#include "H5private.h" /* Generic Functions */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Ppkg.h" /* Property lists */
#include "H5Zprivate.h" /* Data filters */
/* Local datatypes */
/* Static function prototypes */
static herr_t H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout);
/*-------------------------------------------------------------------------
* Function: H5P_set_layout
*
* Purpose: Sets the layout of raw data in the file.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Tuesday, November 23, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout)
{
unsigned alloc_time_state; /* State of allocation time property */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_NOAPI_NOINIT(H5P_set_layout);
/* Get the allocation time state */
if(H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time");
/* If we still have the "default" allocation time, change it according to the new layout */
if(alloc_time_state) {
H5D_alloc_time_t alloc_time; /* Space allocation time */
/* Set the default based on layout */
switch(layout) {
case H5D_COMPACT:
alloc_time=H5D_ALLOC_TIME_EARLY;
break;
case H5D_CONTIGUOUS:
alloc_time=H5D_ALLOC_TIME_LATE;
break;
case H5D_CHUNKED:
alloc_time=H5D_ALLOC_TIME_INCR;
break;
default:
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layou t type")
} /* end switch */
/* Set new allocation time */
if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &alloc_time) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocat ion time");
} /* end if */
/* Set layout value */
if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout");
done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5P_set_layout() */
/*-------------------------------------------------------------------------
* Function: H5Pset_layout
*
* Purpose: Sets the layout of raw data in the file.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and set property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_layout(hid_t plist_id, H5D_layout_t layout)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_layout, FAIL);
H5TRACE2("e","iDl",plist_id,layout);
/* Check arguments */
if (layout < 0 || layout >= H5D_NLAYOUTS)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "raw data layout method is not valid");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Set value */
if(H5P_set_layout (plist, layout) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_layout
*
* Purpose: Retrieves layout type of a dataset creation property list.
*
* Return: Success: The layout type
*
* Failure: H5D_LAYOUT_ERROR (negative)
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and get property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
H5D_layout_t
H5Pget_layout(hid_t plist_id)
{
H5P_genplist_t *plist; /* Property list pointer */
H5D_layout_t ret_value=H5D_LAYOUT_ERROR;
FUNC_ENTER_API(H5Pget_layout, H5D_LAYOUT_ERROR);
H5TRACE1("Dl","i",plist_id);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5D_LAYOUT_ERROR, "can't find object for ID");
/* Get value */
if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &ret_value) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5D_LAYOUT_ERROR, "can't get layout");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_chunk
*
* Purpose: Sets the number of dimensions and the size of each chunk to
* the values specified. The dimensionality of the chunk should
* match the dimensionality of the data space.
*
* As a side effect, the layout method is changed to
* H5D_CHUNKED.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and set property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/])
{
int i;
size_t real_dims[H5O_LAYOUT_NDIMS]; /* Full-sized array to hold chunk dims */
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_chunk, FAIL);
H5TRACE3("e","iIs*[a1]h",plist_id,ndims,dim);
/* Check arguments */
if (ndims <= 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality must be positive");
if (ndims > H5S_MAX_RANK)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality is too large");
if (!dim)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no chunk dimensions specified");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Initialize chunk dims to 0s */
HDmemset(real_dims,0,sizeof(real_dims));
for (i=0; i<ndims; i++) {
if (dim[i] == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be positive");
if (dim[i] != (dim[i]&0xffffffff))
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be less than 2^32");
real_dims[i]=(size_t)dim[i]; /* Store user's chunk dimensions */
} /* end for */
if(H5P_set_layout (plist, H5D_CHUNKED) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout");
if(H5P_set(plist, H5D_CRT_CHUNK_DIM_NAME, &ndims) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set chunk dimensionanlity");
if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, real_dims) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set chunk size");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_chunk
*
* Purpose: Retrieves the chunk size of chunked layout. The chunk
* dimensionality is returned and the chunk size in each
* dimension is returned through the DIM argument. At most
* MAX_NDIMS elements of DIM will be initialized.
*
* Return: Success: Positive Chunk dimensionality.
*
* Failure: Negative
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and set property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
int
H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/)
{
int ndims;
H5D_layout_t layout;
H5P_genplist_t *plist; /* Property list pointer */
int ret_value;
FUNC_ENTER_API(H5Pget_chunk, FAIL);
H5TRACE3("Is","iIsx",plist_id,max_ndims,dim);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout");
if(H5D_CHUNKED != layout)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout");
if(H5P_get(plist, H5D_CRT_CHUNK_DIM_NAME, &ndims) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get chunk dimensionality");
if(dim) {
int i;
size_t chunk_size[H5O_LAYOUT_NDIMS];
if(H5P_get(plist, H5D_CRT_CHUNK_SIZE_NAME, chunk_size) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get chunk size");
/* Get the dimension sizes */
for (i=0; i<ndims && i<max_ndims; i++)
dim[i] = chunk_size[i];
} /* end if */
/* Set the return value */
ret_value=ndims;
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_external
*
* Purpose: Adds an external file to the list of external files. PLIST_ID
* should be an object ID for a dataset creation property list.
* NAME is the name of an external file, OFFSET is the location
* where the data starts in that file, and SIZE is the number of
* bytes reserved in the file for the data.
*
* If a dataset is split across multiple files then the files
* should be defined in order. The total size of the dataset is
* the sum of the SIZE arguments for all the external files. If
* the total size is larger than the size of a dataset then the
* dataset can be extended (provided the data space also allows
* the extending).
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Tuesday, March 3, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and set property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size)
{
size_t idx;
hsize_t total, tmp;
H5O_efl_t efl;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pset_external, FAIL);
H5TRACE4("e","isoh",plist_id,name,offset,size);
/* Check arguments */
if (!name || !*name)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given");
if (offset<0)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "negative external file offset");
if (size<=0)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "zero size");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list");
if(efl.nused > 0 && H5O_EFL_UNLIMITED==efl.slot[efl.nused-1].size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "previous file size is unlimited");
if (H5O_EFL_UNLIMITED!=size) {
for (idx=0, total=size; idx<efl.nused; idx++, total=tmp) {
tmp = total + efl.slot[idx].size;
if (tmp <= total)
HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "total external data size overflowed");
} /* end for */
} /* end if */
/* Add to the list */
if (efl.nused >= efl.nalloc) {
size_t na = efl.nalloc + H5O_EFL_ALLOC;
H5O_efl_entry_t *x = H5MM_realloc (efl.slot, na*sizeof(H5O_efl_entry_t));
if (!x)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
efl.nalloc = na;
efl.slot = x;
}
idx = efl.nused;
efl.slot[idx].name_offset = 0; /*not entered into heap yet*/
efl.slot[idx].name = H5MM_xstrdup (name);
efl.slot[idx].offset = offset;
efl.slot[idx].size = size;
efl.nused++;
if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set external file list");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_external_count
*
* Purpose: Returns the number of external files for this dataset.
*
* Return: Success: Number of external files
*
* Failure: Negative
*
* Programmer: Robb Matzke
* Tuesday, March 3, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and set property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
int
H5Pget_external_count(hid_t plist_id)
{
H5O_efl_t efl;
H5P_genplist_t *plist; /* Property list pointer */
int ret_value; /* return value */
FUNC_ENTER_API(H5Pget_external_count, FAIL);
H5TRACE1("Is","i",plist_id);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get value */
if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list");
/* Set return value */
ret_value=(int)efl.nused;
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_external
*
* Purpose: Returns information about an external file. External files
* are numbered from zero to N-1 where N is the value returned
* by H5Pget_external_count(). At most NAME_SIZE characters are
* copied into the NAME array. If the external file name is
* longer than NAME_SIZE with the null terminator, then the
* return value is not null terminated (similar to strncpy()).
*
* If NAME_SIZE is zero or NAME is the null pointer then the
* external file name is not returned. If OFFSET or SIZE are
* null pointers then the corresponding information is not
* returned.
*
* See Also: H5Pset_external()
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Tuesday, March 3, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and get property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name/*out*/,
off_t *offset/*out*/, hsize_t *size/*out*/)
{
H5O_efl_t efl;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pget_external, FAIL);
H5TRACE6("e","iIuzxxx",plist_id,idx,name_size,name,offset,size);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get value */
if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list");
if (idx>=efl.nused)
HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, "external file index is out of range");
/* Return values */
if (name_size>0 && name)
HDstrncpy (name, efl.slot[idx].name, name_size);
if (offset)
*offset = efl.slot[idx].offset;
if (size)
*size = efl.slot[idx].size;
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pmodify_filter
*
* Purpose: Modifies the specified FILTER in the
* transient or permanent output filter pipeline
* depending on whether PLIST is a dataset creation or dataset
* transfer property list. The FLAGS argument specifies certain
* general properties of the filter and is documented below.
* The CD_VALUES is an array of CD_NELMTS integers which are
* auxiliary data for the filter. The integer vlues will be
* stored in the dataset object header as part of the filter
* information.
*
* The FLAGS argument is a bit vector of the following fields:
*
* H5Z_FLAG_OPTIONAL(0x0001)
* If this bit is set then the filter is optional. If the
* filter fails during an H5Dwrite() operation then the filter
* is just excluded from the pipeline for the chunk for which it
* failed; the filter will not participate in the pipeline
* during an H5Dread() of the chunk. If this bit is clear and
* the filter fails then the entire I/O operation fails.
* If this bit is set but encoding is disabled for a filter,
* attempting to write will generate an error.
*
* Note: This function currently supports only the permanent filter
* pipeline. That is, PLIST_ID must be a dataset creation
* property list.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Friday, April 5, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags,
size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
{
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pmodify_filter, FAIL);
H5TRACE5("e","iZfIuz*[a3]Iu",plist_id,filter,flags,cd_nelmts,cd_values);
/* Check args */
if (filter<0 || filter>H5Z_FILTER_MAX)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier");
if (flags & ~((unsigned)H5Z_FLAG_DEFMASK))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags");
if (cd_nelmts>0 && !cd_values)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no client data values supplied");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get the pipeline property to append to */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
/* Modify the filter parameters of the I/O pipeline */
if(H5Z_modify(&pline, filter, flags, cd_nelmts, cd_values) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline");
/* Put the I/O pipeline information back into the property list */
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pmodify_filter() */
/*-------------------------------------------------------------------------
* Function: H5Pset_filter
*
* Purpose: Adds the specified FILTER and corresponding properties to the
* end of the transient or permanent output filter pipeline
* depending on whether PLIST is a dataset creation or dataset
* transfer property list. The FLAGS argument specifies certain
* general properties of the filter and is documented below.
* The CD_VALUES is an array of CD_NELMTS integers which are
* auxiliary data for the filter. The integer vlues will be
* stored in the dataset object header as part of the filter
* information.
*
* The FLAGS argument is a bit vector of the following fields:
*
* H5Z_FLAG_OPTIONAL(0x0001)
* If this bit is set then the filter is optional. If the
* filter fails during an H5Dwrite() operation then the filter
* is just excluded from the pipeline for the chunk for which it
* failed; the filter will not participate in the pipeline
* during an H5Dread() of the chunk. If this bit is clear and
* the filter fails then the entire I/O operation fails.
* If this bit is set but encoding is disabled for a filter,
* attempting to write will generate an error.
*
* Note: This function currently supports only the permanent filter
* pipeline. That is, PLIST_ID must be a dataset creation
* property list.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Wednesday, April 15, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and set property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags,
size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
{
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_filter, FAIL);
H5TRACE5("e","iZfIuz*[a3]Iu",plist_id,filter,flags,cd_nelmts,cd_values);
/* Check args */
if (filter<0 || filter>H5Z_FILTER_MAX)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier");
if (flags & ~((unsigned)H5Z_FLAG_DEFMASK))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags");
if (cd_nelmts>0 && !cd_values)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no client data values supplied");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get the pipeline property to append to */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
/* Add the filter to the I/O pipeline */
if(H5Z_append(&pline, filter, flags, cd_nelmts, cd_values) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline");
/* Put the I/O pipeline information back into the property list */
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_nfilters
*
* Purpose: Returns the number of filters in the permanent or transient
* pipeline depending on whether PLIST_ID is a dataset creation
* or dataset transfer property list. In each pipeline the
* filters are numbered from zero through N-1 where N is the
* value returned by this function. During output to the file
* the filters of a pipeline are applied in increasing order
* (the inverse is true for input).
*
* Note: Only permanent filters are supported at this time.
*
* Return: Success: Number of filters or zero if there are none.
*
* Failure: Negative
*
* Programmer: Robb Matzke
* Tuesday, August 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
H5Pget_nfilters(hid_t plist_id)
{
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
int ret_value; /* return value */
FUNC_ENTER_API(H5Pget_nfilters, FAIL);
H5TRACE1("Is","i",plist_id);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get value */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
/* Set return value */
ret_value=(int)(pline.nused);
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_filter
*
* Purpose: This is the query counterpart of H5Pset_filter() and returns
* information about a particular filter number in a permanent
* or transient pipeline depending on whether PLIST_ID is a
* dataset creation or transfer property list. On input,
* CD_NELMTS indicates the number of entries in the CD_VALUES
* array allocated by the caller while on exit it contains the
* number of values defined by the filter. FILTER_CONFIG is a bit
* field contaning encode/decode flags from H5Zpublic.h. The IDX
* should be a value between zero and N-1 as described for
* H5Pget_nfilters() and the function will return failure if the
* filter number is out of range.
*
* Return: Success: Filter identification number.
*
* Failure: H5Z_FILTER_ERROR (Negative)
*
* Programmer: Robb Matzke
* Wednesday, April 15, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check paramter and set property for
* generic property list.
*
* James Laird and Nat Furrer
* Tuesday, June 15, 2004
* Function now retrieves filter_config flags.
*
*-------------------------------------------------------------------------
*/
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Z_filter_t
H5Pget_filter(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/,
size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
size_t namelen, char name[]/*out*/)
#else /* H5_WANT_H5_V1_6_COMPAT */
H5Z_filter_t
H5Pget_filter(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/,
size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
size_t namelen, char name[]/*out*/,
unsigned int *filter_config /*out*/)
#endif /* H5_WANT_H5_V1_6_COMPAT */
{
H5O_pline_t pline; /* Filter pipeline */
H5Z_filter_info_t *filter; /* Pointer to filter information */
H5P_genplist_t *plist; /* Property list pointer */
size_t i; /* Local index variable */
H5Z_filter_t ret_value; /* return value */
FUNC_ENTER_API(H5Pget_filter, H5Z_FILTER_ERROR);
#ifdef H5_WANT_H5_V1_6_COMPAT
H5TRACE7("Zf","iIux*zxzx",plist_id,idx,flags,cd_nelmts,cd_values,namelen,
name);
#else /* H5_WANT_H5_V1_6_COMPAT */
H5TRACE7("Zf","iIux*zxzx",plist_id,idx,flags,cd_nelmts,cd_values,namelen,
name);
#endif /* H5_WANT_H5_V1_6_COMPAT */
/* Check args */
if (cd_nelmts || cd_values)
{
if (cd_nelmts && *cd_nelmts>256)
/*
* It's likely that users forget to initialize this on input, so
* we'll check that it has a reasonable value. The actual number
* is unimportant because the H5O layer will detect when a message
* is too large.
*/
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "probable uninitialized *cd_nelmts argument");
if (cd_nelmts && *cd_nelmts>0 && !cd_values)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "client data values not supplied");
/*
* If cd_nelmts is null but cd_values is non-null then just ignore
* cd_values
*/
if (!cd_nelmts)
cd_values = NULL;
}
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_FILTER_ERROR, "can't find object for ID");
/* Get pipeline info */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline");
/* Check more args */
if (idx>=pline.nused)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "filter number is invalid");
/* Set pointer to particular filter to query */
filter=&pline.filter[idx];
if (flags)
*flags = filter->flags;
if (cd_values) {
for (i=0; i<filter->cd_nelmts && i<*cd_nelmts; i++)
cd_values[i] = filter->cd_values[i];
}
if (cd_nelmts)
*cd_nelmts = filter->cd_nelmts;
if (namelen>0 && name) {
const char *s = filter->name;
if (!s) {
H5Z_class_t *cls = H5Z_find(filter->id);
if (cls)
s = cls->name;
}
if (s)
HDstrncpy(name, s, namelen);
else
name[0] = '\0';
}
#ifndef H5_WANT_H5_V1_6_COMPAT
/* Get filter configuration, assume filter ID has already been checked */
if(filter_config != NULL)
H5Zget_filter_info(filter->id, filter_config);
#endif
/* Set return value */
ret_value=filter->id;
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_filter_by_id
*
* Purpose: This is an additional query counterpart of H5Pset_filter() and
* returns information about a particular filter in a permanent
* or transient pipeline depending on whether PLIST_ID is a
* dataset creation or transfer property list. On input,
* CD_NELMTS indicates the number of entries in the CD_VALUES
* array allocated by the caller while on exit it contains the
* number of values defined by the filter. FILTER_CONFIG is a bit
* field contaning encode/decode flags from H5Zpublic.h. The ID
* should be the filter ID to retrieve the parameters for. If the
* filter is not set for the property list, an error will be returned.
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Friday, April 5, 2003
*
* Modifications:
* James Laird and Nat Furrer
* Tuesday, June 15, 2004
* Function now retrieves filter_config flags.
*
*-------------------------------------------------------------------------
*/
#ifdef H5_WANT_H5_V1_6_COMPAT
herr_t
H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/,
size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
size_t namelen, char name[]/*out*/)
#else
herr_t
H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/,
size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/,
size_t namelen, char name[]/*out*/, unsigned int *filter_config)
#endif /* H5_WANT_H5_V1_6_COMPAT */
{
H5O_pline_t pline; /* Filter pipeline */
H5Z_filter_info_t *filter; /* Pointer to filter information */
H5P_genplist_t *plist; /* Property list pointer */
size_t i; /* Local index variable */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_filter_by_id, FAIL);
#ifdef H5_WANT_H5_V1_6_COMPAT
H5TRACE7("e","iZfx*zxzx",plist_id,id,flags,cd_nelmts,cd_values,namelen,
name);
#else
H5TRACE8("e","iZfx*zxzx*Iu",plist_id,id,flags,cd_nelmts,cd_values,namelen,
name,filter_config);
#endif /* H5_WANT_H5_V1_6_COMPAT */
/* Check args */
if (cd_nelmts || cd_values)
{
if (cd_nelmts && *cd_nelmts>256)
/*
* It's likely that users forget to initialize this on input, so
* we'll check that it has a reasonable value. The actual number
* is unimportant because the H5O layer will detect when a message
* is too large.
*/
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "probable uninitialized *cd_nelmts argument");
if (cd_nelmts && *cd_nelmts>0 && !cd_values)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "client data values not supplied");
/*
* If cd_nelmts is null but cd_values is non-null then just ignore
* cd_values
*/
if (!cd_nelmts)
cd_values = NULL;
}
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get pipeline info */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
/* Get pointer to filter in pipeline */
if ((filter=H5Z_filter_info(&pline,id))==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "filter ID is invalid");
/* Copy filter information into user's parameters */
if (flags)
*flags = filter->flags;
if (cd_values) {
for (i=0; i<filter->cd_nelmts && i<*cd_nelmts; i++)
cd_values[i] = filter->cd_values[i];
}
if (cd_nelmts)
*cd_nelmts = filter->cd_nelmts;
if (namelen>0 && name) {
const char *s = filter->name;
if (!s) {
H5Z_class_t *cls = H5Z_find(filter->id);
if (cls)
s = cls->name;
}
if (s)
HDstrncpy(name, s, namelen);
else
name[0] = '\0';
}
#ifndef H5_WANT_H5_V1_6_COMPAT
/* Get filter configuration, assume filter ID has already been checked */
if(filter_config != NULL)
H5Zget_filter_info(id, filter_config);
#endif
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pget_filter_by_id() */
/*-------------------------------------------------------------------------
* Function: H5Pall_filters_avail
*
* Purpose: This is a query routine to verify that all the filters set
* in the dataset creation property list are available currently.
*
* Return: Success: TRUE if all filters available, FALSE if one or
* more filters not currently available.
* Failure: FAIL on error
*
* Programmer: Quincey Koziol
* Tuesday, April 8, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
htri_t
H5Pall_filters_avail(hid_t plist_id)
{
H5O_pline_t pline; /* Filter pipeline */
H5P_genplist_t *plist; /* Property list pointer */
hbool_t ret_value=TRUE; /* return value */
FUNC_ENTER_API(H5Pall_filters_avail, UFAIL);
H5TRACE1("t","i",plist_id);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, UFAIL, "can't find object for ID");
/* Get pipeline info */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get pipeline");
/* Set return value */
if((ret_value=H5Z_all_filters_avail(&pline))==UFAIL)
HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, UFAIL, "can't check pipeline information");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pall_filters_avail() */
/*-------------------------------------------------------------------------
* Function: H5Pset_deflate
*
* Purpose: Sets the compression method for a permanent or transient
* filter pipeline (depending on whether PLIST_ID is a dataset
* creation or transfer property list) to H5Z_FILTER_DEFLATE
* and the compression level to LEVEL which should be a value
* between zero and nine, inclusive. Lower compression levels
* are faster but result in less compression. This is the same
* algorithm as used by the GNU gzip program.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Wednesday, April 15, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and set property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_deflate(hid_t plist_id, unsigned level)
{
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_deflate, FAIL);
H5TRACE2("e","iIu",plist_id,level);
/* Check arguments */
if (level>9)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid deflate level");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Add the filter */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
if(H5Z_append(&pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 1, &level)<0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add deflate filter to pipeline");
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pset_deflate() */
/*-------------------------------------------------------------------------
* Function: H5Pset_szip
*
* Purpose: Sets the compression method for a permanent or transient
* filter pipeline (depending on whether PLIST_ID is a dataset
* creation or transfer property list) to H5Z_FILTER_SZIP
* Szip is a special compression package that is said to be good
* for scientific data.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Kent Yang
* Tuesday, April 1, 2003
*
* Modifications:
*
* Nat Furrer and James Laird
* June 30, 2004
* Now ensures that SZIP encoding is enabled
* SZIP defaults to k13 compression
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block)
{
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
unsigned cd_values[2]; /* Filter parameters */
unsigned int config_flags;
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_szip, FAIL);
H5TRACE3("e","iIuIu",plist_id,options_mask,pixels_per_block);
if(H5Zget_filter_info(H5Z_FILTER_SZIP, &config_flags) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't get filter info")
if(! (config_flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED))
HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled.");
/* Check arguments */
if ((pixels_per_block%2)==1)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is not even");
if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is too large");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Always set K13 compression (and un-set CHIP compression) */
options_mask &= (~H5_SZIP_CHIP_OPTION_MASK);
options_mask |= H5_SZIP_ALLOW_K13_OPTION_MASK;
/* Always set "raw" (no szip header) flag for data */
options_mask |= H5_SZIP_RAW_OPTION_MASK;
/* Mask off the LSB and MSB options, if they were given */
/* (The HDF5 library sets them internally, as needed) */
options_mask &= ~(H5_SZIP_LSB_OPTION_MASK|H5_SZIP_MSB_OPTION_MASK);
/* Set the parameters for the filter */
cd_values[0]=options_mask;
cd_values[1]=pixels_per_block;
/* Add the filter */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
if(H5Z_append(&pline, H5Z_FILTER_SZIP, H5Z_FLAG_OPTIONAL, 2, cd_values)<0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add szip filter to pipeline");
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pset_szip() */
/*-------------------------------------------------------------------------
* Function: H5Pset_shuffle
*
* Purpose: Sets the shuffling method for a permanent
* filter to H5Z_FILTER_SHUFFLE
* and bytes of the datatype of the array to be shuffled
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Kent Yang
* Wednesday, November 13, 2002
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_shuffle(hid_t plist_id)
{
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_shuffle, FAIL);
H5TRACE1("e","i",plist_id);
/* Check arguments */
if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list");
/* Get the plist structure */
if(NULL == (plist = H5I_object(plist_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Add the filter */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
if(H5Z_append(&pline, H5Z_FILTER_SHUFFLE, H5Z_FLAG_OPTIONAL, 0, NULL)<0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to shuffle the data");
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pset_shuffle() */
/*-------------------------------------------------------------------------
* Function: H5Pset_nbit
*
* Purpose: Sets nbit filter for a dataset creation property list
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Xiaowen Wu
* Wednesday, December 22, 2004
*
* Modifications:
*
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_nbit(hid_t plist_id)
{
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_nbit, FAIL);
H5TRACE1("e","i",plist_id);
/* Check arguments */
if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list");
/* Get the plist structure */
if(NULL == (plist = H5I_object(plist_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Add the nbit filter */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
if(H5Z_append(&pline, H5Z_FILTER_NBIT, H5Z_FLAG_OPTIONAL, 0, NULL)<0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add nbit filter to pipeline");
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pset_nbit() */
/*-------------------------------------------------------------------------
* Function: H5Pset_scaleoffset
*
* Purpose: Sets scaleoffset filter for a dataset creation property list
* and user-supplied parameters
*
* Parameters: scale_factor:
for integer datatype,
this parameter will be
minimum-bits, if this value is set to 0,
scaleoffset filter will calculate the minimum-bits.
For floating-point datatype,
For variable-minimum-bits method, this will be
the decimal precision of the filter,
For fixed-minimum-bits method, this will be
the minimum-bit of the filter.
scale_type: 0 for floating-point variable-minimum-bits,
1 for floating-point fixed-minimum-bits,
other values, for integer datatype
* Return: Non-negative on success/Negative on failure
*
* Programmer: Xiaowen Wu
* Thursday, April 14, 2005
*
* Modifications:
*
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_factor)
{
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
unsigned cd_values[2]; /* Filter parameters */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_scaleoffset, FAIL);
H5TRACE3("e","iZaIs",plist_id,scale_type,scale_factor);
/* Check arguments */
if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list");
if(scale_type!=H5Z_SO_FLOAT_DSCALE && scale_type!=H5Z_SO_FLOAT_ESCALE && scale_type!=H5Z_SO_INT)
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type");
/* Get the plist structure */
if(NULL == (plist = H5I_object(plist_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Set parameters for the filter
* scale_type = 0: floating-point type, filter uses variable-minimum-bits method,
* scale_factor is decimal scale factor
* scale_type = 1: floating-point type, filter uses fixed-minimum-bits method,
* scale_factor is the fixed minimum number of bits
* scale type = other: integer type, scale_factor is minimum number of bits
* if scale_factor = 0, then filter calculates minimum number of bits
*/
cd_values[0] = scale_type;
cd_values[1] = scale_factor;
/* Add the scaleoffset filter */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
if(H5Z_append(&pline, H5Z_FILTER_SCALEOFFSET, H5Z_FLAG_OPTIONAL, 2, cd_values)<0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add scaleoffset filter to pipeline");
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pset_scaleoffset() */
/*-------------------------------------------------------------------------
* Function: H5Pset_fletcher32
*
* Purpose: Sets Fletcher32 checksum of EDC for a dataset creation
* property list.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Dec 19, 2002
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_fletcher32(hid_t plist_id)
{
H5O_pline_t pline;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_fletcher32, FAIL);
H5TRACE1("e","i",plist_id);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Add the Fletcher32 checksum as a filter */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline");
if(H5Z_append(&pline, H5Z_FILTER_FLETCHER32, H5Z_FLAG_MANDATORY, 0, NULL)<0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add deflate filter to pipeline");
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pset_fletcher32() */
/*-------------------------------------------------------------------------
* Function: H5Pset_fill_value
*
* Purpose: Set the fill value for a dataset creation property list. The
* VALUE is interpretted as being of type TYPE, which need not
* be the same type as the dataset but the library must be able
* to convert VALUE to the dataset type when the dataset is
* created. If VALUE is NULL, it will be interpreted as
* undefining fill value.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Thursday, October 1, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and set property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value)
{
H5O_fill_t fill;
H5T_t *type = NULL;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_fill_value, FAIL);
H5TRACE3("e","iix",plist_id,type_id,value);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get the "basic" fill value structure */
if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value");
/* Reset the fill structure */
if(H5O_reset(H5O_FILL_ID, &fill)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset fill value");
if(value) {
if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
/* Set the fill value */
if (NULL==(fill.type=H5T_copy(type, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data type");
fill.size = H5T_get_size(type);
if (NULL==(fill.buf=H5MM_malloc(fill.size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for fill value");
HDmemcpy(fill.buf, value, fill.size);
} else {
fill.type = fill.buf = NULL;
fill.size = (size_t)-1;
}
if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set fill value");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_fill_value
*
* Purpose: Queries the fill value property of a dataset creation
* property list. The fill value is returned through the VALUE
* pointer and the memory is allocated by the caller. The fill
* value will be converted from its current data type to the
* specified TYPE.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Thursday, October 1, 1998
*
* Modifications:
*
* Raymond Lu
* Tuesday, October 2, 2001
* Changed the way to check parameter and get property for
* generic property list.
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/)
{
H5O_fill_t fill;
H5T_t *type = NULL; /*data type */
H5T_path_t *tpath = NULL; /*type conversion info */
void *buf = NULL; /*conversion buffer */
void *bkg = NULL; /*conversion buffer */
hid_t src_id = -1; /*source data type id */
herr_t ret_value=SUCCEED; /* Return value */
H5P_genplist_t *plist; /* Property list pointer */
FUNC_ENTER_API(H5Pget_fill_value, FAIL);
H5TRACE3("e","iix",plist_id,type_id,value);
/* Check arguments */
if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
if (!value)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,"no fill value output buffer");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/*
* If no fill value is defined then return an error. We can't even
* return zero because we don't know the data type of the dataset and
* data type conversion might not have resulted in zero. If fill value
* is undefined, also return error.
*/
if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value");
if(fill.size == (size_t)-1)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "fill value is undefined");
if(fill.size == 0) {
HDmemset(value, 0, H5T_get_size(type));
HGOTO_DONE(SUCCEED);
}
/*
* Can we convert between the source and destination data types?
*/
if(NULL==(tpath=H5T_path_find(fill.type, type, NULL, NULL, H5AC_dxpl_id, FALSE)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst data types");
src_id = H5I_register(H5I_DATATYPE, H5T_copy (fill.type, H5T_COPY_TRANSIENT));
if (src_id<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register data type");
/*
* Data type conversions are always done in place, so we need a buffer
* other than the fill value buffer that is large enough for both source
* and destination. The app-supplied buffer might do okay.
*/
if (H5T_get_size(type)>=H5T_get_size(fill.type)) {
buf = value;
if (H5T_path_bkg(tpath) && NULL==(bkg=H5MM_malloc(H5T_get_size(type))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
} else {
if (NULL==(buf=H5MM_malloc(H5T_get_size(fill.type))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
if (H5T_path_bkg(tpath))
bkg = value;
}
HDmemcpy(buf, fill.buf, H5T_get_size(fill.type));
/* Do the conversion */
if (H5T_convert(tpath, src_id, type_id, 1, 0, 0, buf, bkg, H5AC_dxpl_id)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed");
if (buf!=value)
HDmemcpy(value, buf, H5T_get_size(type));
done:
if (buf!=value)
H5MM_xfree(buf);
if (bkg!=value)
H5MM_xfree(bkg);
if (src_id>=0)
H5I_dec_ref(src_id);
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5P_is_fill_value_defined
*
* Purpose: Check if fill value is defined. Internal version of function
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Wednesday, January 16, 2002
*
* Modifications:
* Extracted from H5P_fill_value_defined, QAK, Dec. 13, 2002
*
*-------------------------------------------------------------------------
*/
herr_t
H5P_is_fill_value_defined(const struct H5O_fill_t *fill, H5D_fill_value_t *status)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5P_is_fill_value_defined, FAIL);
assert(fill);
assert(status);
/* Check if the fill value was never set */
if(fill->size == (size_t)-1 && !fill->buf)
*status = H5D_FILL_VALUE_UNDEFINED;
/* Check if the fill value was set to the default fill value by the library */
else if(fill->size == 0 && !fill->buf)
*status = H5D_FILL_VALUE_DEFAULT;
/* Check if the fill value was set by the application */
else if(fill->size > 0 && fill->buf)
*status = H5D_FILL_VALUE_USER_DEFINED;
else {
*status = H5D_FILL_VALUE_ERROR;
HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "invalid combination of fill-value info");
}
done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5P_is_fill_value_defined() */
/*-------------------------------------------------------------------------
* Function: H5Pfill_value_defined
*
* Purpose: Check if fill value is defined.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Wednesday, January 16, 2002
*
* Modifications:
*
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status)
{
H5P_genplist_t *plist;
H5O_fill_t fill;
herr_t ret_value = SUCCEED;
FUNC_ENTER_API(H5Pfill_value_defined, FAIL);
H5TRACE2("e","i*DF",plist_id,status);
assert(status);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get the fill value struct */
if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value");
/* Get the fill-value status */
if(H5P_is_fill_value_defined(&fill, status) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't check fill value status");
done:
FUNC_LEAVE_API(ret_value);
} /* end H5Pfill_value_defined() */
/*-------------------------------------------------------------------------
* Function: H5Pset_alloc_time
*
* Purpose: Set space allocation time for dataset during creation.
* Valid values are H5D_ALLOC_TIME_DEFAULT, H5D_ALLOC_TIME_EARLY,
* H5D_ALLOC_TIME_LATE, H5D_ALLOC_TIME_INCR
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Wednesday, January 16, 2002
*
* Modifications:
*
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time)
{
H5P_genplist_t *plist; /* Property list pointer */
unsigned alloc_time_state; /* State of allocation time property */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_alloc_time, FAIL);
H5TRACE2("e","iDa",plist_id,alloc_time);
/* Get the property list structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Check for resetting to default for layout type */
if(alloc_time==H5D_ALLOC_TIME_DEFAULT) {
H5D_layout_t layout; /* Type of storage layout */
/* Retrieve the storage layout */
if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout");
/* Set the default based on layout */
switch(layout) {
case H5D_COMPACT:
alloc_time=H5D_ALLOC_TIME_EARLY;
break;
case H5D_CONTIGUOUS:
alloc_time=H5D_ALLOC_TIME_LATE;
break;
case H5D_CHUNKED:
alloc_time=H5D_ALLOC_TIME_INCR;
break;
default:
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type")
} /* end switch */
/* Reset the "state" of the allocation time property back to the "default" */
alloc_time_state=1;
} /* end if */
else
/* Set the "state" of the allocation time property to indicate the user modified it */
alloc_time_state=0;
/* Set values */
if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &alloc_time) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time");
if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_alloc_time
*
* Purpose: Get space allocation time for dataset creation.
* Valid values are H5D_ALLOC_TIME_DEFAULT, H5D_ALLOC_TIME_EARLY,
* H5D_ALLOC_TIME_LATE, H5D_ALLOC_TIME_INCR
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Wednesday, January 16, 2002
*
* Modifications:
*
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(H5Pget_alloc_time, FAIL);
H5TRACE2("e","ix",plist_id,alloc_time);
/* Get the property list structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get values */
if(!alloc_time || H5P_get(plist, H5D_CRT_ALLOC_TIME_NAME, alloc_time) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get space allocation time");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pset_fill_time
*
* Purpose: Set fill value writing time for dataset. Valid values are
* H5D_FILL_TIME_ALLOC and H5D_FILL_TIME_NEVER.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Wednesday, January 16, 2002
*
* Modifications:
*
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(H5Pset_fill_time, FAIL);
H5TRACE2("e","iDf",plist_id,fill_time);
/* Check arguments */
if(fill_time<H5D_FILL_TIME_ALLOC || fill_time>H5D_FILL_TIME_IFSET)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fill time setting");
/* Get the property list structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Set values */
if(H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Pget_fill_time
*
* Purpose: Get fill value writing time. Valid values are H5D_NEVER
* and H5D_ALLOC.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Raymond Lu
* Wednesday, January 16, 2002
*
* Modifications:
*
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(H5Pget_fill_time, FAIL);
H5TRACE2("e","ix",plist_id,fill_time);
/* Get the property list structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Set values */
if(!fill_time || H5P_get(plist, H5D_CRT_FILL_TIME_NAME, fill_time) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time");
done:
FUNC_LEAVE_API(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Premove_filter
*
* Purpose: Deletes a filter from the dataset creation property list;
* deletes all filters if FILTER is H5Z_FILTER_NONE
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Pedro Vicente
* January 26, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Premove_filter(hid_t plist_id, H5Z_filter_t filter)
{
H5P_genplist_t *plist; /* Property list pointer */
H5O_pline_t pline; /* Filter pipeline */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(H5Premove_filter, FAIL)
H5TRACE2("e","iZf",plist_id,filter);
/* Get the property list structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* Get pipeline info */
if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline")
/* Check if there are any filters */
if (pline.filter) {
/* Delete filter */
if(H5Z_delete(&pline, filter) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't delete filter")
/* Put the I/O pipeline information back into the property list */
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline")
} /* end if */
done:
FUNC_LEAVE_API(ret_value);
}
|