40#include<InternalErr.h>
46int hinv_init(
int insys,
int inzone,
double *inparm,
int indatum,
char *fn27,
char *fn83,
int *iflg,
int (*hinv_trans[])(
double,
double,
double*,
double*));
48int hfor_init(
int outsys,
int outzone,
double *outparm,
int outdatum,
char *fn27,
char *fn83,
int *iflg,
int (*hfor_trans[])(
double,
double,
double *,
double *));
58 switch (H5Tget_class(h5_type_id)) {
61 size = H5Tget_size(h5_type_id);
62 sign = H5Tget_sign(h5_type_id);
65 if (sign == H5T_SGN_2)
71 if (sign == H5T_SGN_2)
77 if (sign == H5T_SGN_2)
83 if (sign == H5T_SGN_2)
88 else return H5UNSUPTYPE;
91 size = H5Tget_size(h5_type_id);
93 if (size == 4)
return H5FLOAT32;
94 else if (size == 8)
return H5FLOAT64;
95 else return H5UNSUPTYPE;
98 if (H5Tis_variable_str(h5_type_id))
100 else return H5FSTRING;
118size_t HDF5CFUtil::H5_numeric_atomic_type_size(H5DataType h5type) {
136 throw InternalErr(__FILE__,__LINE__,
"This routine doesn't support to return the size of this datatype");
142bool HDF5CFUtil::use_lrdata_mem_cache(H5DataType h5type, CVType cvtype,
bool islatlon ) {
143 if(h5type != H5CHAR && h5type !=H5UCHAR && h5type!=H5INT16 && h5type !=H5UINT16 &&
144 h5type != H5INT32 && h5type !=H5UINT32 && h5type !=H5FLOAT32 && h5type!=H5FLOAT64 &&
145 h5type != H5INT64 && h5type !=H5UINT64)
148 if(cvtype != CV_UNSUPPORTED)
151 else if(varpath ==
"")
163bool HDF5CFUtil::use_data_mem_cache(H5DataType h5type, CVType cvtype,
const string &varpath) {
164 if(h5type != H5CHAR && h5type !=H5UCHAR && h5type!=H5INT16 && h5type !=H5UINT16 &&
165 h5type != H5INT32 && h5type !=H5UINT32 && h5type !=H5FLOAT32 && h5type!=H5FLOAT64 &&
166 h5type != H5INT64 && h5type !=H5UINT64)
169 if(cvtype != CV_UNSUPPORTED)
172 else if(varpath ==
"")
181bool HDF5CFUtil::cf_strict_support_type(H5DataType dtype,
bool is_dap4) {
182 if ((H5UNSUPTYPE == dtype)||(H5REFERENCE == dtype)
183 || (H5COMPOUND == dtype) || (H5ARRAY == dtype))
188 else if ((H5INT64 == dtype) || (H5UINT64 == dtype)) {
189 if (
true == is_dap4 || HDF5RequestHandler::get_dmr_long_int()==
true)
198bool HDF5CFUtil::cf_dap2_support_numeric_type(H5DataType dtype,
bool is_dap4) {
199 if ((H5UNSUPTYPE == dtype)||(H5REFERENCE == dtype)
200 || (H5COMPOUND == dtype) || (H5ARRAY == dtype)
201 || (H5INT64 == dtype) ||(H5UINT64 == dtype)
202 || (H5FSTRING == dtype) ||(H5VSTRING == dtype))
204 else if ((H5INT64 == dtype) ||(H5UINT64 == dtype)) {
205 if(
true == is_dap4 ||
true == HDF5RequestHandler::get_dmr_long_int())
214string HDF5CFUtil::obtain_string_after_lastslash(
const string &s) {
217 size_t last_fslash_pos = s.find_last_of(
"/");
218 if (string::npos != last_fslash_pos &&
219 last_fslash_pos != (s.size()-1))
220 ret_str=s.substr(last_fslash_pos+1);
224string HDF5CFUtil::obtain_string_before_lastslash(
const string & s) {
227 size_t last_fslash_pos = s.find_last_of(
"/");
228 if (string::npos != last_fslash_pos)
229 ret_str=s.substr(0,last_fslash_pos+1);
236 string temp_sect_str =
"";
237 string temp_sect_newstr =
"";
240 for (
int i = 0; i < num_sect; i++) {
242 if (i != (num_sect-1))
243 temp_sect_str = s.substr(i*sect_size,sect_size);
245 temp_sect_str = s.substr((num_sect-1)*sect_size,s.size()-(num_sect-1)*sect_size);
249 if (H5T_STR_NULLTERM == H5Tget_strpad(ty_id))
250 temp_pos = temp_sect_str.find_first_of(
'\0');
251 else if (H5T_STR_SPACEPAD == H5Tget_strpad(ty_id))
252 temp_pos = temp_sect_str.find_last_not_of(
' ')+1;
253 else temp_pos = temp_sect_str.find_last_not_of(
'0')+1;
255 if (temp_pos != string::npos) {
261 if (H5T_STR_SPACEPAD == H5Tget_strpad(ty_id)) {
263 if (temp_pos == temp_sect_str.size())
264 temp_sect_newstr = temp_sect_str +
" ";
266 temp_sect_newstr = temp_sect_str.substr(0,temp_pos+1);
268 sect_newsize[i] = temp_pos +1;
271 temp_sect_newstr = temp_sect_str.substr(0,temp_pos);
272 sect_newsize[i] = temp_pos ;
279 temp_sect_newstr = temp_sect_str;
284 if (H5T_STR_SPACEPAD == H5Tget_strpad(ty_id)) {
285 temp_sect_newstr.resize(temp_sect_str.size()+1);
286 temp_sect_newstr.append(1,
' ');
287 sect_newsize[i] = sect_size + 1;
290 sect_newsize[i] = sect_size;
292 final_str+=temp_sect_newstr;
298string HDF5CFUtil::remove_substrings(
string str,
const string &substr) {
300 string::size_type i = str.find(substr);
301 while (i != std::string::npos) {
302 str.erase(i, substr.size());
303 i = str.find(substr, i);
308void HDF5CFUtil::gen_unique_name(
string &str,set<string>& namelist,
int&clash_index) {
310 pair<set<string>::iterator,
bool> ret;
312 stringstream sclash_index;
313 sclash_index << clash_index;
314 newstr = str + sclash_index.str();
316 ret = namelist.insert(newstr);
317 if (
false == ret.second) {
319 gen_unique_name(str,namelist,clash_index);
326HDF5CFUtil::Split_helper(vector<string> &tokens,
const string &text,
const char sep)
328 string::size_type start = 0;
329 string::size_type end = 0;
331 while ((end = text.find(sep, start)) != string::npos) {
332 tokens.push_back(text.substr(start, end - start));
335 tokens.push_back(text.substr(start));
345 for (
int i = 0, j = 0; j <= len; ++j) {
346 if ((j == len && len) || s[j] == sep) {
347 string elem(s + i, j - i);
348 names.push_back(elem);
360 Split(sz, (
int)strlen(sz), sep, names);
363void HDF5CFUtil::parser_gpm_l3_gridheader(
const vector<char>& value,
364 int& latsize,
int&lonsize,
365 float& lat_start,
float& lon_start,
366 float& lat_res,
float& lon_res,
367 bool check_reg_orig ){
369 float lat_north = 0.;
370 float lat_south = 0.;
374 vector<string> ind_elems;
383 if(ind_elems.size()<9)
384 throw InternalErr(__FILE__,__LINE__,
"The number of elements in the GPM level 3 GridHeader is not right.");
386 if(
false == check_reg_orig) {
387 if (0 != ind_elems[1].find(
"Registration=CENTER"))
388 throw InternalErr(__FILE__,__LINE__,
"The GPM grid registration is not center.");
391 if (0 == ind_elems[2].find(
"LatitudeResolution")){
393 size_t equal_pos = ind_elems[2].find_first_of(
'=');
394 if(string::npos == equal_pos)
395 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
397 size_t scolon_pos = ind_elems[2].find_first_of(
';');
398 if(string::npos == scolon_pos)
399 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
400 if (equal_pos < scolon_pos){
402 string latres_str = ind_elems[2].substr(equal_pos+1,scolon_pos-equal_pos-1);
403 lat_res = strtof(latres_str.c_str(),
nullptr);
406 throw InternalErr(__FILE__,__LINE__,
"latitude resolution is not right for GPM level 3 products");
409 throw InternalErr(__FILE__,__LINE__,
"The GPM grid LatitudeResolution doesn't exist.");
411 if (0 == ind_elems[3].find(
"LongitudeResolution")){
413 size_t equal_pos = ind_elems[3].find_first_of(
'=');
414 if(string::npos == equal_pos)
415 throw InternalErr(__FILE__,__LINE__,
"Cannot find longitude resolution for GPM level 3 products");
417 size_t scolon_pos = ind_elems[3].find_first_of(
';');
418 if(string::npos == scolon_pos)
419 throw InternalErr(__FILE__,__LINE__,
"Cannot find longitude resolution for GPM level 3 products");
420 if (equal_pos < scolon_pos){
421 string lonres_str = ind_elems[3].substr(equal_pos+1,scolon_pos-equal_pos-1);
422 lon_res = strtof(lonres_str.c_str(),
nullptr);
425 throw InternalErr(__FILE__,__LINE__,
"longitude resolution is not right for GPM level 3 products");
428 throw InternalErr(__FILE__,__LINE__,
"The GPM grid LongitudeResolution doesn't exist.");
430 if (0 == ind_elems[4].find(
"NorthBoundingCoordinate")){
432 size_t equal_pos = ind_elems[4].find_first_of(
'=');
433 if(string::npos == equal_pos)
434 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
436 size_t scolon_pos = ind_elems[4].find_first_of(
';');
437 if(string::npos == scolon_pos)
438 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
439 if (equal_pos < scolon_pos){
440 string north_bounding_str = ind_elems[4].substr(equal_pos+1,scolon_pos-equal_pos-1);
441 lat_north = strtof(north_bounding_str.c_str(),
nullptr);
444 throw InternalErr(__FILE__,__LINE__,
"NorthBoundingCoordinate is not right for GPM level 3 products");
448 throw InternalErr(__FILE__,__LINE__,
"The GPM grid NorthBoundingCoordinate doesn't exist.");
450 if (0 == ind_elems[5].find(
"SouthBoundingCoordinate")){
452 size_t equal_pos = ind_elems[5].find_first_of(
'=');
453 if(string::npos == equal_pos)
454 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
456 size_t scolon_pos = ind_elems[5].find_first_of(
';');
457 if(string::npos == scolon_pos)
458 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
459 if (equal_pos < scolon_pos){
460 string lat_south_str = ind_elems[5].substr(equal_pos+1,scolon_pos-equal_pos-1);
461 lat_south = strtof(lat_south_str.c_str(),
nullptr);
464 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
468 throw InternalErr(__FILE__,__LINE__,
"The GPM grid SouthBoundingCoordinate doesn't exist.");
470 if (0 == ind_elems[6].find(
"EastBoundingCoordinate")){
472 size_t equal_pos = ind_elems[6].find_first_of(
'=');
473 if(string::npos == equal_pos)
474 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
476 size_t scolon_pos = ind_elems[6].find_first_of(
';');
477 if(string::npos == scolon_pos)
478 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
479 if (equal_pos < scolon_pos){
480 string lon_east_str = ind_elems[6].substr(equal_pos+1,scolon_pos-equal_pos-1);
481 lon_east = strtof(lon_east_str.c_str(),
nullptr);
484 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
488 throw InternalErr(__FILE__,__LINE__,
"The GPM grid EastBoundingCoordinate doesn't exist.");
490 if (0 == ind_elems[7].find(
"WestBoundingCoordinate")){
492 size_t equal_pos = ind_elems[7].find_first_of(
'=');
493 if(string::npos == equal_pos)
494 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
496 size_t scolon_pos = ind_elems[7].find_first_of(
';');
497 if(string::npos == scolon_pos)
498 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
499 if (equal_pos < scolon_pos){
500 string lon_west_str = ind_elems[7].substr(equal_pos+1,scolon_pos-equal_pos-1);
501 lon_west = strtof(lon_west_str.c_str(),
nullptr);
504 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
508 throw InternalErr(__FILE__,__LINE__,
"The GPM grid WestBoundingCoordinate doesn't exist.");
510 if (
false == check_reg_orig) {
511 if (0 != ind_elems[8].find(
"Origin=SOUTHWEST"))
512 throw InternalErr(__FILE__,__LINE__,
"The GPM grid origin is not SOUTHWEST.");
517 latsize =(int)((lat_north-lat_south)/lat_res);
518 lonsize =(int)((lon_east-lon_west)/lon_res);
519 lat_start = lat_south;
520 lon_start = lon_west;
523void HDF5CFUtil::close_fileid(hid_t file_id,
bool pass_fileid) {
524 if((
false == pass_fileid) && (file_id !=-1))
533void HDF5CFUtil::rev_str(
char *str,
int len)
551int HDF5CFUtil::int_to_str(
int x,
char str[],
int d)
556 str[i++] = (x%10) +
'0';
571void HDF5CFUtil::dtoa(
double n,
char *res,
int afterpoint)
577 double fpart = n - (double)ipart;
580 int i = int_to_str(ipart, res, 0);
590 fpart = fpart * pow(10, afterpoint);
594 auto final_fpart = (int)fpart;
595 if(fpart -(
int)fpart >0.5)
596 final_fpart = (int)fpart +1;
597 int_to_str(final_fpart, res + i + 1, afterpoint);
603string HDF5CFUtil::get_int_str(
int x) {
607 str.push_back(x+
'0');
609 else if (x >10 && x<100) {
610 str.push_back(x/10+
'0');
611 str.push_back(x%10+
'0');
615 int abs_x = (x<0)?-x:x;
621 buf.resize(num_digit);
622 snprintf(buf.data(),num_digit,
"%d",x);
623 str.assign(buf.data());
632string HDF5CFUtil::get_double_str(
double x,
int total_digit,
int after_point) {
637 res.resize(total_digit);
638 for(
int i = 0; i<total_digit;i++)
642 dtoa(-x,res.data(),after_point);
643 for(
int i = 0; i<total_digit;i++) {
645 str.push_back(res[i]);
649 dtoa(x, res.data(), after_point);
650 for(
int i = 0; i<total_digit;i++) {
652 str.push_back(res[i]);
666int GDij2ll(
int projcode,
int zonecode,
double projparm[],
667 int spherecode,
int xdimsize,
int ydimsize,
668 double upleftpt[],
double lowrightpt[],
669 int npnts,
int row[],
int col[],
670 double longitude[],
double latitude[], EOS5GridPRType pixcen, EOS5GridOriginType pixcnr)
678 int(*hinv_trans[100]) (double,double,
double*,
double*);
679 int(*hfor_trans[100]) (double,double,
double*,
double*);
699 if (pixcen == HE5_HDFE_CENTER)
750 throw InternalErr(__FILE__,__LINE__,
"Unknown pixel corner to retrieve lat/lon from a grid.");
758 if (projcode != HE5_GCTP_GEO && projcode != HE5_GCTP_BCEA)
761 scaleX = (lowrightpt[0] - upleftpt[0]) / xdimsize;
762 scaleY = (lowrightpt[1] - upleftpt[1]) / ydimsize;
763 string eastFile = HDF5RequestHandler::get_stp_east_filename();
764 string northFile = HDF5RequestHandler::get_stp_north_filename();
766 hinv_init(projcode, zonecode, projparm, spherecode, (
char*)eastFile.c_str(), (
char*)northFile.c_str(),
767 &errorcode, hinv_trans);
774 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_init Error to retrieve lat/lon from a grid.");
781 for (
int i = 0; i < npnts; i++)
795 arg1 = ((col[i] + pixadjX) * scaleX + upleftpt[0]);
796 arg2 = ((row[i] + pixadjY) * scaleY + upleftpt[1]);
797 errorcode = hinv_trans[projcode] (arg1, arg2, &lonrad, &latrad);
804 if(projcode == HE5_GCTP_LAMAZ) {
805 longitude[i] = 1.0e51;
806 latitude[i] = 1.0e51;
809 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_trans Error to retrieve lat/lon from a grid.");
817 longitude[i] = HE5_EHconvAng(lonrad, HE5_HDFE_RAD_DEG);
818 latitude[i] = HE5_EHconvAng(latrad, HE5_HDFE_RAD_DEG);
824 else if (projcode == HE5_GCTP_BCEA)
834 hfor_init(projcode, zonecode, projparm, spherecode,
nullptr,
nullptr,&errorcode, hfor_trans);
840 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_init Error to retrieve lat/lon from a grid.");
845 lonrad0 =HE5_EHconvAng(upleftpt[0], HE5_HDFE_DMS_RAD);
846 lonrad = HE5_EHconvAng(lowrightpt[0], HE5_HDFE_DMS_RAD);
850 latrad0 = HE5_EHconvAng(upleftpt[1], HE5_HDFE_DMS_RAD);
851 latrad = HE5_EHconvAng(lowrightpt[1], HE5_HDFE_DMS_RAD);
856 errorcode = hfor_trans[projcode] (lonrad0, latrad0, &xMtr0, &yMtr0);
861 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_trans Error to retrieve lat/lon from a grid.");
868 errorcode = hfor_trans[projcode] (lonrad, latrad, &xMtr1, &yMtr1);
873 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_trans Error to retrieve lat/lon from a grid.");
878 scaleX = (xMtr1 - xMtr0) / xdimsize;
882 scaleY = (yMtr1 - yMtr0) / ydimsize;
886 hinv_init(projcode, zonecode, projparm, spherecode,
nullptr,
nullptr, &errorcode, hinv_trans);
891 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_init Error to retrieve lat/lon from a grid.");
895 for (
int i = 0; i < npnts; i++)
900 errorcode = hinv_trans[projcode] (
901 (col[i] + pixadjX) * scaleX + xMtr0,
902 (row[i] + pixadjY) * scaleY + yMtr0,
916 longitude[i] = 1.0e51;
917 latitude[i] = 1.0e51;
922 longitude[i] = HE5_EHconvAng(lonrad, HE5_HDFE_RAD_DEG);
923 latitude[i] = HE5_EHconvAng(latrad, HE5_HDFE_RAD_DEG);
927 else if (projcode == HE5_GCTP_GEO)
940 lonrad0 = HE5_EHconvAng(upleftpt[0], HE5_HDFE_DMS_DEG);
941 lonrad = HE5_EHconvAng(lowrightpt[0], HE5_HDFE_DMS_DEG);
945 scaleX = (lonrad - lonrad0) / xdimsize;
949 latrad0 = HE5_EHconvAng(upleftpt[1], HE5_HDFE_DMS_DEG);
950 latrad = HE5_EHconvAng(lowrightpt[1], HE5_HDFE_DMS_DEG);
954 scaleY = (latrad - latrad0) / ydimsize;
958 for (
int i = 0; i < npnts; i++)
962 longitude[i] = (col[i] + pixadjX) * scaleX + lonrad0;
963 latitude[i] = (row[i] + pixadjY) * scaleY + latrad0;
969 hinv_init(projcode, zonecode, projparm, spherecode, eastFile, northFile,
970 (
int *)&errorcode, hinv_trans);
972 for (
int i = 0; i < npnts; i++)
978 hinv_trans[projcode] (
993HE5_EHconvAng(
double inAngle,
int code)
999 double outAngle = 0.;
1000 double pi = 3.14159265358979324;
1001 double r2d = 180 / pi;
1002 double d2r = 1 / r2d;
1009 case HE5_HDFE_RAD_DEG:
1010 outAngle = inAngle * r2d;
1015 case HE5_HDFE_DEG_RAD:
1016 outAngle = inAngle * d2r;
1022 case HE5_HDFE_DMS_DEG:
1023 deg = (long)(inAngle / 1000000);
1024 min = (long)((inAngle - deg * 1000000) / 1000);
1025 sec = (inAngle - deg * 1000000 - min * 1000);
1026 outAngle = deg + min / 60.0 + sec / 3600.0;
1032 case HE5_HDFE_DEG_DMS:
1034 deg = (long)inAngle;
1035 min = (long)((inAngle - deg) * 60);
1036 sec = (inAngle - deg - min / 60.0) * 3600;
1046 if ( fabs(sec - 0.0) < 1.e-7 )
1051 if ( (fabs(sec - 60) < 1.e-7 ) || ( sec > 60.0 ))
1065 outAngle = deg * 1000000 + min * 1000 + sec;
1072 case HE5_HDFE_RAD_DMS:
1074 inAngle = inAngle * r2d;
1075 deg = (long)inAngle;
1076 min = (long)((inAngle - deg) * 60);
1077 sec = ((inAngle - deg - min / 60.0) * 3600);
1087 if ( fabs(sec - 0.0) < 1.e-7 )
1092 if ( (fabs(sec - 60) < 1.e-7 ) || ( sec > 60.0 ))
1106 outAngle = deg * 1000000 + min * 1000 + sec;
1113 case HE5_HDFE_DMS_RAD:
1114 deg = (long)(inAngle / 1000000);
1115 min = (long)((inAngle - deg * 1000000) / 1000);
1116 sec = (inAngle - deg * 1000000 - min * 1000);
1117 outAngle = deg + min / 60.0 + sec / 3600.0;
1118 outAngle = outAngle * d2r;
1133HDF5CFUtil::INDEX_nD_TO_1D (
const std::vector <size_t > &dims,
1134 const std::vector < size_t > &pos)
1140 if(dims.size () != pos.size ())
1141 throw InternalErr(__FILE__,__LINE__,
"dimension error in INDEX_nD_TO_1D routine.");
1145 for (
size_t p = 0; p < pos.size (); p++) {
1148 for (
size_t j = start; j < dims.size (); j++)
1171int HDF5CFUtil::subset(
1178 std::vector<T> *poutput,
1182 for(
int k=0; k<edge[index]; k++)
1184 pos[index] = start[index] + k*stride[index];
1186 subset(input, rank, dim, start, stride, edge, poutput,pos,index+1);
1189 poutput->push_back(input[INDEX_nD_TO_1D( dim, pos)]);
1199 ssize_t ret_val = read(fd,buf,total_read);
1204string HDF5CFUtil::obtain_cache_fname(
const string & fprefix,
const string &fname,
const string &vname) {
1206 string cache_fname = fprefix;
1208 string correct_fname = fname;
1209 std::replace(correct_fname.begin(),correct_fname.end(),
'/',
'_');
1211 string correct_vname = vname;
1214 std::replace(correct_vname.begin(),correct_vname.end(),
'/',
'_');
1217 std::replace(correct_vname.begin(),correct_vname.end(),
' ',
'_');
1220 cache_fname = cache_fname +correct_fname +correct_vname;
1224size_t INDEX_nD_TO_1D (
const std::vector < size_t > &dims,
1225 const std::vector < size_t > &pos){
1230 if(dims.size () != pos.size ())
1231 throw InternalErr(__FILE__,__LINE__,
"dimension error in INDEX_nD_TO_1D routine.");
1235 for (
const auto &pos_ele:pos) {
1238 for (
size_t j = start; j < dims.size (); j++)
1248void HDF5CFUtil::get_relpath_pos(
const string& temp_str,
const string& relpath, vector<size_t>&s_pos) {
1253 size_t pos = temp_str.find(relpath, 0);
1254 while(pos != string::npos)
1256 s_pos.push_back(pos);
1260 pos = temp_str.find(relpath,pos+1);
1269void HDF5CFUtil::cha_co(
string &co,
const string & vpath) {
1272 string rp_sep=
"../";
1273 if(vpath.find(sep,1)!=string::npos) {
1274 if(co.find(sep)!=string::npos) {
1276 if(co.find(rp_sep)!=string::npos) {
1277 vector<size_t>var_sep_pos;
1278 get_relpath_pos(vpath,sep,var_sep_pos);
1279 vector<size_t>co_rp_sep_pos;
1280 get_relpath_pos(co,rp_sep,co_rp_sep_pos);
1282 if(co_rp_sep_pos[0]==0) {
1284 if(co_rp_sep_pos.size() <var_sep_pos.size()) {
1286 size_t var_prefix_pos=var_sep_pos[var_sep_pos.size()-co_rp_sep_pos.size()-1];
1287 string var_prefix=vpath.substr(1,var_prefix_pos);
1288 string co_suffix = co.substr(co_rp_sep_pos[co_rp_sep_pos.size()-1]+rp_sep.size());
1289 co = var_prefix+co_suffix;
1302 string var_prefix = obtain_string_before_lastslash(vpath).substr(1);
1303 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.