Gets the variable ``varname`` from the ``job_info`` file and returns as a string
| 430 | /// string |
| 431 | /// |
| 432 | std::string GetVarFromJobInfo (const std::string pltfile, const std::string varname) { |
| 433 | std::string filename = pltfile + "/job_info"; |
| 434 | std::regex re("(?:[ \\t]*)" + varname + "\\s*:\\s*(.*)\\s*\\n"); |
| 435 | |
| 436 | std::smatch m; |
| 437 | |
| 438 | std::ifstream jobfile(filename); |
| 439 | if (jobfile.is_open()) { |
| 440 | std::stringstream buf; |
| 441 | buf << jobfile.rdbuf(); |
| 442 | std::string file_contents = buf.str(); |
| 443 | |
| 444 | if (std::regex_search(file_contents, m, re)) { |
| 445 | return m[1]; |
| 446 | } else { |
| 447 | Print() << "Unable to find " << varname << " in job_info file!" << std::endl; |
| 448 | } |
| 449 | } else { |
| 450 | Print() << "Could not open job_info file!" << std::endl; |
| 451 | } |
| 452 | |
| 453 | return ""; |
| 454 | } |
| 455 | |
| 456 | // Get the center from the job info file and return as a Real Vector |
| 457 | Vector<Real> GetCenter (const std::string pltfile) { |