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) {
183 if ((H5UNSUPTYPE == dtype)||(H5REFERENCE == dtype)
184 || (H5COMPOUND == dtype) || (H5ARRAY == dtype))
189 else if ((H5INT64 == dtype) || (H5UINT64 == dtype)) {
190 if (HDF5RequestHandler::get_dmr_long_int()==
false)
199 bool HDF5CFUtil::cf_dap2_support_numeric_type(H5DataType dtype) {
200 if ((H5UNSUPTYPE == dtype)||(H5REFERENCE == dtype)
201 || (H5COMPOUND == dtype) || (H5ARRAY == dtype)
202 || (H5INT64 == dtype) ||(H5UINT64 == dtype)
203 || (H5FSTRING == dtype) ||(H5VSTRING == dtype))
209 string HDF5CFUtil::obtain_string_after_lastslash(
const string s) {
212 size_t last_fslash_pos = s.find_last_of(
"/");
213 if (string::npos != last_fslash_pos &&
214 last_fslash_pos != (s.size()-1))
215 ret_str=s.substr(last_fslash_pos+1);
219 string HDF5CFUtil::obtain_string_before_lastslash(
const string & s) {
222 size_t last_fslash_pos = s.find_last_of(
"/");
223 if (string::npos != last_fslash_pos)
224 ret_str=s.substr(0,last_fslash_pos+1);
231 string temp_sect_str =
"";
232 string temp_sect_newstr =
"";
235 for (
int i = 0; i < num_sect; i++) {
237 if (i != (num_sect-1))
238 temp_sect_str = s.substr(i*sect_size,sect_size);
240 temp_sect_str = s.substr((num_sect-1)*sect_size,s.size()-(num_sect-1)*sect_size);
244 if (H5T_STR_NULLTERM == H5Tget_strpad(ty_id))
245 temp_pos = temp_sect_str.find_first_of(
'\0');
246 else if (H5T_STR_SPACEPAD == H5Tget_strpad(ty_id))
247 temp_pos = temp_sect_str.find_last_not_of(
' ')+1;
248 else temp_pos = temp_sect_str.find_last_not_of(
'0')+1;
250 if (temp_pos != string::npos) {
256 if (H5T_STR_SPACEPAD == H5Tget_strpad(ty_id)) {
258 if (temp_pos == temp_sect_str.size())
259 temp_sect_newstr = temp_sect_str +
" ";
261 temp_sect_newstr = temp_sect_str.substr(0,temp_pos+1);
263 sect_newsize[i] = temp_pos +1;
266 temp_sect_newstr = temp_sect_str.substr(0,temp_pos);
267 sect_newsize[i] = temp_pos ;
274 temp_sect_newstr = temp_sect_str;
279 if (H5T_STR_SPACEPAD == H5Tget_strpad(ty_id)) {
280 temp_sect_newstr.resize(temp_sect_str.size()+1);
281 temp_sect_newstr.append(1,
' ');
282 sect_newsize[i] = sect_size + 1;
285 sect_newsize[i] = sect_size;
287 final_str+=temp_sect_newstr;
293 string HDF5CFUtil::remove_substrings(
string str,
const string &substr) {
295 string::size_type i = str.find(substr);
296 while (i != std::string::npos) {
297 str.erase(i, substr.size());
298 i = str.find(substr, i);
303 void HDF5CFUtil::gen_unique_name(
string &str,set<string>& namelist,
int&clash_index) {
305 pair<set<string>::iterator,
bool> ret;
307 stringstream sclash_index;
308 sclash_index << clash_index;
309 newstr = str + sclash_index.str();
311 ret = namelist.insert(newstr);
312 if (
false == ret.second) {
314 gen_unique_name(str,namelist,clash_index);
321 HDF5CFUtil::Split_helper(vector<string> &tokens,
const string &text,
const char sep)
323 string::size_type start = 0, end = 0;
324 while ((end = text.find(sep, start)) != string::npos) {
325 tokens.push_back(text.substr(start, end - start));
328 tokens.push_back(text.substr(start));
338 for (
int i = 0, j = 0; j <= len; ++j) {
339 if ((j == len && len) || s[j] == sep) {
340 string elem(s + i, j - i);
341 names.push_back(elem);
353 Split(sz, (
int)strlen(sz), sep, names);
356 void HDF5CFUtil::parser_gpm_l3_gridheader(
const vector<char>& value,
357 int& latsize,
int&lonsize,
358 float& lat_start,
float& lon_start,
359 float& lat_res,
float& lon_res,
360 bool check_reg_orig ){
362 float lat_north = 0.;
363 float lat_south = 0.;
367 vector<string> ind_elems;
372 if(ind_elems.size()!=10)
373 throw InternalErr(__FILE__,__LINE__,
"The number of elements in the GPM level 3 GridHeader is not right.");
375 if(
false == check_reg_orig) {
376 if (0 != ind_elems[1].find(
"Registration=CENTER"))
377 throw InternalErr(__FILE__,__LINE__,
"The GPM grid registration is not center.");
380 if (0 == ind_elems[2].find(
"LatitudeResolution")){
382 size_t equal_pos = ind_elems[2].find_first_of(
'=');
383 if(string::npos == equal_pos)
384 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
386 size_t scolon_pos = ind_elems[2].find_first_of(
';');
387 if(string::npos == scolon_pos)
388 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
389 if (equal_pos < scolon_pos){
391 string latres_str = ind_elems[2].substr(equal_pos+1,scolon_pos-equal_pos-1);
392 lat_res = strtof(latres_str.c_str(),NULL);
395 throw InternalErr(__FILE__,__LINE__,
"latitude resolution is not right for GPM level 3 products");
398 throw InternalErr(__FILE__,__LINE__,
"The GPM grid LatitudeResolution doesn't exist.");
400 if (0 == ind_elems[3].find(
"LongitudeResolution")){
402 size_t equal_pos = ind_elems[3].find_first_of(
'=');
403 if(string::npos == equal_pos)
404 throw InternalErr(__FILE__,__LINE__,
"Cannot find longitude resolution for GPM level 3 products");
406 size_t scolon_pos = ind_elems[3].find_first_of(
';');
407 if(string::npos == scolon_pos)
408 throw InternalErr(__FILE__,__LINE__,
"Cannot find longitude resolution for GPM level 3 products");
409 if (equal_pos < scolon_pos){
410 string lonres_str = ind_elems[3].substr(equal_pos+1,scolon_pos-equal_pos-1);
411 lon_res = strtof(lonres_str.c_str(),NULL);
414 throw InternalErr(__FILE__,__LINE__,
"longitude resolution is not right for GPM level 3 products");
417 throw InternalErr(__FILE__,__LINE__,
"The GPM grid LongitudeResolution doesn't exist.");
419 if (0 == ind_elems[4].find(
"NorthBoundingCoordinate")){
421 size_t equal_pos = ind_elems[4].find_first_of(
'=');
422 if(string::npos == equal_pos)
423 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
425 size_t scolon_pos = ind_elems[4].find_first_of(
';');
426 if(string::npos == scolon_pos)
427 throw InternalErr(__FILE__,__LINE__,
"Cannot find latitude resolution for GPM level 3 products");
428 if (equal_pos < scolon_pos){
429 string north_bounding_str = ind_elems[4].substr(equal_pos+1,scolon_pos-equal_pos-1);
430 lat_north = strtof(north_bounding_str.c_str(),NULL);
433 throw InternalErr(__FILE__,__LINE__,
"NorthBoundingCoordinate is not right for GPM level 3 products");
437 throw InternalErr(__FILE__,__LINE__,
"The GPM grid NorthBoundingCoordinate doesn't exist.");
439 if (0 == ind_elems[5].find(
"SouthBoundingCoordinate")){
441 size_t equal_pos = ind_elems[5].find_first_of(
'=');
442 if(string::npos == equal_pos)
443 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
445 size_t scolon_pos = ind_elems[5].find_first_of(
';');
446 if(string::npos == scolon_pos)
447 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
448 if (equal_pos < scolon_pos){
449 string lat_south_str = ind_elems[5].substr(equal_pos+1,scolon_pos-equal_pos-1);
450 lat_south = strtof(lat_south_str.c_str(),NULL);
453 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
457 throw InternalErr(__FILE__,__LINE__,
"The GPM grid SouthBoundingCoordinate doesn't exist.");
459 if (0 == ind_elems[6].find(
"EastBoundingCoordinate")){
461 size_t equal_pos = ind_elems[6].find_first_of(
'=');
462 if(string::npos == equal_pos)
463 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
465 size_t scolon_pos = ind_elems[6].find_first_of(
';');
466 if(string::npos == scolon_pos)
467 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
468 if (equal_pos < scolon_pos){
469 string lon_east_str = ind_elems[6].substr(equal_pos+1,scolon_pos-equal_pos-1);
470 lon_east = strtof(lon_east_str.c_str(),NULL);
473 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
477 throw InternalErr(__FILE__,__LINE__,
"The GPM grid EastBoundingCoordinate doesn't exist.");
479 if (0 == ind_elems[7].find(
"WestBoundingCoordinate")){
481 size_t equal_pos = ind_elems[7].find_first_of(
'=');
482 if(string::npos == equal_pos)
483 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
485 size_t scolon_pos = ind_elems[7].find_first_of(
';');
486 if(string::npos == scolon_pos)
487 throw InternalErr(__FILE__,__LINE__,
"Cannot find south bound coordinate for GPM level 3 products");
488 if (equal_pos < scolon_pos){
489 string lon_west_str = ind_elems[7].substr(equal_pos+1,scolon_pos-equal_pos-1);
490 lon_west = strtof(lon_west_str.c_str(),NULL);
493 throw InternalErr(__FILE__,__LINE__,
"south bound coordinate is not right for GPM level 3 products");
497 throw InternalErr(__FILE__,__LINE__,
"The GPM grid WestBoundingCoordinate doesn't exist.");
499 if (
false == check_reg_orig) {
500 if (0 != ind_elems[8].find(
"Origin=SOUTHWEST"))
501 throw InternalErr(__FILE__,__LINE__,
"The GPM grid origin is not SOUTHWEST.");
506 latsize =(
int)((lat_north-lat_south)/lat_res);
507 lonsize =(
int)((lon_east-lon_west)/lon_res);
508 lat_start = lat_south;
509 lon_start = lon_west;
512 void HDF5CFUtil::close_fileid(hid_t file_id,
bool pass_fileid) {
513 if(
false == pass_fileid) {
525 void HDF5CFUtil::rev_str(
char *str,
int len)
543 int HDF5CFUtil::int_to_str(
int x,
char str[],
int d)
548 str[i++] = (x%10) +
'0';
563 void HDF5CFUtil::dtoa(
double n,
char *res,
int afterpoint)
569 double fpart = n - (double)ipart;
572 int i = int_to_str(ipart, res, 0);
582 fpart = fpart * pow(10, afterpoint);
586 int final_fpart = (
int)fpart;
587 if(fpart -(
int)fpart >0.5)
588 final_fpart = (
int)fpart +1;
589 int_to_str(final_fpart, res + i + 1, afterpoint);
595 string HDF5CFUtil::get_int_str(
int x) {
599 str.push_back(x+
'0');
601 else if (x >10 && x<100) {
602 str.push_back(x/10+
'0');
603 str.push_back(x%10+
'0');
607 int abs_x = (x<0)?-x:x;
613 buf.resize(num_digit);
614 snprintf(&buf[0],num_digit,
"%d",x);
624 string HDF5CFUtil::get_double_str(
double x,
int total_digit,
int after_point) {
630 res.resize(total_digit);
631 for(
int i = 0; i<total_digit;i++)
635 dtoa(-x,&res[0],after_point);
636 for(
int i = 0; i<total_digit;i++) {
638 str.push_back(res[i]);
642 dtoa(x, &res[0], after_point);
644 for(
int i = 0; i<total_digit;i++) {
646 str.push_back(res[i]);
660 int GDij2ll(
int projcode,
int zonecode,
double projparm[],
661 int spherecode,
int xdimsize,
int ydimsize,
662 double upleftpt[],
double lowrightpt[],
663 int npnts,
int row[],
int col[],
664 double longitude[],
double latitude[], EOS5GridPRType pixcen, EOS5GridOriginType pixcnr)
672 int(*hinv_trans[100]) (double,double,
double*,
double*);
673 int(*hfor_trans[100]) (double,double,
double*,
double*);
683 double xMtr0, yMtr0, xMtr1, yMtr1;
689 if (pixcen == HE5_HDFE_CENTER)
740 throw InternalErr(__FILE__,__LINE__,
"Unknown pixel corner to retrieve lat/lon from a grid.");
748 if (projcode != HE5_GCTP_GEO && projcode != HE5_GCTP_BCEA)
751 scaleX = (lowrightpt[0] - upleftpt[0]) / xdimsize;
752 scaleY = (lowrightpt[1] - upleftpt[1]) / ydimsize;
753 string eastFile = HDF5RequestHandler::get_stp_east_filename();
754 string northFile = HDF5RequestHandler::get_stp_north_filename();
756 hinv_init(projcode, zonecode, projparm, spherecode, (
char*)eastFile.c_str(), (
char*)northFile.c_str(),
757 &errorcode, hinv_trans);
764 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_init Error to retrieve lat/lon from a grid.");
771 for (
int i = 0; i < npnts; i++)
785 arg1 = (((
int)col[i] + pixadjX) * scaleX + upleftpt[0]);
786 arg2 = (((
int)row[i] + pixadjY) * scaleY + upleftpt[1]);
787 errorcode = hinv_trans[projcode] (arg1, arg2, &lonrad, &latrad);
794 if(projcode == HE5_GCTP_LAMAZ) {
795 longitude[i] = 1.0e51;
796 latitude[i] = 1.0e51;
799 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_trans Error to retrieve lat/lon from a grid.");
807 longitude[i] = HE5_EHconvAng(lonrad, HE5_HDFE_RAD_DEG);
808 latitude[i] = HE5_EHconvAng(latrad, HE5_HDFE_RAD_DEG);
814 else if (projcode == HE5_GCTP_BCEA)
824 hfor_init(projcode, zonecode, projparm, spherecode, NULL, NULL,&errorcode, hfor_trans);
830 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_init Error to retrieve lat/lon from a grid.");
835 lonrad0 =HE5_EHconvAng(upleftpt[0], HE5_HDFE_DMS_RAD);
836 lonrad = HE5_EHconvAng(lowrightpt[0], HE5_HDFE_DMS_RAD);
840 latrad0 = HE5_EHconvAng(upleftpt[1], HE5_HDFE_DMS_RAD);
841 latrad = HE5_EHconvAng(lowrightpt[1], HE5_HDFE_DMS_RAD);
846 errorcode = hfor_trans[projcode] (lonrad0, latrad0, &xMtr0, &yMtr0);
851 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_trans Error to retrieve lat/lon from a grid.");
858 errorcode = hfor_trans[projcode] (lonrad, latrad, &xMtr1, &yMtr1);
863 throw InternalErr(__FILE__,__LINE__,
"GCTP hfor_trans Error to retrieve lat/lon from a grid.");
868 scaleX = (xMtr1 - xMtr0) / xdimsize;
872 scaleY = (yMtr1 - yMtr0) / ydimsize;
876 hinv_init(projcode, zonecode, projparm, spherecode, NULL, NULL, &errorcode, hinv_trans);
881 throw InternalErr(__FILE__,__LINE__,
"GCTP hinv_init Error to retrieve lat/lon from a grid.");
885 for (
int i = 0; i < npnts; i++)
890 errorcode = hinv_trans[projcode] (
891 (col[i] + pixadjX) * scaleX + xMtr0,
892 (row[i] + pixadjY) * scaleY + yMtr0,
906 longitude[i] = 1.0e51;
907 latitude[i] = 1.0e51;
912 longitude[i] = HE5_EHconvAng(lonrad, HE5_HDFE_RAD_DEG);
913 latitude[i] = HE5_EHconvAng(latrad, HE5_HDFE_RAD_DEG);
917 else if (projcode == HE5_GCTP_GEO)
930 lonrad0 = HE5_EHconvAng(upleftpt[0], HE5_HDFE_DMS_DEG);
931 lonrad = HE5_EHconvAng(lowrightpt[0], HE5_HDFE_DMS_DEG);
935 scaleX = (lonrad - lonrad0) / xdimsize;
939 latrad0 = HE5_EHconvAng(upleftpt[1], HE5_HDFE_DMS_DEG);
940 latrad = HE5_EHconvAng(lowrightpt[1], HE5_HDFE_DMS_DEG);
944 scaleY = (latrad - latrad0) / ydimsize;
948 for (
int i = 0; i < npnts; i++)
952 longitude[i] = (col[i] + pixadjX) * scaleX + lonrad0;
953 latitude[i] = (row[i] + pixadjY) * scaleY + latrad0;
959 hinv_init(projcode, zonecode, projparm, spherecode, eastFile, northFile,
960 (
int *)&errorcode, hinv_trans);
962 for (
int i = 0; i < npnts; i++)
968 hinv_trans[projcode] (
983 HE5_EHconvAng(
double inAngle,
int code)
989 double outAngle = 0.;
990 double pi = 3.14159265358979324;
991 double r2d = 180 / pi;
992 double d2r = 1 / r2d;
999 case HE5_HDFE_RAD_DEG:
1000 outAngle = inAngle * r2d;
1005 case HE5_HDFE_DEG_RAD:
1006 outAngle = inAngle * d2r;
1012 case HE5_HDFE_DMS_DEG:
1013 deg = (long)(inAngle / 1000000);
1014 min = (long)((inAngle - deg * 1000000) / 1000);
1015 sec = (inAngle - deg * 1000000 - min * 1000);
1016 outAngle = deg + min / 60.0 + sec / 3600.0;
1022 case HE5_HDFE_DEG_DMS:
1024 deg = (long)inAngle;
1025 min = (long)((inAngle - deg) * 60);
1026 sec = (inAngle - deg - min / 60.0) * 3600;
1036 if ( fabs(sec - 0.0) < 1.e-7 )
1041 if ( (fabs(sec - 60) < 1.e-7 ) || ( sec > 60.0 ))
1055 outAngle = deg * 1000000 + min * 1000 + sec;
1062 case HE5_HDFE_RAD_DMS:
1064 inAngle = inAngle * r2d;
1065 deg = (long)inAngle;
1066 min = (long)((inAngle - deg) * 60);
1067 sec = ((inAngle - deg - min / 60.0) * 3600);
1077 if ( fabs(sec - 0.0) < 1.e-7 )
1082 if ( (fabs(sec - 60) < 1.e-7 ) || ( sec > 60.0 ))
1096 outAngle = deg * 1000000 + min * 1000 + sec;
1103 case HE5_HDFE_DMS_RAD:
1104 deg = (long)(inAngle / 1000000);
1105 min = (long)((inAngle - deg * 1000000) / 1000);
1106 sec = (inAngle - deg * 1000000 - min * 1000);
1107 outAngle = deg + min / 60.0 + sec / 3600.0;
1108 outAngle = outAngle * d2r;
1123 HDF5CFUtil::INDEX_nD_TO_1D (
const std::vector <size_t > &dims,
1124 const std::vector < size_t > &pos)
1130 if(dims.size () != pos.size ())
1131 throw InternalErr(__FILE__,__LINE__,
"dimension error in INDEX_nD_TO_1D routine.");
1135 for (
size_t p = 0; p < pos.size (); p++) {
1138 for (
size_t j = start; j < dims.size (); j++)
1160 template<
typename T>
1161 int HDF5CFUtil::subset(
1168 std::vector<T> *poutput,
1172 for(
int k=0; k<edge[index]; k++)
1174 pos[index] = start[index] + k*stride[index];
1176 subset(input, rank, dim, start, stride, edge, poutput,pos,index+1);
1179 poutput->push_back(input[INDEX_nD_TO_1D( dim, pos)]);
1189 ssize_t ret_val = read(fd,buf,total_read);
1194 string HDF5CFUtil::obtain_cache_fname(
const string & fprefix,
const string &fname,
const string &vname) {
1196 string cache_fname = fprefix;
1198 string correct_fname = fname;
1199 std::replace(correct_fname.begin(),correct_fname.end(),
'/',
'_');
1201 string correct_vname = vname;
1204 std::replace(correct_vname.begin(),correct_vname.end(),
'/',
'_');
1207 std::replace(correct_vname.begin(),correct_vname.end(),
' ',
'_');
1210 cache_fname = cache_fname +correct_fname +correct_vname;
1214 size_t INDEX_nD_TO_1D (
const std::vector < size_t > &dims,
1215 const std::vector < size_t > &pos){
1220 if(dims.size () != pos.size ())
1221 throw InternalErr(__FILE__,__LINE__,
"dimension error in INDEX_nD_TO_1D routine.");
1225 for (
size_t p = 0; p < pos.size (); p++) {
1228 for (
size_t j = start; j < dims.size (); j++)
1236 void HDF5CFUtil::get_relpath_pos(
const string& temp_str,
const string& relpath, vector<size_t>&s_pos) {
1241 size_t pos = temp_str.find(relpath, 0);
1242 while(pos != string::npos)
1244 s_pos.push_back(pos);
1246 pos = temp_str.find(relpath,pos+1);
1253 void HDF5CFUtil::cha_co(
string &co,
const string & vpath) {
1256 string rp_sep=
"../";
1257 if(vpath.find(sep,1)!=string::npos) {
1259 if(co.find(sep)!=string::npos) {
1261 if(co.find(rp_sep)!=string::npos) {
1262 vector<size_t>var_sep_pos;
1263 get_relpath_pos(vpath,sep,var_sep_pos);
1264 vector<size_t>co_rp_sep_pos;
1265 get_relpath_pos(co,rp_sep,co_rp_sep_pos);
1266 if(co_rp_sep_pos[0]==0) {
1268 if(co_rp_sep_pos.size() <var_sep_pos.size()) {
1269 size_t var_prefix_pos=var_sep_pos[var_sep_pos.size()-co_rp_sep_pos.size()-1];
1271 string var_prefix=vpath.substr(1,var_prefix_pos);
1273 string co_suffix = co.substr(co_rp_sep_pos[co_rp_sep_pos.size()-1]+rp_sep.size());
1275 co = var_prefix+co_suffix;
1283 string var_prefix = obtain_string_before_lastslash(vpath).substr(1);
1284 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)