41#include<InternalErr.h>
47int hinv_init(
int insys,
int inzone,
double *inparm,
int indatum,
char *fn27,
char *fn83,
int *iflg,
int (*hinv_trans[])(
double,
double,
double*,
double*));
49int hfor_init(
int outsys,
int outzone,
double *outparm,
int outdatum,
char *fn27,
char *fn83,
int *iflg,
int (*hfor_trans[])(
double,
double,
double *,
double *));
59 switch (H5Tget_class(h5_type_id)) {
62 size = H5Tget_size(h5_type_id);
63 sign = H5Tget_sign(h5_type_id);
66 if (sign == H5T_SGN_2)
72 if (sign == H5T_SGN_2)
78 if (sign == H5T_SGN_2)
84 if (sign == H5T_SGN_2)
89 else return H5UNSUPTYPE;
92 size = H5Tget_size(h5_type_id);
94 if (size == 4)
return H5FLOAT32;
95 else if (size == 8)
return H5FLOAT64;
96 else return H5UNSUPTYPE;
99 if (H5Tis_variable_str(h5_type_id))
101 else return H5FSTRING;
119size_t HDF5CFUtil::H5_numeric_atomic_type_size(H5DataType h5type) {
137 throw InternalErr(__FILE__,__LINE__,
"This routine doesn't support to return the size of this datatype");
143bool HDF5CFUtil::use_lrdata_mem_cache(H5DataType h5type, CVType cvtype,
bool islatlon ) {
144 if(h5type != H5CHAR && h5type !=H5UCHAR && h5type!=H5INT16 && h5type !=H5UINT16 &&
145 h5type != H5INT32 && h5type !=H5UINT32 && h5type !=H5FLOAT32 && h5type!=H5FLOAT64 &&
146 h5type != H5INT64 && h5type !=H5UINT64)
149 if(cvtype != CV_UNSUPPORTED)
152 else if(varpath ==
"")
164bool HDF5CFUtil::use_data_mem_cache(H5DataType h5type, CVType cvtype,
const string &varpath) {
165 if(h5type != H5CHAR && h5type !=H5UCHAR && h5type!=H5INT16 && h5type !=H5UINT16 &&
166 h5type != H5INT32 && h5type !=H5UINT32 && h5type !=H5FLOAT32 && h5type!=H5FLOAT64 &&
167 h5type != H5INT64 && h5type !=H5UINT64)
170 if(cvtype != CV_UNSUPPORTED)
173 else if(varpath ==
"")
182bool HDF5CFUtil::cf_strict_support_type(H5DataType dtype,
bool is_dap4) {
183 if ((H5UNSUPTYPE == dtype)||(H5REFERENCE == dtype)
184 || (H5COMPOUND == dtype) || (H5ARRAY == dtype))
189 else if ((H5INT64 == dtype) || (H5UINT64 == dtype)) {
190 if (
true == is_dap4 || HDF5RequestHandler::get_dmr_long_int()==
true)
199bool HDF5CFUtil::cf_dap2_support_numeric_type(H5DataType dtype,
bool is_dap4) {
200 if ((H5UNSUPTYPE == dtype)||(H5REFERENCE == dtype)
201 || (H5COMPOUND == dtype) || (H5ARRAY == dtype)
202 || (H5INT64 == dtype) ||(H5UINT64 == dtype)
203 || (H5FSTRING == dtype) ||(H5VSTRING == dtype))
205 else if ((H5INT64 == dtype) ||(H5UINT64 == dtype)) {
206 if(
true == is_dap4 ||
true == HDF5RequestHandler::get_dmr_long_int())
215string HDF5CFUtil::obtain_string_after_lastslash(
const string &s) {
218 size_t last_fslash_pos = s.find_last_of(
"/");
219 if (string::npos != last_fslash_pos &&
220 last_fslash_pos != (s.size()-1))
221 ret_str=s.substr(last_fslash_pos+1);
225string HDF5CFUtil::obtain_string_before_lastslash(
const string & s) {
228 size_t last_fslash_pos = s.find_last_of(
"/");
229 if (string::npos != last_fslash_pos)
230 ret_str=s.substr(0,last_fslash_pos+1);
237 string temp_sect_str =
"";
238 string temp_sect_newstr =
"";
241 for (
int i = 0; i < num_sect; i++) {
243 if (i != (num_sect-1))
244 temp_sect_str = s.substr(i*sect_size,sect_size);
246 temp_sect_str = s.substr((num_sect-1)*sect_size,s.size()-(num_sect-1)*sect_size);
250 if (H5T_STR_NULLTERM == H5Tget_strpad(ty_id))
251 temp_pos = temp_sect_str.find_first_of(
'\0');
252 else if (H5T_STR_SPACEPAD == H5Tget_strpad(ty_id))
253 temp_pos = temp_sect_str.find_last_not_of(
' ')+1;
254 else temp_pos = temp_sect_str.find_last_not_of(
'0')+1;
256 if (temp_pos != string::npos) {
262 if (H5T_STR_SPACEPAD == H5Tget_strpad(ty_id)) {
264 if (temp_pos == temp_sect_str.size())
265 temp_sect_newstr = temp_sect_str +
" ";
267 temp_sect_newstr = temp_sect_str.substr(0,temp_pos+1);
269 sect_newsize[i] = temp_pos +1;
272 temp_sect_newstr = temp_sect_str.substr(0,temp_pos);
273 sect_newsize[i] = temp_pos ;
280 temp_sect_newstr = temp_sect_str;
285 if (H5T_STR_SPACEPAD == H5Tget_strpad(ty_id)) {
286 temp_sect_newstr.resize(temp_sect_str.size()+1);
287 temp_sect_newstr.append(1,
' ');
288 sect_newsize[i] = sect_size + 1;
291 sect_newsize[i] = sect_size;
293 final_str+=temp_sect_newstr;
299string HDF5CFUtil::remove_substrings(
string str,
const string &substr) {
301 string::size_type i = str.find(substr);
302 while (i != std::string::npos) {
303 str.erase(i, substr.size());
304 i = str.find(substr, i);
309void HDF5CFUtil::gen_unique_name(
string &str,set<string>& namelist,
int&clash_index) {
311 pair<set<string>::iterator,
bool> ret;
313 stringstream sclash_index;
314 sclash_index << clash_index;
315 newstr = str + sclash_index.str();
317 ret = namelist.insert(newstr);
318 if (
false == ret.second) {
320 gen_unique_name(str,namelist,clash_index);
327HDF5CFUtil::Split_helper(vector<string> &tokens,
const string &text,
const char sep)
329 string::size_type start = 0;
330 string::size_type end = 0;
332 while ((end = text.find(sep, start)) != string::npos) {
333 tokens.push_back(text.substr(start, end - start));
336 tokens.push_back(text.substr(start));
346 for (
int i = 0, j = 0; j <= len; ++j) {
347 if ((j == len && len) || s[j] == sep) {
348 string elem(s + i, j - i);
349 names.push_back(elem);
361 Split(sz, (
int)strlen(sz), sep, names);
364void HDF5CFUtil::parser_gpm_l3_gridheader(
const vector<char>& value,
365 int& latsize,
int&lonsize,
366 float& lat_start,
float& lon_start,
367 float& lat_res,
float& lon_res,
368 bool check_reg_orig ){
370 float lat_north = 0.;
371 float lat_south = 0.;
375 vector<string> ind_elems;
384 if(ind_elems.size()<9)
385 throw InternalErr(__FILE__,__LINE__,
"The number of elements in the GPM level 3 GridHeader is not right.");
387 if(
false == check_reg_orig) {
388 if (0 != ind_elems[1].find(
"Registration=CENTER"))
389 throw InternalErr(__FILE__,__LINE__,
"The GPM grid registration is not center.");
392 if (0 == ind_elems[2].find(
"LatitudeResolution")){
394 size_t equal_pos = ind_elems[2].find_first_of(
'=');
395 if(string::npos == equal_pos)
396 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
398 size_t scolon_pos = ind_elems[2].find_first_of(
';');
399 if(string::npos == scolon_pos)
400 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
401 if (equal_pos < scolon_pos){
403 string latres_str = ind_elems[2].substr(equal_pos+1,scolon_pos-equal_pos-1);
404 lat_res = strtof(latres_str.c_str(),
nullptr);
407 throw InternalErr(__FILE__,__LINE__,
"latitude resolution is not right for GPM level 3 products");
410 throw InternalErr(__FILE__,__LINE__,
"The GPM grid LatitudeResolution doesn't exist.");
412 if (0 == ind_elems[3].find(
"LongitudeResolution")){
414 size_t equal_pos = ind_elems[3].find_first_of(
'=');
415 if(string::npos == equal_pos)
416 throw InternalErr(__FILE__,__LINE__,
"Cannot find longitude resolution for GPM level 3 products");
418 size_t scolon_pos = ind_elems[3].find_first_of(
';');
419 if(string::npos == scolon_pos)
420 throw InternalErr(__FILE__,__LINE__,
"Cannot find longitude resolution for GPM level 3 products");
421 if (equal_pos < scolon_pos){
422 string lonres_str = ind_elems[3].substr(equal_pos+1,scolon_pos-equal_pos-1);
423 lon_res = strtof(lonres_str.c_str(),
nullptr);
426 throw InternalErr(__FILE__,__LINE__,
"longitude resolution is not right for GPM level 3 products");
429 throw InternalErr(__FILE__,__LINE__,
"The GPM grid LongitudeResolution doesn't exist.");
431 if (0 == ind_elems[4].find(
"NorthBoundingCoordinate")){
433 size_t equal_pos = ind_elems[4].find_first_of(
'=');
434 if(string::npos == equal_pos)
435 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
437 size_t scolon_pos = ind_elems[4].find_first_of(
';');
438 if(string::npos == scolon_pos)
439 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
440 if (equal_pos < scolon_pos){
441 string north_bounding_str = ind_elems[4].substr(equal_pos+1,scolon_pos-equal_pos-1);
442 lat_north = strtof(north_bounding_str.c_str(),
nullptr);
445 throw InternalErr(__FILE__,__LINE__,
"NorthBoundingCoordinate is not right for GPM level 3 products");
449 throw InternalErr(__FILE__,__LINE__,
"The GPM grid NorthBoundingCoordinate doesn't exist.");
451 if (0 == ind_elems[5].find(
"SouthBoundingCoordinate")){
453 size_t equal_pos = ind_elems[5].find_first_of(
'=');
454 if(string::npos == equal_pos)
455 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
457 size_t scolon_pos = ind_elems[5].find_first_of(
';');
458 if(string::npos == scolon_pos)
459 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
460 if (equal_pos < scolon_pos){
461 string lat_south_str = ind_elems[5].substr(equal_pos+1,scolon_pos-equal_pos-1);
462 lat_south = strtof(lat_south_str.c_str(),
nullptr);
465 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
469 throw InternalErr(__FILE__,__LINE__,
"The GPM grid SouthBoundingCoordinate doesn't exist.");
471 if (0 == ind_elems[6].find(
"EastBoundingCoordinate")){
473 size_t equal_pos = ind_elems[6].find_first_of(
'=');
474 if(string::npos == equal_pos)
475 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
477 size_t scolon_pos = ind_elems[6].find_first_of(
';');
478 if(string::npos == scolon_pos)
479 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
480 if (equal_pos < scolon_pos){
481 string lon_east_str = ind_elems[6].substr(equal_pos+1,scolon_pos-equal_pos-1);
482 lon_east = strtof(lon_east_str.c_str(),
nullptr);
485 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
489 throw InternalErr(__FILE__,__LINE__,
"The GPM grid EastBoundingCoordinate doesn't exist.");
491 if (0 == ind_elems[7].find(
"WestBoundingCoordinate")){
493 size_t equal_pos = ind_elems[7].find_first_of(
'=');
494 if(string::npos == equal_pos)
495 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
497 size_t scolon_pos = ind_elems[7].find_first_of(
';');
498 if(string::npos == scolon_pos)
499 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
500 if (equal_pos < scolon_pos){
501 string lon_west_str = ind_elems[7].substr(equal_pos+1,scolon_pos-equal_pos-1);
502 lon_west = strtof(lon_west_str.c_str(),
nullptr);
505 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
509 throw InternalErr(__FILE__,__LINE__,
"The GPM grid WestBoundingCoordinate doesn't exist.");
511 if (
false == check_reg_orig) {
512 if (0 != ind_elems[8].find(
"Origin=SOUTHWEST"))
513 throw InternalErr(__FILE__,__LINE__,
"The GPM grid origin is not SOUTHWEST.");
518 latsize =(
int)((lat_north-lat_south)/lat_res);
519 lonsize =(
int)((lon_east-lon_west)/lon_res);
520 lat_start = lat_south;
521 lon_start = lon_west;
524void HDF5CFUtil::close_fileid(hid_t file_id,
bool pass_fileid) {
525 if((
false == pass_fileid) && (file_id !=-1))
534void HDF5CFUtil::rev_str(
char *str,
int len)
552int HDF5CFUtil::int_to_str(
int x,
char str[],
int d)
557 str[i++] = (x%10) +
'0';
572void HDF5CFUtil::dtoa(
double n,
char *res,
int afterpoint)
578 double fpart = n - (double)ipart;
581 int i = int_to_str(ipart, res, 0);
591 fpart = fpart * pow(10, afterpoint);
595 auto final_fpart = (
int)fpart;
596 if(fpart -(
int)fpart >0.5)
597 final_fpart = (
int)fpart +1;
598 int_to_str(final_fpart, res + i + 1, afterpoint);
604string HDF5CFUtil::get_int_str(
int x) {
608 str.push_back(x+
'0');
610 else if (x >10 && x<100) {
611 str.push_back(x/10+
'0');
612 str.push_back(x%10+
'0');
616 int abs_x = (x<0)?-x:x;
622 buf.resize(num_digit);
623 snprintf(buf.data(),num_digit,
"%d",x);
624 str.assign(buf.data());
633string HDF5CFUtil::get_double_str(
double x,
int total_digit,
int after_point) {
638 res.resize(total_digit);
639 for(
int i = 0; i<total_digit;i++)
643 dtoa(-x,res.data(),after_point);
644 for(
int i = 0; i<total_digit;i++) {
646 str.push_back(res[i]);
650 dtoa(x, res.data(), after_point);
651 for(
int i = 0; i<total_digit;i++) {
653 str.push_back(res[i]);
667int GDij2ll(
int projcode,
int zonecode,
double projparm[],
668 int spherecode,
int xdimsize,
int ydimsize,
669 double upleftpt[],
double lowrightpt[],
670 int npnts,
int row[],
int col[],
671 double longitude[],
double latitude[], EOS5GridPRType pixcen, EOS5GridOriginType pixcnr)
679 int(*hinv_trans[100]) (double,double,
double*,
double*);
680 int(*hfor_trans[100]) (double,double,
double*,
double*);
690 double xMtr0, yMtr0, xMtr1, yMtr1;
696 if (pixcen == HE5_HDFE_CENTER)
747 throw InternalErr(__FILE__,__LINE__,
"Unknown pixel corner to retrieve lat/lon from a grid.");
755 if (projcode != HE5_GCTP_GEO && projcode != HE5_GCTP_BCEA)
758 scaleX = (lowrightpt[0] - upleftpt[0]) / xdimsize;
759 scaleY = (lowrightpt[1] - upleftpt[1]) / ydimsize;
760 string eastFile = HDF5RequestHandler::get_stp_east_filename();
761 string northFile = HDF5RequestHandler::get_stp_north_filename();
763 hinv_init(projcode, zonecode, projparm, spherecode, (
char*)eastFile.c_str(), (
char*)northFile.c_str(),
764 &errorcode, hinv_trans);
771 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_init Error to retrieve lat/lon from a grid.");
778 for (
int i = 0; i < npnts; i++)
792 arg1 = ((col[i] + pixadjX) * scaleX + upleftpt[0]);
793 arg2 = ((row[i] + pixadjY) * scaleY + upleftpt[1]);
794 errorcode = hinv_trans[projcode] (arg1, arg2, &lonrad, &latrad);
801 if(projcode == HE5_GCTP_LAMAZ) {
802 longitude[i] = 1.0e51;
803 latitude[i] = 1.0e51;
806 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_trans Error to retrieve lat/lon from a grid.");
814 longitude[i] = HE5_EHconvAng(lonrad, HE5_HDFE_RAD_DEG);
815 latitude[i] = HE5_EHconvAng(latrad, HE5_HDFE_RAD_DEG);
821 else if (projcode == HE5_GCTP_BCEA)
831 hfor_init(projcode, zonecode, projparm, spherecode,
nullptr,
nullptr,&errorcode, hfor_trans);
837 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_init Error to retrieve lat/lon from a grid.");
842 lonrad0 =HE5_EHconvAng(upleftpt[0], HE5_HDFE_DMS_RAD);
843 lonrad = HE5_EHconvAng(lowrightpt[0], HE5_HDFE_DMS_RAD);
847 latrad0 = HE5_EHconvAng(upleftpt[1], HE5_HDFE_DMS_RAD);
848 latrad = HE5_EHconvAng(lowrightpt[1], HE5_HDFE_DMS_RAD);
853 errorcode = hfor_trans[projcode] (lonrad0, latrad0, &xMtr0, &yMtr0);
858 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_trans Error to retrieve lat/lon from a grid.");
865 errorcode = hfor_trans[projcode] (lonrad, latrad, &xMtr1, &yMtr1);
870 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_trans Error to retrieve lat/lon from a grid.");
875 scaleX = (xMtr1 - xMtr0) / xdimsize;
879 scaleY = (yMtr1 - yMtr0) / ydimsize;
883 hinv_init(projcode, zonecode, projparm, spherecode,
nullptr,
nullptr, &errorcode, hinv_trans);
888 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_init Error to retrieve lat/lon from a grid.");
892 for (
int i = 0; i < npnts; i++)
897 errorcode = hinv_trans[projcode] (
898 (col[i] + pixadjX) * scaleX + xMtr0,
899 (row[i] + pixadjY) * scaleY + yMtr0,
913 longitude[i] = 1.0e51;
914 latitude[i] = 1.0e51;
919 longitude[i] = HE5_EHconvAng(lonrad, HE5_HDFE_RAD_DEG);
920 latitude[i] = HE5_EHconvAng(latrad, HE5_HDFE_RAD_DEG);
924 else if (projcode == HE5_GCTP_GEO)
937 lonrad0 = HE5_EHconvAng(upleftpt[0], HE5_HDFE_DMS_DEG);
938 lonrad = HE5_EHconvAng(lowrightpt[0], HE5_HDFE_DMS_DEG);
942 scaleX = (lonrad - lonrad0) / xdimsize;
946 latrad0 = HE5_EHconvAng(upleftpt[1], HE5_HDFE_DMS_DEG);
947 latrad = HE5_EHconvAng(lowrightpt[1], HE5_HDFE_DMS_DEG);
951 scaleY = (latrad - latrad0) / ydimsize;
955 for (
int i = 0; i < npnts; i++)
959 longitude[i] = (col[i] + pixadjX) * scaleX + lonrad0;
960 latitude[i] = (row[i] + pixadjY) * scaleY + latrad0;
966 hinv_init(projcode, zonecode, projparm, spherecode, eastFile, northFile,
967 (
int *)&errorcode, hinv_trans);
969 for (
int i = 0; i < npnts; i++)
975 hinv_trans[projcode] (
990HE5_EHconvAng(
double inAngle,
int code)
996 double outAngle = 0.;
997 double pi = 3.14159265358979324;
998 double r2d = 180 / pi;
999 double d2r = 1 / r2d;
1006 case HE5_HDFE_RAD_DEG:
1007 outAngle = inAngle * r2d;
1012 case HE5_HDFE_DEG_RAD:
1013 outAngle = inAngle * d2r;
1019 case HE5_HDFE_DMS_DEG:
1020 deg = (long)(inAngle / 1000000);
1021 min = (long)((inAngle - deg * 1000000) / 1000);
1022 sec = (inAngle - deg * 1000000 - min * 1000);
1023 outAngle = deg + min / 60.0 + sec / 3600.0;
1029 case HE5_HDFE_DEG_DMS:
1031 deg = (long)inAngle;
1032 min = (long)((inAngle - deg) * 60);
1033 sec = (inAngle - deg - min / 60.0) * 3600;
1043 if ( fabs(sec - 0.0) < 1.e-7 )
1048 if ( (fabs(sec - 60) < 1.e-7 ) || ( sec > 60.0 ))
1062 outAngle = deg * 1000000 + min * 1000 + sec;
1069 case HE5_HDFE_RAD_DMS:
1071 inAngle = inAngle * r2d;
1072 deg = (long)inAngle;
1073 min = (long)((inAngle - deg) * 60);
1074 sec = ((inAngle - deg - min / 60.0) * 3600);
1084 if ( fabs(sec - 0.0) < 1.e-7 )
1089 if ( (fabs(sec - 60) < 1.e-7 ) || ( sec > 60.0 ))
1103 outAngle = deg * 1000000 + min * 1000 + sec;
1110 case HE5_HDFE_DMS_RAD:
1111 deg = (long)(inAngle / 1000000);
1112 min = (long)((inAngle - deg * 1000000) / 1000);
1113 sec = (inAngle - deg * 1000000 - min * 1000);
1114 outAngle = deg + min / 60.0 + sec / 3600.0;
1115 outAngle = outAngle * d2r;
1130HDF5CFUtil::INDEX_nD_TO_1D (
const std::vector <size_t > &dims,
1131 const std::vector < size_t > &pos)
1137 if(dims.size () != pos.size ())
1138 throw InternalErr(__FILE__,__LINE__,
"dimension error in INDEX_nD_TO_1D routine.");
1142 for (
size_t p = 0; p < pos.size (); p++) {
1145 for (
size_t j = start; j < dims.size (); j++)
1168int HDF5CFUtil::subset(
1175 std::vector<T> *poutput,
1179 for(
int k=0; k<edge[index]; k++)
1181 pos[index] = start[index] + k*stride[index];
1183 subset(input, rank, dim, start, stride, edge, poutput,pos,index+1);
1186 poutput->push_back(input[INDEX_nD_TO_1D( dim, pos)]);
1196 ssize_t ret_val = read(fd,buf,total_read);
1201string HDF5CFUtil::obtain_cache_fname(
const string & fprefix,
const string &fname,
const string &vname) {
1203 string cache_fname = fprefix;
1205 string correct_fname = fname;
1206 std::replace(correct_fname.begin(),correct_fname.end(),
'/',
'_');
1208 string correct_vname = vname;
1211 std::replace(correct_vname.begin(),correct_vname.end(),
'/',
'_');
1214 std::replace(correct_vname.begin(),correct_vname.end(),
' ',
'_');
1217 cache_fname = cache_fname +correct_fname +correct_vname;
1221size_t INDEX_nD_TO_1D (
const std::vector < size_t > &dims,
1222 const std::vector < size_t > &pos){
1227 if(dims.size () != pos.size ())
1228 throw InternalErr(__FILE__,__LINE__,
"dimension error in INDEX_nD_TO_1D routine.");
1232 for (
size_t p = 0; p < pos.size (); p++) {
1235 for (
size_t j = start; j < dims.size (); j++)
1243void HDF5CFUtil::get_relpath_pos(
const string& temp_str,
const string& relpath, vector<size_t>&s_pos) {
1248 size_t pos = temp_str.find(relpath, 0);
1249 while(pos != string::npos)
1251 s_pos.push_back(pos);
1255 pos = temp_str.find(relpath,pos+1);
1263void HDF5CFUtil::cha_co(
string &co,
const string & vpath) {
1266 string rp_sep=
"../";
1267 if(vpath.find(sep,1)!=string::npos) {
1268 if(co.find(sep)!=string::npos) {
1270 if(co.find(rp_sep)!=string::npos) {
1271 vector<size_t>var_sep_pos;
1272 get_relpath_pos(vpath,sep,var_sep_pos);
1273 vector<size_t>co_rp_sep_pos;
1274 get_relpath_pos(co,rp_sep,co_rp_sep_pos);
1275 if(co_rp_sep_pos[0]==0) {
1277 if(co_rp_sep_pos.size() <var_sep_pos.size()) {
1278 size_t var_prefix_pos=var_sep_pos[var_sep_pos.size()-co_rp_sep_pos.size()-1];
1279 string var_prefix=vpath.substr(1,var_prefix_pos);
1280 string co_suffix = co.substr(co_rp_sep_pos[co_rp_sep_pos.size()-1]+rp_sep.size());
1281 co = var_prefix+co_suffix;
1294 string var_prefix = obtain_string_before_lastslash(vpath).substr(1);
1295 co = var_prefix +co;
This file includes several helper functions for translating HDF5 to CF-compliant.
include the entry functions to execute the handlers
static void Split(const char *s, int len, char sep, std::vector< std::string > &names)
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)
static ssize_t read_buffer_from_file(int fd, void *buf, size_t)
Getting a subset of a variable.