Skip to content
Snippets Groups Projects
Commit ae8572af authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Fix bug in reading IOG vector

parent ca8c9b3a
No related branches found
No related tags found
No related merge requests found
......@@ -72,14 +72,8 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(string file_name) {
regex re = regex("-?[0-9]+");
str_target = file_lines[last_read_line++];
regex_search(str_target, m, re);
//sscanf(file_lines[last_read_line].c_str(), " %d", &_nsph);
_nsph = stoi(m.str());
if (_nsph == 1) {
//sscanf(
// file_lines[last_read_line++].c_str(),
// " %*d %d %d %d %d %d",
// &_lm, &_in_pol, &_npnt, &_npntts, &_isam
//);
for (int ri = 0; ri < 5; ri++) {
str_target = m.suffix().str();
regex_search(str_target, m, re);
......@@ -90,11 +84,6 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(string file_name) {
if (ri == 4) _isam = stoi(m.str());
}
} else {
//sscanf(
// file_lines[last_read_line++].c_str(),
// " %*d %d %d %d %d %d %d %d %d",
// &_li, &_le, &_mxndm, &_in_pol, &_npnt, &_npntts, &_iavm, &_isam
//);
for (int ri = 0; ri < 8; ri++) {
str_target = m.suffix().str();
regex_search(str_target, m, re);
......@@ -166,7 +155,6 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(string file_name) {
re = regex("[0-9]+");
str_target = file_lines[last_read_line++];
regex_search(str_target, m, re);
//sscanf(file_lines[last_read_line].c_str(), " %d", &_nsph);
_jwtm = stoi(m.str());
GeometryConfiguration *conf = new GeometryConfiguration(
_nsph, _lm, _in_pol, _npnt, _npntts, _isam,
......@@ -403,9 +391,7 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(string dedfb_file_nam
variable_name = "XIV";
if (instpc < 1) { // The variable vector is explicitly defined.
double xi;
//int xi_exp;
List<double> xi_vector;
//sscanf(file_lines[++last_read_line].c_str(), " %9lE D%d", &xi, &xi_exp);
str_target = file_lines[++last_read_line];
re = regex("-?[0-9]+\\.[0-9]+([eEdD][-+]?)?[0-9]+");
regex_search(str_target, m, re);
......@@ -448,9 +434,7 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(string dedfb_file_nam
variable_vector = new double[nxi]();
if (instpc == 0) { // The variable vector is explicitly defined
double vs;
//int vs_exp;
for (int jxi_r = 0; jxi_r < nxi; jxi_r++) {
//sscanf(file_lines[++last_read_line].c_str(), " %lf D%d", &vs, &vs_exp);
str_target = file_lines[++last_read_line];
re = regex("-?[0-9]+\\.[0-9]+([eEdD][-+]?)?[0-9]+");
regex_search(str_target, m, re);
......@@ -479,8 +463,6 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(string dedfb_file_nam
}
} else { // The variable vector needs to be computed in steps
double vs, vs_step;
//int vs_exp, vs_step_exp;
//sscanf(file_lines[++last_read_line].c_str(), " %lf D%d %lf D%d", &vs, &vs_exp, &vs_step, &vs_step_exp);
str_target = file_lines[++last_read_line];
re = regex("-?[0-9]+\\.[0-9]+([eEdD][-+]?)?[0-9]+");
regex_search(str_target, m, re);
......@@ -516,33 +498,37 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(string dedfb_file_nam
}
}
}
last_read_line++;
//last_read_line++;
int *iog_vector = new int[nsph]();
double *ros_vector = new double[nsph]();
double **rcf_vector = new double*[nsph];
int *nshl_vector = new int[nsph]();
//printf("\nDEBUG: reading IOG from %s", file_lines[last_read_line].c_str());
//fflush(stdout);
for (int i = 0; i < nsph; i++) {
/*for (int i = 0; i < nsph; i++) {
string read_format = "";
for (int j = 0; j < (i % 15); j++) read_format += " %*d";
read_format += " %d";
sscanf(file_lines[last_read_line].c_str(), read_format.c_str(), (iog_vector + i));
if (i > 0 && i % 15 == 0) {
last_read_line++;
//printf("DEBUG: reading IOG from %s", file_lines[last_read_line].c_str());
//fflush(stdout);
}
}*/
int filled_iogs = 0;
re = regex("[0-9]+");
while (filled_iogs < nsph) {
string str_target = file_lines[++last_read_line];
while(regex_search(str_target, m, re)) {
iog_vector[filled_iogs++] = stoi(m.str());
str_target = m.suffix().str();
if (filled_iogs == nsph) break;
}
}
for (int i113 = 1; i113 <= nsph; i113++) {
int i_val, nsh;
double ros_val;
//int ros_val_exp;
if (iog_vector[i113 - 1] < i113) {
rcf_vector[i113 - 1] = new double[1]();
continue;
}
//sscanf(file_lines[++last_read_line].c_str(), " %d %lf D%d", &i_val, &ros_val, &ros_val_exp);
re = regex("[0-9]+");
str_target = file_lines[++last_read_line];
regex_search(str_target, m, re);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment