Gets the variable ``varname`` from the ``job_info`` file and returns as a string
| 321 | /// string |
| 322 | /// |
| 323 | string GetVarFromJobInfo (const string pltfile, const string varname) { |
| 324 | string filename = pltfile + "/job_info"; |
| 325 | std::regex re("(?:[ \\t]*)" + varname + "\\s*:\\s*(.*)\\s*\\n"); |
| 326 | |
| 327 | std::smatch m; |
| 328 | |
| 329 | std::ifstream jobfile(filename); |
| 330 | if (jobfile.is_open()) { |
| 331 | std::stringstream buf; |
| 332 | buf << jobfile.rdbuf(); |
| 333 | string file_contents = buf.str(); |
| 334 | |
| 335 | if (std::regex_search(file_contents, m, re)) { |
| 336 | return m[1]; |
| 337 | } else { |
| 338 | Print() << "Unable to find " << varname << " in job_info file!" << std::endl; |
| 339 | } |
| 340 | } else { |
| 341 | Print() << "Could not open job_info file!" << std::endl; |
| 342 | } |
| 343 | |
| 344 | return ""; |
| 345 | } |
| 346 | |
| 347 | // Get the center from the job info file and return as a Real Vector |
| 348 | Vector<Real> GetCenter (const string pltfile) { |