mirror of
https://github.com/cosmo-sims/monofonIC.git
synced 2024-09-18 15:53:45 +02:00
Merge pull request #5 from cosmo-sims/output-filenames
name output files after config and write output log
This commit is contained in:
commit
eb5667c6cf
4 changed files with 19 additions and 4 deletions
|
@ -162,6 +162,9 @@ public:
|
|||
|
||||
items_[in_section + '/' + name] = value;
|
||||
}
|
||||
size_t lastindex = filename.find_last_of('.');
|
||||
std::string config_basename = filename.substr(0, lastindex);
|
||||
items_["meta/config_basename"] = config_basename;
|
||||
}
|
||||
|
||||
//! inserts a key/value pair in the hash map
|
||||
|
@ -288,6 +291,12 @@ public:
|
|||
return get_value_safe("", key, default_value);
|
||||
}
|
||||
|
||||
std::string get_path_relative_to_config(std::string const &filename) const {
|
||||
std::string empty_string;
|
||||
const std::string basename = get_value_safe("meta", "config_basename", empty_string);
|
||||
return basename + "_" + filename;
|
||||
}
|
||||
|
||||
//! dumps all key-value pairs to a std::ostream
|
||||
void dump(std::ostream &out) {
|
||||
std::map<std::string, std::string>::const_iterator i = items_.begin();
|
||||
|
|
|
@ -209,8 +209,8 @@ int run( config_file& the_config )
|
|||
const real_t astart = 1.0/(1.0+zstart);
|
||||
const real_t volfac(std::pow(boxlen / ngrid / 2.0 / M_PI, 1.5));
|
||||
|
||||
the_cosmo_calc->write_powerspectrum(astart, "input_powerspec.txt" );
|
||||
the_cosmo_calc->write_transfer("input_transfer.txt" );
|
||||
the_cosmo_calc->write_powerspectrum(astart, the_config.get_path_relative_to_config("input_powerspec.txt"));
|
||||
the_cosmo_calc->write_transfer(the_config.get_path_relative_to_config("input_transfer.txt"));
|
||||
|
||||
// the_cosmo_calc->compute_sigma_bc();
|
||||
// abort();
|
||||
|
@ -763,7 +763,7 @@ int run( config_file& the_config )
|
|||
}, psi);
|
||||
|
||||
the_output_plugin->write_grid_data( rho, this_species, fluid_component::density );
|
||||
rho.Write_PowerSpectrum("input_powerspec_sampled_evolved_semiclassical.txt");
|
||||
rho.Write_PowerSpectrum(the_config.get_path_relative_to_config("input_powerspec_sampled_evolved_semiclassical.txt"));
|
||||
rho.FourierTransformBackward();
|
||||
|
||||
//======================================================================
|
||||
|
|
|
@ -148,6 +148,12 @@ int main( int argc, char** argv )
|
|||
|
||||
// open the configuration file
|
||||
config_file the_config(argv[1]);
|
||||
std::string log_filename = the_config.get_path_relative_to_config("log.txt");
|
||||
music::logger::set_output(log_filename);
|
||||
music::ilog << " argv[1] : " << argv[1] << std::endl;
|
||||
music::ilog << " config_basename : " << the_config.get_path_relative_to_config("") << std::endl;
|
||||
music::ilog << " log file : " << log_filename << std::endl;
|
||||
music::ilog << "-------------------------------------------------------------------------------" << std::endl;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Set up FFTW
|
||||
|
|
|
@ -203,7 +203,7 @@ public:
|
|||
{
|
||||
this->tf_isnormalised_ = true;
|
||||
|
||||
ofs_class_input_.open("input_class_parameters.ini", std::ios::trunc);
|
||||
ofs_class_input_.open(cf.get_path_relative_to_config("input_class_parameters.ini"), std::ios::trunc);
|
||||
|
||||
// all cosmological parameters need to be passed through the_cosmo_calc
|
||||
|
||||
|
|
Loading…
Reference in a new issue