MCPcopy Create free account
hub / github.com/AMReX-Astro/Castro / GetVarFromJobInfo

Function GetVarFromJobInfo

Diagnostics/Sedov/main.cpp:432–454  ·  view source on GitHub ↗

Gets the variable ``varname`` from the ``job_info`` file and returns as a string

Source from the content-addressed store, hash-verified

430/// string
431///
432std::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
457Vector<Real> GetCenter (const std::string pltfile) {

Callers 1

GetCenterFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected