Commit 3099a266 authored by Jan Oliver Oelerich's avatar Jan Oliver Oelerich

Added --tmp-dir parameter to config and CLI

parent 36a5678d
......@@ -61,6 +61,7 @@ void Params::initFromCLI(int argc, const char **argv) {
"The number of Frozen Phonon configurations.",
{"num-configurations"});
ValueFlag<string> output_file(parser, "output-file", "The output file path.", {'o', "output-file"});
ValueFlag<string> tmp_dir(parser, "tmp-dir", "The path to the temporary directory.", {"tmp-dir"});
ValueFlag<string> crystal_file(parser, "crystal-file", "The crystal file path.", {'c', "crystal-file"});
ValueFlag<string> title(parser, "title", "The simulation title.", {'t', "title"});
ValueFlag<string> diag_dir(parser,
......@@ -117,6 +118,11 @@ void Params::initFromCLI(int argc, const char **argv) {
_output_file = get(output_file);
}
if(tmp_dir) {
_cli_options.push_back(tmp_dir.Name());
_tmp_dir = get(tmp_dir);
}
if(diag_dir) {
_cli_options.push_back(diag_dir.Name());
_diagnostics_dir = get(diag_dir);
......@@ -169,6 +175,8 @@ void Params::readParamsFromString(const string &prms) {
if(!cliParamGiven("output-file"))
_cfg.lookupValue("simulation.output_file", _output_file);
if(!cliParamGiven("tmp-dir"))
_cfg.lookupValue("simulation.tmp_dir", _tmp_dir);
_cfg.lookupValue("simulation.output_compress", _output_compress);
_cfg.lookupValue("simulation.normalize_always", _normalize_always);
......@@ -288,6 +296,12 @@ void Params::readParamsFromString(const string &prms) {
}
}
if(_tmp_dir.empty()) {
// use the path of the output file directory for tmp
size_t found = _output_file.find_last_of("/\\");
_tmp_dir = _output_file.substr(0,found);
}
if(_random_seed == 0)
_random_seed = (unsigned int) chrono::system_clock::now().time_since_epoch().count();
_rgen.seed(_random_seed);
......
......@@ -112,6 +112,15 @@ namespace stemsalabim {
return _output_file;
}
/*!
* Return path to the temporary directory. If empty string, use the
* dir of the output file.
* @return tmp dir path
*/
const std::string &tmpDir() const {
return _tmp_dir;
}
/*!
* Returns if output should be compressed.
* @return true if output should be compressed.
......@@ -610,6 +619,7 @@ namespace stemsalabim {
std::string _crystal_file{""};
std::string _param_file{""};
std::string _output_file{""};
std::string _tmp_dir{""};
std::string _field_file{""};
std::string _title{""};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment