diff --git a/include/cosmology_calculator.hh b/include/cosmology_calculator.hh index df876fa..1ec1417 100644 --- a/include/cosmology_calculator.hh +++ b/include/cosmology_calculator.hh @@ -293,7 +293,7 @@ namespace cosmology { cosmo_param_.set("pnorm", 1.0 / Dplus_target_ / Dplus_target_); auto sigma8 = this->compute_sigma8(); - music::ilog << "Measured sigma_8 for given PS normalisation is " << sigma8 << std::endl; + music::COLUMN_ilog("Measured sigma_8", sigma8 ); } cosmo_param_.set("sqrtpnorm", std::sqrt(cosmo_param_["pnorm"])); diff --git a/include/logger.hh b/include/logger.hh index 4df119f..a089254 100644 --- a/include/logger.hh +++ b/include/logger.hh @@ -21,6 +21,8 @@ #include #include #include +#include // for std::setw +#include // for std::string namespace music { @@ -148,4 +150,32 @@ extern log_stream wlog; extern log_stream ilog; extern log_stream dlog; +// global functions for convenience +inline void COLUMN_ilog(const std::string& text1, const std::string& text2) { + music::ilog << std::setw(32) << std::left << text1 << " : " << text2 << std::endl; +} + +inline void COLUMN_ilog(const std::string& text1, bool flag) { + music::ilog << std::setw(32) << std::left << text1 << " : " << (flag?"enabled":"disabled") << std::endl; +} + +inline void COLUMN_ilog(const std::string& text1, double value) { + music::ilog << std::setw(32) << std::left << text1 << " : " << value << std::endl; +} + +inline void COLUMN_ilog(const std::string& text1, size_t value) { + music::ilog << std::setw(32) << std::left << text1 << " : " << value << std::endl; +} + +inline void CODE_PART_msg(const std::string& text) { + music::ilog << "-------------------------------------------------------------------------------" << std::endl; + music::ilog << "|| " << std::setw(48) << std::setfill('.') << text << std::setw(28) << std::right << "||" << std::setfill(' ') << std::endl; +} + +inline void CODE_PART_COMPLETE_msg( double wtime ){ + music::ilog << "||" << std::setw(65) << std::right << "took : " << std::setw(8) << wtime << "s ||" << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; + music::ilog << std::endl; +} + } // namespace music diff --git a/src/grid_fft.cc b/src/grid_fft.cc index 24b52f1..e03ddce 100644 --- a/src/grid_fft.cc +++ b/src/grid_fft.cc @@ -23,16 +23,17 @@ void memory_report(void) { - //... report memory usage size_t curr_mem_high_mark = 0; local_mem_high_mark = memory::getCurrentRSS(); + #if defined(USE_MPI) MPI_Allreduce(&local_mem_high_mark, &curr_mem_high_mark, 1, MPI_UNSIGNED_LONG_LONG, MPI_MAX, MPI_COMM_WORLD); #else curr_mem_high_mark = local_mem_high_mark; #endif - if( curr_mem_high_mark > 1.1*global_mem_high_mark ){ - music::ilog << std::setw(57) << std::setfill(' ') << std::right << "mem high: " << std::setw(8) << curr_mem_high_mark/(1ull<<20) << " MBytes / task" << std::endl; + + if (curr_mem_high_mark > 1.1 * global_mem_high_mark) { + music::ilog << std::setw(32) << std::setfill(' ') << std::left << "[[ New memory high mark " << " : " << std::setw(8) << std::fixed << std::setprecision(2) << curr_mem_high_mark / (1024.0 * 1024.0) << " MB per task " << std::setw(23) << std::right << "]]" << std::endl; global_mem_high_mark = curr_mem_high_mark; } } diff --git a/src/ic_generator.cc b/src/ic_generator.cc index 1794690..bf950ac 100644 --- a/src/ic_generator.cc +++ b/src/ic_generator.cc @@ -97,7 +97,7 @@ int run( config_file& the_config ) //-------------------------------------------------------------------------------------------------------- //! number of resolution elements per dimension const size_t ngrid = the_config.get_value("setup", "GridRes"); - + music::COLUMN_ilog( "Grid resolution", ngrid ); //-------------------------------------------------------------------------------------------------------- //! box side length in h-1 Mpc const real_t boxlen = the_config.get_value("setup", "BoxLength"); @@ -135,23 +135,28 @@ int run( config_file& the_config ) : ((lattice_str=="masked")? particle::lattice_masked : particle::lattice_sc))))); - music::ilog << "Using " << lattice_str << " lattice for particle load." << std::endl; + // music::ilog << "Using " << lattice_str << " lattice for particle load." << std::endl; + music::COLUMN_ilog( "Lattice for particle load", lattice_str ); //-------------------------------------------------------------------------------------------------------- //! apply fixing of the complex mode amplitude following Angulo & Pontzen (2016) [https://arxiv.org/abs/1603.05253] const bool bDoFixing = the_config.get_value_safe("setup", "DoFixing", false); - music::ilog << "Fixing of complex mode amplitudes is " << (bDoFixing?"enabled":"disabled") << std::endl; + music::COLUMN_ilog( "Fixing of mode amplitudes", bDoFixing ); + // music::ilog << "Fixing of complex mode amplitudes is " << (bDoFixing?"enabled":"disabled") << std::endl; const bool bDoInversion = the_config.get_value_safe("setup", "DoInversion", false); - music::ilog << "Inversion of the phase field is " << (bDoInversion?"enabled":"disabled") << std::endl; + music::COLUMN_ilog( "Inversion of the phase field", bDoInversion ); + // music::ilog << "Inversion of the phase field is " << (bDoInversion?"enabled":"disabled") << std::endl; //-------------------------------------------------------------------------------------------------------- //! do baryon ICs? const bool bDoBaryons = the_config.get_value_safe("setup", "DoBaryons", false ); - music::ilog << "Baryon ICs are " << (bDoBaryons?"enabled":"disabled") << std::endl; + // music::ilog << "Baryon ICs are " << (bDoBaryons?"enabled":"disabled") << std::endl; + music::COLUMN_ilog( "Baryon ICs", bDoBaryons ); //! enable also back-scaled decaying relative velocity mode? only first order! const bool bDoLinearBCcorr = the_config.get_value_safe("setup", "DoBaryonVrel", false); - music::ilog << "Baryon linear relative velocity mode is " << (bDoLinearBCcorr?"enabled":"disabled") << std::endl; + // music::ilog << "Baryon linear relative velocity" << (bDoLinearBCcorr?"enabled":"disabled") << std::endl; + music::COLUMN_ilog( "Baryon linear relative velocity", bDoLinearBCcorr ); // compute mass fractions std::map< cosmo_species, double > Omega; if( bDoBaryons ){