44#include "h5apicompatible.h"
47using namespace HDF5CF;
49Var::Var(
const Var *var)
52 newname = var->newname;
54 fullpath = var->fullpath;
56 total_elems = var->total_elems;
57 zero_storage_size = var->zero_storage_size;
59 comp_ratio = var->comp_ratio;
60 unsupported_attr_dtype = var->unsupported_attr_dtype;
61 unsupported_attr_dspace = var->unsupported_attr_dspace;
62 unsupported_dspace = var->unsupported_dspace;
63 unsupported_attr_dspace = var->unsupported_attr_dspace;
64 dimnameflag = var->dimnameflag;
65 coord_attr_add_path = var->coord_attr_add_path;
67 for (
const auto &vattr:var->attrs) {
68 auto attr_unique = make_unique<Attribute>();
69 auto attr = attr_unique.release();
70 attr->name = vattr->name;
71 attr->newname = vattr->newname;
72 attr->dtype = vattr->dtype;
73 attr->count = vattr->count;
74 attr->strsize = vattr->strsize;
75 attr->fstrsize = vattr->fstrsize;
76 attr->value = vattr->value;
77 attrs.push_back(attr);
80 for (
const auto &vdim:var->dims) {
81 auto dim_unique = make_unique<Dimension>(vdim->size);
82 auto dim = dim_unique.release();
83 dim->name = vdim->name;
84 dim->newname = vdim->newname;
85 dim->unlimited_dim = vdim->unlimited_dim;
91bool CVar::isLatLon()
const
94 bool ret_value =
false;
95 if (CV_EXIST == this->cvartype || CV_MODIFY == this->cvartype || CV_SPECIAL == this->cvartype) {
96 string attr_name =
"units";
97 string lat_unit_value =
"degrees_north";
98 string lon_unit_value =
"degrees_east";
100 for (
const auto &attr:this->attrs) {
102 if ((H5FSTRING == attr->getType()) || (H5VSTRING == attr->getType())) {
103 if (attr_name == attr->newname) {
104 string attr_value1(attr->getValue().begin(), attr->getValue().end());
106 if (attr->getCount() == 1) {
107 string attr_value(attr->getValue().begin(), attr->getValue().end());
108 if (attr_value.compare(0, lat_unit_value.size(), lat_unit_value) == 0) {
109 if (attr_value.size() == lat_unit_value.size()) {
113 else if (attr_value.size() == (lat_unit_value.size() + 1)) {
114 if (attr_value[attr_value.size() - 1] ==
'\0'
115 || attr_value[attr_value.size() - 1] ==
' ') {
121 else if (attr_value.compare(0, lon_unit_value.size(), lon_unit_value) == 0) {
122 if (attr_value.size() == lon_unit_value.size()) {
126 else if (attr_value.size() == (lon_unit_value.size() + 1)) {
127 if (attr_value[attr_value.size() - 1] ==
'\0'
128 || attr_value[attr_value.size() - 1] ==
' ') {
141 else if (this->cvartype == CV_LAT_MISS || this->cvartype == CV_LON_MISS) ret_value =
true;
148 if (this->fileid >= 0) {
149 if (this->rootid >= 0) {
150 for_each(this->
groups.begin(), this->groups.end(), delete_elem());
151 for_each(this->
vars.begin(), this->vars.end(), delete_elem());
152 for_each(this->
root_attrs.begin(), this->root_attrs.end(), delete_elem());
160 for_each(this->attrs.begin(), this->attrs.end(), delete_elem());
165 for_each(this->dims.begin(), this->dims.end(), delete_elem());
166 for_each(this->attrs.begin(), this->attrs.end(), delete_elem());
173 BESDEBUG(
"h5",
"coming to Retrieve_H5_Info" <<endl);
175 if (
true == include_attr) {
179 this->check_ignored = HDF5RequestHandler::get_check_ignore_obj();
180 if (
true == this->check_ignored) this->add_ignored_info_page_header();
185 if ((root_id = H5Gopen(file_id,
"/", H5P_DEFAULT)) < 0) {
186 throw1(
"Cannot open the HDF5 root group ");
188 this->rootid = root_id;
190 this->Retrieve_H5_Obj(root_id,
"/", include_attr);
197 if (
true == include_attr) {
205 if (H5OGET_INFO(root_id, &oinfo) < 0)
206 throw1(
"Error obtaining the info for the root group");
208 num_attrs = (
int)(oinfo.num_attrs);
209 bool temp_unsup_attr_atype =
false;
210 bool temp_unsup_attr_dspace =
false;
212 for (
int j = 0; j < num_attrs; j++) {
213 auto attr_unique = make_unique<Attribute>();
214 auto attr = attr_unique.release();
216 this->Retrieve_H5_Attr_Info(attr, root_id, j, temp_unsup_attr_atype, temp_unsup_attr_dspace);
226 this->unsupported_attr_dtype = temp_unsup_attr_atype;
227 this->unsupported_attr_dspace = temp_unsup_attr_dspace;
231void File::Retrieve_H5_Obj(hid_t grp_id,
const char*gname,
bool include_attr)
238 if (H5Gget_info(grp_id, &g_info) < 0)
239 throw2(
"Counting hdf5 group elements error for ", gname);
240 nelems = g_info.nlinks;
242 ssize_t oname_size = 0;
243 for (hsize_t i = 0; i < nelems; i++) {
247 Group *group =
nullptr;
253 size_t dummy_name_len = 1;
256 oname_size = H5Lget_name_by_idx(grp_id,
".", H5_INDEX_NAME, H5_ITER_NATIVE, i,
nullptr, dummy_name_len,
259 throw2(
"Error getting the size of the hdf5 object from the group: ", gname);
263 oname.resize((
size_t) oname_size + 1);
265 if (H5Lget_name_by_idx(grp_id,
".", H5_INDEX_NAME, H5_ITER_NATIVE, i, oname.data(), (
size_t) (oname_size + 1),
267 throw2(
"Error getting the hdf5 object name from the group: ", gname);
271 if (H5Lget_info(grp_id, oname.data(), &linfo, H5P_DEFAULT) < 0)
272 throw2(
"HDF5 link name error from ", gname);
275 if (H5L_TYPE_SOFT == linfo.type || H5L_TYPE_EXTERNAL == linfo.type) {
276 if (
true == include_attr &&
true == check_ignored) {
277 this->add_ignored_info_links_header();
278 string full_path_name;
279 string temp_oname(oname.begin(), oname.end());
282 (
string(gname) +
"/" + temp_oname.substr(0, temp_oname.size() - 1)) :
283 (
"/" + temp_oname.substr(0, temp_oname.size() - 1)));
284 this->add_ignored_info_links(full_path_name);
293 if (H5OGET_INFO_BY_IDX(grp_id,
".", H5_INDEX_NAME, H5_ITER_NATIVE, i, &oinfo, H5P_DEFAULT) < 0)
294 throw2(
"Error obtaining the info for the object ",
string(oname.begin(), oname.end()));
296 H5O_type_t obj_type = oinfo.type;
300 case H5O_TYPE_GROUP: {
303 string full_path_name;
304 string temp_oname(oname.begin(), oname.end());
307 (string(gname) !=
"/") ?
308 (string(gname) +
"/" + temp_oname.substr(0, temp_oname.size() - 1)) :
309 (
"/" + temp_oname.substr(0, temp_oname.size() - 1)));
311 cgroup = H5Gopen(grp_id, full_path_name.c_str(), H5P_DEFAULT);
313 throw2(
"Error opening the group ", full_path_name);
315 auto group_unique = make_unique<Group>();
316 group = group_unique.release();
317 group->path = full_path_name;
318 group->newname = full_path_name;
321 if (
true == include_attr) {
323 auto num_attrs = (int)(oinfo.num_attrs);
324 bool temp_unsup_attr_dtype =
false;
325 bool temp_unsup_attr_dspace =
false;
327 for (
int j = 0; j < num_attrs; j++) {
329 auto attr_unique = make_unique<Attribute>();
330 attr = attr_unique.release();
331 Retrieve_H5_Attr_Info(attr, cgroup, j, temp_unsup_attr_dtype, temp_unsup_attr_dspace);
332 group->attrs.push_back(attr);
336 group->unsupported_attr_dtype = temp_unsup_attr_dtype;
337 group->unsupported_attr_dspace = temp_unsup_attr_dspace;
339 this->
groups.push_back(group);
340 Retrieve_H5_Obj(cgroup, full_path_name.c_str(), include_attr);
341 if (H5Gclose(cgroup) < 0)
342 throw2(
"Error closing the group ", full_path_name);
345 case H5O_TYPE_DATASET: {
348 string temp_oname(oname.begin(), oname.end());
349 string full_path_name = (
350 (string(gname) !=
"/") ?
351 (string(gname) +
"/" + temp_oname.substr(0, temp_oname.size() - 1)) :
352 (
"/" + temp_oname.substr(0, temp_oname.size() - 1)));
354 auto var_unique = make_unique<Var>();
355 var = var_unique.release();
356 var->name = temp_oname.substr(0, temp_oname.size() - 1);
357 var->fullpath = full_path_name;
360 var->newname = full_path_name;
362 cdset = H5Dopen(grp_id, full_path_name.c_str(), H5P_DEFAULT);
364 throw2(
"Error opening the HDF5 dataset ", full_path_name);
367 bool temp_unsup_var_dtype =
false;
368 Retrieve_H5_VarType(var, cdset, full_path_name, temp_unsup_var_dtype);
371 if (!this->unsupported_var_dtype && temp_unsup_var_dtype) this->unsupported_var_dtype =
true;
374 bool temp_unsup_var_dspace =
false;
375 Retrieve_H5_VarDim(var, cdset, full_path_name, temp_unsup_var_dspace);
378 if (!this->unsupported_var_dspace && temp_unsup_var_dspace) this->unsupported_var_dspace =
true;
380 hsize_t d_storage_size = H5Dget_storage_size(cdset);
381 var->zero_storage_size =(d_storage_size ==0);
382 var->comp_ratio = Retrieve_H5_VarCompRatio(var, cdset);
385 if (
true == include_attr) {
387 auto num_attrs = (int)(oinfo.num_attrs);
388 bool temp_unsup_attr_dtype =
false;
389 bool temp_unsup_attr_dspace =
false;
391 for (
int j = 0; j < num_attrs; j++) {
393 auto attr_unique = make_unique<Attribute>();
394 attr = attr_unique.release();
396 Retrieve_H5_Attr_Info(attr, cdset, j, temp_unsup_attr_dtype, temp_unsup_attr_dspace);
397 var->attrs.push_back(attr);
401 var->unsupported_attr_dtype = temp_unsup_attr_dtype;
402 var->unsupported_attr_dspace = temp_unsup_attr_dspace;
404 if (!this->unsupported_var_attr_dspace && temp_unsup_attr_dspace)
405 this->unsupported_var_attr_dspace =
true;
408 this->
vars.push_back(var);
409 if (H5Dclose(cdset) < 0)
410 throw2(
"Error closing the HDF5 dataset ", full_path_name);
414 case H5O_TYPE_NAMED_DATATYPE: {
416 if (
true == include_attr &&
true == check_ignored) {
417 this->add_ignored_info_namedtypes(
string(gname),
string(oname.begin(), oname.end()));
427 if (attr !=
nullptr) {
432 if (var !=
nullptr) {
437 if (group !=
nullptr) {
442 if (cgroup != -1) H5Gclose(cgroup);
444 if (cdset != -1) H5Dclose(cdset);
453float File::Retrieve_H5_VarCompRatio(
const Var *var,
const hid_t dset_id)
const
456 float comp_ratio = 1.0;
458 hid_t dset_create_plist = H5Dget_create_plist(dset_id);
459 if (dset_create_plist < 0)
460 throw1(
"unable to obtain hdf5 dataset creation property list ");
461 H5D_layout_t dset_layout = H5Pget_layout(dset_create_plist);
462 if (dset_layout < 0) {
463 H5Pclose(dset_create_plist);
464 throw1(
"unable to obtain hdf5 dataset creation property list storage layout");
467 if (dset_layout == H5D_CHUNKED) {
469 hsize_t dstorage_size = H5Dget_storage_size(dset_id);
470 if (dstorage_size > 0 && var->total_elems > 0) {
474 if ((ty_id = H5Dget_type(dset_id)) < 0)
475 throw1(
"unable to obtain hdf5 datatype for the dataset ");
476 size_t type_size = H5Tget_size(ty_id);
477 comp_ratio = ((float)((var->total_elems) * type_size))/(
float)dstorage_size;
482 H5Pclose(dset_create_plist);
487void File::Retrieve_H5_VarType(
Var *var, hid_t dset_id,
const string & varname,
bool &unsup_var_dtype)
const
493 if ((ty_id = H5Dget_type(dset_id)) < 0)
494 throw2(
"unable to obtain hdf5 datatype for the dataset ", varname);
513 if (
false == HDF5CFUtil::cf_strict_support_type(var->dtype,_is_dap4))
514 unsup_var_dtype =
true;
516 if (H5Tclose(ty_id) < 0)
517 throw1(
"Unable to close the HDF5 datatype ");
521void File::Retrieve_H5_VarDim(
Var *var, hid_t dset_id,
const string & varname,
bool &unsup_var_dspace)
524 vector<hsize_t> dsize;
525 vector<hsize_t> maxsize;
527 hid_t dspace_id = -1;
531 if ((dspace_id = H5Dget_space(dset_id)) < 0)
532 throw2(
"Cannot get hdf5 dataspace id for the variable ", varname);
534 H5S_class_t space_class = H5S_NO_CLASS;
535 if ((space_class = H5Sget_simple_extent_type(dspace_id)) < 0)
536 throw2(
"Cannot obtain the HDF5 dataspace class for the variable ", varname);
538 if (H5S_NULL == space_class)
539 unsup_var_dspace =
true;
541 if (
false == unsup_var_dspace) {
543 hssize_t h5_total_elms = H5Sget_simple_extent_npoints(dspace_id);
544 if (h5_total_elms < 0)
545 throw2(
"Cannot get the total number of elements of HDF5 dataset ", varname);
547 var->total_elems = (size_t) h5_total_elms;
548 int ndims = H5Sget_simple_extent_ndims(dspace_id);
550 throw2(
"Cannot get the hdf5 dataspace number of dimension for the variable ", varname);
555 maxsize.resize(ndims);
560 if (H5Sget_simple_extent_dims(dspace_id, dsize.data(), maxsize.data()) < 0)
561 throw2(
"Cannot obtain the dim. info for the variable ", varname);
563 for (
int i = 0; i < ndims; i++) {
564 auto dim_unique = make_unique<Dimension>(dsize[i]);
565 auto dim = dim_unique.release();
566 if (maxsize[i] == H5S_UNLIMITED) {
567 dim->unlimited_dim =
true;
568 if (
false == have_udim)
571 var->dims.push_back(dim);
576 var->unsupported_dspace = unsup_var_dspace;
578 if (H5Sclose(dspace_id) < 0)
579 throw1(
"Cannot close the HDF5 dataspace .");
585 if (dspace_id != -1) H5Sclose(dspace_id);
587 if (ty_id != -1) H5Tclose(ty_id);
594void File::Retrieve_H5_Attr_Info(
Attribute * attr, hid_t obj_id,
const int j,
bool &unsup_attr_dtype,
595 bool &unsup_attr_dspace)
const
601 hid_t aspace_id = -1;
607 if ((attrid = H5Aopen_by_idx(obj_id,
".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) j, H5P_DEFAULT,
609 throw1(
"Unable to open attribute by index ");
612 ssize_t name_size = H5Aget_name(attrid, 0,
nullptr);
614 throw1(
"Unable to obtain the size of the hdf5 attribute name ");
617 attr_name.resize(name_size + 1);
620 if ((H5Aget_name(attrid, name_size + 1, &attr_name[0])) < 0)
621 throw1(
"unable to obtain the hdf5 attribute name ");
624 if ((ty_id = H5Aget_type(attrid)) < 0)
625 throw2(
"unable to obtain hdf5 datatype for the attribute ", attr_name);
643 if (
false == HDF5CFUtil::cf_strict_support_type(attr->dtype,_is_dap4))
644 unsup_attr_dtype =
true;
646 if(H5VSTRING == attr->dtype || H5FSTRING == attr->dtype) {
647 H5T_cset_t c_set_type = H5Tget_cset(ty_id);
649 throw2(
"Cannot get hdf5 character set type for the attribute ", attr_name);
651 if(c_set_type == H5T_CSET_UTF8)
652 attr->is_cset_ascii =
false;
655 if ((aspace_id = H5Aget_space(attrid)) < 0)
656 throw2(
"Cannot get hdf5 dataspace id for the attribute ", attr_name);
658 int ndims = H5Sget_simple_extent_ndims(aspace_id);
660 throw2(
"Cannot get the hdf5 dataspace number of dimension for attribute ", attr_name);
667 vector<hsize_t> asize;
668 vector<hsize_t> maxsize;
670 maxsize.resize(ndims);
673 if (H5Sget_simple_extent_dims(aspace_id, asize.data(), maxsize.data()) < 0)
674 throw2(
"Cannot obtain the dim. info for the attribute ", attr_name);
677 for (
int dim_count = 0;dim_count < ndims; dim_count ++) {
679 if (asize[dim_count] == 0) {
680 unsup_attr_dspace =
true;
685 if (
false == unsup_attr_dspace) {
687 for (
int dim_count = 0; dim_count< ndims; dim_count++)
688 nelmts *= asize[dim_count];
694 size_t ty_size = H5Tget_size(ty_id);
696 throw2(
"Cannot obtain the dtype size for the attribute ", attr_name);
698 memtype = H5Tget_native_type(ty_id, H5T_DIR_ASCEND);
700 throw2(
"Cannot obtain the memory datatype for the attribute ", attr_name);
703 string temp_aname(attr_name.begin(), attr_name.end());
704 attr->name = temp_aname.substr(0, temp_aname.size() - 1);
705 attr->newname = attr->name;
706 attr->count = nelmts;
709 if (H5Tclose(ty_id) < 0)
710 throw1(
"Cannot successfully close the attribute datatype.");
711 if (H5Tclose(memtype) < 0)
712 throw1(
"Cannot successfully close the attribute memory datatype.");
713 if (H5Sclose(aspace_id) < 0)
714 throw1(
"Cannot successfully close the HDF5 dataspace.");
715 if (H5Aclose(attrid) < 0)
716 throw1(
"Cannot successfully close the HDF5 attribute.");
721 if (ty_id != -1) H5Tclose(ty_id);
723 if (memtype != -1) H5Tclose(memtype);
725 if (aspace_id != -1) H5Sclose(aspace_id);
727 if (attrid != -1) H5Aclose(attrid);
739 Retrieve_H5_Attr_Value(root_attr,
"/");
741 for (
const auto &grp:this->
groups) {
742 for (
auto &grp_attr:grp->attrs)
743 Retrieve_H5_Attr_Value(grp_attr, grp->path);
746 for (
const auto &var:this->
vars) {
747 for (
auto &var_attr:var->attrs) {
748 Retrieve_H5_Attr_Value(var_attr, var->fullpath);
755 for (
auto &attr:var->attrs)
756 Retrieve_H5_Attr_Value(attr, var->fullpath);
760void File::Retrieve_H5_Attr_Value(
Attribute *attr,
const string & obj_name)
const
767 hid_t memtype_id = -1;
768 hid_t aspace_id = -1;
773 obj_id = H5Oopen(this->fileid, obj_name.c_str(), H5P_DEFAULT);
775 throw2(
"Cannot open the object ", obj_name);
777 attr_id = H5Aopen(obj_id, (attr->name).c_str(), H5P_DEFAULT);
779 throw4(
"Cannot open the attribute ", attr->name,
" of object ", obj_name);
781 ty_id = H5Aget_type(attr_id);
783 throw4(
"Cannot obtain the datatype of the attribute ", attr->name,
" of object ", obj_name);
785 memtype_id = H5Tget_native_type(ty_id, H5T_DIR_ASCEND);
787 throw2(
"Cannot obtain the memory datatype for the attribute ", attr->name);
789 size_t ty_size = H5Tget_size(memtype_id);
791 throw4(
"Cannot obtain the dtype size for the attribute ", attr->name,
" of object ", obj_name);
793 size_t total_bytes = attr->count * ty_size;
796 if (H5VSTRING == attr->dtype) {
800 temp_buf.resize(total_bytes);
802 if (H5Aread(attr_id, memtype_id, temp_buf.data()) < 0)
803 throw4(
"Cannot obtain the value of the attribute ", attr->name,
" of object ", obj_name);
805 char *temp_bp =
nullptr;
806 const char *ptr_1stvlen_ptr = temp_buf.data();
807 temp_bp = temp_buf.data();
808 const char* onestring =
nullptr;
809 string total_vstring;
811 attr->strsize.resize(attr->count);
813 for (
unsigned int temp_i = 0; temp_i < attr->count; temp_i++) {
816 onestring = *(
char **) temp_bp;
817 if (onestring !=
nullptr) {
818 total_vstring +=
string(onestring);
819 attr->strsize[temp_i] = (
string(onestring)).size();
822 attr->strsize[temp_i] = 0;
828 if (ptr_1stvlen_ptr !=
nullptr) {
829 aspace_id = H5Aget_space(attr_id);
831 throw4(
"Cannot obtain space id for ", attr->name,
" of object ", obj_name);
834 if (H5Dvlen_reclaim(memtype_id, aspace_id, H5P_DEFAULT, temp_buf.data()) < 0)
835 throw4(
"Cannot reclaim VL memory for ", attr->name,
" of object ", obj_name);
841 throw4(
"Error to obtain the VL string type for attribute ", attr->name,
" of object ", obj_name);
843 attr->value.resize(total_vstring.size());
845 copy(total_vstring.begin(), total_vstring.end(), attr->value.begin());
850 if (attr->dtype == H5FSTRING) {
851 attr->fstrsize = ty_size;
854 attr->value.resize(total_bytes);
857 if (H5Aread(attr_id, memtype_id, (
void *) &attr->value[0]) < 0)
858 throw4(
"Cannot obtain the dtype size for the attribute ", attr->name,
" of object ", obj_name);
860 if (attr->dtype == H5FSTRING) {
862 size_t sect_size = ty_size;
866 (total_bytes % sect_size == 0) ? (total_bytes / sect_size) : (total_bytes / sect_size + 1);
868 throw4(
"The attribute datatype size is not a positive integer ", attr->name,
" of object ",
871 vector<size_t> sect_newsize;
872 sect_newsize.resize(num_sect);
874 auto total_fstring = string(attr->value.begin(), attr->value.end());
878 attr->value.resize(new_total_fstring.size());
879 copy(new_total_fstring.begin(), new_total_fstring.end(), attr->value.begin());
880 attr->strsize.resize(num_sect);
881 for (
int temp_i = 0; temp_i < num_sect; temp_i++)
882 attr->strsize[temp_i] = sect_newsize[temp_i];
886 cerr<<
"Attr name is "<<attr->name <<endl;
887 for (
int temp_i = 0; temp_i <num_sect; temp_i ++)
888 cerr<<
"string new section size = " << attr->strsize[temp_i] <<endl;
893 if (H5Tclose(memtype_id) < 0)
894 throw1(
"Fail to close the HDF5 memory datatype ID.");
895 if (H5Tclose(ty_id) < 0)
896 throw1(
"Fail to close the HDF5 datatype ID.");
897 if (H5Aclose(attr_id) < 0)
898 throw1(
"Fail to close the HDF5 attribute ID.");
899 if (H5Oclose(obj_id) < 0)
900 throw1(
"Fail to close the HDF5 object ID.");
906 if (memtype_id != -1) H5Tclose(memtype_id);
908 if (ty_id != -1) H5Tclose(ty_id);
910 if (aspace_id != -1) H5Sclose(aspace_id);
912 if (attr_id != -1) H5Aclose(attr_id);
914 if (obj_id != -1) H5Oclose(obj_id);
925 if (
true == include_attr) {
926 Handle_Group_Unsupported_Dtype();
927 Handle_VarAttr_Unsupported_Dtype();
930 Handle_Var_Unsupported_Dtype();
936if (
true == include_attr) {
937 if (
true == this->unsupported_attr_dtype) {
939 ira != this->root_attrs.end(); ) {
940 H5DataType temp_dtype = (*ira)->getType();
941 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype)) {
943 ira = this->root_attrs.erase(ira);
954if (
false == this->groups.empty()) {
955 for (vector<Group *>::iterator irg = this->groups.begin();
956 irg != this->groups.end(); ++irg) {
957 if (
false == (*irg)->attrs.empty()) {
958 if (
true == (*irg)->unsupported_attr_dtype) {
959 for (vector<Attribute *>::iterator ira = (*irg)->attrs.begin();
960 ira != (*irg)->attrs.end(); ) {
961 H5DataType temp_dtype = (*ira)->getType();
962 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype)) {
964 ira = (*irg)->attrs.erase(ira);
977if (
false == this->vars.empty()) {
978if (
true == include_attr) {
979 for (vector<Var *>::iterator irv = this->vars.begin();
980 irv != this->vars.end();++irv ) {
981 if (
false == (*irv)->attrs.empty()) {
982 if (
true == (*irv)->unsupported_attr_dtype) {
983 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
984 ira != (*irv)->attrs.end(); ) {
985 H5DataType temp_dtype = (*ira)->getType();
986 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype)) {
988 ira = (*irv)->attrs.erase(ira);
999if (
true == this->unsupported_var_dtype) {
1001 for (vector<Var *>::iterator irv = this->vars.begin();
1002 irv != this->vars.end(); ) {
1003 H5DataType temp_dtype = (*irv)->getType();
1004 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype)) {
1006 irv = this->vars.erase(irv);
1016void File::Handle_Group_Unsupported_Dtype()
1021 if (
true == this->unsupported_attr_dtype) {
1022 for (
auto ira = this->
root_attrs.begin(); ira != this->root_attrs.end();) {
1023 H5DataType temp_dtype = (*ira)->getType();
1024 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)) {
1036 if (
false == this->
groups.empty()) {
1037 for (
const auto &grp:this->
groups) {
1038 if (
false == grp->attrs.empty()) {
1039 if (
true == grp->unsupported_attr_dtype) {
1040 for (
auto ira = grp->attrs.begin(); ira != grp->attrs.end();) {
1041 H5DataType temp_dtype = (*ira)->getType();
1042 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)) {
1044 ira = grp->attrs.erase(ira);
1057void File::Gen_Group_Unsupported_Dtype_Info()
1063 for (
const auto &root_attr:this->
root_attrs) {
1064 H5DataType temp_dtype = root_attr->getType();
1067 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)
1068 || temp_dtype == H5INT64 || temp_dtype == H5UINT64) {
1069 this->add_ignored_info_attrs(
true,
"/", root_attr->name);
1076 if (
false == this->
groups.empty()) {
1077 for (
const auto &grp:this->
groups) {
1078 if (
false == grp->attrs.empty()) {
1080 for (
const auto &grp_attr:grp->attrs) {
1081 H5DataType temp_dtype = grp_attr->getType();
1084 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)
1085 || temp_dtype == H5INT64 || temp_dtype==H5UINT64 ) {
1086 this->add_ignored_info_attrs(
true, grp->path, grp_attr->name);
1096void File::Handle_Var_Unsupported_Dtype()
1098 if (
false == this->
vars.empty()) {
1099 if (
true == this->unsupported_var_dtype) {
1100 for (
auto irv = this->
vars.begin(); irv != this->vars.end();) {
1101 H5DataType temp_dtype = (*irv)->getType();
1102 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)) {
1104 irv = this->
vars.erase(irv);
1116void File::Gen_Var_Unsupported_Dtype_Info()
1119 if (
false == this->
vars.empty()) {
1121 for (
const auto &var:this->
vars) {
1122 H5DataType temp_dtype = var->
getType();
1125 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)
1126 ||(H5INT64 == temp_dtype) ||(H5UINT64 == temp_dtype)) {
1127 this->add_ignored_info_objs(
false, var->fullpath);
1136void File::Handle_VarAttr_Unsupported_Dtype()
1138 if (
false == this->
vars.empty()) {
1139 for (
const auto &var:this->
vars) {
1140 if (
false == var->attrs.empty()) {
1141 if (
true == var->unsupported_attr_dtype) {
1142 for (
auto ira = var->attrs.begin(); ira != var->attrs.end();) {
1143 H5DataType temp_dtype = (*ira)->getType();
1144 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)) {
1146 ira = var->attrs.erase(ira);
1159void File::Gen_VarAttr_Unsupported_Dtype_Info()
1162 if (
false == this->
vars.empty()) {
1163 for (
const auto &var:this->
vars) {
1164 if (
false == var->attrs.empty()) {
1166 for (
const auto &attr:var->attrs) {
1167 H5DataType temp_dtype = attr->getType();
1170 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)
1171 || (temp_dtype==H5INT64) || (temp_dtype == H5UINT64)) {
1172 this->add_ignored_info_attrs(
false, var->fullpath, attr->name);
1185void File::Gen_DimScale_VarAttr_Unsupported_Dtype_Info()
1188 for (
const auto &var:this->
vars) {
1192 bool is_ignored = ignored_dimscale_ref_list(var);
1193 if (
false == var->attrs.empty()) {
1195 for (
const auto &attr:var->attrs) {
1196 H5DataType temp_dtype = attr->getType();
1198 if (
false == HDF5CFUtil::cf_strict_support_type(temp_dtype,_is_dap4)
1199 || (temp_dtype == H5INT64) || (temp_dtype == H5UINT64)) {
1203 if ((
"DIMENSION_LIST" != attr->name)
1204 && (
"REFERENCE_LIST" != attr->name ||
true == is_ignored))
1205 this->add_ignored_info_attrs(
false, var->fullpath, attr->name);
1214void File::Handle_GroupAttr_Unsupported_Dspace()
1219 if (
true == this->unsupported_attr_dspace) {
1220 for (
auto ira = this->
root_attrs.begin(); ira != this->root_attrs.end();) {
1222 if ((*ira)->count == 0) {
1234 if (
false == this->
groups.empty()) {
1235 for (
auto irg = this->
groups.begin(); irg != this->groups.end(); ++irg) {
1236 if (
false == (*irg)->attrs.empty()) {
1237 if (
true == (*irg)->unsupported_attr_dspace) {
1238 for (
auto ira = (*irg)->attrs.begin(); ira != (*irg)->attrs.end();) {
1239 if ((*ira)->count == 0) {
1241 ira = (*irg)->attrs.erase(ira);
1254void File::Handle_VarAttr_Unsupported_Dspace()
1257 if (
false == this->
vars.empty()) {
1258 if (
true == this->unsupported_var_attr_dspace) {
1259 for (
const auto &var:this->
vars) {
1260 if (
false == var->attrs.empty()) {
1261 if (
true == var->unsupported_attr_dspace) {
1262 for (
auto ira = var->attrs.begin(); ira != var->attrs.end();) {
1263 if (0 == (*ira)->count) {
1265 ira = var->attrs.erase(ira);
1283 if (
false == this->vars.empty()) {
1284 if (
true == this->unsupported_var_dspace) {
1285 for (
auto irv = this->vars.begin(); irv != this->vars.end();) {
1286 if (
true == (*irv)->unsupported_dspace) {
1288 irv = this->vars.erase(irv);
1298 if (
true == include_attr) {
1299 Handle_GroupAttr_Unsupported_Dspace();
1300 Handle_VarAttr_Unsupported_Dspace();
1305void File::Gen_Unsupported_Dspace_Info()
1313 if (
false == this->vars.empty()) {
1314 if (
true == this->unsupported_var_dspace) {
1315 for (
const auto &var:this->vars) {
1316 if (
true == var->unsupported_dspace) {
1317 this->add_ignored_info_objs(
true, var->fullpath);
1329 if (
true == this->check_ignored &&
true == include_attr) {
1331 if (
true == HDF5RequestHandler::get_drop_long_string()) {
1336 if (H5FSTRING == (*ira)->dtype || H5VSTRING == (*ira)->dtype) {
1337 if ((*ira)->getBufSize() > NC_JAVA_STR_SIZE_LIMIT) {
1338 this->add_ignored_droplongstr_hdr();
1339 this->add_ignored_grp_longstr_info(
"/", (*ira)->name);
1346 if (H5FSTRING == (*ira)->dtype || H5VSTRING == (*ira)->dtype) {
1347 if ((*ira)->getBufSize() > NC_JAVA_STR_SIZE_LIMIT) {
1348 this->add_ignored_droplongstr_hdr();
1349 this->add_ignored_grp_longstr_info((*irg)->path, (*ira)->name);
1355 for (
const auto &var:this->vars) {
1356 if (
true == Check_DropLongStr(var,
nullptr)) {
1357 this->add_ignored_droplongstr_hdr();
1358 this->add_ignored_var_longstr_info(var,
nullptr);
1362 for (
auto ira = (*irv)->attrs.begin(); ira != (*irv)->attrs.end(); ++ira) {
1363 if (
true == Check_DropLongStr((*irv), (*ira))) {
1364 this->add_ignored_droplongstr_hdr();
1365 this->add_ignored_var_longstr_info((*irv), (*ira));
1378 for (
auto &var:this->vars) {
1379 var->newname = get_CF_string(var->newname);
1380 for (
auto &dim:var->dims)
1381 dim->newname = get_CF_string(dim->newname);
1384 if (
true == include_attr) {
1386 for (
auto &root_attr:this->root_attrs) {
1387 root_attr->newname = get_CF_string(root_attr->newname);
1390 for (
auto &grp:this->groups) {
1391 grp->newname = get_CF_string(grp->newname);
1392 for (
auto &grp_attr:grp->attrs)
1393 grp_attr->newname = get_CF_string(grp_attr->newname);
1396 for (
const auto &var:this->vars) {
1397 for (
auto attr:var->attrs)
1398 attr->newname = get_CF_string(attr->newname);
1404void File::Handle_Var_NameClashing(
set<string>&objnameset)
1407 Handle_General_NameClashing(objnameset, this->vars);
1411void File::Handle_Group_NameClashing(
set<string> &objnameset)
1424 setret = objnameset.insert(FILE_ATTR_TABLE_NAME);
1425 if (
false == setret.second) {
1427 int clash_index = 1;
1428 string fa_clash_name = FILE_ATTR_TABLE_NAME;
1429 HDF5CFUtil::gen_unique_name(fa_clash_name, objnameset, clash_index);
1430 FILE_ATTR_TABLE_NAME = fa_clash_name;
1434 Handle_General_NameClashing(objnameset, this->
groups);
1439void File::Handle_Obj_AttrNameClashing()
1450 set<string> objnameset;
1453 Handle_General_NameClashing(objnameset, this->
root_attrs);
1456 for (
const auto &grp:this->
groups) {
1458 Handle_General_NameClashing(objnameset, grp->attrs);
1462 for (
const auto &var:this->
vars) {
1464 Handle_General_NameClashing(objnameset, var->attrs);
1470template<
class T>
void File::Handle_General_NameClashing(set<string>&objnameset, vector<T*>& objvec)
1477 pair<set<string>::iterator,
bool> setret;
1478 set<string>::iterator iss;
1480 vector<string> clashnamelist;
1482 map<int, int> cl_to_ol;
1488 for (
const auto &obj:objvec) {
1489 setret = objnameset.insert(obj->newname);
1490 if (
false == setret.second) {
1491 clashnamelist.insert(clashnamelist.end(), obj->newname);
1492 cl_to_ol[cl_index] = ol_index;
1500 for (
auto &clashname:clashnamelist) {
1501 int clash_index = 1;
1502 string temp_clashname = clashname +
'_';
1503 HDF5CFUtil::gen_unique_name(temp_clashname, objnameset, clash_index);
1504 clashname = temp_clashname;
1508 for (
unsigned int i = 0; i < clashnamelist.size(); i++)
1509 objvec[cl_to_ol[i]]->newname = clashnamelist[i];
1514void File::Handle_GeneralObj_NameClashing(
bool include_attr, set<string>& objnameset)
1517 Handle_Var_NameClashing(objnameset);
1518 if (
true == include_attr) {
1519 Handle_Group_NameClashing(objnameset);
1520 Handle_Obj_AttrNameClashing();
1525string File::get_CF_string(
string s)
1528 if (
"" == s)
return s;
1529 string insertString(1,
'_');
1532 if (
true == isdigit(s[0])) s.insert(0, insertString);
1534 for (
unsigned int i = 0; i < s.size(); i++)
1535 if ((
false == isalnum(s[i])) && (s[i] !=
'_')) s[i] =
'_';
1542void File::Insert_One_NameSizeMap_Element(
const string &name, hsize_t size,
bool unlimited)
1544 pair<map<string, hsize_t>::iterator,
bool> mapret;
1545 mapret = dimname_to_dimsize.insert(pair<string, hsize_t>(name, size));
1546 if (
false == mapret.second)
1547 throw4(
"The dimension name ", name,
" should map to ", size);
1549 pair<map<string, bool>::iterator,
bool> mapret2;
1550 mapret2 = dimname_to_unlimited.insert(pair<string, bool>(name, unlimited));
1551 if (
false == mapret2.second)
1552 throw3(
"The dimension name ", name,
" unlimited dimension info. should be provided.");
1557void File::Insert_One_NameSizeMap_Element2(map<string, hsize_t>& name_to_size, map<string, bool>& name_to_unlimited,
1558 const string &name, hsize_t size,
bool unlimited)
const
1560 pair<map<string, hsize_t>::iterator,
bool> mapret;
1561 mapret = name_to_size.insert(pair<string, hsize_t>(name, size));
1562 if (
false == mapret.second)
1563 throw4(
"The dimension name ", name,
" should map to ", size);
1565 pair<map<string, bool>::iterator,
bool> mapret2;
1566 mapret2 = name_to_unlimited.insert(pair<string, bool>(name, unlimited));
1567 if (
false == mapret2.second)
1568 throw3(
"The dimension name ", name,
" unlimited dimension info. should be provided.");
1585void File::Add_One_FakeDim_Name(
Dimension *dim)
1588 stringstream sfakedimindex;
1589 string fakedimstr =
"FakeDim";
1590 pair<set<string>::iterator,
bool> setret;
1591 map<hsize_t, string>::iterator im;
1592 pair<map<hsize_t, string>::iterator,
bool> mapret;
1594 sfakedimindex << addeddimindex;
1595 string added_dimname = fakedimstr + sfakedimindex.str();
1599 if (
false == mapret.second) {
1601 dim->newname = dim->name;
1608 setret = dimnamelist.insert(added_dimname);
1609 if (
false == setret.second) {
1610 int clash_index = 1;
1611 string temp_clashname = added_dimname +
'_';
1612 HDF5CFUtil::gen_unique_name(temp_clashname, dimnamelist, clash_index);
1613 dim->name = temp_clashname;
1614 dim->newname = dim->name;
1615 setret = dimnamelist.insert(dim->name);
1616 if (
false == setret.second)
1617 throw2(
"Fail to insert the unique dimsizede name ", dim->name);
1623 if (
false == mapret.second)
1624 throw4(
"The dimension size ", dim->size,
" should map to ", dim->name);
1628 dim->name = added_dimname;
1629 dim->newname = dim->name;
1630 Insert_One_NameSizeMap_Element(dim->name, dim->size, dim->unlimited_dim);
1638void File::Adjust_Duplicate_FakeDim_Name(
Dimension * dim)
1646 stringstream sfakedimindex;
1647 pair<set<string>::iterator,
bool> setret;
1650 sfakedimindex << addeddimindex;
1651 string added_dimname =
"FakeDim" + sfakedimindex.str();
1652 setret = dimnamelist.insert(added_dimname);
1653 if (
false == setret.second) {
1654 int clash_index = 1;
1655 string temp_clashname = added_dimname +
'_';
1656 HDF5CFUtil::gen_unique_name(temp_clashname, dimnamelist, clash_index);
1657 dim->name = temp_clashname;
1658 dim->newname = dim->name;
1659 setret = dimnamelist.insert(dim->name);
1660 if (
false == setret.second)
1661 throw2(
"Fail to insert the unique dimsizede name ", dim->name);
1663 dim->name = added_dimname;
1664 dim->newname = dim->name;
1665 Insert_One_NameSizeMap_Element(dim->name, dim->size, dim->unlimited_dim);
1678void File::Adjust_Duplicate_FakeDim_Name2(
Dimension * dim,
int dup_dim_size_index)
1686 bool dup_dim_size_exist =
false;
1687 int temp_dup_dim_size_index = 0;
1688 for (
const auto &one_dup_dimsize_dimname:dup_dimsize_dimname) {
1691 if(dim->size == one_dup_dimsize_dimname.first) {
1692 temp_dup_dim_size_index++;
1694 if(dup_dim_size_index == temp_dup_dim_size_index) {
1695 dup_dim_size_exist =
true;
1696 dim->name = one_dup_dimsize_dimname.second;
1697 dim->newname = dim->name;
1705 if(dup_dim_size_exist ==
false) {
1707 stringstream sfakedimindex;
1708 pair<set<string>::iterator,
bool> setret;
1710 sfakedimindex << addeddimindex;
1711 string added_dimname =
"FakeDim" + sfakedimindex.str();
1712 setret = dimnamelist.insert(added_dimname);
1713 if (
false == setret.second) {
1714 throw2(
"Inside Adjust_Duplicate_FakeDim_Name2(), Fail to insert the unique dim name ", dim->name);
1716 dim->name = added_dimname;
1717 dim->newname = dim->name;
1718 Insert_One_NameSizeMap_Element(dim->name, dim->size, dim->unlimited_dim);
1720 dup_dimsize_dimname.emplace_back(dim->size,dim->name);
1729void File::Replace_Dim_Name_All(
const string orig_dim_name,
const string new_dim_name) {
1732 for (vector<Var *>::iterator irv = this->
vars.begin();
1733 irv != this->vars.end(); ++irv) {
1734 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
1735 ird != (*irv)->dims.end(); ++ird) {
1736 if((*ird)->name == orig_dim_name) {
1737 (*ird)->name = new_dim_name;
1738 (*ird)->newname = new_dim_name;
1747void File::Use_Dim_Name_With_Size_All(
const string dim_name,
const size_t dim_size) {
1750 for (vector<Var *>::iterator irv = this->
vars.begin();
1751 irv != this->vars.end(); ++irv) {
1752 for (vector<Dimension *>::iterator ird= (*irv)->dims.begin();
1753 ird != (*irv)->dims.end(); ++ird) {
1754 if((*ird)->size == orig_dim_name) {
1755 (*ird)->name = new_dim_name;
1756 (*ird)->newname = new_dim_name;
1766void File::Add_Str_Attr(
Attribute* attr,
const string &attrname,
const string& strvalue)
const
1769 attr->name = attrname;
1770 attr->newname = attr->name;
1771 attr->dtype = H5FSTRING;
1773 attr->fstrsize = strvalue.size();
1774 attr->strsize.resize(1);
1775 attr->strsize[0] = attr->fstrsize;
1776 attr->value.resize(strvalue.size());
1777 copy(strvalue.begin(), strvalue.end(), attr->value.begin());
1782File:: Var_Has_Attr(
Var*var,
const string &attrname) {
1784 for (vector<Attribute *>:: iterator ira =var->attrs.begin(); ira !=var->attrs.end(); ++ira) {
1788 if((*ira)->name == attrname || (*ira)->newname == attrname) {
1797string File::Retrieve_Str_Attr_Value(
Attribute *attr,
const string & var_path)
const
1800 if (attr !=
nullptr && var_path !=
"") {
1801 Retrieve_H5_Attr_Value(attr, var_path);
1802 string orig_attr_value(attr->value.begin(), attr->value.end());
1803 return orig_attr_value;
1810bool File::Is_Str_Attr(
Attribute* attr,
const string& varfullpath,
const string &attrname,
const string& strvalue)
1812 bool ret_value =
false;
1813 if (attrname == get_CF_string(attr->newname)) {
1814 Retrieve_H5_Attr_Value(attr, varfullpath);
1815 string attr_value(attr->value.begin(), attr->value.end());
1816 if (attr_value == strvalue) ret_value =
true;
1822bool File::has_latlon_cf_units(
Attribute *attr,
const string &varfullpath,
bool is_lat)
1824 string attr_name =
"units";
1825 if (
true == is_lat) {
1826 string lat_unit_value =
"degrees_north";
1827 return Is_Str_Attr(attr, varfullpath, attr_name, lat_unit_value);
1830 string lon_unit_value =
"degrees_east";
1831 return Is_Str_Attr(attr, varfullpath, attr_name, lon_unit_value);
1836void File::Add_One_Float_Attr(
Attribute* attr,
const string &attrname,
float float_value)
const
1838 attr->name = attrname;
1839 attr->newname = attr->name;
1840 attr->dtype = H5FLOAT32;
1842 attr->value.resize(
sizeof(
float));
1843 memcpy(&(attr->value[0]), (
void*) (&float_value),
sizeof(
float));
1848void File::Change_Attr_One_Str_to_Others(
Attribute* attr,
const Var*var)
const
1853 long int num_sli = 0;
1854 if (attr->dtype != H5FSTRING)
1855 throw2(
"Currently we only convert fixed-size string to other datatypes. ", attr->name);
1856 if (attr->count != 1)
1857 throw4(
"The fixed-size string count must be 1 and the current count is ", attr->count,
" for the attribute ",
1860 Retrieve_H5_Attr_Value(attr, var->fullpath);
1862 attr_value.resize(attr->value.size());
1863 copy(attr->value.begin(), attr->value.end(), attr_value.begin());
1865 switch (var->dtype) {
1868 num_sli = strtol(&(attr->value[0]), &pEnd, 10);
1869 if (num_sli < 0 || num_sli > UCHAR_MAX)
1870 throw5(
"Attribute type is unsigned char, the current attribute ", attr->name,
" has the value ", num_sli,
1871 ". It is overflowed. ");
1873 auto num_suc = (
unsigned char) num_sli;
1874 attr->dtype = H5UCHAR;
1875 attr->value.resize(
sizeof(
unsigned char));
1876 memcpy(&(attr->value[0]), (
void*) (&num_suc),
sizeof(
unsigned char));
1882 num_sli = strtol(&(attr->value[0]), &pEnd, 10);
1883 if (num_sli < SCHAR_MIN || num_sli > SCHAR_MAX)
1884 throw5(
"Attribute type is signed char, the current attribute ", attr->name,
" has the value ", num_sli,
1885 ". It is overflowed. ");
1887 auto num_sc = (char) num_sli;
1888 attr->dtype = H5CHAR;
1889 attr->value.resize(
sizeof(
char));
1890 memcpy(&(attr->value[0]), (
void*) (&num_sc),
sizeof(
char));
1896 num_sli = strtol(&(attr->value[0]), &pEnd, 10);
1897 if (num_sli < SHRT_MIN || num_sli > SHRT_MAX)
1898 throw5(
"Attribute type is 16-bit integer, the current attribute ", attr->name,
" has the value ", num_sli,
1899 ". It is overflowed. ");
1901 auto num_ss = (short) num_sli;
1902 attr->dtype = H5INT16;
1903 attr->value.resize(
sizeof(
short));
1904 memcpy(&(attr->value[0]), (
void*) (&num_ss),
sizeof(
short));
1910 num_sli = strtol(&(attr->value[0]), &pEnd, 10);
1911 if (num_sli < 0 || num_sli > USHRT_MAX)
1912 throw5(
"Attribute type is unsigned 16-bit integer, the current attribute ", attr->name,
" has the value ",
1913 num_sli,
". It is overflowed. ");
1915 auto num_uss = (
unsigned short) num_sli;
1916 attr->dtype = H5UINT16;
1917 attr->value.resize(
sizeof(
unsigned short));
1918 memcpy(&(attr->value[0]), (
void*) (&num_uss),
sizeof(
unsigned short));
1923 num_sli = strtol(&(attr->value[0]), &pEnd, 10);
1929 attr->dtype = H5INT32;
1930 attr->value.resize(
sizeof(
long int));
1931 memcpy(&(attr->value[0]), (
void*) (&num_sli),
sizeof(
long int));
1936 unsigned long int num_suli = strtoul(&(attr->value[0]), &pEnd, 10);
1938 attr->dtype = H5UINT32;
1939 attr->value.resize(
sizeof(
unsigned long int));
1940 memcpy(&(attr->value[0]), (
void*) (&num_suli),
sizeof(
unsigned long int));
1944 float num_sf = strtof(&(attr->value[0]),
nullptr);
1946 attr->dtype = H5FLOAT32;
1947 attr->value.resize(
sizeof(
float));
1948 memcpy(&(attr->value[0]), (
void*) (&num_sf),
sizeof(
float));
1952 double num_sd = strtod(&(attr->value[0]),
nullptr);
1954 attr->dtype = H5FLOAT64;
1955 attr->value.resize(
sizeof(
double));
1956 memcpy(&(attr->value[0]), (
void*) (&num_sd),
sizeof(
double));
1961 throw4(
"Unsupported HDF5 datatype that the string is converted to for the attribute ", attr->name,
1962 " of the variable ", var->fullpath);
1968void File::Replace_Var_Str_Attr(
Var* var,
const string &attr_name,
const string& strvalue)
1971 bool rep_attr =
true;
1972 bool rem_attr =
false;
1973 for (
auto &attr:var->attrs) {
1974 if (attr->name == attr_name) {
1975 if (
true == Is_Str_Attr(attr, var->fullpath, attr_name, strvalue))
1984 if (
true == rem_attr) {
1985 for (
auto ira = var->attrs.begin(); ira != var->attrs.end(); ira++) {
1986 if ((*ira)->name == attr_name) {
1988 var->attrs.erase(ira);
1995 if (
true == rep_attr) {
1996 auto attr_unique = make_unique<Attribute>();
1997 auto attr = attr_unique.release();
1998 Add_Str_Attr(attr, attr_name, strvalue);
1999 var->attrs.push_back(attr);
2004bool File::Is_geolatlon(
const string & var_name,
bool is_lat)
const
2007 bool ret_value =
false;
2008 if (
true == is_lat) {
2009 string lat1 =
"lat";
2010 string lat2 =
"latitude";
2011 string lat3 =
"Latitude";
2013 if (var_name.compare(lat1) == 0 || var_name.compare(lat2) == 0 || var_name.compare(lat3) == 0) ret_value =
true;
2017 string lon1 =
"lon";
2018 string lon2 =
"longitude";
2019 string lon3 =
"Longitude";
2020 if (var_name.compare(lon1) == 0 || var_name.compare(lon2) == 0 || var_name.compare(lon3) == 0) ret_value =
true;
2030 if (
false == add_path)
return;
2033 for (
auto &var:this->vars) {
2034 auto attr_unique = make_unique<Attribute>();
2035 auto attr = attr_unique.release();
2036 const string varname = var->name;
2037 const string attrname =
"origname";
2038 Add_Str_Attr(attr, attrname, varname);
2039 var->attrs.push_back(attr);
2042 for (
auto &var:this->vars) {
2046 if (var->zero_storage_size==
false
2047 || HDF5RequestHandler::get_no_zero_size_fullnameattr() ==
false) {
2048 auto attr_unique = make_unique<Attribute>();
2049 auto attr = attr_unique.release();
2050 const string varname = var->fullpath;
2051 const string attrname =
"fullnamepath";
2052 Add_Str_Attr(attr, attrname, varname);
2053 var->attrs.push_back(attr);
2058 for (
const auto &grp:this->groups) {
2060 if (
false == grp->attrs.empty()) {
2062 const string varname = grp->path;
2063 const string attrname =
"fullnamepath";
2064 auto attr_unique = make_unique<Attribute>();
2065 auto attr = attr_unique.release();
2066 Add_Str_Attr(attr, attrname, varname);
2067 grp->attrs.push_back(attr);
2075void File::Replace_Var_Info(
const Var *src,
Var *target)
2079 for_each (target->dims.begin (), target->dims.end (),
2081 for_each (target->attrs.begin (), target->attrs.end (),
2085 target->newname = src->newname;
2086 target->name = src->name;
2087 target->fullpath = src->fullpath;
2088 target->rank = src->rank;
2089 target->dtype = src->dtype;
2090 target->unsupported_attr_dtype = src->unsupported_attr_dtype;
2091 target->unsupported_dspace = src->unsupported_dspace;
2093 for (
auto ira = target->attrs.begin();
2094 ira!=target->attrs.end(); ++ira) {
2096 target->attrs.erase(ira);
2100 for (
auto ird = target->dims.begin(); ird != target->dims.end();) {
2102 ird = target->dims.erase(ird);
2107 for (vector<Attribute*>::iterator ira = src->attrs.begin();
2108 ira!=src->attrs.end(); ++ira) {
2109 Attribute* attr=
new Attribute();
2110 attr->name = (*ira)->name;
2111 attr->newname = (*ira)->newname;
2112 attr->dtype =(*ira)->dtype;
2113 attr->count =(*ira)->count;
2114 attr->strsize = (*ira)->strsize;
2115 attr->fstrsize = (*ira)->fstrsize;
2116 attr->value =(*ira)->value;
2117 target->attrs.push_back(attr);
2121 for (
const auto& sdim:src->dims) {
2122 auto dim_unique = make_unique<Dimension>(sdim->size);
2123 auto dim = dim_unique.release();
2124 dim->name = sdim->name;
2125 dim->newname = sdim->newname;
2126 target->dims.push_back(dim);
2132void File::Replace_Var_Attrs(
const Var *src,
Var *target)
2136 for_each (target->dims.begin (), target->dims.end (),
2138 for_each (target->attrs.begin (), target->attrs.end (),
2142 for (
auto ira = target->attrs.begin(); ira != target->attrs.end();) {
2144 ira = target->attrs.erase(ira);
2146 for (
const auto &sattr:src->attrs) {
2147 auto attr_unique = make_unique<Attribute>();
2148 auto attr = attr_unique.release();
2149 attr->name = sattr->name;
2150 attr->newname = sattr->newname;
2151 attr->dtype = sattr->dtype;
2152 attr->count = sattr->count;
2153 attr->strsize = sattr->strsize;
2154 attr->fstrsize = sattr->fstrsize;
2155 attr->value = sattr->value;
2156 target->attrs.push_back(attr);
2164bool File::is_var_under_group(
const string &varname,
const string &grpname,
const int var_rank,
2165 vector<size_t> & var_size)
const
2168 bool ret_value =
false;
2169 for (
const auto &var:this->
vars) {
2171 if (var->rank == var_rank) {
2172 if (var->name == varname) {
2175 string var_path = HDF5CFUtil::obtain_string_before_lastslash(var->fullpath);
2178 if (grpname == var_path) {
2180 for (
int i = 0; i < var_rank; i++)
2193 bool ret_value =
false;
2194 for (
const auto& var:this->vars) {
2195 for (
const auto& attr:var->attrs) {
2196 if(attr->name ==
"grid_mapping") {
2201 if(
true == ret_value)
2210 for (
auto &var:this->vars) {
2212 for (
auto ira = var->attrs.begin(); ira != var->attrs.end(); ++ira) {
2213 if((*ira)->name ==
"grid_mapping") {
2214 Retrieve_H5_Attr_Value(*ira, var->fullpath);
2215 attr_value.resize((*ira)->value.size());
2216 copy((*ira)->value.begin(), (*ira)->value.end(), attr_value.begin());
2221 if(attr_value.find(
'/') ==string::npos){
2222 string new_name = Check_Grid_Mapping_VarName(attr_value,var->fullpath);
2224 Replace_Var_Str_Attr(var,
"grid_mapping",new_name);
2228 string new_name = Check_Grid_Mapping_FullPath(attr_value);
2231 Replace_Var_Str_Attr(var,
"grid_mapping",new_name);
2237string File::Check_Grid_Mapping_VarName(
const string & a_value,
const string & var_fpath)
const {
2239 string var_path = HDF5CFUtil::obtain_string_before_lastslash(var_fpath);
2240 string gmap_new_name;
2241 for (
const auto &var:this->vars) {
2242 if(var->name == a_value){
2243 if(var_path == HDF5CFUtil::obtain_string_before_lastslash(var->fullpath)) {
2244 gmap_new_name = var->newname;
2249 return gmap_new_name;
2253string File::Check_Grid_Mapping_FullPath(
const string & a_value)
const {
2255 string gmap_new_name;
2256 for (
const auto &var:this->
vars) {
2257 if(var->fullpath == a_value){
2258 gmap_new_name = var->newname;
2263 return gmap_new_name;
2266void File::remove_netCDF_internal_attributes(
bool include_attr) {
2268 if(
true == include_attr) {
2270 for (
const auto &var:this->
vars) {
2272 bool var_has_dimscale =
false;
2274 for (
auto ira = var->attrs.begin(); ira != var->attrs.end();) {
2275 if((*ira)->name ==
"CLASS") {
2276 string class_value = Retrieve_Str_Attr_Value(*ira,var->fullpath);
2280 if (0 == class_value.compare(0,15,
"DIMENSION_SCALE")) {
2282 ira = var->attrs.erase(ira);
2283 var_has_dimscale =
true;
2296 else if((*ira)->name ==
"NAME") {
2297 string name_value = Retrieve_Str_Attr_Value(*ira,var->fullpath);
2298 if( 0 == name_value.compare(0,var->name.size(),var->name)) {
2300 ira =var->attrs.erase(ira);
2303 string netcdf_dim_mark=
"This is a netCDF dimension but not a netCDF variable";
2304 if( 0 == name_value.compare(0,netcdf_dim_mark.size(),netcdf_dim_mark)) {
2306 ira =var->attrs.erase(ira);
2315 else if((*ira)->name ==
"_Netcdf4Dimid") {
2317 ira =var->attrs.erase(ira);
2319 else if((*ira)->name ==
"_Netcdf4Coordinates") {
2321 ira =var->attrs.erase(ira);
2324 else if((*ira)->name ==
"_nc3_strict") {
2326 ira =var->attrs.erase(ira);
2334 if(
true == var_has_dimscale) {
2335 for(
auto ira = var->attrs.begin();
2336 ira != var->attrs.end();++ira) {
2337 if((*ira)->name ==
"NAME") {
2339 ira =var->attrs.erase(ira);
2349void File::add_ignored_info_page_header()
2352 " \n This page is for HDF5 CF hyrax data providers or distributors to check if any HDF5 object or attribute information are ignored during the mapping. \n\n";
2356void File::add_ignored_info_obj_header()
2359 ignored_msg +=
" Some HDF5 objects or the object information are ignored when mapping to DAP2 by the HDF5 OPeNDAP";
2360 ignored_msg +=
" handler due to the restrictions of DAP2, CF conventions or CF tools.";
2361 ignored_msg +=
" Please use HDF5 tools(h5dump or HDFView) to check carefully and make sure that these objects";
2363 " are OK to ignore for your service. For questions or requests to find a way to handle the ignored objects, please";
2364 ignored_msg +=
" contact the HDF5 OPeNDAP handler developer or send an email to help@hdfgroup.org.\n";
2366 ignored_msg +=
" \n In general, ignored HDF5 objects include HDF5 soft links, external links and named datatype.\n";
2368 " \n The HDF5 datasets(variables in the CF term) and attributes that have the following datatypes are ignored: \n";
2370 " Signed and unsigned 64-bit integers, HDF5 compound, HDF5 variable size(excluding variable length string),";
2371 ignored_msg +=
" HDF5 reference, HDF5 enum, HDF5 opaque , HDF5 bitfield, HDF5 Array and HDF5 Time datatypes.\n";
2374 " \n The HDF5 datasets(variables in the CF term) and attributes associated with the following dimensions are ignored: \n";
2375 ignored_msg +=
" 1) variables that have HDF5 NULL dataspace(H5S_NULL)(rarely occurred)\n";
2376 ignored_msg +=
" 2) attributes that have any zero size dimensions(not reported due to extreme rarity and non-trivial coding)\n\n";
2381void File::add_ignored_info_links_header()
2384 if (
false == this->have_ignored) {
2385 add_ignored_info_obj_header();
2386 have_ignored =
true;
2389 string lh_msg =
"******WARNING******\n";
2390 lh_msg +=
"IGNORED soft links or external links are: ";
2391 if (ignored_msg.rfind(lh_msg) == string::npos) ignored_msg += lh_msg +
"\n";
2398File:: add_ignored_info_obj_dtype_header() {
2401 ignored_msg +=
" \n Variables and attributes ignored due to the unsupported datatypes. \n";
2402 ignored_msg +=
" In general, the unsupported datatypes include: \n";
2403 ignored_msg +=
" Signed and unsigned 64-bit integers, HDF5 compound, HDF5 variable size(excluding variable length string),";
2404 ignored_msg +=
" HDF5 reference, HDF5 enum, HDF5 opaque , HDF5 bitfield, HDF5 Array and HDF5 Time datatypes.\n";
2409File:: add_ignored_info_obj_dspace_header() {
2412 ignored_msg +=
" \n Variables and attributes ignored due to the unsupported dimensions. \n";
2413 ignored_msg +=
" In general, the unsupported dimensions include: \n";
2414 ignored_msg +=
" 1) variables that have HDF5 NULL dataspace(H5S_NULL)(rarely occurred)\n";
2415 ignored_msg +=
" 2) variables that have any zero size dimensions\n";
2421void File::add_ignored_info_links(
const string & link_path)
2423 if (ignored_msg.find(
"Link paths: ") == string::npos)
2424 ignored_msg +=
" Link paths: " + link_path;
2426 ignored_msg +=
" " + link_path;
2430void File::add_ignored_info_namedtypes(
const string& grp_name,
const string& named_dtype_name)
2433 if (
false == this->have_ignored) {
2434 add_ignored_info_obj_header();
2435 have_ignored =
true;
2438 string ignored_HDF5_named_dtype_hdr =
"\n******WARNING******";
2439 ignored_HDF5_named_dtype_hdr +=
"\n IGNORED HDF5 named datatype objects:\n";
2440 string ignored_HDF5_named_dtype_msg =
" Group name: " + grp_name +
" HDF5 named datatype name: " + named_dtype_name.substr(0,named_dtype_name.size()-1)
2442 if (ignored_msg.find(ignored_HDF5_named_dtype_hdr) == string::npos)
2443 ignored_msg += ignored_HDF5_named_dtype_hdr + ignored_HDF5_named_dtype_msg;
2445 ignored_msg += ignored_HDF5_named_dtype_msg;
2451void File::add_ignored_info_attrs(
bool is_grp,
const string & obj_path,
const string & attr_name)
2454 if (
false == this->have_ignored) {
2455 add_ignored_info_obj_header();
2456 have_ignored =
true;
2460 string ignored_warning_str =
"\n******WARNING******";
2461 string ignored_HDF5_grp_hdr = ignored_warning_str +
"\n Ignored attributes under root and groups:\n";
2462 string ignored_HDF5_grp_msg =
" Group path: " + obj_path +
" Attribute names: " + attr_name +
"\n";
2463 string ignored_HDF5_var_hdr = ignored_warning_str +
"\n Ignored attributes for variables:\n";
2464 string ignored_HDF5_var_msg =
" Variable path: " + obj_path +
" Attribute names: " + attr_name +
"\n";
2467 if (
true == is_grp) {
2468 if (ignored_msg.find(ignored_HDF5_grp_hdr) == string::npos)
2469 ignored_msg += ignored_HDF5_grp_hdr + ignored_HDF5_grp_msg;
2471 ignored_msg += ignored_HDF5_grp_msg;
2474 if (ignored_msg.find(ignored_HDF5_var_hdr) == string::npos)
2475 ignored_msg += ignored_HDF5_var_hdr + ignored_HDF5_var_msg;
2477 ignored_msg += ignored_HDF5_var_msg;
2484void File::add_ignored_info_objs(
bool is_dim_related,
const string & obj_path)
2487 if (
false == this->have_ignored) {
2488 add_ignored_info_obj_header();
2489 have_ignored =
true;
2492 string ignored_warning_str =
"\n******WARNING******";
2493 string ignored_HDF5_dtype_var_hdr = ignored_warning_str +
"\n IGNORED variables due to unsupported datatypes:\n";
2494 string ignored_HDF5_dspace_var_hdr = ignored_warning_str +
"\n IGNORED variables due to unsupported dimensions:\n";
2495 string ignored_HDF5_var_msg =
" Variable path: " + obj_path +
"\n";
2497 if (
true == is_dim_related) {
2498 if (ignored_msg.find(ignored_HDF5_dspace_var_hdr) == string::npos)
2499 ignored_msg += ignored_HDF5_dspace_var_hdr + ignored_HDF5_var_msg;
2501 ignored_msg += ignored_HDF5_var_msg;
2505 if (ignored_msg.find(ignored_HDF5_dtype_var_hdr) == string::npos)
2506 ignored_msg += ignored_HDF5_dtype_var_hdr + ignored_HDF5_var_msg;
2508 ignored_msg += ignored_HDF5_var_msg;
2514void File::add_no_ignored_info()
2517 ignored_msg +=
"There are no ignored HDF5 objects or attributes.";
2523bool File::ignored_dimscale_ref_list(
const Var *var)
const
2526 bool ignored_dimscale =
true;
2529 bool has_dimscale =
false;
2530 bool has_reference_list =
false;
2531 for (
const auto &attr:var->attrs) {
2532 if (attr->name ==
"REFERENCE_LIST" &&
false == HDF5CFUtil::cf_strict_support_type(attr->getType(),_is_dap4))
2533 has_reference_list =
true;
2534 if (attr->name ==
"CLASS") {
2535 Retrieve_H5_Attr_Value(attr, var->fullpath);
2537 class_value.resize(attr->value.size());
2538 copy(attr->value.begin(), attr->value.end(), class_value.begin());
2542 if (0 == class_value.compare(0, 15,
"DIMENSION_SCALE")) {
2543 has_dimscale =
true;
2547 if (
true == has_dimscale &&
true == has_reference_list) {
2548 ignored_dimscale =
false;
2553 return ignored_dimscale;
2557bool File::Check_DropLongStr(
const Var *var,
const Attribute * attr)
2560 bool drop_longstr =
false;
2561 if (
nullptr == attr) {
2562 if (H5FSTRING == var->dtype || H5VSTRING == var->dtype) {
2564 drop_longstr = Check_VarDropLongStr(var->fullpath, var->dims, var->dtype);
2567 throw1(
"Check_VarDropLongStr fails ");
2574 if (H5FSTRING == attr->dtype || H5VSTRING == attr->dtype) {
2575 if (attr->getBufSize() > NC_JAVA_STR_SIZE_LIMIT) {
2576 drop_longstr =
true;
2582 return drop_longstr;
2588bool File::Check_VarDropLongStr(
const string & varpath,
const vector<Dimension *>& dims, H5DataType dtype)
const
2592 bool drop_longstr =
false;
2594 hid_t dset_id = H5Dopen2(this->fileid, varpath.c_str(), H5P_DEFAULT);
2596 throw2(
"Cannot open the dataset ", varpath);
2598 hid_t dtype_id = -1;
2599 if ((dtype_id = H5Dget_type(dset_id)) < 0) {
2601 throw2(
"Cannot obtain the datatype of the dataset ", varpath);
2604 size_t ty_size = H5Tget_size(dtype_id);
2608 throw2(
"Cannot obtain the datatype size of the dataset ", varpath);
2611 if (H5FSTRING == dtype) {
2612 if (ty_size > NC_JAVA_STR_SIZE_LIMIT) drop_longstr =
true;
2614 else if (H5VSTRING == dtype) {
2616 unsigned long long total_elms = 1;
2617 if (dims.empty() ==
false) {
2618 for (
const auto &dim:dims)
2619 total_elms = total_elms * (dim->size);
2621 vector<char> strval;
2622 strval.resize(total_elms * ty_size);
2623 hid_t read_ret = H5Dread(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, (
void*) strval.data());
2627 throw2(
"Cannot read the data of the dataset ", varpath);
2630 vector<string> finstrval;
2631 finstrval.resize(total_elms);
2632 char*temp_bp = strval.data();
2633 char*onestring =
nullptr;
2634 for (
unsigned long long i = 0; i < total_elms; i++) {
2635 onestring = *(
char**) temp_bp;
2636 if (onestring !=
nullptr) {
2637 finstrval[i] = string(onestring);
2638 if(finstrval[i].size()>NC_JAVA_STR_SIZE_LIMIT) {
2639 drop_longstr =
true;
2646 if (
false == strval.empty()) {
2647 herr_t ret_vlen_claim;
2648 hid_t dspace_id = H5Dget_space(dset_id);
2649 if (dspace_id < 0) {
2652 throw2(
"Cannot obtain the dataspace id.", varpath);
2654 ret_vlen_claim = H5Dvlen_reclaim(dtype_id, dspace_id, H5P_DEFAULT, (
void*) strval.data());
2655 if (ret_vlen_claim < 0) {
2657 H5Sclose(dspace_id);
2659 throw2(
"Cannot reclaim the vlen space ", varpath);
2661 if (H5Sclose(dspace_id) < 0) {
2664 throw2(
"Cannot close the HDF5 data space.", varpath);
2668 if (H5Tclose(dtype_id) < 0) {
2670 throw2(
"Cannot close the HDF5 data type.", varpath);
2672 if (H5Dclose(dset_id) < 0)
2673 throw2(
"Cannot close the HDF5 data type.", varpath);
2675 return drop_longstr;
2678bool File::Check_VarDropLongStr(
const string & varpath,
const vector<Dimension *>& dims, H5DataType dtype)
2682 bool drop_longstr =
false;
2684 unsigned long long total_elms = 1;
2685 if (dims.size() != 0) {
2686 for (
unsigned int i = 0; i < dims.size(); i++)
2687 total_elms = total_elms * ((dims[i])->size);
2690 if (total_elms > NC_JAVA_STR_SIZE_LIMIT)
2691 drop_longstr =
true;
2695 hid_t dset_id = H5Dopen2(this->fileid, varpath.c_str(), H5P_DEFAULT);
2697 throw2(
"Cannot open the dataset ", varpath);
2699 hid_t dtype_id = -1;
2700 if ((dtype_id = H5Dget_type(dset_id)) < 0) {
2702 throw2(
"Cannot obtain the datatype of the dataset ", varpath);
2705 size_t ty_size = H5Tget_size(dtype_id);
2709 throw2(
"Cannot obtain the datatype size of the dataset ", varpath);
2712 if (H5FSTRING == dtype) {
2713 if ((ty_size * total_elms) > NC_JAVA_STR_SIZE_LIMIT) drop_longstr =
true;
2715 else if (H5VSTRING == dtype) {
2717 vector<char> strval;
2718 strval.resize(total_elms * ty_size);
2719 hid_t read_ret = H5Dread(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, (
void*) strval.data());
2723 throw2(
"Cannot read the data of the dataset ", varpath);
2726 vector<string> finstrval;
2727 finstrval.resize(total_elms);
2728 char*temp_bp = strval.data();
2729 char*onestring =
nullptr;
2730 for (
unsigned long long i = 0; i < total_elms; i++) {
2731 onestring = *(
char**) temp_bp;
2732 if (onestring !=
nullptr)
2733 finstrval[i] = string(onestring);
2740 if (
false == strval.empty()) {
2741 herr_t ret_vlen_claim;
2742 hid_t dspace_id = H5Dget_space(dset_id);
2743 if (dspace_id < 0) {
2746 throw2(
"Cannot obtain the dataspace id.", varpath);
2748 ret_vlen_claim = H5Dvlen_reclaim(dtype_id, dspace_id, H5P_DEFAULT, (
void*) strval.data());
2749 if (ret_vlen_claim < 0) {
2751 H5Sclose(dspace_id);
2753 throw2(
"Cannot reclaim the vlen space ", varpath);
2755 if (H5Sclose(dspace_id) < 0) {
2758 throw2(
"Cannot close the HDF5 data space.", varpath);
2761 unsigned long long total_str_size = 0;
2762 for (
unsigned long long i = 0; i < total_elms; i++) {
2763 total_str_size += finstrval[i].size();
2764 if (total_str_size > NC_JAVA_STR_SIZE_LIMIT) {
2765 drop_longstr =
true;
2770 if (H5Tclose(dtype_id) < 0) {
2772 throw2(
"Cannot close the HDF5 data type.", varpath);
2774 if (H5Dclose(dset_id) < 0)
2775 throw2(
"Cannot close the HDF5 data type.", varpath);
2777 return drop_longstr;
2783void File::add_ignored_grp_longstr_info(
const string& grp_path,
const string & attr_name)
2785 ignored_msg +=
"The HDF5 group: " + grp_path +
" has an empty-set string attribute: " + attr_name +
"\n";
2790void File::add_ignored_var_longstr_info(
const Var *var,
const Attribute *attr)
2793 if (
nullptr == attr)
2794 ignored_msg +=
"String variable: " + var->fullpath +
" value is set to empty.\n";
2796 ignored_msg +=
"The variable: " + var->fullpath +
" has an empty-set string attribute: " + attr->name +
"\n";
2803void File::add_ignored_droplongstr_hdr()
2806 if (
false == this->have_ignored) this->have_ignored =
true;
2807 string hdr =
"\n\n The values of the following string variables ";
2808 hdr +=
" are set to empty because at least one string size in this variable exceeds netCDF Java string limit(32767 bytes).\n";
2809 hdr +=
"To obtain the values, change the BES key H5.EnableDropLongString=true at the handler BES";
2810 hdr +=
" configuration file(h5.conf)\nto H5.EnableDropLongString=false.\n\n";
2812 if (ignored_msg.rfind(hdr) == string::npos) ignored_msg += hdr;
2817void File::release_standalone_var_vector(vector<Var*>&temp_vars)
2820 for (
auto i = temp_vars.begin(); i != temp_vars.end();) {
2822 i = temp_vars.erase(i);
This class specifies the core engineering of mapping HDF5 to DAP by following CF.
include the entry functions to execute the handlers
This class represents one attribute.
This class repersents one dimension of an HDF5 dataset(variable).
std::vector< Group * > groups
Non-root group vectors.
virtual void Retrieve_H5_Var_Attr_Values(Var *var)
Retrieve attribute values for a variable.
virtual void Handle_Unsupported_Dspace(bool)
Handle unsupported HDF5 dataspaces for datasets.
std::map< hsize_t, std::string > dimsize_to_fakedimname
Handle added dimension names.
virtual void Handle_Grid_Mapping_Vars()
Handle Grid Mapping Vars.
virtual void Handle_Unsupported_Others(bool)
Handle other unmapped objects/attributes.
virtual void Retrieve_H5_Supported_Attr_Values()
Retrieve attribute values for the supported HDF5 datatypes.
std::vector< Var * > vars
Var vectors.
virtual void Add_Supplement_Attrs(bool)
Add supplemental attributes such as fullpath and original name.
virtual void Retrieve_H5_Info(const char *path, hid_t file_id, bool)
std::vector< Attribute * > root_attrs
Root attribute vectors.
virtual void Handle_Unsupported_Dtype(bool)
Handle unsupported HDF5 datatypes.
virtual void Flatten_Obj_Name(bool)
Flatten the object name.
virtual bool Have_Grid_Mapping_Attrs()
Check if having Grid Mapping Attrs.
This class represents an HDF5 group. The group will be flattened according to the CF conventions.
This class represents one HDF5 dataset(CF variable)
H5DataType getType() const
Get the data type of this variable(Not HDF5 datatype id)
const std::vector< Dimension * > & getDimensions() const
Get the list of the dimensions.
Helper functions for generating DAS attributes and a function to check BES Key.
static H5DataType H5type_to_H5DAPtype(hid_t h5_type_id)
Map HDF5 Datatype to the intermediate H5DAPtype for the future use.
static std::string trim_string(hid_t dtypeid, const std::string &s, int num_sect, size_t section_size, std::vector< size_t > §_newsize)