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

Function GetVarFromJobInfo

Diagnostics/DustCollapse/main.cpp:323–345  ·  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

321/// string
322///
323string 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
348Vector<Real> GetCenter (const string pltfile) {

Callers 1

GetCenterFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected