41 #include<InternalErr.h>
47 int hinv_init(
int insys,
int inzone,
double *inparm,
int indatum,
char *fn27,
char *fn83,
int *iflg,
int (*hinv_trans[])(
double,
double,
double*,
double*));
49 int 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;
119 size_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");
143 bool 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 ==
"")
164 bool 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 ==
"")
182 bool 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)
199 bool 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())
215 string 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);
225 string 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;
299 string 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);
309 void 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);
327 HDF5CFUtil::Split_helper(vector<string> &tokens,
const string &text,
const char sep)
329 string::size_type start = 0, end = 0;
330 while ((end = text.find(sep, start)) != string::npos) {
331 tokens.push_back(text.substr(start, end - start));
334 tokens.push_back(text.substr(start));
344 for (
int i = 0, j = 0; j <= len; ++j) {
345 if ((j == len && len) || s[j] == sep) {
346 string elem(s + i, j - i);
347 names.push_back(elem);
359 Split(sz, (
int)strlen(sz), sep, names);
362 void HDF5CFUtil::parser_gpm_l3_gridheader(
const vector<char>& value,
363 int& latsize,
int&lonsize,
364 float& lat_start,
float& lon_start,
365 float& lat_res,
float& lon_res,
366 bool check_reg_orig ){
368 float lat_north = 0.;
369 float lat_south = 0.;
373 vector<string> ind_elems;
380 if(ind_elems.size()<9)
381 throw InternalErr(__FILE__,__LINE__,
"The number of elements in the GPM level 3 GridHeader is not right.");
383 if(
false == check_reg_orig) {
384 if (0 != ind_elems[1].find(
"Registration=CENTER"))
385 throw InternalErr(__FILE__,__LINE__,
"The GPM grid registration is not center.");
388 if (0 == ind_elems[2].find(
"LatitudeResolution")){
390 size_t equal_pos = ind_elems[2].find_first_of(
'=');
391 if(string::npos == equal_pos)
392 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
394 size_t scolon_pos = ind_elems[2].find_first_of(
';');
395 if(string::npos == scolon_pos)
396 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
397 if (equal_pos < scolon_pos){
399 string latres_str = ind_elems[2].substr(equal_pos+1,scolon_pos-equal_pos-1);
400 lat_res = strtof(latres_str.c_str(),NULL);
403 throw InternalErr(__FILE__,__LINE__,
"latitude resolution is not right for GPM level 3 products");
406 throw InternalErr(__FILE__,__LINE__,
"The GPM grid LatitudeResolution doesn't exist.");
408 if (0 == ind_elems[3].find(
"LongitudeResolution")){
410 size_t equal_pos = ind_elems[3].find_first_of(
'=');
411 if(string::npos == equal_pos)
412 throw InternalErr(__FILE__,__LINE__,
"Cannot find longitude resolution for GPM level 3 products");
414 size_t scolon_pos = ind_elems[3].find_first_of(
';');
415 if(string::npos == scolon_pos)
416 throw InternalErr(__FILE__,__LINE__,
"Cannot find longitude resolution for GPM level 3 products");
417 if (equal_pos < scolon_pos){
418 string lonres_str = ind_elems[3].substr(equal_pos+1,scolon_pos-equal_pos-1);
419 lon_res = strtof(lonres_str.c_str(),NULL);
422 throw InternalErr(__FILE__,__LINE__,
"longitude resolution is not right for GPM level 3 products");
425 throw InternalErr(__FILE__,__LINE__,
"The GPM grid LongitudeResolution doesn't exist.");
427 if (0 == ind_elems[4].find(
"NorthBoundingCoordinate")){
429 size_t equal_pos = ind_elems[4].find_first_of(
'=');
430 if(string::npos == equal_pos)
431 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
433 size_t scolon_pos = ind_elems[4].find_first_of(
';');
434 if(string::npos == scolon_pos)
435 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
436 if (equal_pos < scolon_pos){
437 string north_bounding_str = ind_elems[4].substr(equal_pos+1,scolon_pos-equal_pos-1);
438 lat_north = strtof(north_bounding_str.c_str(),NULL);
441 throw InternalErr(__FILE__,__LINE__,
"NorthBoundingCoordinate is not right for GPM level 3 products");
445 throw InternalErr(__FILE__,__LINE__,
"The GPM grid NorthBoundingCoordinate doesn't exist.");
447 if (0 == ind_elems[5].find(
"SouthBoundingCoordinate")){
449 size_t equal_pos = ind_elems[5].find_first_of(
'=');
450 if(string::npos == equal_pos)
451 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
453 size_t scolon_pos = ind_elems[5].find_first_of(
';');
454 if(string::npos == scolon_pos)
455 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
456 if (equal_pos < scolon_pos){
457 string lat_south_str = ind_elems[5].substr(equal_pos+1,scolon_pos-equal_pos-1);
458 lat_south = strtof(lat_south_str.c_str(),NULL);
461 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
465 throw InternalErr(__FILE__,__LINE__,
"The GPM grid SouthBoundingCoordinate doesn't exist.");
467 if (0 == ind_elems[6].find(
"EastBoundingCoordinate")){
469 size_t equal_pos = ind_elems[6].find_first_of(
'=');
470 if(string::npos == equal_pos)
471 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
473 size_t scolon_pos = ind_elems[6].find_first_of(
';');
474 if(string::npos == scolon_pos)
475 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
476 if (equal_pos < scolon_pos){
477 string lon_east_str = ind_elems[6].substr(equal_pos+1,scolon_pos-equal_pos-1);
478 lon_east = strtof(lon_east_str.c_str(),NULL);
481 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
485 throw InternalErr(__FILE__,__LINE__,
"The GPM grid EastBoundingCoordinate doesn't exist.");
487 if (0 == ind_elems[7].find(
"WestBoundingCoordinate")){
489 size_t equal_pos = ind_elems[7].find_first_of(
'=');
490 if(string::npos == equal_pos)
491 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
493 size_t scolon_pos = ind_elems[7].find_first_of(
';');
494 if(string::npos == scolon_pos)
495 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
496 if (equal_pos < scolon_pos){
497 string lon_west_str = ind_elems[7].substr(equal_pos+1,scolon_pos-equal_pos-1);
498 lon_west = strtof(lon_west_str.c_str(),NULL);
501 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
505 throw InternalErr(__FILE__,__LINE__,
"The GPM grid WestBoundingCoordinate doesn't exist.");
507 if (
false == check_reg_orig) {
508 if (0 != ind_elems[8].find(
"Origin=SOUTHWEST"))
509 throw InternalErr(__FILE__,__LINE__,
"The GPM grid origin is not SOUTHWEST.");
514 latsize =(
int)((lat_north-lat_south)/lat_res);
515 lonsize =(
int)((lon_east-lon_west)/lon_res);
516 lat_start = lat_south;
517 lon_start = lon_west;
520 void HDF5CFUtil::close_fileid(hid_t file_id,
bool pass_fileid) {
521 if(
false == pass_fileid) {
533 void HDF5CFUtil::rev_str(
char *str,
int len)
551 int HDF5CFUtil::int_to_str(
int x,
char str[],
int d)
556 str[i++] = (x%10) +
'0';
571 void 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 int 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);
603 string 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[0],num_digit,
"%d",x);
632 string 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[0],after_point);
644 for(
int i = 0; i<total_digit;i++) {
646 str.push_back(res[i]);
650 dtoa(x, &res[0], after_point);
652 for(
int i = 0; i<total_digit;i++) {
654 str.push_back(res[i]);
668 int GDij2ll(
int projcode,
int zonecode,
double projparm[],
669 int spherecode,
int xdimsize,
int ydimsize,
670 double upleftpt[],
double lowrightpt[],
671 int npnts,
int row[],
int col[],
672 double longitude[],
double latitude[], EOS5GridPRType pixcen, EOS5GridOriginType pixcnr)
680 int(*hinv_trans[100]) (double,double,
double*,
double*);
681 int(*hfor_trans[100]) (double,double,
double*,
double*);
691 double xMtr0, yMtr0, xMtr1, yMtr1;
697 if (pixcen == HE5_HDFE_CENTER)
748 throw InternalErr(__FILE__,__LINE__,
"Unknown pixel corner to retrieve lat/lon from a grid.");
756 if (projcode != HE5_GCTP_GEO && projcode != HE5_GCTP_BCEA)
759 scaleX = (lowrightpt[0] - upleftpt[0]) / xdimsize;
760 scaleY = (lowrightpt[1] - upleftpt[1]) / ydimsize;
761 string eastFile = HDF5RequestHandler::get_stp_east_filename();
762 string northFile = HDF5RequestHandler::get_stp_north_filename();
764 hinv_init(projcode, zonecode, projparm, spherecode, (
char*)eastFile.c_str(), (
char*)northFile.c_str(),
765 &errorcode, hinv_trans);
772 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_init Error to retrieve lat/lon from a grid.");
779 for (
int i = 0; i < npnts; i++)
793 arg1 = (((
int)col[i] + pixadjX) * scaleX + upleftpt[0]);
794 arg2 = (((
int)row[i] + pixadjY) * scaleY + upleftpt[1]);
795 errorcode = hinv_trans[projcode] (arg1, arg2, &lonrad, &latrad);
802 if(projcode == HE5_GCTP_LAMAZ) {
803 longitude[i] = 1.0e51;
804 latitude[i] = 1.0e51;
807 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_trans Error to retrieve lat/lon from a grid.");
815 longitude[i] = HE5_EHconvAng(lonrad, HE5_HDFE_RAD_DEG);
816 latitude[i] = HE5_EHconvAng(latrad, HE5_HDFE_RAD_DEG);
822 else if (projcode == HE5_GCTP_BCEA)
832 hfor_init(projcode, zonecode, projparm, spherecode, NULL, NULL,&errorcode, hfor_trans);
838 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_init Error to retrieve lat/lon from a grid.");
843 lonrad0 =HE5_EHconvAng(upleftpt[0], HE5_HDFE_DMS_RAD);
844 lonrad = HE5_EHconvAng(lowrightpt[0], HE5_HDFE_DMS_RAD);
848 latrad0 = HE5_EHconvAng(upleftpt[1], HE5_HDFE_DMS_RAD);
849 latrad = HE5_EHconvAng(lowrightpt[1], HE5_HDFE_DMS_RAD);
854 errorcode = hfor_trans[projcode] (lonrad0, latrad0, &xMtr0, &yMtr0);
859 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_trans Error to retrieve lat/lon from a grid.");
866 errorcode = hfor_trans[projcode] (lonrad, latrad, &xMtr1, &yMtr1);
871 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_trans Error to retrieve lat/lon from a grid.");
876 scaleX = (xMtr1 - xMtr0) / xdimsize;
880 scaleY = (yMtr1 - yMtr0) / ydimsize;
884 hinv_init(projcode, zonecode, projparm, spherecode, NULL, NULL, &errorcode, hinv_trans);
889 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_init Error to retrieve lat/lon from a grid.");
893 for (
int i = 0; i < npnts; i++)
898 errorcode = hinv_trans[projcode] (
899 (col[i] + pixadjX) * scaleX + xMtr0,
900 (row[i] + pixadjY) * scaleY + yMtr0,
914 longitude[i] = 1.0e51;
915 latitude[i] = 1.0e51;
920 longitude[i] = HE5_EHconvAng(lonrad, HE5_HDFE_RAD_DEG);
921 latitude[i] = HE5_EHconvAng(latrad, HE5_HDFE_RAD_DEG);
925 else if (projcode == HE5_GCTP_GEO)
938 lonrad0 = HE5_EHconvAng(upleftpt[0], HE5_HDFE_DMS_DEG);
939 lonrad = HE5_EHconvAng(lowrightpt[0], HE5_HDFE_DMS_DEG);
943 scaleX = (lonrad - lonrad0) / xdimsize;
947 latrad0 = HE5_EHconvAng(upleftpt[1], HE5_HDFE_DMS_DEG);
948 latrad = HE5_EHconvAng(lowrightpt[1], HE5_HDFE_DMS_DEG);
952 scaleY = (latrad - latrad0) / ydimsize;
956 for (
int i = 0; i < npnts; i++)
960 longitude[i] = (col[i] + pixadjX) * scaleX + lonrad0;
961 latitude[i] = (row[i] + pixadjY) * scaleY + latrad0;
967 hinv_init(projcode, zonecode, projparm, spherecode, eastFile, northFile,
968 (
int *)&errorcode, hinv_trans);
970 for (
int i = 0; i < npnts; i++)
976 hinv_trans[projcode] (
991 HE5_EHconvAng(
double inAngle,
int code)
997 double outAngle = 0.;
998 double pi = 3.14159265358979324;
999 double r2d = 180 / pi;
1000 double d2r = 1 / r2d;
1007 case HE5_HDFE_RAD_DEG:
1008 outAngle = inAngle * r2d;
1013 case HE5_HDFE_DEG_RAD:
1014 outAngle = inAngle * d2r;
1020 case HE5_HDFE_DMS_DEG:
1021 deg = (long)(inAngle / 1000000);
1022 min = (long)((inAngle - deg * 1000000) / 1000);
1023 sec = (inAngle - deg * 1000000 - min * 1000);
1024 outAngle = deg + min / 60.0 + sec / 3600.0;
1030 case HE5_HDFE_DEG_DMS:
1032 deg = (long)inAngle;
1033 min = (long)((inAngle - deg) * 60);
1034 sec = (inAngle - deg - min / 60.0) * 3600;
1044 if ( fabs(sec - 0.0) < 1.e-7 )
1049 if ( (fabs(sec - 60) < 1.e-7 ) || ( sec > 60.0 ))
1063 outAngle = deg * 1000000 + min * 1000 + sec;
1070 case HE5_HDFE_RAD_DMS:
1072 inAngle = inAngle * r2d;
1073 deg = (long)inAngle;
1074 min = (long)((inAngle - deg) * 60);
1075 sec = ((inAngle - deg - min / 60.0) * 3600);
1085 if ( fabs(sec - 0.0) < 1.e-7 )
1090 if ( (fabs(sec - 60) < 1.e-7 ) || ( sec > 60.0 ))
1104 outAngle = deg * 1000000 + min * 1000 + sec;
1111 case HE5_HDFE_DMS_RAD:
1112 deg = (long)(inAngle / 1000000);
1113 min = (long)((inAngle - deg * 1000000) / 1000);
1114 sec = (inAngle - deg * 1000000 - min * 1000);
1115 outAngle = deg + min / 60.0 + sec / 3600.0;
1116 outAngle = outAngle * d2r;
1131 HDF5CFUtil::INDEX_nD_TO_1D (
const std::vector <size_t > &dims,
1132 const std::vector < size_t > &pos)
1138 if(dims.size () != pos.size ())
1139 throw InternalErr(__FILE__,__LINE__,
"dimension error in INDEX_nD_TO_1D routine.");
1143 for (
size_t p = 0; p < pos.size (); p++) {
1146 for (
size_t j = start; j < dims.size (); j++)
1168 template<
typename T>
1169 int HDF5CFUtil::subset(
1176 std::vector<T> *poutput,
1180 for(
int k=0; k<edge[index]; k++)
1182 pos[index] = start[index] + k*stride[index];
1184 subset(input, rank, dim, start, stride, edge, poutput,pos,index+1);
1187 poutput->push_back(input[INDEX_nD_TO_1D( dim, pos)]);
1197 ssize_t ret_val = read(fd,buf,total_read);
1202 string HDF5CFUtil::obtain_cache_fname(
const string & fprefix,
const string &fname,
const string &vname) {
1204 string cache_fname = fprefix;
1206 string correct_fname = fname;
1207 std::replace(correct_fname.begin(),correct_fname.end(),
'/',
'_');
1209 string correct_vname = vname;
1212 std::replace(correct_vname.begin(),correct_vname.end(),
'/',
'_');
1215 std::replace(correct_vname.begin(),correct_vname.end(),
' ',
'_');
1218 cache_fname = cache_fname +correct_fname +correct_vname;
1222 size_t INDEX_nD_TO_1D (
const std::vector < size_t > &dims,
1223 const std::vector < size_t > &pos){
1228 if(dims.size () != pos.size ())
1229 throw InternalErr(__FILE__,__LINE__,
"dimension error in INDEX_nD_TO_1D routine.");
1233 for (
size_t p = 0; p < pos.size (); p++) {
1236 for (
size_t j = start; j < dims.size (); j++)
1244 void HDF5CFUtil::get_relpath_pos(
const string& temp_str,
const string& relpath, vector<size_t>&s_pos) {
1249 size_t pos = temp_str.find(relpath, 0);
1250 while(pos != string::npos)
1252 s_pos.push_back(pos);
1254 pos = temp_str.find(relpath,pos+1);
1261 void HDF5CFUtil::cha_co(
string &co,
const string & vpath) {
1264 string rp_sep=
"../";
1265 if(vpath.find(sep,1)!=string::npos) {
1267 if(co.find(sep)!=string::npos) {
1269 if(co.find(rp_sep)!=string::npos) {
1270 vector<size_t>var_sep_pos;
1271 get_relpath_pos(vpath,sep,var_sep_pos);
1272 vector<size_t>co_rp_sep_pos;
1273 get_relpath_pos(co,rp_sep,co_rp_sep_pos);
1274 if(co_rp_sep_pos[0]==0) {
1276 if(co_rp_sep_pos.size() <var_sep_pos.size()) {
1277 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);
1281 string co_suffix = co.substr(co_rp_sep_pos[co_rp_sep_pos.size()-1]+rp_sep.size());
1283 co = var_prefix+co_suffix;
1291 string var_prefix = obtain_string_before_lastslash(vpath).substr(1);
1292 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 ssize_t read_buffer_from_file(int fd, void *buf, size_t)
Getting a subset of a variable.
static std::string trim_string(hid_t dtypeid, const std::string s, int num_sect, size_t section_size, std::vector< size_t > §_newsize)