mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
Testing for [NCF-331] in pure-hdf5 form.
This commit is contained in:
parent
fa1d61b980
commit
a3251c08ad
@ -1,4 +1,4 @@
|
||||
SET(H5TESTS tst_h_files tst_h_files2 tst_h_files4 tst_h_atts tst_h_atts3 tst_h_atts4 tst_h_vars tst_h_vars2 tst_h_vars3 tst_h_grps tst_h_compounds tst_h_compounds2 tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl tst_h_opaques tst_h_strings tst_h_strings1 tst_h_strings2 tst_h_ints tst_h_dimscales tst_h_dimscales1 tst_h_dimscales2 tst_h_dimscales3 tst_h_enums tst_h_dimscales4)
|
||||
SET(H5TESTS tst_h_files tst_h_files2 tst_h_files4 tst_h_atts tst_h_atts3 tst_h_atts4 tst_h_vars tst_h_vars2 tst_h_vars3 tst_h_grps tst_h_compounds tst_h_compounds2 tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl tst_h_opaques tst_h_strings tst_h_strings1 tst_h_strings2 tst_h_ints tst_h_dimscales tst_h_dimscales1 tst_h_dimscales2 tst_h_dimscales3 tst_h_enums tst_h_dimscales4 tst_endian_float)
|
||||
|
||||
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h5 ${CMAKE_CURRENT_SOURCE_DIR}/*.nc)
|
||||
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
|
||||
@ -18,5 +18,3 @@ FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SO
|
||||
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} ref_tst_h_compounds.h5 ref_tst_h_compounds2.h5 ref_tst_compounds.nc CMakeLists.txt Makefile.am)
|
||||
|
||||
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
|
||||
|
||||
|
||||
|
48
h5_test/tst_endian_float.c
Normal file
48
h5_test/tst_endian_float.c
Normal file
@ -0,0 +1,48 @@
|
||||
/* Test introduced May 12, 2015 as part of debugging NCF-331,
|
||||
found in the Undiata JIRA system. We are investigating
|
||||
how endianness is stored to a file.
|
||||
*/
|
||||
|
||||
#include "hdf5.h"
|
||||
#include <stdio.h>
|
||||
#define FILE_NAME "tst_endian_float.h5"
|
||||
int main() {
|
||||
|
||||
hid_t file_id, dataset_id, attribute_id, dataspace_id; /* identifiers */
|
||||
hsize_t dims;
|
||||
int attr_data[2];
|
||||
herr_t status;
|
||||
|
||||
/* Initialize the attribute data. */
|
||||
attr_data[0] = 100;
|
||||
attr_data[1] = 200;
|
||||
|
||||
/* Open an existing file. */
|
||||
file_id = H5Fcreate(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT, H5P_DEFAULT);
|
||||
|
||||
/* Open an existing dataset. */
|
||||
dataset_id = H5Dopen(file_id, "/dset", H5P_DEFAULT);
|
||||
|
||||
/* Create the data space for the attribute. */
|
||||
dims = 2;
|
||||
dataspace_id = H5Screate_simple(1, &dims, NULL);
|
||||
|
||||
/* Create a dataset attribute. */
|
||||
attribute_id = H5Acreate (dataset_id, "Units", H5T_STD_I32BE, dataspace_id,
|
||||
H5P_DEFAULT, H5P_DEFAULT);
|
||||
|
||||
/* Write the attribute data. */
|
||||
status = H5Awrite(attribute_id, H5T_NATIVE_INT, attr_data);
|
||||
|
||||
/* Close the attribute. */
|
||||
status = H5Aclose(attribute_id);
|
||||
|
||||
/* Close the dataspace. */
|
||||
status = H5Sclose(dataspace_id);
|
||||
|
||||
/* Close to the dataset. */
|
||||
status = H5Dclose(dataset_id);
|
||||
|
||||
/* Close the file. */
|
||||
status = H5Fclose(file_id);
|
||||
}
|
Loading…
Reference in New Issue
Block a user