35#include <libdap/InternalErr.h>
43HDF5CFInt16::HDF5CFInt16(
const string &n,
const string &d) :
Int16(n, d)
48HDF5CFInt16::HDF5CFInt16(
const string &n,
const string &d,
const string &d_f) :
Int16(n, d),filename(d_f)
52BaseType *HDF5CFInt16::ptr_duplicate()
54 auto HDF5CFInt16_unique = make_unique<HDF5CFInt16>(*
this);
55 return HDF5CFInt16_unique.release();
58bool HDF5CFInt16::read()
60 BESDEBUG(
"h5",
"Coming to HDF5CFInt16 read "<<endl);
65 hid_t file_id = H5Fopen(filename.c_str(),H5F_ACC_RDONLY,H5P_DEFAULT);
67 throw InternalErr(__FILE__,__LINE__,
"Fail to obtain the HDF5 file ID .");
71 dset_id = H5Dopen2(file_id,dataset().c_str(),H5P_DEFAULT);
74 throw InternalErr(__FILE__,__LINE__,
"Fail to obtain the dataset .");
77 hid_t dtypeid = H5Dget_type(dset_id);
81 throw InternalErr(__FILE__,__LINE__,
"Fail to obtain the datatype .");
84 hid_t memtype = H5Tget_native_type(dtypeid, H5T_DIR_ASCEND);
89 throw InternalErr(__FILE__, __LINE__,
"Cannot obtain the native datatype.");
95 if(1 == H5Tget_size(memtype) && H5T_SGN_2 == H5Tget_sign(memtype)) {
106 if(H5Tclose(memtype) < 0) {
107 throw InternalErr(__FILE__, __LINE__,
"Unable to close the memory datatype.");
109 if(H5Tclose(dtypeid) < 0) {
110 throw InternalErr(__FILE__, __LINE__,
"Unable to close the datatype id.");
113 if (H5Dclose(dset_id) < 0) {
114 throw InternalErr(__FILE__, __LINE__,
"Unable to close the dset.");
This class provides a way to map HDF5 int16 to DAP int16 for the CF option.
void get_data(hid_t dset, void *buf)