summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
Diffstat (limited to 'hl')
-rw-r--r--hl/CMakeLists.txt20
-rw-r--r--hl/Makefile.am5
-rw-r--r--hl/c++/src/H5PacketTable.cpp25
-rw-r--r--hl/c++/src/H5PacketTable.h20
-rw-r--r--hl/c++/test/ptableTest.cpp2
-rw-r--r--hl/examples/ex_table_01.c8
-rw-r--r--hl/examples/ex_table_02.c10
-rw-r--r--hl/examples/ex_table_03.c6
-rw-r--r--hl/examples/ex_table_04.c10
-rw-r--r--hl/examples/ex_table_05.c4
-rw-r--r--hl/examples/ex_table_06.c2
-rw-r--r--hl/examples/ex_table_07.c10
-rw-r--r--hl/examples/ex_table_08.c10
-rw-r--r--hl/examples/ex_table_09.c10
-rw-r--r--hl/examples/ex_table_10.c8
-rw-r--r--hl/examples/ex_table_11.c10
-rw-r--r--hl/examples/ex_table_12.c10
-rw-r--r--hl/fortran/src/H5LTfc.c4
-rw-r--r--hl/src/CMakeLists.txt29
-rw-r--r--hl/src/H5DS.c900
-rw-r--r--hl/src/H5DSprivate.h8
-rw-r--r--hl/src/H5DSpublic.h2
-rw-r--r--hl/src/H5LD.c70
-rw-r--r--hl/src/H5LT.c117
-rw-r--r--hl/src/H5LTpublic.h6
-rw-r--r--hl/test/CMakeTests.cmake2
-rw-r--r--hl/test/gen_test_ds.c8
-rw-r--r--hl/test/test_ds.c73
-rw-r--r--hl/test/test_ds_be_new_ref-32bit.h5bin0 -> 13480 bytes
-rw-r--r--hl/test/test_ds_be_new_ref.h5bin0 -> 16040 bytes
-rw-r--r--hl/test/test_ds_le_new_ref.h5bin0 -> 16040 bytes
-rw-r--r--hl/test/test_lite.c109
-rw-r--r--hl/test/test_packet.c8
-rw-r--r--hl/test/test_packet_vlen.c4
-rw-r--r--hl/test/test_table.c46
-rw-r--r--hl/tools/h5watch/h5watchgentest.c4
36 files changed, 1004 insertions, 556 deletions
diff --git a/hl/CMakeLists.txt b/hl/CMakeLists.txt
index 083c60e..9391231 100644
--- a/hl/CMakeLists.txt
+++ b/hl/CMakeLists.txt
@@ -2,14 +2,30 @@ cmake_minimum_required (VERSION 3.12)
project (HDF5_HL C)
#-----------------------------------------------------------------------------
+# Option to use new-style references with dimension scale APIs
+#-----------------------------------------------------------------------------
+option (HDF5_DIMENSION_SCALES_NEW_REF "Use new-style references with dimension scale APIs" OFF)
+if (HDF5_DIMENSION_SCALES_NEW_REF)
+ set (H5_DIMENSION_SCALES_WITH_NEW_REF 1)
+endif ()
+
+#-----------------------------------------------------------------------------
# List Source files
#-----------------------------------------------------------------------------
add_subdirectory (src)
-#-- Build the High level Tools
+# Build HDF5 Tools
if (HDF5_BUILD_TOOLS)
- add_subdirectory (tools)
+ #-----------------------------------------------------------------------------
+ #-- Option to build the High level Tools
+ #-----------------------------------------------------------------------------
+ if (EXISTS "${HDF5_HL_SOURCE_DIR}/tools" AND IS_DIRECTORY "${HDF5_HL_SOURCE_DIR}/tools")
+ option (HDF5_BUILD_HL_TOOLS "Build HDF5 HL Tools" ON)
+ if (HDF5_BUILD_HL_TOOLS)
+ add_subdirectory (tools)
+ endif ()
+ endif ()
endif ()
#-- Add High Level Examples
diff --git a/hl/Makefile.am b/hl/Makefile.am
index 9bf209e..8c427d3 100644
--- a/hl/Makefile.am
+++ b/hl/Makefile.am
@@ -37,16 +37,19 @@ else
TEST_DIR =
endif
if BUILD_TOOLS_CONDITIONAL
+if BUILD_TOOLS_HL_CONDITIONAL
TOOLS_DIR = tools
else
TOOLS_DIR =
endif
+else
+ TOOLS_DIR =
+endif
## Don't recurse into any subdirectories if HDF5 is not configured to
## use the HL library
if BUILD_HDF5_HL_CONDITIONAL
SUBDIRS=src $(TEST_DIR) $(TOOLS_DIR) $(CXX_DIR) $(FORTRAN_DIR)
-
endif
DIST_SUBDIRS=src test tools c++ fortran examples
diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp
index 2908626..086c702 100644
--- a/hl/c++/src/H5PacketTable.cpp
+++ b/hl/c++/src/H5PacketTable.cpp
@@ -62,12 +62,9 @@ PacketTable::~PacketTable()
* any trouble making or opening the packet table.
*/
bool
-PacketTable::IsValid()
+PacketTable::IsValid() const
{
- if (H5PTis_valid(table_id) == 0)
- return true;
- else
- return false;
+ return H5PTis_valid(table_id) == 0;
}
/* IsVariableLength
@@ -75,7 +72,7 @@ PacketTable::IsValid()
* and 0, otherwise. Returns -1 if the table is invalid (not open).
*/
int
-PacketTable::IsVariableLength()
+PacketTable::IsVariableLength() const
{
return H5PTis_varlen(table_id);
}
@@ -84,7 +81,7 @@ PacketTable::IsVariableLength()
* Sets the index to point to the first packet in the packet table
*/
void
-PacketTable::ResetIndex()
+PacketTable::ResetIndex() const
{
H5PTcreate_index(table_id);
}
@@ -94,7 +91,7 @@ PacketTable::ResetIndex()
* Returns 0 on success, negative on failure (if index is out of bounds)
*/
int
-PacketTable::SetIndex(hsize_t index)
+PacketTable::SetIndex(hsize_t index) const
{
return H5PTset_index(table_id, index);
}
@@ -104,7 +101,7 @@ PacketTable::SetIndex(hsize_t index)
* Returns 0 on success, negative on failure (if index is out of bounds)
*/
hsize_t
-PacketTable::GetIndex(int &error)
+PacketTable::GetIndex(int &error) const
{
hsize_t index;
@@ -121,7 +118,7 @@ PacketTable::GetIndex(int &error)
* error is set to negative.
*/
hsize_t
-PacketTable::GetPacketCount(int &error)
+PacketTable::GetPacketCount(int &error) const
{
hsize_t npackets;
@@ -133,7 +130,7 @@ PacketTable::GetPacketCount(int &error)
* Returns the identifier of the packet table
*/
hid_t
-PacketTable::GetTableId()
+PacketTable::GetTableId() const
{
return table_id;
}
@@ -145,7 +142,7 @@ PacketTable::GetTableId()
* the desired functionality cannot be performed via the packet table ID.
*/
hid_t
-PacketTable::GetDatatype()
+PacketTable::GetDatatype() const
{
return H5PTget_type(table_id);
}
@@ -157,7 +154,7 @@ PacketTable::GetDatatype()
* the desired functionality cannot be performed via the packet table ID.
*/
hid_t
-PacketTable::GetDataset()
+PacketTable::GetDataset() const
{
return H5PTget_dataset(table_id);
}
@@ -169,7 +166,7 @@ PacketTable::GetDataset()
* Returns 0 on success, negative on error.
*/
int
-PacketTable::FreeBuff(size_t numStructs, hvl_t *buffer)
+PacketTable::FreeBuff(size_t numStructs, hvl_t *buffer) const
{
return H5PTfree_vlen_buff(table_id, numStructs, buffer);
}
diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h
index eae66f1..c1f1eb5 100644
--- a/hl/c++/src/H5PacketTable.h
+++ b/hl/c++/src/H5PacketTable.h
@@ -54,39 +54,39 @@ class H5_HLCPPDLL PacketTable {
* Use this after the constructor to ensure HDF did not have
* any trouble making or opening the packet table.
*/
- bool IsValid();
+ bool IsValid() const;
/* IsVariableLength
* Return 1 if this packet table uses variable-length datatype,
* return 0 if it is Fixed Length. Returns -1 if the table is
* invalid (not open).
*/
- int IsVariableLength();
+ int IsVariableLength() const;
/* ResetIndex
* Sets the "current packet" index to point to the first packet in the
* packet table
*/
- void ResetIndex();
+ void ResetIndex() const;
/* SetIndex
* Sets the current packet to point to the packet specified by index.
* Returns 0 on success, negative on failure (if index is out of bounds)
*/
- int SetIndex(hsize_t index);
+ int SetIndex(hsize_t index) const;
/* GetIndex
* Returns the position of the current packet.
* On failure, returns 0 and error is set to negative.
*/
- hsize_t GetIndex(int &error);
+ hsize_t GetIndex(int &error) const;
/* GetPacketCount
* Returns the number of packets in the packet table. Error
* is set to 0 on success. On failure, returns 0 and
* error is set to negative.
*/
- hsize_t GetPacketCount(int &error);
+ hsize_t GetPacketCount(int &error) const;
hsize_t
GetPacketCount()
@@ -98,7 +98,7 @@ class H5_HLCPPDLL PacketTable {
/* GetTableId
* Returns the identifier of the packet table.
*/
- hid_t GetTableId();
+ hid_t GetTableId() const;
/* GetDatatype
* Returns the datatype identifier used by the packet table, on success,
@@ -106,7 +106,7 @@ class H5_HLCPPDLL PacketTable {
* Note: it is best to avoid using this identifier in applications, unless
* the desired functionality cannot be performed via the packet table ID.
*/
- hid_t GetDatatype();
+ hid_t GetDatatype() const;
/* GetDataset
* Returns the dataset identifier associated with the packet table, on
@@ -114,7 +114,7 @@ class H5_HLCPPDLL PacketTable {
* Note: it is best to avoid using this identifier in applications, unless
* the desired functionality cannot be performed via the packet table ID.
*/
- hid_t GetDataset();
+ hid_t GetDataset() const;
/* FreeBuff
* Frees the buffers created when variable-length packets are read.
@@ -122,7 +122,7 @@ class H5_HLCPPDLL PacketTable {
* location in memory.
* Returns 0 on success, negative on error.
*/
- int FreeBuff(size_t numStructs, hvl_t *buffer);
+ int FreeBuff(size_t numStructs, hvl_t *buffer) const;
protected:
hid_t table_id;
diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp
index 6deb24d..ab49303 100644
--- a/hl/c++/test/ptableTest.cpp
+++ b/hl/c++/test/ptableTest.cpp
@@ -620,7 +620,7 @@ TestHDFFV_9758()
for (hsize_t i = 0; i < NUM_PACKETS; i++) {
s1[i].a = static_cast<int>(i);
- s1[i].b = 1.0f * static_cast<float>(i * i);
+ s1[i].b = 1.0F * static_cast<float>(i * i);
s1[i].c = 1.0 / static_cast<double>(i + 1);
HDsprintf(s1[i].d, "string%" PRIuHSIZE "", i);
s1[i].e = static_cast<int>(100 + i);
diff --git a/hl/examples/ex_table_01.c b/hl/examples/ex_table_01.c
index 8635acf..3294ef4 100644
--- a/hl/examples/ex_table_01.c
+++ b/hl/examples/ex_table_01.c
@@ -50,10 +50,10 @@ main(void)
sizeof(dst_buf[0].pressure), sizeof(dst_buf[0].temperature)};
/* Define an array of Particles */
- Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
- {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
- {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
- {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0},
+ {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0},
+ {"four", 40, 40, 4.0F, 40.0}, {"five", 50, 50, 5.0F, 50.0},
+ {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}};
/* Define field information */
const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
diff --git a/hl/examples/ex_table_02.c b/hl/examples/ex_table_02.c
index 9c476b3..fb2cad6 100644
--- a/hl/examples/ex_table_02.c
+++ b/hl/examples/ex_table_02.c
@@ -42,10 +42,10 @@ main(void)
Particle dst_buf[NRECORDS + NRECORDS_ADD];
/* Define an array of Particles */
- Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
- {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
- {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
- {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0},
+ {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0},
+ {"four", 40, 40, 4.0F, 40.0}, {"five", 50, 50, 5.0F, 50.0},
+ {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}};
/* Calculate the size and the offsets of our struct members in memory */
size_t dst_size = sizeof(Particle);
@@ -66,7 +66,7 @@ main(void)
int i;
/* Append particles */
- Particle particle_in[NRECORDS_ADD] = {{"eight", 80, 80, 8.0f, 80.0}, {"nine", 90, 90, 9.0f, 90.0}};
+ Particle particle_in[NRECORDS_ADD] = {{"eight", 80, 80, 8.0F, 80.0}, {"nine", 90, 90, 9.0F, 90.0}};
/* Initialize the field field_type */
string_type = H5Tcopy(H5T_C_S1);
diff --git a/hl/examples/ex_table_03.c b/hl/examples/ex_table_03.c
index 31cf970..3caa45e 100644
--- a/hl/examples/ex_table_03.c
+++ b/hl/examples/ex_table_03.c
@@ -46,14 +46,14 @@ main(void)
size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
- Particle p = {"zero", 0, 0, 0.0f, 0.0};
+ Particle p = {"zero", 0, 0, 0.0F, 0.0};
size_t dst_sizes[NFIELDS] = {sizeof(p.name), sizeof(p.lati), sizeof(p.longi), sizeof(p.pressure),
sizeof(p.temperature)};
/* Define field information */
const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
/* Fill value particle */
- Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}};
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0F, -99.0}};
hid_t field_type[NFIELDS];
hid_t string_type;
hid_t file_id;
@@ -63,7 +63,7 @@ main(void)
int i;
/* Define 2 new particles to write */
- Particle particle_in[NRECORDS_WRITE] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0}};
+ Particle particle_in[NRECORDS_WRITE] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0}};
/* Initialize the field field_type */
string_type = H5Tcopy(H5T_C_S1);
diff --git a/hl/examples/ex_table_04.c b/hl/examples/ex_table_04.c
index 863fe15..9b39ef7 100644
--- a/hl/examples/ex_table_04.c
+++ b/hl/examples/ex_table_04.c
@@ -65,23 +65,23 @@ main(void)
hid_t string_type;
hid_t file_id;
hsize_t chunk_size = 10;
- Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}}; /* Fill value particle */
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0F, -99.0}}; /* Fill value particle */
hsize_t start; /* Record to start reading/writing */
hsize_t nrecords; /* Number of records to read/write */
int compress = 0;
int i;
Particle *p_data = NULL; /* Initially no data */
float pressure_in[NRECORDS_ADD] = /* Define new values for the field "Pressure" */
- {0.0f, 1.0f, 2.0f};
+ {0.0F, 1.0F, 2.0F};
Position position_in[NRECORDS_ADD] = {/* Define new values for "Latitude,Longitude" */
{0, 0},
{10, 10},
{20, 20}};
NamePressure namepre_in[NRECORDS_ADD] = /* Define new values for "Name,Pressure" */
{
- {"zero", 0.0f},
- {"one", 1.0f},
- {"two", 2.0f},
+ {"zero", 0.0F},
+ {"one", 1.0F},
+ {"two", 2.0F},
};
size_t field_sizes_pos[2] = {sizeof(position_in[0].longi), sizeof(position_in[0].lati)};
size_t field_sizes_pre[1] = {sizeof(namepre_in[0].pressure)};
diff --git a/hl/examples/ex_table_05.c b/hl/examples/ex_table_05.c
index 337bfb6..cac406b 100644
--- a/hl/examples/ex_table_05.c
+++ b/hl/examples/ex_table_05.c
@@ -64,7 +64,7 @@ main(void)
hid_t string_type;
hid_t file_id;
hsize_t chunk_size = 10;
- Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}}; /* Fill value particle */
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0F, -99.0}}; /* Fill value particle */
int compress = 0;
hsize_t nfields;
hsize_t start; /* Record to start reading/writing */
@@ -72,7 +72,7 @@ main(void)
int i;
/* Define new values for the field "Pressure" */
- float pressure_in[NRECORDS_ADD] = {0.0f, 1.0f, 2.0f};
+ float pressure_in[NRECORDS_ADD] = {0.0F, 1.0F, 2.0F};
int field_index_pre[1] = {3};
int field_index_pos[2] = {1, 2};
diff --git a/hl/examples/ex_table_06.c b/hl/examples/ex_table_06.c
index f6b67c8..cc1bc01 100644
--- a/hl/examples/ex_table_06.c
+++ b/hl/examples/ex_table_06.c
@@ -49,7 +49,7 @@ main(void)
hid_t string_type;
hid_t file_id;
hsize_t chunk_size = 10;
- Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}}; /* Fill value particle */
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0F, -99.0}}; /* Fill value particle */
int compress = 0;
hsize_t nfields_out;
hsize_t nrecords_out;
diff --git a/hl/examples/ex_table_07.c b/hl/examples/ex_table_07.c
index ab36613..e05a681 100644
--- a/hl/examples/ex_table_07.c
+++ b/hl/examples/ex_table_07.c
@@ -44,10 +44,10 @@ main(void)
HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
/* Define an array of Particles */
- Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
- {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
- {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
- {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0},
+ {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0},
+ {"four", 40, 40, 4.0F, 40.0}, {"five", 50, 50, 5.0F, 50.0},
+ {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}};
const char *field_names[NFIELDS] = /* Define field information */
{"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
@@ -56,7 +56,7 @@ main(void)
hid_t file_id;
hsize_t chunk_size = 10;
int compress = 0;
- Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}};
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0F, -99.0}};
hsize_t start; /* Record to start reading */
hsize_t nrecords; /* Number of records to insert/delete */
hsize_t nfields_out;
diff --git a/hl/examples/ex_table_08.c b/hl/examples/ex_table_08.c
index 5d447dd..1063172 100644
--- a/hl/examples/ex_table_08.c
+++ b/hl/examples/ex_table_08.c
@@ -41,10 +41,10 @@ main(void)
Particle dst_buf[NRECORDS + NRECORDS_INS];
/* Define an array of Particles */
- Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
- {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
- {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
- {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0},
+ {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0},
+ {"four", 40, 40, 4.0F, 40.0}, {"five", 50, 50, 5.0F, 50.0},
+ {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}};
/* Calculate the size and the offsets of our struct members in memory */
size_t dst_size = sizeof(Particle);
@@ -54,7 +54,7 @@ main(void)
sizeof(p_data[0].pressure), sizeof(p_data[0].temperature)};
/* Define an array of Particles to insert */
- Particle p_data_insert[NRECORDS_INS] = {{"new", 30, 30, 3.0f, 30.0}, {"new", 40, 40, 4.0f, 40.0}};
+ Particle p_data_insert[NRECORDS_INS] = {{"new", 30, 30, 3.0F, 30.0}, {"new", 40, 40, 4.0F, 40.0}};
/* Define field information */
const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
diff --git a/hl/examples/ex_table_09.c b/hl/examples/ex_table_09.c
index 381925f..171de2e 100644
--- a/hl/examples/ex_table_09.c
+++ b/hl/examples/ex_table_09.c
@@ -49,10 +49,10 @@ main(void)
sizeof(dst_buf[0].pressure), sizeof(dst_buf[0].temperature)};
/* Define an array of Particles */
- Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
- {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
- {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
- {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0},
+ {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0},
+ {"four", 40, 40, 4.0F, 40.0}, {"five", 50, 50, 5.0F, 50.0},
+ {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}};
/* Define field information */
const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
@@ -61,7 +61,7 @@ main(void)
hid_t file_id;
hsize_t chunk_size = 10;
int compress = 0;
- Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}}; /* Fill value particle */
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0F, -99.0}}; /* Fill value particle */
hsize_t start1; /* Record to start reading from 1st table */
hsize_t nrecords; /* Number of records to insert */
hsize_t start2; /* Record to start writing in 2nd table */
diff --git a/hl/examples/ex_table_10.c b/hl/examples/ex_table_10.c
index 4ba5d64..c974e84 100644
--- a/hl/examples/ex_table_10.c
+++ b/hl/examples/ex_table_10.c
@@ -40,10 +40,10 @@ main(void)
} Particle;
/* Define an array of Particles */
- Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
- {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
- {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
- {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0},
+ {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0},
+ {"four", 40, 40, 4.0F, 40.0}, {"five", 50, 50, 5.0F, 50.0},
+ {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}};
Particle dst_buf[2 * NRECORDS];
/* Calculate the size and the offsets of our struct members in memory */
diff --git a/hl/examples/ex_table_11.c b/hl/examples/ex_table_11.c
index 9bf3927..6b38b95 100644
--- a/hl/examples/ex_table_11.c
+++ b/hl/examples/ex_table_11.c
@@ -38,10 +38,10 @@ main(void)
} Particle1;
/* Define an array of Particles */
- Particle1 p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
- {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
- {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
- {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+ Particle1 p_data[NRECORDS] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0},
+ {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0},
+ {"four", 40, 40, 4.0F, 40.0}, {"five", 50, 50, 5.0F, 50.0},
+ {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}};
/* Calculate the size and the offsets of our struct members in memory */
size_t dst_size1 = sizeof(Particle1);
@@ -56,7 +56,7 @@ main(void)
hid_t file_id;
hsize_t chunk_size = 10;
int compress = 0;
- Particle1 fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}};
+ Particle1 fill_data[1] = {{"no data", -1, -1, -99.0F, -99.0}};
int fill_data_new[1] = {-100};
hsize_t position;
hsize_t nfields_out;
diff --git a/hl/examples/ex_table_12.c b/hl/examples/ex_table_12.c
index 3e7c27a..a1a2c54 100644
--- a/hl/examples/ex_table_12.c
+++ b/hl/examples/ex_table_12.c
@@ -44,10 +44,10 @@ main(void)
HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
/* Define an array of Particles */
- Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
- {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
- {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
- {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0},
+ {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0},
+ {"four", 40, 40, 4.0F, 40.0}, {"five", 50, 50, 5.0F, 50.0},
+ {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}};
/* Define field information */
const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
@@ -56,7 +56,7 @@ main(void)
hid_t file_id;
hsize_t chunk_size = 10;
int compress = 0;
- Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}};
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0F, -99.0}};
hsize_t nfields_out;
hsize_t nrecords_out;
diff --git a/hl/fortran/src/H5LTfc.c b/hl/fortran/src/H5LTfc.c
index e87a9d3..4cb9265 100644
--- a/hl/fortran/src/H5LTfc.c
+++ b/hl/fortran/src/H5LTfc.c
@@ -319,11 +319,9 @@ h5ltset_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f
else if ((size_t)*sizeof_val == sizeof(double))
ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_DOUBLE,
(const double *)buf);
-#if H5_SIZEOF_LONG_DOUBLE != 0
else if ((size_t)*sizeof_val == sizeof(long double))
ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_LDOUBLE,
(const long double *)buf);
-#endif
else
goto done;
}
@@ -413,10 +411,8 @@ h5ltget_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f
ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_FLOAT, buf);
else if ((size_t)*sizeof_val == sizeof(double))
ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_DOUBLE, buf);
-#if H5_SIZEOF_LONG_DOUBLE != 0
else if ((size_t)*sizeof_val == sizeof(long double))
ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_LDOUBLE, buf);
-#endif
else
goto done;
}
diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt
index 7678de8..a97d6fa 100644
--- a/hl/src/CMakeLists.txt
+++ b/hl/src/CMakeLists.txt
@@ -169,3 +169,32 @@ if (NOT WIN32 AND NOT MINGW)
COMPONENT hllibraries
)
endif ()
+
+#-----------------------------------------------------------------------------
+# Option to build documentation
+#-----------------------------------------------------------------------------
+if (DOXYGEN_FOUND)
+# This cmake function requires that the non-default doxyfile settings are provided with set (DOXYGEN_xxx) commands
+# In addition the doxyfile aliases @INCLUDE option is not supported and would need to be provided in a set (DOXYGEN_ALIASES) command.
+# doxygen_add_docs (hdf5lib_doc
+## ${HL_SOURCES} ${HL_HEADERS} ${HDF5_DOXYGEN_DIR}/dox
+# ${DOXYGEN_INPUT_DIRECTORY}
+# ALL
+# WORKING_DIRECTORY ${HDF5_HL_SRC_DIR}
+# COMMENT "Generating HDF5 HL library Source Documentation"
+# )
+
+# This custom target and doxygen/configure work together
+ # Replace variables inside @@ with the current values
+ add_custom_target (hdf5hllib_doc ALL
+ COMMAND ${DOXYGEN_EXECUTABLE} ${HDF5_BINARY_DIR}/Doxyfile
+ WORKING_DIRECTORY ${HDF5_HL_SRC_DIR}
+ COMMENT "Generating HDF5 HL library Source API documentation with Doxygen"
+ VERBATIM )
+
+ if (NOT TARGET doxygen)
+ add_custom_target (doxygen)
+ endif ()
+
+ add_dependencies (doxygen hdf5hllib_doc)
+endif ()
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c
index 2bd4046..c947d16 100644
--- a/hl/src/H5DS.c
+++ b/hl/src/H5DS.c
@@ -18,7 +18,40 @@
/* Local routines */
static herr_t H5DS_is_reserved(hid_t did);
-static hid_t H5DS_get_REFLIST_type(void);
+
+/*-------------------------------------------------------------------------
+ * Function: H5DSwith_new_ref
+ *
+ * Purpose: Determines if new references are used with dimension scales.
+ * The function H5DSwith_new_ref takes any object identifier and checks
+ * if new references are used for dimension scales. Currently,
+ * new references are used when non-native VOL connector is used or when
+ * H5_DIMENSION_SCALES_WITH_NEW_REF is set up via configure option.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5DSwith_new_ref(hid_t obj_id, hbool_t *with_new_ref)
+{
+ hbool_t config_flag = FALSE;
+ hbool_t native = FALSE;
+
+ if (!with_new_ref)
+ return FAIL;
+
+ if (H5VLobject_is_native(obj_id, &native) < 0)
+ return FAIL;
+
+#ifdef H5_DIMENSION_SCALES_WITH_NEW_REF
+ config_flag = TRUE;
+#endif
+
+ *with_new_ref = (config_flag || !native);
+
+ return SUCCEED;
+}
/*-------------------------------------------------------------------------
* Function: H5DSset_scale
@@ -106,22 +139,34 @@ H5DSset_scale(hid_t dsid, const char *dimname)
herr_t
H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
{
- int has_dimlist;
- int has_reflist;
- int is_ds;
- hssize_t nelmts;
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t ntid = -1; /* attribute native type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */
- ds_list_t dsl; /* attribute data in the DS pointing to the dataset */
- ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
- hobj_ref_t ref_to_ds; /* reference to the DS */
- hobj_ref_t ref_j; /* iterator reference */
- hvl_t * buf = NULL; /* VL buffer to store in the attribute */
- hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
+ int has_dimlist;
+ int has_reflist;
+ int is_ds;
+ hssize_t nelmts;
+ hid_t sid, sid_w; /* space ID */
+ hid_t tid = H5I_INVALID_HID; /* attribute type ID */
+ hid_t ntid = H5I_INVALID_HID; /* attribute native type ID */
+ hid_t aid = H5I_INVALID_HID; /* attribute ID */
+ int rank; /* rank of dataset */
+ hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */
+
+ ds_list_t dsl; /* attribute data in the DS pointing to the dataset */
+ ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
+ ds_list_t *dsbuf_w =
+ NULL; /* array of "REFERENCE_LIST" attribute data to write when adding new reference to a dataset */
+ hobj_ref_t ref_to_ds; /* reference to the DS */
+ hobj_ref_t ref_j; /* iterator reference */
+
+ /* Variables to be used when new references are used */
+ nds_list_t ndsl;
+ nds_list_t *ndsbuf = NULL;
+ nds_list_t *ndsbuf_w = NULL;
+ H5R_ref_t nref_to_ds;
+ H5R_ref_t nref_j;
+ hbool_t is_new_ref;
+
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
H5O_info2_t oi1, oi2;
H5I_type_t it1, it2;
int i;
@@ -159,6 +204,14 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
return FAIL;
} /* end if */
+ /*-------------------------------------------------------------------------
+ * determine if old or new references should be used
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5DSwith_new_ref(did, &is_new_ref) < 0)
+ return FAIL;
+
/* get ID type */
if ((it1 = H5Iget_type(did)) < 0)
return FAIL;
@@ -209,14 +262,23 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
* and one to the dataset, saved in "REFERENCE_LIST"
*-------------------------------------------------------------------------
*/
- /* create a reference for the >>DS<< dataset */
- if (H5Rcreate(&ref_to_ds, dsid, ".", H5R_OBJECT, (hid_t)-1) < 0)
- return FAIL;
-
- /* create a reference for the >>data<< dataset */
- if (H5Rcreate(&dsl.ref, did, ".", H5R_OBJECT, (hid_t)-1) < 0)
- return FAIL;
+ if (is_new_ref) {
+ /* create a reference for the >>DS<< dataset */
+ if (H5Rcreate_object(dsid, ".", H5P_DEFAULT, &nref_to_ds) < 0)
+ return FAIL;
+ /* create a reference for the >>data<< dataset */
+ if (H5Rcreate_object(did, ".", H5P_DEFAULT, &ndsl.ref) < 0)
+ return FAIL;
+ }
+ else {
+ /* create a reference for the >>DS<< dataset */
+ if (H5Rcreate(&ref_to_ds, dsid, ".", H5R_OBJECT, (hid_t)-1) < 0)
+ return FAIL;
+ /* create a reference for the >>data<< dataset */
+ if (H5Rcreate(&dsl.ref, did, ".", H5R_OBJECT, (hid_t)-1) < 0)
+ return FAIL;
+ }
/* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
return FAIL;
@@ -234,9 +296,14 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
return FAIL;
/* create the type for the attribute "DIMENSION_LIST" */
- if ((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0)
- goto out;
-
+ if (is_new_ref) {
+ if ((tid = H5Tvlen_create(H5T_STD_REF)) < 0)
+ goto out;
+ }
+ else {
+ if ((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0)
+ goto out;
+ }
/* create the attribute */
if ((aid = H5Acreate2(did, DIMENSION_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
@@ -252,24 +319,32 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
}
/* store the REF information in the index of the dataset that has the DS */
- buf[idx].len = 1;
- buf[idx].p = HDmalloc(1 * sizeof(hobj_ref_t));
- ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds;
-
+ buf[idx].len = 1;
+ if (is_new_ref) {
+ buf[idx].p = HDmalloc(1 * sizeof(H5R_ref_t));
+ ((H5R_ref_t *)buf[idx].p)[0] = nref_to_ds;
+ }
+ else {
+ buf[idx].p = HDmalloc(1 * sizeof(hobj_ref_t));
+ ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds;
+ }
/* write the attribute with the reference */
if (H5Awrite(aid, tid, buf) < 0)
goto out;
/* close */
- if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0)
- goto out;
+ if (is_new_ref) {
+ if (H5Rdestroy(&nref_to_ds) < 0)
+ goto out;
+ }
if (H5Sclose(sid) < 0)
goto out;
if (H5Tclose(tid) < 0)
goto out;
if (H5Aclose(aid) < 0)
goto out;
-
+ HDfree(buf[idx].p);
+ buf[idx].p = NULL;
HDfree(buf);
buf = NULL;
}
@@ -302,12 +377,20 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
/* iterate all the REFs in this dimension IDX */
for (i = 0; i < (int)buf[idx].len; i++) {
/* get the reference */
- ref_j = ((hobj_ref_t *)buf[idx].p)[i];
+ if (is_new_ref) {
+ nref_j = ((H5R_ref_t *)buf[idx].p)[i];
- /* get the scale id for this REF */
- if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0)
- goto out;
+ /* get the scale id for this REF */
+ if ((dsid_j = H5Ropen_object(&nref_j, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ }
+ else {
+ ref_j = ((hobj_ref_t *)buf[idx].p)[i];
+ /* get the scale id for this REF */
+ if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0)
+ goto out;
+ }
/* get info for DS in the parameter list */
if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0)
goto out;
@@ -335,17 +418,33 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
/* we are adding one more DS to this dimension */
if (buf[idx].len > 0) {
buf[idx].len++;
- len = buf[idx].len;
- buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t));
- ((hobj_ref_t *)buf[idx].p)[len - 1] = ref_to_ds;
+ len = buf[idx].len;
+ if (is_new_ref) {
+ buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(H5R_ref_t));
+ ((H5R_ref_t *)buf[idx].p)[len - 1] = nref_to_ds;
+ }
+ else {
+ buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t));
+ ((hobj_ref_t *)buf[idx].p)[len - 1] = ref_to_ds;
+ }
} /* end if */
else {
/* store the REF information in the index of the dataset that has the DS */
- buf[idx].len = 1;
- buf[idx].p = HDmalloc(sizeof(hobj_ref_t));
- ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds;
+ buf[idx].len = 1;
+ if (is_new_ref) {
+ buf[idx].p = HDmalloc(sizeof(H5R_ref_t));
+ ((H5R_ref_t *)buf[idx].p)[0] = nref_to_ds;
+ }
+ else {
+ buf[idx].p = HDmalloc(sizeof(hobj_ref_t));
+ ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds;
+ }
} /* end else */
} /* end if */
+ else {
+ if (is_new_ref && H5Rdestroy(&nref_to_ds) < 0)
+ goto out;
+ }
/* write the attribute with the new references */
if (H5Awrite(aid, tid, buf) < 0)
@@ -385,29 +484,40 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
goto out;
/* create the compound datatype for the attribute "REFERENCE_LIST" */
- if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0)
- goto out;
-
- /* insert reference field */
- if (H5Tinsert(tid, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0)
- goto out;
-
- /* insert dimension idx of the dataset field */
- if (H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0)
- goto out;
+ if (is_new_ref) {
+ if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(nds_list_t))) < 0)
+ goto out;
+ if (H5Tinsert(tid, "dataset", HOFFSET(nds_list_t, ref), H5T_STD_REF) < 0)
+ goto out;
+ if (H5Tinsert(tid, "dimension", HOFFSET(nds_list_t, dim_idx), H5T_NATIVE_UINT) < 0)
+ goto out;
+ }
+ else {
+ if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0)
+ goto out;
+ if (H5Tinsert(tid, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0)
+ goto out;
+ if (H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_UINT) < 0)
+ goto out;
+ }
/* create the attribute */
if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* store the IDX information */
- dsl.dim_idx = idx;
-
- /* write the attribute with the reference */
- if (H5Awrite(aid, tid, &dsl) < 0)
- goto out;
-
- /* close */
+ if (is_new_ref) {
+ ndsl.dim_idx = idx;
+ if (H5Awrite(aid, tid, &ndsl) < 0)
+ goto out;
+ if (H5Rdestroy(&ndsl.ref) < 0)
+ goto out;
+ }
+ else {
+ dsl.dim_idx = idx;
+ if (H5Awrite(aid, tid, &dsl) < 0)
+ goto out;
+ }
if (H5Sclose(sid) < 0)
goto out;
if (H5Tclose(tid) < 0)
@@ -421,6 +531,9 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
*-------------------------------------------------------------------------
*/
else if (has_reflist == 1) {
+ hid_t tmp_id; /* Temporary DS dataset ID to recreate reference */
+ int j;
+
if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0)
goto out;
@@ -428,7 +541,7 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
goto out;
/* get native type to read attribute REFERENCE_LIST */
- if ((ntid = H5DS_get_REFLIST_type()) < 0)
+ if ((ntid = H5Tget_native_type(tid, H5T_DIR_ASCEND)) < 0)
goto out;
/* get and save the old reference(s) */
@@ -439,17 +552,22 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
goto out;
nelmts++;
-
- dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
- if (dsbuf == NULL)
- goto out;
-
- if (H5Aread(aid, ntid, dsbuf) < 0)
- goto out;
+ if (is_new_ref) {
+ ndsbuf = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t));
+ if (ndsbuf == NULL)
+ goto out;
+ if (H5Aread(aid, ntid, ndsbuf) < 0)
+ goto out;
+ }
+ else {
+ dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
+ if (dsbuf == NULL)
+ goto out;
+ if (H5Aread(aid, ntid, dsbuf) < 0)
+ goto out;
+ }
/* close */
- if (H5Sclose(sid) < 0)
- goto out;
if (H5Aclose(aid) < 0)
goto out;
@@ -458,40 +576,93 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
*-------------------------------------------------------------------------
*/
+ /* Allocate new buffer to copy old references and add new one */
+
+ if (is_new_ref) {
+ ndsbuf_w = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t));
+ if (ndsbuf_w == NULL)
+ goto out;
+ }
+ else {
+ dsbuf_w = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
+ if (dsbuf_w == NULL)
+ goto out;
+ }
+ /* Recreate the references we read from the existing "REFERENCE_LIST" attribute */
+ for (j = 0; j < nelmts - 1; j++) {
+ if (is_new_ref) {
+ ndsbuf_w[j].dim_idx = ndsbuf[j].dim_idx;
+ tmp_id = H5Ropen_object(&ndsbuf[j].ref, H5P_DEFAULT, H5P_DEFAULT);
+ if (tmp_id < 0)
+ goto out;
+ if (H5Rcreate_object(tmp_id, ".", H5P_DEFAULT, &ndsbuf_w[j].ref) < 0) {
+ H5Dclose(tmp_id);
+ goto out;
+ }
+ }
+ else {
+ dsbuf_w[j] = dsbuf[j];
+ }
+ }
+ /* store the IDX information (index of the dataset that has the DS) */
+ if (is_new_ref) {
+ ndsl.dim_idx = idx;
+ ndsbuf_w[nelmts - 1] = ndsl;
+ }
+ else {
+ dsl.dim_idx = idx;
+ dsbuf_w[nelmts - 1] = dsl;
+ }
+
/* the attribute must be deleted, in order to the new one can reflect the changes*/
if (H5Adelete(dsid, REFERENCE_LIST) < 0)
goto out;
- /* store the IDX information (index of the dataset that has the DS) */
- dsl.dim_idx = idx;
- dsbuf[nelmts - 1] = dsl;
-
/* create a new data space for the new references array */
dims[0] = (hsize_t)nelmts;
- if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ if ((sid_w = H5Screate_simple(1, dims, NULL)) < 0)
goto out;
/* create the attribute again with the changes of space */
- if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid_w, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* write the attribute with the new references */
- if (H5Awrite(aid, ntid, dsbuf) < 0)
- goto out;
-
- /* close */
+ if (is_new_ref) {
+ if (H5Awrite(aid, ntid, ndsbuf_w) < 0)
+ goto out;
+ if (H5Treclaim(tid, sid, H5P_DEFAULT, ndsbuf_w) < 0)
+ goto out;
+ }
+ else {
+ if (H5Awrite(aid, ntid, dsbuf_w) < 0)
+ goto out;
+ if (H5Treclaim(tid, sid, H5P_DEFAULT, dsbuf_w) < 0)
+ goto out;
+ }
if (H5Sclose(sid) < 0)
goto out;
+ if (H5Sclose(sid_w) < 0)
+ goto out;
if (H5Tclose(tid) < 0)
goto out;
if (H5Aclose(aid) < 0)
goto out;
if (H5Tclose(ntid) < 0)
goto out;
-
- HDfree(dsbuf);
- dsbuf = NULL;
+ if (is_new_ref) {
+ HDfree(ndsbuf);
+ dsbuf = NULL;
+ HDfree(ndsbuf_w);
+ dsbuf = NULL;
+ }
+ else {
+ HDfree(dsbuf);
+ dsbuf = NULL;
+ HDfree(dsbuf_w);
+ dsbuf = NULL;
+ }
} /* has_reflist */
/*-------------------------------------------------------------------------
@@ -515,6 +686,8 @@ out:
HDfree(buf);
if (dsbuf)
HDfree(dsbuf);
+ if (dsbuf_w)
+ HDfree(dsbuf_w);
H5E_BEGIN_TRY
{
@@ -554,27 +727,35 @@ out:
herr_t
H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
{
- int has_dimlist;
- int has_reflist;
- hssize_t nelmts;
- hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
- hid_t did_i; /* dataset ID in REFERENCE_LIST */
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t ntid = -1; /* attribute native type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
- hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */
- hobj_ref_t ref; /* reference to the DS */
- hvl_t * buf = NULL; /* VL buffer to store in the attribute */
- int i;
- size_t j;
- hssize_t ii;
- H5O_info2_t did_oi, dsid_oi, tmp_oi;
- int found_dset = 0, found_ds = 0;
- int have_ds = 0;
- htri_t is_scale;
+ int has_dimlist;
+ int has_reflist;
+ hssize_t nelmts;
+ hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
+ hid_t did_i; /* dataset ID in REFERENCE_LIST */
+ hid_t sid = H5I_INVALID_HID; /* space ID */
+ hid_t sid_w = H5I_INVALID_HID; /* space ID */
+ hid_t tid = H5I_INVALID_HID; /* attribute type ID */
+ hid_t ntid = H5I_INVALID_HID; /* attribute native type ID */
+ hid_t aid = H5I_INVALID_HID; /* attribute ID */
+ int rank; /* rank of dataset */
+ nds_list_t * ndsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
+ nds_list_t * ndsbuf_w = NULL; /* array of attribute data in the DS pointing to the dataset to write*/
+ ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
+ ds_list_t * dsbuf_w = NULL; /* array of attribute data in the DS pointing to the dataset to write*/
+ hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */
+ H5R_ref_t nref;
+ hobj_ref_t ref; /* reference to the DS */
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ int i;
+ size_t j;
+ hssize_t ii;
+ H5O_info2_t did_oi, dsid_oi, tmp_oi;
+ int found_dset = 0, found_ds = 0;
+ int have_ds = 0;
+ htri_t is_scale;
+ hbool_t is_new_ref;
+ unsigned int tmp_idx;
+ hid_t tmp_id;
/*-------------------------------------------------------------------------
* parameter checking
@@ -612,9 +793,17 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
} /* end if */
/*-------------------------------------------------------------------------
- * Find "DIMENSION_LIST"
+ * determine if old or new references should be used
+ *-------------------------------------------------------------------------
+ */
+ if (H5DSwith_new_ref(did, &is_new_ref) < 0)
+ return FAIL;
+
+ /*-------------------------------------------------------------------------
+ * find "DIMENSION_LIST"
*-------------------------------------------------------------------------
*/
+
/* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
return FAIL;
@@ -676,13 +865,22 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
/* reset */
if (buf[idx].len > 0) {
for (j = 0; j < buf[idx].len; j++) {
- /* get the reference */
- ref = ((hobj_ref_t *)buf[idx].p)[j];
+ if (is_new_ref) {
+ /* get the reference */
+ nref = ((H5R_ref_t *)buf[idx].p)[j];
- /* get the DS id */
- if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
- goto out;
+ /* get the scale id for this REF */
+ if ((dsid_j = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ }
+ else {
+ /* get the reference */
+ ref = ((hobj_ref_t *)buf[idx].p)[j];
+ /* get the DS id */
+ if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
+ goto out;
+ }
/* get info for this DS */
if (H5Oget_info3(dsid_j, &tmp_oi, H5O_INFO_BASIC) < 0)
goto out;
@@ -708,8 +906,14 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
size_t len = buf[idx].len;
- if (j < len - 1)
- ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len - 1];
+ if (j < len - 1) {
+ if (is_new_ref) {
+ ((H5R_ref_t *)buf[idx].p)[j] = ((H5R_ref_t *)buf[idx].p)[len - 1];
+ }
+ else {
+ ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len - 1];
+ }
+ }
len = --buf[idx].len;
if (len == 0) {
HDfree(buf[idx].p);
@@ -770,7 +974,7 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
goto out;
/* get native type to read attribute REFERENCE_LIST */
- if ((ntid = H5DS_get_REFLIST_type()) < 0)
+ if ((ntid = H5Tget_native_type(tid, H5T_DIR_ASCEND)) < 0)
goto out;
/* get and save the old reference(s) */
@@ -780,22 +984,65 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
- dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
- if (dsbuf == NULL)
- goto out;
-
- if (H5Aread(aid, ntid, dsbuf) < 0)
- goto out;
-
+ if (is_new_ref) {
+ ndsbuf = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t));
+ if (ndsbuf == NULL)
+ goto out;
+ if (H5Aread(aid, ntid, ndsbuf) < 0)
+ goto out;
+ ndsbuf_w = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t));
+ if (ndsbuf_w == NULL)
+ goto out;
+ }
+ else {
+ dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
+ if (dsbuf == NULL)
+ goto out;
+ if (H5Aread(aid, ntid, dsbuf) < 0)
+ goto out;
+ dsbuf_w = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
+ if (dsbuf_w == NULL)
+ goto out;
+ }
+ /* Recreate the references we read from the existing "REFERENCE_LIST" attribute */
+ for (i = 0; i < nelmts; i++) {
+ if (is_new_ref) {
+ ndsbuf_w[i].dim_idx = ndsbuf[i].dim_idx;
+ tmp_id = H5Ropen_object(&ndsbuf[i].ref, H5P_DEFAULT, H5P_DEFAULT);
+ if (tmp_id < 0)
+ goto out;
+ if (H5Rcreate_object(tmp_id, ".", H5P_DEFAULT, &ndsbuf_w[i].ref) < 0) {
+ H5Dclose(tmp_id);
+ goto out;
+ }
+ H5Dclose(tmp_id);
+ }
+ else {
+ dsbuf_w[i] = dsbuf[i];
+ }
+ }
for (ii = 0; ii < nelmts; ii++) {
/* First check if we have the same dimension index */
- if (idx == dsbuf[ii].dim_idx) {
+ if (is_new_ref) {
+ tmp_idx = ndsbuf_w[ii].dim_idx;
+ }
+ else {
+ tmp_idx = dsbuf_w[ii].dim_idx;
+ }
+ if (idx == tmp_idx) {
/* get the reference to the dataset */
- ref = dsbuf[ii].ref;
-
- /* get the dataset id */
- if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
- goto out;
+ if (is_new_ref) {
+ /* get the dataset id */
+ nref = ndsbuf_w[ii].ref;
+ if ((did_i = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ }
+ else {
+ /* get the dataset id */
+ ref = dsbuf_w[ii].ref;
+ if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
+ goto out;
+ }
/* get info for this dataset */
if (H5Oget_info3(did_i, &tmp_oi, H5O_INFO_BASIC) < 0)
@@ -813,7 +1060,12 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
goto out;
if (!token_cmp) {
/* copy the last one to replace the one which is found */
- dsbuf[ii] = dsbuf[nelmts - 1];
+ if (is_new_ref) {
+ ndsbuf_w[ii] = ndsbuf_w[nelmts - 1];
+ }
+ else {
+ dsbuf_w[ii] = dsbuf_w[nelmts - 1];
+ }
nelmts--;
found_dset = 1;
break;
@@ -822,9 +1074,7 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
} /* if we have the same dimension index */
} /* ii */
- /* close space and attribute */
- if (H5Sclose(sid) < 0)
- goto out;
+ /* close attribute */
if (H5Aclose(aid) < 0)
goto out;
@@ -851,32 +1101,69 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
/* create a new data space for the new references array */
dims[0] = (hsize_t)nelmts;
- if ((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ if ((sid_w = H5Screate_simple(1, dims, NULL)) < 0)
goto out;
/* create the attribute again with the changes of space */
- if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid_w, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* write the new attribute with the new references */
- if (H5Awrite(aid, ntid, dsbuf) < 0)
- goto out;
+ if (is_new_ref) {
+ if (H5Awrite(aid, ntid, ndsbuf_w) < 0)
+ goto out;
+ }
+ else {
+ if (H5Awrite(aid, ntid, dsbuf_w) < 0)
+ goto out;
+ }
- /* close space and attribute */
- if (H5Sclose(sid) < 0)
- goto out;
if (H5Aclose(aid) < 0)
goto out;
} /* nelmts */
+ /* Free refrences */
+ if (is_new_ref) {
+ if (H5Treclaim(tid, sid, H5P_DEFAULT, ndsbuf) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+ if (sid_w > 0) {
+ if (H5Treclaim(tid, sid_w, H5P_DEFAULT, ndsbuf_w) < 0)
+ goto out;
+ if (H5Sclose(sid_w) < 0)
+ goto out;
+ }
+ }
+ else {
+ if (H5Treclaim(tid, sid, H5P_DEFAULT, dsbuf) < 0)
+ goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+ if (sid_w > 0) {
+ if (H5Treclaim(tid, sid_w, H5P_DEFAULT, dsbuf_w) < 0)
+ goto out;
+ if (H5Sclose(sid_w) < 0)
+ goto out;
+ }
+ }
/* close type */
if (H5Tclose(tid) < 0)
goto out;
if (H5Tclose(ntid) < 0)
goto out;
-
- HDfree(dsbuf);
- dsbuf = NULL;
+ if (is_new_ref) {
+ HDfree(ndsbuf);
+ HDfree(ndsbuf_w);
+ ndsbuf = NULL;
+ ndsbuf_w = NULL;
+ }
+ else {
+ HDfree(dsbuf);
+ HDfree(dsbuf_w);
+ dsbuf = NULL;
+ dsbuf_w = NULL;
+ }
return SUCCEED;
@@ -889,6 +1176,14 @@ out:
H5Tclose(ntid);
H5Tclose(tid);
+ if (ndsbuf) {
+ HDfree(ndsbuf);
+ ndsbuf = NULL;
+ }
+ if (ndsbuf_w) {
+ HDfree(ndsbuf_w);
+ ndsbuf_w = NULL;
+ }
if (dsbuf) {
HDfree(dsbuf);
dsbuf = NULL;
@@ -936,21 +1231,24 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
int has_dimlist;
int has_reflist;
hssize_t nelmts;
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t ntid = -1; /* attribute native type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
- hobj_ref_t ref; /* reference to the DS */
- hvl_t * buf = NULL; /* VL buffer to store in the attribute */
- hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
- hid_t did_i; /* dataset ID in REFERENCE_LIST */
+ hid_t sid; /* space ID */
+ hid_t tid = H5I_INVALID_HID; /* attribute type ID */
+ hid_t ntid = H5I_INVALID_HID; /* attribute native type ID */
+ hid_t aid = H5I_INVALID_HID; /* attribute ID */
+ int rank; /* rank of dataset */
+ nds_list_t *ndsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
+ ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */
+ H5R_ref_t nref; /* reference to the DS */
+ hobj_ref_t ref; /* reference to the DS */
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
+ hid_t did_i; /* dataset ID in REFERENCE_LIST */
H5O_info2_t oi1, oi2, oi3, oi4;
H5I_type_t it1, it2;
int i;
int found_dset = 0, found_ds = 0;
htri_t is_scale;
+ hbool_t is_new_ref;
/*-------------------------------------------------------------------------
* parameter checking
@@ -982,6 +1280,14 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
return FAIL;
} /* end if */
+ /*-------------------------------------------------------------------------
+ * determine if old or new references should be used
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5DSwith_new_ref(did, &is_new_ref) < 0)
+ return FAIL;
+
/* get ID type */
if ((it1 = H5Iget_type(did)) < 0)
return FAIL;
@@ -1042,12 +1348,22 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
/* iterate all the REFs in this dimension IDX */
for (i = 0; i < (int)buf[idx].len; i++) {
- /* get the reference */
- ref = ((hobj_ref_t *)buf[idx].p)[i];
+ if (is_new_ref) {
+ /* get the reference */
+ nref = ((H5R_ref_t *)buf[idx].p)[i];
- /* get the scale id for this REF */
- if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
- goto out;
+ /* get the scale id for this REF */
+ if ((dsid_j = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ }
+ else {
+ /* get the reference */
+ ref = ((hobj_ref_t *)buf[idx].p)[i];
+
+ /* get the scale id for this REF */
+ if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
+ goto out;
+ }
/* get info for DS in the parameter list */
if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0)
@@ -1107,7 +1423,7 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
goto out;
/* get native type to read REFERENCE_LIST attribute */
- if ((ntid = H5DS_get_REFLIST_type()) < 0)
+ if ((ntid = H5Tget_native_type(tid, H5T_DIR_ASCEND)) < 0)
goto out;
/* get and save the old reference(s) */
@@ -1117,13 +1433,20 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
- dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
-
- if (dsbuf == NULL)
- goto out;
-
- if (H5Aread(aid, ntid, dsbuf) < 0)
- goto out;
+ if (is_new_ref) {
+ ndsbuf = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t));
+ if (ndsbuf == NULL)
+ goto out;
+ if (H5Aread(aid, ntid, ndsbuf) < 0)
+ goto out;
+ }
+ else {
+ dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t));
+ if (dsbuf == NULL)
+ goto out;
+ if (H5Aread(aid, ntid, dsbuf) < 0)
+ goto out;
+ }
/*-------------------------------------------------------------------------
* iterate
@@ -1131,40 +1454,58 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
*/
for (i = 0; i < nelmts; i++) {
- /* get the reference */
- ref = dsbuf[i].ref;
- /* the reference was not deleted */
- if (ref) {
+ if (is_new_ref) {
+ nref = ndsbuf[i].ref;
+ /* get the dataset id */
+ if ((did_i = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ }
+ else {
+ ref = dsbuf[i].ref;
/* get the dataset id */
if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
goto out;
+ }
- /* get info for dataset in the parameter list */
- if (H5Oget_info3(did, &oi3, H5O_INFO_BASIC) < 0)
- goto out;
+ /* get info for dataset in the parameter list */
+ if (H5Oget_info3(did, &oi3, H5O_INFO_BASIC) < 0)
+ goto out;
- /* get info for this dataset */
- if (H5Oget_info3(did_i, &oi4, H5O_INFO_BASIC) < 0)
- goto out;
+ /* get info for this dataset */
+ if (H5Oget_info3(did_i, &oi4, H5O_INFO_BASIC) < 0)
+ goto out;
- /* same object */
- if (oi3.fileno == oi4.fileno) {
- int token_cmp;
+ /* same object */
+ if (oi3.fileno == oi4.fileno) {
+ int token_cmp;
- if (H5Otoken_cmp(did, &oi3.token, &oi4.token, &token_cmp) < 0)
- goto out;
+ if (H5Otoken_cmp(did, &oi3.token, &oi4.token, &token_cmp) < 0)
+ goto out;
+ if (is_new_ref) {
+ if (!token_cmp && (idx == ndsbuf[i].dim_idx))
+ found_dset = 1;
+ }
+ else {
if (!token_cmp && (idx == dsbuf[i].dim_idx))
found_dset = 1;
- } /* end if */
+ }
+ } /* end if */
- /* close the dereferenced dataset */
- if (H5Dclose(did_i) < 0)
- goto out;
- } /* if */
- } /* i */
+ /* close the dereferenced dataset */
+ if (H5Dclose(did_i) < 0)
+ goto out;
+ } /* for */
/* close */
+ if (is_new_ref) {
+ if (H5Treclaim(ntid, sid, H5P_DEFAULT, ndsbuf) < 0)
+ goto out;
+ }
+ else {
+ if (H5Treclaim(ntid, sid, H5P_DEFAULT, dsbuf) < 0)
+ goto out;
+ }
if (H5Sclose(sid) < 0)
goto out;
if (H5Tclose(ntid) < 0)
@@ -1174,8 +1515,14 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
if (H5Aclose(aid) < 0)
goto out;
- HDfree(dsbuf);
- dsbuf = NULL;
+ if (ndsbuf) {
+ HDfree(ndsbuf);
+ ndsbuf = NULL;
+ }
+ if (dsbuf) {
+ HDfree(dsbuf);
+ dsbuf = NULL;
+ }
} /* has_reflist */
if (found_ds && found_dset)
@@ -1198,6 +1545,10 @@ out:
HDfree(buf);
buf = NULL;
}
+ if (ndsbuf) {
+ HDfree(ndsbuf);
+ ndsbuf = NULL;
+ }
if (dsbuf) {
HDfree(dsbuf);
dsbuf = NULL;
@@ -1249,17 +1600,19 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visi
{
hid_t scale_id;
int rank;
- hobj_ref_t ref; /* reference to the DS */
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- hvl_t * buf = NULL; /* VL buffer to store in the attribute */
- H5I_type_t it; /* ID type */
+ H5R_ref_t nref; /* reference to the DS */
+ hobj_ref_t ref; /* reference to the DS */
+ hid_t sid; /* space ID */
+ hid_t tid = H5I_INVALID_HID; /* attribute type ID */
+ hid_t aid = H5I_INVALID_HID; /* attribute ID */
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ H5I_type_t it; /* ID type */
herr_t ret_value = 0;
int j_idx;
int nscales;
int has_dimlist;
int i;
+ hbool_t is_new_ref;
/*-------------------------------------------------------------------------
* parameter checking
@@ -1272,6 +1625,14 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visi
if (H5I_DATASET != it)
return FAIL;
+ /*-------------------------------------------------------------------------
+ * determine if old or new references should be used
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5DSwith_new_ref(did, &is_new_ref) < 0)
+ return FAIL;
+
/* get the number of scales assotiated with this DIM */
if ((nscales = H5DSget_num_scales(did, dim)) < 0)
return FAIL;
@@ -1330,17 +1691,32 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visi
/* iterate */
for (i = j_idx; i < nscales; i++) {
- /* get the reference */
- ref = ((hobj_ref_t *)buf[dim].p)[i];
-
- /* disable error reporting, the ID might refer to a deleted dataset */
- H5E_BEGIN_TRY
- {
- /* get the DS id */
- if ((scale_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
- goto out;
+ if (is_new_ref) {
+ /* get the reference */
+ nref = ((H5R_ref_t *)buf[dim].p)[i];
+
+ /* disable error reporting, the ID might refer to a deleted dataset */
+ H5E_BEGIN_TRY
+ {
+ /* get the DS id */
+ if ((scale_id = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ }
+ H5E_END_TRY;
+ }
+ else {
+ /* get the reference */
+ ref = ((hobj_ref_t *)buf[dim].p)[i];
+
+ /* disable error reporting, the ID might refer to a deleted dataset */
+ H5E_BEGIN_TRY
+ {
+ /* get the DS id */
+ if ((scale_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0)
+ goto out;
+ }
+ H5E_END_TRY;
}
- H5E_END_TRY;
/* set the return IDX OUT value at current scale index */
if (ds_idx != NULL) {
@@ -1413,12 +1789,12 @@ herr_t
H5DSset_label(hid_t did, unsigned int idx, const char *label)
{
int has_labels;
- hid_t sid = -1; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- hsize_t dims[1]; /* dimensions of dataset */
- H5I_type_t it; /* ID type */
+ hid_t sid = H5I_INVALID_HID; /* space ID */
+ hid_t tid = H5I_INVALID_HID; /* attribute type ID */
+ hid_t aid = H5I_INVALID_HID; /* attribute ID */
+ int rank; /* rank of dataset */
+ hsize_t dims[1]; /* dimensions of dataset */
+ H5I_type_t it; /* ID type */
unsigned int i;
union { /* union is needed to eliminate compiler warnings about */
char ** buf; /* discarding the 'const' qualifier in the free */
@@ -1616,12 +1992,12 @@ ssize_t
H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
{
int has_labels;
- hid_t sid = -1; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- char ** buf = NULL; /* buffer to store in the attribute */
- H5I_type_t it; /* ID type */
+ hid_t sid = H5I_INVALID_HID; /* space ID */
+ hid_t tid = H5I_INVALID_HID; /* attribute type ID */
+ hid_t aid = H5I_INVALID_HID; /* attribute ID */
+ int rank; /* rank of dataset */
+ char ** buf = NULL; /* buffer to store in the attribute */
+ H5I_type_t it; /* ID type */
size_t nbytes = 0;
size_t copy_len;
int i;
@@ -1764,10 +2140,10 @@ out:
ssize_t
H5DSget_scale_name(hid_t did, char *name, size_t size)
{
- hid_t aid; /* attribute ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t sid; /* space ID */
- H5I_type_t it; /* ID type */
+ hid_t aid = H5I_INVALID_HID; /* attribute ID */
+ hid_t tid = H5I_INVALID_HID; /* attribute type ID */
+ hid_t sid = H5I_INVALID_HID; /* space ID */
+ H5I_type_t it; /* ID type */
size_t nbytes;
size_t copy_len;
int has_name;
@@ -1881,13 +2257,13 @@ out:
htri_t
H5DSis_scale(hid_t did)
{
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- herr_t attr_class; /* has the "CLASS" attribute */
- htri_t is_ds = -1; /* set to "not a dimension scale" */
- H5I_type_t it; /* type of identifier */
- char * buf = NULL; /* buffer to read name of attribute */
- size_t string_size; /* size of storage for the attribute */
+ hid_t tid = H5I_INVALID_HID; /* attribute type ID */
+ hid_t aid = H5I_INVALID_HID; /* attribute ID */
+ herr_t attr_class; /* has the "CLASS" attribute */
+ htri_t is_ds = -1; /* set to "not a dimension scale" */
+ H5I_type_t it; /* type of identifier */
+ char * buf = NULL; /* buffer to read name of attribute */
+ size_t string_size; /* size of storage for the attribute */
H5T_class_t type_class;
H5T_str_t strpad;
@@ -1995,12 +2371,12 @@ int
H5DSget_num_scales(hid_t did, unsigned int idx)
{
int has_dimlist;
- hid_t sid; /* space ID */
- hid_t tid = -1; /* attribute type ID */
- hid_t aid = -1; /* attribute ID */
- int rank; /* rank of dataset */
- hvl_t * buf = NULL; /* VL buffer to store in the attribute */
- H5I_type_t it; /* ID type */
+ hid_t sid; /* space ID */
+ hid_t tid = H5I_INVALID_HID; /* attribute type ID */
+ hid_t aid = H5I_INVALID_HID; /* attribute ID */
+ int rank; /* rank of dataset */
+ hvl_t * buf = NULL; /* VL buffer to store in the attribute */
+ H5I_type_t it; /* ID type */
int nscales;
/*-------------------------------------------------------------------------
@@ -2112,12 +2488,12 @@ out:
static herr_t
H5DS_is_reserved(hid_t did)
{
- int has_class;
- hid_t tid = -1;
- hid_t aid = -1;
- char * buf; /* Name of attribute */
- hsize_t storage_size; /* Size of storage for attribute */
- herr_t ret;
+ int has_class;
+ hid_t tid = H5I_INVALID_HID;
+ hid_t aid = H5I_INVALID_HID;
+ char * buf = NULL; /* Name of attribute */
+ size_t string_size; /* Size of storage for attribute */
+ herr_t ret;
/* try to find the attribute "CLASS" on the dataset */
if ((has_class = H5LT_find_attribute(did, "CLASS")) < 0)
@@ -2142,10 +2518,10 @@ H5DS_is_reserved(hid_t did)
goto out;
/* allocate buffer large enough to hold string */
- if ((storage_size = H5Aget_storage_size(aid)) == 0)
+ if ((string_size = H5Tget_size(tid)) == 0)
goto out;
- buf = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1);
+ buf = (char *)HDmalloc((size_t)string_size * sizeof(char));
if (buf == NULL)
goto out;
@@ -2174,51 +2550,11 @@ H5DS_is_reserved(hid_t did)
out:
H5E_BEGIN_TRY
{
+ if (buf)
+ HDfree(buf);
H5Tclose(tid);
H5Aclose(aid);
}
H5E_END_TRY;
return FAIL;
}
-
-/*-------------------------------------------------------------------------
- * Function: H5DS_get_REFLIST_type
- *
- * Purpose: This is a helper function to return a native type for
- * the REFERENCE_LIST attribute.
- *
- * Return: Type identifier on success and negative on failure
- *
- * Programmer: Elena Pourmal
- *
- * Date: May 22, 2010
- *
- *-------------------------------------------------------------------------
- */
-static hid_t
-H5DS_get_REFLIST_type(void)
-{
- hid_t ntid_t = -1;
-
- /* Build native type that corresponds to compound datatype
- used to store ds_list_t structure in the REFERENCE_LIST
- attribute */
-
- if ((ntid_t = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0)
- goto out;
-
- if (H5Tinsert(ntid_t, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0)
- goto out;
-
- if (H5Tinsert(ntid_t, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0)
- goto out;
-
- return ntid_t;
-out:
- H5E_BEGIN_TRY
- {
- H5Tclose(ntid_t);
- }
- H5E_END_TRY;
- return FAIL;
-}
diff --git a/hl/src/H5DSprivate.h b/hl/src/H5DSprivate.h
index 0403a4c..ede0209 100644
--- a/hl/src/H5DSprivate.h
+++ b/hl/src/H5DSprivate.h
@@ -20,12 +20,18 @@
/* public LT prototypes */
#include "H5DSpublic.h"
-/* attribute type of a DS dataset */
+/* attribute type of a DS dataset when old references are used*/
typedef struct ds_list_t {
hobj_ref_t ref; /* object reference */
unsigned int dim_idx; /* dimension index of the dataset */
} ds_list_t;
+/* attribute type of a DS dataset when new references are used*/
+typedef struct nds_list_t {
+ H5R_ref_t ref;
+ unsigned int dim_idx; /* dimension index of the dataset */
+} nds_list_t;
+
/*-------------------------------------------------------------------------
* private functions
*-------------------------------------------------------------------------
diff --git a/hl/src/H5DSpublic.h b/hl/src/H5DSpublic.h
index 7306cbc..979a173 100644
--- a/hl/src/H5DSpublic.h
+++ b/hl/src/H5DSpublic.h
@@ -25,6 +25,8 @@ typedef herr_t (*H5DS_iterate_t)(hid_t dset, unsigned dim, hid_t scale, void *vi
extern "C" {
#endif
+H5_HLDLL herr_t H5DSwith_new_ref(hid_t obj_id, hbool_t *with_new_ref);
+
H5_HLDLL herr_t H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx);
H5_HLDLL herr_t H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx);
diff --git a/hl/src/H5LD.c b/hl/src/H5LD.c
index 8bfd0d6..2368127 100644
--- a/hl/src/H5LD.c
+++ b/hl/src/H5LD.c
@@ -29,9 +29,9 @@ static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsi
* Function: H5LD_clean_vector
*
* Purpose: Process the vector of info:
- * 1) free the array of pointers to member names in listv[n]
- * 2) close the type id of the last member in listv[n]
- * 3) free the H5LD_memb_t structure itself as pointed to by listv[n]
+ * 1) free the array of pointers to member names in listv[n]
+ * 2) close the type id of the last member in listv[n]
+ * 3) free the H5LD_memb_t structure itself as pointed to by listv[n]
*
* Return: void
*
@@ -69,12 +69,12 @@ H5LD_clean_vector(H5LD_memb_t *listv[])
* Function: H5LD_construct_info()
*
* Purpose: Get the remaining info for a field:
- * 1) Get the type id of the last member in the field
- * 2) Get the total offset of all the members in the field
- * 3) Get the type size of the last member in the field
+ * 1) Get the type id of the last member in the field
+ * 2) Get the total offset of all the members in the field
+ * 3) Get the type size of the last member in the field
*
* Return: Success: 0
- * Failure: negative
+ * Failure: negative
*
* Programmer: Vailin Choi; Aug 2010
*
@@ -129,24 +129,24 @@ done:
* Function: H5LD_construct_vector
*
* Purpose: Process the comma-separated list of fields in "fields" as follows:
- * Example:
- * "fields": "a.b.c,d"
- * listv[0]->tot_offset = total offset of "a" & "b" & "c"
- * listv[0]->last_tid = type id of "c"
- * listv[0]->last_tsize = type size of "c"
- * listv[0]->names[0] = "a"
- * listv[0]->names[1] = "b"
- * listv[0]->names[2] = "c"
- * listv[0]->names[3] = NULL
- *
- * listv[1]->tot_offset = offset of "d"
- * listv[1]->last_tid = type id of "d"
- * listv[1]->last_tsize = type size of "d"
- * listv[1]->names[0] = "d"
- * listv[1]->names[1] = NULL
+ * Example:
+ * "fields": "a.b.c,d"
+ * listv[0]->tot_offset = total offset of "a" & "b" & "c"
+ * listv[0]->last_tid = type id of "c"
+ * listv[0]->last_tsize = type size of "c"
+ * listv[0]->names[0] = "a"
+ * listv[0]->names[1] = "b"
+ * listv[0]->names[2] = "c"
+ * listv[0]->names[3] = NULL
+ *
+ * listv[1]->tot_offset = offset of "d"
+ * listv[1]->last_tid = type id of "d"
+ * listv[1]->last_tsize = type size of "d"
+ * listv[1]->names[0] = "d"
+ * listv[1]->names[1] = NULL
*
* Return: Success: # of comma-separated fields in "fields"
- * Failure: negative value
+ * Failure: negative value
*
* Programmer: Vailin Choi; Aug 2010
*
@@ -251,8 +251,10 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[] /*OUT*/, hid_t par_tid)
goto done;
} /* end if */
else {
- if (memb)
+ if (memb) {
+ HDfree(memb->names);
HDfree(memb);
+ }
goto done;
} /* end else */
} /* while !end_of_fields */
@@ -272,10 +274,10 @@ done:
* Function: H5LD_get_dset_dims
*
* Purpose: To return the current size for each dimension of the
- * dataset's dataspace
+ * dataset's dataspace
*
* Return: Success: 0
- * Failure: negative value
+ * Failure: negative value
*
* Programmer: Vailin Choi; March 2010
*
@@ -316,12 +318,12 @@ done:
* Function: H5LD_get_dset_type_size
*
* Purpose: To return the size of the dataset's datatype in bytes
- * null "fields": return the size of the dataset's datatype
- * non-null "fields": return the size of the dataset's datatype
- * with respect to the selection in "fields"
+ * null "fields": return the size of the dataset's datatype
+ * non-null "fields": return the size of the dataset's datatype
+ * with respect to the selection in "fields"
*
* Return: Success: size of the dataset's datatype
- * Failure: 0 (valid datatypes are never zero size)
+ * Failure: 0 (valid datatypes are never zero size)
*
* Programmer: Vailin Choi; March 2010
*
@@ -402,7 +404,7 @@ done:
* Purpose: To retrieve selected data from the dataset
*
* Return: Success: 0
- * Failure: negative
+ * Failure: negative
*
* Programmer: Vailin Choi; August 2010
*
@@ -578,7 +580,7 @@ done:
* Purpose: To retrieve the current dimension sizes for a dataset
*
* Return: Success: 0
- * Failure: negative value
+ * Failure: negative value
*
* Programmer: Vailin Choi; March 2010
*
@@ -596,7 +598,7 @@ H5LDget_dset_dims(hid_t did, hsize_t *cur_dims)
* Purpose: To return the size in bytes of the datatype for the dataset
*
* Return: Success: size in bytes of the dataset's datatype
- * Failure: 0 (valid datatypes are never zero size)
+ * Failure: 0 (valid datatypes are never zero size)
*
* Programmer: Vailin Choi; March 2010
*
@@ -614,7 +616,7 @@ H5LDget_dset_type_size(hid_t did, const char *fields)
* Purpose: To retrieve selected data from the dataset
*
* Return: Success: 0
- * Failure: negative value
+ * Failure: negative value
*
* Programmer: Vailin Choi; March 2010
*
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index 1ef0f9d..238bbf2 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -1352,13 +1352,13 @@ find_dataset(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const
* modify the op_data buffer (i.e.: dset_name) during the traversal, and the
* library never modifies that buffer.
*/
-H5_GCC_DIAG_OFF("cast-qual")
+H5_GCC_CLANG_DIAG_OFF("cast-qual")
herr_t
H5LTfind_dataset(hid_t loc_id, const char *dset_name)
{
return H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name);
}
-H5_GCC_DIAG_ON("cast-qual")
+H5_GCC_CLANG_DIAG_ON("cast-qual")
/*-------------------------------------------------------------------------
*
@@ -1776,34 +1776,33 @@ H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_nam
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_float
+ * Function: H5LTset_attribute_ullong
*
* Purpose: Create and write an attribute.
*
* Return: Success: 0, Failure: -1
*
- * Programmer: Pedro Vicente
+ * Programmer: Alessandro Felder
*
- * Date: July 25, 2001
+ * Date: August 27, 2021
*
* Comments:
*
*-------------------------------------------------------------------------
*/
-
herr_t
-H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *data,
- size_t size)
+H5LTset_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const unsigned long long *data, size_t size)
{
- if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_FLOAT, data) < 0)
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULLONG, data) < 0)
return -1;
return 0;
}
/*-------------------------------------------------------------------------
- * Function: H5LTset_attribute_double
+ * Function: H5LTset_attribute_float
*
* Purpose: Create and write an attribute.
*
@@ -1811,7 +1810,7 @@ H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_nam
*
* Programmer: Pedro Vicente
*
- * Date: November 7, 2001
+ * Date: July 25, 2001
*
* Comments:
*
@@ -1819,54 +1818,41 @@ H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_nam
*/
herr_t
-H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, const double *data,
- size_t size)
+H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *data,
+ size_t size)
{
- if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_DOUBLE, data) < 0)
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_FLOAT, data) < 0)
return -1;
return 0;
}
/*-------------------------------------------------------------------------
- * Function: find_attr
+ * Function: H5LTset_attribute_double
*
- * Purpose: operator function used by H5LT_find_attribute
+ * Purpose: Create and write an attribute.
+ *
+ * Return: Success: 0, Failure: -1
*
* Programmer: Pedro Vicente
*
- * Date: June 21, 2001
+ * Date: November 7, 2001
*
* Comments:
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-static herr_t
-find_attr(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5A_info_t *ainfo,
- void *op_data)
-{
- int ret = H5_ITER_CONT;
-
- /* check the arguments */
- if (name == NULL)
- return H5_ITER_CONT;
- /* Shut compiler up */
- (void)loc_id;
- (void)ainfo;
-
- /* Define a positive value for return value if the attribute was found. This will
- * cause the iterator to immediately return that positive value,
- * indicating short-circuit success
- */
+herr_t
+H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, const double *data,
+ size_t size)
+{
- if (HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data), HDstrlen(name))) == 0)
- ret = H5_ITER_STOP;
+ if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_DOUBLE, data) < 0)
+ return -1;
- return ret;
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -1900,32 +1886,22 @@ H5LTfind_attribute(hid_t loc_id, const char *attr_name)
*
* Date: June 21, 2001
*
- * Comments:
- * The function uses H5Aiterate2 with the operator function find_attr
- *
* Return:
- * Success: The return value of the first operator that
- * returns non-zero, or zero if all members were
- * processed with no operator returning non-zero.
+ * Success: Positive if the attribute exists attached to the
+ * object loc_id. Zero if the attribute does not
+ * exist attached to the object loc_id.
*
* Failure: Negative if something goes wrong within the
- * library, or the negative value returned by one
- * of the operators.
+ * library.
*
*-------------------------------------------------------------------------
*/
-/* H5Aiterate wants a non-const pointer but we have a const pointer in the API
- * call. It's safe to ignore this because we control the callback, don't
- * modify the op_data buffer (i.e.: attr_name) during the traversal, and the
- * library never modifies that buffer.
- */
-H5_GCC_DIAG_OFF("cast-qual")
herr_t
H5LT_find_attribute(hid_t loc_id, const char *attr_name)
{
- return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name);
+ htri_t attr_exists = H5Aexists(loc_id, attr_name);
+ return (attr_exists < 0) ? (herr_t)-1 : (attr_exists) ? (herr_t)1 : (herr_t)0;
}
-H5_GCC_DIAG_ON("cast-qual")
/*-------------------------------------------------------------------------
* Function: H5LTget_attribute_ndims
@@ -2180,7 +2156,7 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str
*/
if (size_str < *len - 1) {
if (size_str + size_str_to_add < *len - 1) {
- HDstrncat(buf, str_to_add, size_str_to_add);
+ HDstrcat(buf, str_to_add);
}
else {
HDstrncat(buf, str_to_add, (*len - 1) - size_str);
@@ -2553,11 +2529,9 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb
}
else if (H5Tequal(dtype, H5T_NATIVE_DOUBLE)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_DOUBLE");
-#if H5_SIZEOF_LONG_DOUBLE != 0
}
else if (H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) {
HDsnprintf(dt_str, *slen, "H5T_NATIVE_LDOUBLE");
-#endif
}
else {
HDsnprintf(dt_str, *slen, "undefined float");
@@ -3317,6 +3291,33 @@ H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_nam
}
/*-------------------------------------------------------------------------
+ * Function: H5LTget_attribute_ullong
+ *
+ * Purpose: Reads an attribute named attr_name
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Alessandro Felder
+ *
+ * Date: August 27, 2021
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5LTget_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long long *data)
+{
+ /* Get the attribute */
+ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULLONG, data) < 0)
+ return -1;
+
+ return 0;
+}
+
+/*-------------------------------------------------------------------------
* Function: H5LTget_attribute_float
*
* Purpose: Reads an attribute named attr_name
diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h
index 2af9b07..f19d353 100644
--- a/hl/src/H5LTpublic.h
+++ b/hl/src/H5LTpublic.h
@@ -139,6 +139,9 @@ H5_HLDLL herr_t H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name,
H5_HLDLL herr_t H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name,
const unsigned long *buffer, size_t size);
+H5_HLDLL herr_t H5LTset_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name,
+ const unsigned long long *buffer, size_t size);
+
H5_HLDLL herr_t H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name,
const float *buffer, size_t size);
@@ -182,6 +185,9 @@ H5_HLDLL herr_t H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name,
H5_HLDLL herr_t H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name,
unsigned long *data);
+H5_HLDLL herr_t H5LTget_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name,
+ unsigned long long *data);
+
H5_HLDLL herr_t H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name,
float *data);
diff --git a/hl/test/CMakeTests.cmake b/hl/test/CMakeTests.cmake
index 44208e3..e532253 100644
--- a/hl/test/CMakeTests.cmake
+++ b/hl/test/CMakeTests.cmake
@@ -31,7 +31,9 @@ set (HL_REFERENCE_TEST_FILES
dslat.txt
dslon.txt
test_ds_be.h5
+ test_ds_be_new_ref.h5
test_ds_le.h5
+ test_ds_le_new_ref.h5
test_ld.h5
)
diff --git a/hl/test/gen_test_ds.c b/hl/test/gen_test_ds.c
index 368c083..d7a9f44 100644
--- a/hl/test/gen_test_ds.c
+++ b/hl/test/gen_test_ds.c
@@ -63,7 +63,11 @@ static int test_foreign_scaleattached(const char *filename);
#define SCALE_4_NAME "scalename_4_"
#define FILENAME "test_ds_"
-#define FILEEXT ".h5"
+#ifdef H5_DIMENSION_SCALES_WITH_NEW_REF
+#define FILEEXT "_new_ref.h5"
+#else
+#define FILEEXT ".h5"
+#endif
/*-------------------------------------------------------------------------
* the main program
@@ -75,7 +79,7 @@ main(int argc, char **argv)
int nerrors = 0;
char filename[65];
- if (argc < 2) {
+ if (argc < 2 || !argv[0] || !argv[1]) {
HDprintf("Usage: gen_test [le | be]\n");
return 1;
}
diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c
index 8c6ef91..c66ef49 100644
--- a/hl/test/test_ds.c
+++ b/hl/test/test_ds.c
@@ -137,10 +137,15 @@ static int test_attach_detach(void);
#define DIM0_LABEL "Latitude"
#define DIM1_LABEL "Longitude"
+#ifdef H5_DIMENSION_SCALES_WITH_NEW_REF
+#define FOREIGN_FILE1 "test_ds_le_new_ref.h5"
+#define FOREIGN_FILE2 "test_ds_be_new_ref.h5"
+#else
#define FOREIGN_FILE1 "test_ds_le.h5"
#define FOREIGN_FILE2 "test_ds_be.h5"
-#define FILENAME "test_ds"
-#define FILEEXT ".h5"
+#endif
+#define FILENAME "test_ds"
+#define FILEEXT ".h5"
#define FILE1 "test_ds3.h5"
#define FILE2 "test_ds4.h5"
@@ -161,10 +166,15 @@ static int test_attach_detach(void);
int
main(void)
{
- int nerrors = 0;
+ hid_t file_id = H5I_INVALID_HID;
+ int nerrors = 0;
/* create file to be used in following tests */
- if (create_test_file("1") < 0) {
+ if ((file_id = create_test_file("1")) < 0) {
+ nerrors = 1;
+ goto error;
+ }
+ if (H5Fclose(file_id) < 0) {
nerrors = 1;
goto error;
}
@@ -179,7 +189,11 @@ main(void)
nerrors += test_long_scalenames("1") < 0 ? 1 : 0;
nerrors += test_float_scalenames("1") < 0 ? 1 : 0;
nerrors += test_numberofscales("1") < 0 ? 1 : 0;
- if (create_test_file("2") < 0) {
+ if ((file_id = create_test_file("2")) < 0) {
+ nerrors = 1;
+ goto error;
+ }
+ if (H5Fclose(file_id) < 0) {
nerrors = 1;
goto error;
}
@@ -254,10 +268,9 @@ open_test_file(const char *fileext)
herr_t
create_char_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = 3;
- int rankds = 1;
- hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE};
- char buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE];
+ int rank = 3;
+ int rankds = 1;
+ hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE};
hsize_t s1_dim[1] = {DIM1_SIZE};
hsize_t s2_dim[1] = {DIM2_SIZE};
hsize_t s3_dim[1] = {DIM3_SIZE};
@@ -275,7 +288,7 @@ create_char_dataset(hid_t fid, const char *dsidx, int fulldims)
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if (H5LTmake_dataset_char(fid, name, rank, dims, buf) >= 0) {
+ if (H5LTmake_dataset_char(fid, name, rank, dims, NULL) >= 0) {
if (fulldims == 0) {
/* make a DS dataset for the first dimension */
if (create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
@@ -309,10 +322,9 @@ create_char_dataset(hid_t fid, const char *dsidx, int fulldims)
herr_t
create_short_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = 3;
- int rankds = 1;
- hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE};
- short buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE];
+ int rank = 3;
+ int rankds = 1;
+ hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE};
hsize_t s1_dim[1] = {DIM1_SIZE};
hsize_t s2_dim[1] = {DIM2_SIZE};
hsize_t s3_dim[1] = {DIM3_SIZE};
@@ -330,7 +342,7 @@ create_short_dataset(hid_t fid, const char *dsidx, int fulldims)
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if (H5LTmake_dataset_short(fid, name, rank, dims, buf) >= 0) {
+ if (H5LTmake_dataset_short(fid, name, rank, dims, NULL) >= 0) {
if (fulldims == 0) {
/* make a DS dataset for the first dimension */
if (create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
@@ -364,10 +376,9 @@ create_short_dataset(hid_t fid, const char *dsidx, int fulldims)
herr_t
create_int_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = RANK;
- int rankds = 1;
- hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
- int buf[DIM1_SIZE * DIM2_SIZE];
+ int rank = RANK;
+ int rankds = 1;
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
hsize_t s1_dim[1] = {DIM1_SIZE};
hsize_t s2_dim[1] = {DIM2_SIZE};
int s1_wbuf[DIM1_SIZE] = {10, 20, 30};
@@ -380,7 +391,7 @@ create_int_dataset(hid_t fid, const char *dsidx, int fulldims)
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if (H5LTmake_dataset_int(fid, name, rank, dims, buf) >= 0) {
+ if (H5LTmake_dataset_int(fid, name, rank, dims, NULL) >= 0) {
if (fulldims == 0) {
/* make a DS dataset for the first dimension */
if (create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
@@ -409,7 +420,6 @@ create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldi
int rank = 4;
int rankds = 1;
hsize_t dims[4] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE, DIM4_SIZE};
- long * buf = NULL;
hsize_t s1_dim[1] = {DIM1_SIZE};
hsize_t s2_dim[1] = {DIM2_SIZE};
hsize_t s3_dim[1] = {DIM3_SIZE};
@@ -429,12 +439,8 @@ create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldi
long s43_wbuf[DIM4_SIZE] = {180, 180};
long s44_wbuf[DIM4_SIZE] = {280, 280};
- /* Allocate buffer */
- if (NULL == (buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE)))
- goto error;
-
/* make a dataset */
- if (H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) {
+ if (H5LTmake_dataset_long(fid, dsname, rank, dims, NULL) >= 0) {
if (fulldims == 0) {
/* make a DS dataset for the first dimension */
if (create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
@@ -471,23 +477,18 @@ create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldi
else
goto error;
- HDfree(buf);
-
return SUCCEED;
error:
- HDfree(buf);
-
return FAIL;
}
herr_t
create_float_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = RANK;
- int rankds = 1;
- hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
- float buf[DIM1_SIZE * DIM2_SIZE];
+ int rank = RANK;
+ int rankds = 1;
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
hsize_t s1_dim[1] = {DIM1_SIZE};
hsize_t s2_dim[1] = {DIM2_SIZE};
float s1_wbuf[DIM1_SIZE] = {10, 20, 30};
@@ -500,7 +501,7 @@ create_float_dataset(hid_t fid, const char *dsidx, int fulldims)
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if (H5LTmake_dataset_float(fid, name, rank, dims, buf) >= 0) {
+ if (H5LTmake_dataset_float(fid, name, rank, dims, NULL) >= 0) {
if (fulldims == 0) {
/* make a DS dataset for the first dimension */
if (create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
@@ -5210,6 +5211,8 @@ test_attach_detach(void)
HL_TESTING2("permutations of attaching and detaching");
+ gid = var1_id = var2_id = var3_id = H5I_INVALID_HID;
+
if ((fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
diff --git a/hl/test/test_ds_be_new_ref-32bit.h5 b/hl/test/test_ds_be_new_ref-32bit.h5
new file mode 100644
index 0000000..ee327e9
--- /dev/null
+++ b/hl/test/test_ds_be_new_ref-32bit.h5
Binary files differ
diff --git a/hl/test/test_ds_be_new_ref.h5 b/hl/test/test_ds_be_new_ref.h5
new file mode 100644
index 0000000..eddfa02
--- /dev/null
+++ b/hl/test/test_ds_be_new_ref.h5
Binary files differ
diff --git a/hl/test/test_ds_le_new_ref.h5 b/hl/test/test_ds_le_new_ref.h5
new file mode 100644
index 0000000..8625d77
--- /dev/null
+++ b/hl/test/test_ds_le_new_ref.h5
Binary files differ
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index cae91ff..53f834a 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -43,8 +43,9 @@
#define ATTR7_NAME "attr ushort"
#define ATTR8_NAME "attr uint"
#define ATTR9_NAME "attr ulong"
-#define ATTR10_NAME "attr float"
-#define ATTR11_NAME "attr double"
+#define ATTR10_NAME "attr ullong"
+#define ATTR11_NAME "attr float"
+#define ATTR12_NAME "attr double"
static herr_t make_attributes(hid_t loc_id, const char *obj_name);
@@ -472,28 +473,30 @@ make_attributes(hid_t loc_id, const char *obj_name)
size_t type_size;
int i;
- char attr_str_in[] = {"My attribute"};
- char attr_str_out[20];
- char attr_char_in[5] = {1, 2, 3, 4, 5};
- char attr_char_out[5];
- short attr_short_in[5] = {1, 2, 3, 4, 5};
- short attr_short_out[5];
- int attr_int_in[5] = {1, 2, 3, 4, 5};
- int attr_int_out[5];
- long attr_long_in[5] = {1, 2, 3, 4, 5};
- long attr_long_out[5];
- float attr_float_in[5] = {1, 2, 3, 4, 5};
- float attr_float_out[5];
- double attr_double_in[5] = {1, 2, 3, 4, 5};
- double attr_double_out[5];
- unsigned char attr_uchar_in[5] = {1, 2, 3, 4, 5};
- unsigned char attr_uchar_out[5];
- unsigned short attr_ushort_in[5] = {1, 2, 3, 4, 5};
- unsigned short attr_ushort_out[5];
- unsigned int attr_uint_in[5] = {1, 2, 3, 4, 5};
- unsigned int attr_uint_out[5];
- unsigned long attr_ulong_in[5] = {1, 2, 3, 4, 5};
- unsigned long attr_ulong_out[5];
+ char attr_str_in[] = {"My attribute"};
+ char attr_str_out[20];
+ char attr_char_in[5] = {1, 2, 3, 4, 5};
+ char attr_char_out[5];
+ short attr_short_in[5] = {1, 2, 3, 4, 5};
+ short attr_short_out[5];
+ int attr_int_in[5] = {1, 2, 3, 4, 5};
+ int attr_int_out[5];
+ long attr_long_in[5] = {1, 2, 3, 4, 5};
+ long attr_long_out[5];
+ float attr_float_in[5] = {1, 2, 3, 4, 5};
+ float attr_float_out[5];
+ double attr_double_in[5] = {1, 2, 3, 4, 5};
+ double attr_double_out[5];
+ unsigned char attr_uchar_in[5] = {1, 2, 3, 4, 5};
+ unsigned char attr_uchar_out[5];
+ unsigned short attr_ushort_in[5] = {1, 2, 3, 4, 5};
+ unsigned short attr_ushort_out[5];
+ unsigned int attr_uint_in[5] = {1, 2, 3, 4, 5};
+ unsigned int attr_uint_out[5];
+ unsigned long attr_ulong_in[5] = {1, 2, 3, 4, 5};
+ unsigned long attr_ulong_out[5];
+ unsigned long long attr_ullong_in[5] = {1, 2, 3, 4, 5};
+ unsigned long long attr_ullong_out[5];
/*-------------------------------------------------------------------------
* H5LTset_attribute_string test
@@ -509,7 +512,7 @@ make_attributes(hid_t loc_id, const char *obj_name)
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_string test
+ * H5LTget_attribute_string test
*-------------------------------------------------------------------------
*/
@@ -859,7 +862,7 @@ make_attributes(hid_t loc_id, const char *obj_name)
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_long test
+ * H5LTget_attribute_ulong test
*-------------------------------------------------------------------------
*/
@@ -888,6 +891,48 @@ make_attributes(hid_t loc_id, const char *obj_name)
PASSED();
/*-------------------------------------------------------------------------
+ * H5LTset_attribute_ullong test
+ *-------------------------------------------------------------------------
+ */
+
+ HL_TESTING2("H5LTset_attribute_ullong");
+
+ /* Set the attribute */
+ if (H5LTset_attribute_ullong(loc_id, obj_name, ATTR10_NAME, attr_ullong_in, (size_t)5) < 0)
+ return -1;
+
+ PASSED();
+
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_ullong test
+ *-------------------------------------------------------------------------
+ */
+
+ HL_TESTING2("H5LTget_attribute_ullong");
+
+ /* Get the attribute */
+ if (H5LTget_attribute_ullong(loc_id, obj_name, ATTR10_NAME, attr_ullong_out) < 0)
+ return -1;
+
+ for (i = 0; i < 5; i++) {
+ if (attr_ullong_in[i] != attr_ullong_out[i]) {
+ return -1;
+ }
+ }
+
+ /* Get the attribute */
+ if (H5LTget_attribute(loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_ULLONG, attr_ullong_out) < 0)
+ return -1;
+
+ for (i = 0; i < 5; i++) {
+ if (attr_ullong_in[i] != attr_ullong_out[i]) {
+ return -1;
+ }
+ }
+
+ PASSED();
+
+ /*-------------------------------------------------------------------------
* H5LTset_attribute_float test
*-------------------------------------------------------------------------
*/
@@ -895,7 +940,7 @@ make_attributes(hid_t loc_id, const char *obj_name)
HL_TESTING2("H5LTset_attribute_float");
/* Set the attribute */
- if (H5LTset_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5) < 0)
+ if (H5LTset_attribute_float(loc_id, obj_name, ATTR11_NAME, attr_float_in, (size_t)5) < 0)
return -1;
PASSED();
@@ -908,7 +953,7 @@ make_attributes(hid_t loc_id, const char *obj_name)
HL_TESTING2("H5LTget_attribute_float");
/* Get the attribute */
- if (H5LTget_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_out) < 0)
+ if (H5LTget_attribute_float(loc_id, obj_name, ATTR11_NAME, attr_float_out) < 0)
return -1;
for (i = 0; i < 5; i++) {
@@ -918,7 +963,7 @@ make_attributes(hid_t loc_id, const char *obj_name)
}
/* Get the attribute */
- if (H5LTget_attribute(loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out) < 0)
+ if (H5LTget_attribute(loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_FLOAT, attr_float_out) < 0)
return -1;
for (i = 0; i < 5; i++) {
@@ -937,7 +982,7 @@ make_attributes(hid_t loc_id, const char *obj_name)
HL_TESTING2("H5LTset_attribute_double");
/* Set the attribute */
- if (H5LTset_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5) < 0)
+ if (H5LTset_attribute_double(loc_id, obj_name, ATTR12_NAME, attr_double_in, (size_t)5) < 0)
return -1;
PASSED();
@@ -950,7 +995,7 @@ make_attributes(hid_t loc_id, const char *obj_name)
HL_TESTING2("H5LTget_attribute_double");
/* Get the attribute */
- if (H5LTget_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_out) < 0)
+ if (H5LTget_attribute_double(loc_id, obj_name, ATTR12_NAME, attr_double_out) < 0)
return -1;
for (i = 0; i < 5; i++) {
@@ -960,7 +1005,7 @@ make_attributes(hid_t loc_id, const char *obj_name)
}
/* Get the attribute */
- if (H5LTget_attribute(loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0)
+ if (H5LTget_attribute(loc_id, obj_name, ATTR12_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0)
return -1;
for (i = 0; i < 5; i++) {
diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c
index 1d3a569..5f30d4b 100644
--- a/hl/test/test_packet.c
+++ b/hl/test/test_packet.c
@@ -45,10 +45,10 @@ typedef struct particle_t {
* a static array of particles for writing and checking reads
*-------------------------------------------------------------------------
*/
-static particle_t testPart[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0f}, {"one", 10, 10, 1.0f, 10.0f},
- {"two", 20, 20, 2.0f, 20.0f}, {"three", 30, 30, 3.0f, 30.0f},
- {"four", 40, 40, 4.0f, 40.0f}, {"five", 50, 50, 5.0f, 50.0f},
- {"six", 60, 60, 6.0f, 60.0f}, {"seven", 70, 70, 7.0f, 70.0f}};
+static particle_t testPart[NRECORDS] = {{"zero", 0, 0, 0.0F, 0.0}, {"one", 10, 10, 1.0F, 10.0},
+ {"two", 20, 20, 2.0F, 20.0}, {"three", 30, 30, 3.0F, 30.0},
+ {"Four", 40, 40, 4.0F, 40.0}, {"Five", 50, 50, 5.0F, 50.0},
+ {"six", 60, 60, 6.0F, 60.0}, {"seven", 70, 70, 7.0F, 70.0}};
/*-------------------------------------------------------------------------
* function that compares one particle
diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c
index c668a07..6d6bf34 100644
--- a/hl/test/test_packet_vlen.c
+++ b/hl/test/test_packet_vlen.c
@@ -539,8 +539,8 @@ test_VLof_VLtype(void)
HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
}
- t1->len = vv * 1;
- for (ww = 0; ww < (vv * 1); ww++)
+ t1->len = vv + 1;
+ for (ww = 0; ww < (vv + 1); ww++)
((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww;
} /* end for */
} /* end for */
diff --git a/hl/test/test_table.c b/hl/test/test_table.c
index 0d4a72a..6199e27 100644
--- a/hl/test/test_table.c
+++ b/hl/test/test_table.c
@@ -199,7 +199,7 @@ test_table(hid_t fid, int do_write)
hsize_t chunk_size = 10;
int compress = 0;
int * fill = NULL;
- particle_t fill1[1] = {{"no data", -1, -99.0f, -99.0f, -1}};
+ particle_t fill1[1] = {{"no data", -1, -99.0, -99.0, -1}};
int fill1_new[1] = {-100};
hsize_t position;
char tname[20];
@@ -227,25 +227,25 @@ test_table(hid_t fid, int do_write)
particle2_t rbuf2[NRECORDS];
particle3_t rbuf3[NRECORDS];
particle_t rbufc[NRECORDS * 2];
- particle_t abuf[2] = {{"eight", 80, 8.0f, 80.0f, 80}, {"nine", 90, 9.0f, 90.0f, 90}};
- particle_t ibuf[2] = {{"zero", 0, 0.0f, 0.0f, 0}, {"zero", 0, 0.0f, 0.0f, 0}};
+ particle_t abuf[2] = {{"eight", 80, 8.0, 80.0, 80}, {"nine", 90, 9.0, 90.0, 90}};
+ particle_t ibuf[2] = {{"zero", 0, 0.0, 0.0, 0}, {"zero", 0, 0.0, 0.0, 0}};
particle_t wbufd[NRECORDS];
particle_t wbuf[NRECORDS] = {{
"zero",
0,
- 0.0f,
- 0.0f,
+ 0.0,
+ 0.0,
0,
},
- {"one", 10, 1.0f, 10.0f, 10},
- {"two", 20, 2.0f, 20.0f, 20},
- {"three", 30, 3.0f, 30.0f, 30},
- {"four", 40, 4.0f, 40.0f, 40},
- {"five", 50, 5.0f, 50.0f, 50},
- {"six", 60, 6.0f, 60.0f, 60},
- {"seven", 70, 7.0f, 70.0f, 70}};
+ {"one", 10, 1.0, 10.0, 10},
+ {"two", 20, 2.0, 20.0, 20},
+ {"three", 30, 3.0, 30.0, 30},
+ {"four", 40, 4.0, 40.0, 40},
+ {"five", 50, 5.0, 50.0, 50},
+ {"six", 60, 6.0, 60.0, 60},
+ {"seven", 70, 7.0, 70.0, 70}};
/* buffers for the field "Pressure" and "New_field" */
- float pressure_in[NRECORDS] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f};
+ float pressure_in[NRECORDS] = {0.0F, 1.0F, 2.0F, 3.0F, 4.0F, 5.0F, 6.0F, 7.0F};
float pressure_out[NRECORDS];
int buf_new[NRECORDS] = {0, 1, 2, 3, 4, 5, 6, 7};
/* buffers for the fields "Latitude,Longitude" */
@@ -254,8 +254,8 @@ test_table(hid_t fid, int do_write)
/* buffers for the fields "Name,Pressure" */
namepressure_t namepre_out[NRECORDS];
namepressure_t namepre_in[NRECORDS] = {
- {"zero", 0.0f}, {"one", 1.0f}, {"two", 2.0f}, {"three", 3.0f},
- {"four", 4.0f}, {"five", 5.0f}, {"six", 6.0f}, {"seven", 7.0f},
+ {"zero", 0.0F}, {"one", 1.0F}, {"two", 2.0F}, {"three", 3.0F},
+ {"four", 4.0F}, {"five", 5.0F}, {"six", 6.0F}, {"seven", 7.0F},
};
/*-------------------------------------------------------------------------
@@ -332,14 +332,14 @@ test_table(hid_t fid, int do_write)
HOFFSET(particle4_t, aty), HOFFSET(particle4_t, rro)};
/* Define an array of Particles */
- particle4_t p_data[NRECORDS] = {{12112, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
- {12113, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
- {12114, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
- {12115, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
- {12116, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
- {12117, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
- {12118, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
- {12119, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}}};
+ particle4_t p_data[NRECORDS] = {{12112, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12113, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12114, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12115, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12116, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12117, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12118, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12119, 1.4, 2.5, {1, 2, 3}, {4, 5, 6}, {99, 100}}};
/*-------------------------------------------------------------------------
* initialize table parameters
diff --git a/hl/tools/h5watch/h5watchgentest.c b/hl/tools/h5watch/h5watchgentest.c
index c83e485..44cb0cb 100644
--- a/hl/tools/h5watch/h5watchgentest.c
+++ b/hl/tools/h5watch/h5watchgentest.c
@@ -224,7 +224,7 @@ main(void)
one_cbuf[i].field2.b.a = 20;
one_cbuf[i].field2.b.b = 40;
one_cbuf[i].field2.b.c = 80;
- one_cbuf[i].field3 = 3.0F;
+ one_cbuf[i].field3 = 3.0;
one_cbuf[i].field4.a = 4;
one_cbuf[i].field4.b = 8;
} /* end for */
@@ -313,7 +313,7 @@ main(void)
two_cbuf[i].field2.b.a = 20;
two_cbuf[i].field2.b.b = 40;
two_cbuf[i].field2.b.c = 80;
- two_cbuf[i].field3 = 3.0F;
+ two_cbuf[i].field3 = 3.0;
two_cbuf[i].field4.a = 4;
two_cbuf[i].field4.b = 8;
} /* end for */