diff --git a/CMakeLists.txt b/CMakeLists.txt index bd95567..d69bbcd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,5 +196,6 @@ if(ENABLE_PANPHASIA) target_compile_options(${PRGNAME} PRIVATE "-DHAVE_PANPHASIA") endif(ENABLE_PANPHASIA) +target_include_directories(${PRGNAME} PRIVATE ${GSL_INCLUDE_DIR}) target_link_libraries(${PRGNAME} PRIVATE GSL::gsl) diff --git a/src/convolution_kernel.cc b/src/convolution_kernel.cc index 9b4acb1..c9943e2 100644 --- a/src/convolution_kernel.cc +++ b/src/convolution_kernel.cc @@ -37,11 +37,8 @@ void perform(kernel *pk, void *pd, bool shift, bool fix, bool flip) cdata = reinterpret_cast(data); ckernel = reinterpret_cast(pk->get_ptr()); - std::cout << " - Performing density convolution... (" - << cparam_.nx << ", " << cparam_.ny << ", " << cparam_.nz << ")\n"; - - music::ulog.Print("Performing kernel convolution on (%5d,%5d,%5d) grid", cparam_.nx, cparam_.ny, cparam_.nz); - music::ulog.Print("Performing forward FFT..."); + music::ilog.Print("- Performing kernel convolution on (%5d,%5d,%5d) grid", cparam_.nx, cparam_.ny, cparam_.nz); + music::ilog.Print("- Performing forward FFT..."); fftw_plan_t plan, iplan; plan = FFTW_API(plan_dft_r2c_3d)(cparam_.nx, cparam_.ny, cparam_.nz, data, cdata, FFTW_ESTIMATE); diff --git a/src/densities.cc b/src/densities.cc index 74b1cf6..5f82b28 100644 --- a/src/densities.cc +++ b/src/densities.cc @@ -267,21 +267,17 @@ void GenerateDensityUnigrid(config_file &cf, transfer_function *ptf, tf_type typ unsigned nbase = 1 << levelmin; - std::cerr << " - Running unigrid version\n"; - music::ulog.Print("Running unigrid density convolution..."); + music::ilog.Print("- Running unigrid density convolution..."); //... select the transfer function to be used convolution::kernel_creator *the_kernel_creator = convolution::get_kernel_map()["tf_kernel_k"]; - std::cout << " - Using k-space transfer function kernel.\n"; - music::ulog.Print("Using k-space transfer function kernel."); - + //... initialize convolution kernel convolution::kernel *the_tf_kernel = the_kernel_creator->create(cf, ptf, refh, type); //... - std::cout << " - Performing noise convolution on level " << std::setw(2) << levelmax << " ..." << std::endl; - music::ulog.Print("Performing noise convolution on level %3d", levelmax); + music::ulog.Print("- Performing noise convolution on level %3d", levelmax); //... create convolution mesh DensityGrid *top = new DensityGrid(nbase, nbase, nbase); @@ -322,7 +318,7 @@ void GenerateDensityHierarchy(config_file &cf, transfer_function *ptf, tf_type t double tstart, tend; -#ifndef SINGLETHREAD_FFTW +#if defined(_OPENMP) tstart = omp_get_wtime(); #else tstart = (double)clock() / CLOCKS_PER_SEC; @@ -343,10 +339,6 @@ void GenerateDensityHierarchy(config_file &cf, transfer_function *ptf, tf_type t unsigned nbase = 1 << levelmin; convolution::kernel_creator *the_kernel_creator = convolution::get_kernel_map()["tf_kernel_k"]; - - std::cout << " - Using k-space transfer function kernel.\n"; - music::ulog.Print("Using k-space transfer function kernel."); - convolution::kernel *the_tf_kernel = the_kernel_creator->create(cf, ptf, refh, type); /***** PERFORM CONVOLUTIONS *****/ @@ -423,14 +415,14 @@ void GenerateDensityHierarchy(config_file &cf, transfer_function *ptf, tf_type t delete the_tf_kernel; -#ifndef SINGLETHREAD_FFTW +#if defined(_OPENMP) tend = omp_get_wtime(); if (true) //verbosity > 1 ) - std::cout << " - Density calculation took " << tend - tstart << "s with " << omp_get_max_threads() << " threads." << std::endl; + music::ulog << " - Density calculation took " << tend - tstart << "s with " << omp_get_max_threads() << " threads." << std::endl; #else tend = (double)clock() / CLOCKS_PER_SEC; if (true) //verbosity > 1 ) - std::cout << " - Density calculation took " << tend - tstart << "s." << std::endl; + music::ulog << " - Density calculation took " << tend - tstart << "s." << std::endl; #endif if( !fourier_splicing ){ @@ -467,8 +459,7 @@ void normalize_density(grid_hierarchy &delta) sum /= (double)(nx * ny * nz); } - std::cout << " - Top grid mean density is off by " << sum << ", correcting..." << std::endl; - music::ulog.Print("Grid mean density is %g. Correcting...", sum); + music::ilog << "- Top grid mean density is off by " << sum << ", correcting..." << std::endl; for (unsigned i = levelmin; i <= levelmax; ++i) { diff --git a/src/main.cc b/src/main.cc index 680c335..eaf17fd 100644 --- a/src/main.cc +++ b/src/main.cc @@ -94,18 +94,18 @@ double compute_finest_sigma(grid_hierarchy &u); void splash(void) { - std::cout - << "\n __ __ __ __ ______ __ ______ \n" - << " /\\ \"-./ \\ /\\ \\/\\ \\ /\\ ___\\ /\\ \\ /\\ ___\\ \n" - << " \\ \\ \\-./\\ \\ \\ \\ \\_\\ \\ \\ \\___ \\ \\ \\ \\ \\ \\ \\____ \n" - << " \\ \\_\\ \\ \\_\\ \\ \\_____\\ \\/\\_____\\ \\ \\_\\ \\ \\_____\\ \n" - << " \\/_/ \\/_/ \\/_____/ \\/_____/ \\/_/ \\/_____/ \n\n" - << " this is " << THE_CODE_NAME << " version " << THE_CODE_VERSION << "\n\n"; + music::ilog << std::endl + << " __ __ __ __ ______ __ ______ " << std::endl + << " /\\ \"-./ \\ /\\ \\/\\ \\ /\\ ___\\ /\\ \\ /\\ ___\\ " << std::endl + << " \\ \\ \\-./\\ \\ \\ \\ \\_\\ \\ \\ \\___ \\ \\ \\ \\ \\ \\ \\____ " << std::endl + << " \\ \\_\\ \\ \\_\\ \\ \\_____\\ \\/\\_____\\ \\ \\_\\ \\ \\_____\\ " << std::endl + << " \\/_/ \\/_/ \\/_____/ \\/_____/ \\/_/ \\/_____/ " << std::endl << std::endl + << " this is " << THE_CODE_NAME << " version " << THE_CODE_VERSION << std::endl << std::endl; #if defined(CMAKE_BUILD) music::ilog.Print("Version built from git rev.: %s, tag: %s, branch: %s", GIT_REV, GIT_TAG, GIT_BRANCH); #endif - std::cout << "\n\n"; + music::ilog << std::endl << std::endl; } void modify_grid_for_TF(const refinement_hierarchy &rh_full, refinement_hierarchy &rh_TF, config_file &cf) @@ -151,7 +151,7 @@ void modify_grid_for_TF(const refinement_hierarchy &rh_full, refinement_hierarch if (lbaseTF > lbase) { - std::cout << " - Will use levelmin = " << lbaseTF << " to compute density field...\n"; + music::ilog << "- Will use levelmin = " << lbaseTF << " to compute density field...\n"; for (unsigned i = lbase; i <= lbaseTF; ++i) { @@ -180,48 +180,48 @@ void print_hierarchy_stats(config_file &cf, const refinement_hierarchy &rh) else cmass = omegam * rhom * dx3; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; if (rh.get_shift(0) != 0 || rh.get_shift(1) != 0 || rh.get_shift(2) != 0) - std::cout << " - Domain will be shifted by (" << rh.get_shift(0) << ", " << rh.get_shift(1) << ", " << rh.get_shift(2) << ")\n" + music::ilog << "- Domain will be shifted by (" << rh.get_shift(0) << ", " << rh.get_shift(1) << ", " << rh.get_shift(2) << ")\n" << std::endl; - std::cout << " - Grid structure:\n"; + music::ilog << "- Grid structure:\n"; for (unsigned ilevel = rh.levelmin(); ilevel <= rh.levelmax(); ++ilevel) { double rfac = 1.0 / (1 << (ilevel - rh.levelmin())), rfac3 = rfac * rfac * rfac; mtotgrid = omegam * rhom * dx3 * rfac3 * rh.size(ilevel, 0) * rh.size(ilevel, 1) * rh.size(ilevel, 2); - std::cout + music::ilog << " Level " << std::setw(3) << ilevel << " : offset = (" << std::setw(5) << rh.offset(ilevel, 0) << ", " << std::setw(5) << rh.offset(ilevel, 1) << ", " << std::setw(5) << rh.offset(ilevel, 2) << ")\n" << " size = (" << std::setw(5) << rh.size(ilevel, 0) << ", " << std::setw(5) << rh.size(ilevel, 1) << ", " << std::setw(5) << rh.size(ilevel, 2) << ")\n"; if (ilevel == rh.levelmax()) { - std::cout << "-------------------------------------------------------------\n"; - std::cout << " - Finest level :\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; + music::ilog << "- Finest level :\n"; if (dx * rfac > 0.1) - std::cout << " extent = " << dx * rfac * rh.size(ilevel, 0) << " x " << dx * rfac * rh.size(ilevel, 1) << " x " << dx * rfac * rh.size(ilevel, 2) << " h-3 Mpc**3\n"; + music::ilog << " extent = " << dx * rfac * rh.size(ilevel, 0) << " x " << dx * rfac * rh.size(ilevel, 1) << " x " << dx * rfac * rh.size(ilevel, 2) << " h-3 Mpc**3\n"; else if (dx * rfac > 1e-4) - std::cout << " extent = " << dx * rfac * 1000.0 * rh.size(ilevel, 0) << " x " << dx * rfac * 1000.0 * rh.size(ilevel, 1) << " x " << dx * rfac * 1000.0 * rh.size(ilevel, 2) << " h-3 kpc**3\n"; + music::ilog << " extent = " << dx * rfac * 1000.0 * rh.size(ilevel, 0) << " x " << dx * rfac * 1000.0 * rh.size(ilevel, 1) << " x " << dx * rfac * 1000.0 * rh.size(ilevel, 2) << " h-3 kpc**3\n"; else - std::cout << " extent = " << dx * rfac * 1.e6 * rh.size(ilevel, 0) << " x " << dx * rfac * 1.e6 * rh.size(ilevel, 1) << " x " << dx * rfac * 1.e6 * rh.size(ilevel, 2) << " h-3 pc**3\n"; + music::ilog << " extent = " << dx * rfac * 1.e6 * rh.size(ilevel, 0) << " x " << dx * rfac * 1.e6 * rh.size(ilevel, 1) << " x " << dx * rfac * 1.e6 * rh.size(ilevel, 2) << " h-3 pc**3\n"; - std::cout << " mtotgrid = " << mtotgrid << " h-1 M_o\n"; - std::cout << " particle mass = " << cmass * rfac3 << " h-1 M_o\n"; + music::ilog << " mtotgrid = " << mtotgrid << " h-1 M_o\n"; + music::ilog << " particle mass = " << cmass * rfac3 << " h-1 M_o\n"; if (bbaryons) - std::cout << " baryon mass/cell = " << bmass * rfac3 << " h-1 M_o\n"; + music::ilog << " baryon mass/cell = " << bmass * rfac3 << " h-1 M_o\n"; if (dx * rfac > 0.1) - std::cout << " dx = " << dx * rfac << " h-1 Mpc\n"; + music::ilog << " dx = " << dx * rfac << " h-1 Mpc\n"; else if (dx * rfac > 1e-4) - std::cout << " dx = " << dx * rfac * 1000.0 << " h-1 kpc\n"; + music::ilog << " dx = " << dx * rfac * 1000.0 << " h-1 kpc\n"; else - std::cout << " dx = " << dx * rfac * 1.e6 << " h-1 pc\n"; + music::ilog << " dx = " << dx * rfac * 1.e6 << " h-1 pc\n"; } } - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; } void store_grid_structure(config_file &cf, const refinement_hierarchy &rh) @@ -372,9 +372,10 @@ int main(int argc, const char *argv[]) //... parse command line options //------------------------------------------------------------------------------ - splash(); + if (argc != 2) { + splash(); std::cout << " This version is compiled with the following plug-ins:\n"; print_region_generator_plugins(); @@ -394,6 +395,8 @@ int main(int argc, const char *argv[]) snprintf(logfname, 128, "%s_log.txt", argv[1]); music::logger::set_output(logfname); time_t ltime = time(NULL); + + splash(); music::ilog.Print("Opening log file \'%s\'.", logfname); music::ulog.Print("Running %s, version %s", THE_CODE_NAME, THE_CODE_VERSION); music::ulog.Print("Log is for run started %s", asctime(localtime(<ime))); @@ -412,6 +415,10 @@ int main(int argc, const char *argv[]) //------------------------------------------------------------------------------ CONFIG::FFTW_threads_ok = FFTW_API(init_threads)(); CONFIG::num_threads = cf.get_value_safe("execution", "NumThreads",std::thread::hardware_concurrency()); + + music::ilog << "-------------------------------------------------------------------------------" << std::endl; + output_system_info(); + music::ilog << "-------------------------------------------------------------------------------" << std::endl; //------------------------------------------------------------------------------ //... initialize some parameters about grid set-up @@ -427,8 +434,8 @@ int main(int argc, const char *argv[]) if (lbaseTF < lbase) { - std::cout << " - WARNING: levelminTF < levelmin. This is not good!\n" - << " I will set levelminTF = levelmin.\n"; + music::ilog << " - WARNING: levelminTF < levelmin. This is not good!" << std::endl + << " I will set levelminTF = levelmin." << std::endl; music::ulog.Print("levelminTF < levelmin. set levelminTF = levelmin."); @@ -460,7 +467,7 @@ int main(int argc, const char *argv[]) cosmology cosmo(cf); - std::cout << " - starting at a=" << cosmo.astart << std::endl; + music::ilog << "- starting at a=" << cosmo.astart << std::endl; CosmoCalc ccalc(cosmo, the_transfer_function_plugin); cosmo.pnorm = ccalc.ComputePNorm(2.0 * M_PI / boxlength); @@ -499,8 +506,8 @@ int main(int argc, const char *argv[]) //------------------------------------------------------------------------------ if (!the_transfer_function_plugin->tf_is_distinct() && do_baryons) - std::cout << " - WARNING: The selected transfer function does not support\n" - << " distinct amplitudes for baryon and DM fields!\n" + music::wlog << " - WARNING: The selected transfer function does not support" << std::endl + << " distinct amplitudes for baryon and DM fields!" << std::endl << " Perturbation amplitudes will be identical!" << std::endl; @@ -538,10 +545,10 @@ int main(int argc, const char *argv[]) //------------------------------------------------------------------------------ //... initialize the random numbers //------------------------------------------------------------------------------ - std::cout << "=============================================================\n"; - std::cout << " GENERATING WHITE NOISE\n"; - std::cout << "-------------------------------------------------------------\n"; - music::ulog.Print("Computing white noise..."); + music::ilog << "===============================================================================" << std::endl; + music::ilog << " GENERATING WHITE NOISE\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; + music::ilog << "Computing white noise..." << std::endl; // rand_gen rand(cf, rh_TF, the_transfer_function_plugin); rand.initialize_for_grid_structure( rh_TF ); @@ -597,9 +604,9 @@ int main(int argc, const char *argv[]) //------------------------------------------------------------------------------ //... cdm density and displacements //------------------------------------------------------------------------------ - std::cout << "=============================================================\n"; - std::cout << " COMPUTING DARK MATTER DISPLACEMENTS\n"; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "===============================================================================" << std::endl; + music::ilog << " COMPUTING DARK MATTER DISPLACEMENTS\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ulog.Print("Computing dark matter displacements..."); grid_hierarchy f(nbnd); //, u(nbnd); @@ -667,9 +674,9 @@ int main(int argc, const char *argv[]) //------------------------------------------------------------------------------ if (do_baryons) { - std::cout << "=============================================================\n"; - std::cout << " COMPUTING BARYON DENSITY\n"; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "===============================================================================" << std::endl; + music::ilog << " COMPUTING BARYON DENSITY\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ulog.Print("Computing baryon density..."); GenerateDensityHierarchy(cf, the_transfer_function_plugin, baryon, rh_TF, rand, f, false, bbshift); coarsen_density(rh_Poisson, f, bspectral_sampling); @@ -736,9 +743,9 @@ int main(int argc, const char *argv[]) //------------------------------------------------------------------------------ if ((!the_transfer_function_plugin->tf_has_velocities() || !do_baryons) && !bsph) { - std::cout << "=============================================================\n"; - std::cout << " COMPUTING VELOCITIES\n"; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "===============================================================================" << std::endl; + music::ilog << " COMPUTING VELOCITIES\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ulog.Print("Computing velocitites..."); if (do_baryons || the_transfer_function_plugin->tf_has_velocities()) @@ -807,9 +814,9 @@ int main(int argc, const char *argv[]) else { music::ilog.Print("Computing separate velocities for CDM and baryons:"); - std::cout << "=============================================================\n"; - std::cout << " COMPUTING DARK MATTER VELOCITIES\n"; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "===============================================================================" << std::endl; + music::ilog << " COMPUTING DARK MATTER VELOCITIES" << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ulog.Print("Computing dark matter velocitites..."); //... we do baryons and have velocity transfer functions, or we do SPH and not to shift @@ -868,9 +875,9 @@ int main(int argc, const char *argv[]) data_forIO.deallocate(); f.deallocate(); - std::cout << "=============================================================\n"; - std::cout << " COMPUTING BARYON VELOCITIES\n"; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "===============================================================================" << std::endl; + music::ilog << " COMPUTING BARYON VELOCITIES" << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ulog.Print("Computing baryon velocitites..."); //... do baryons GenerateDensityHierarchy(cf, the_transfer_function_plugin, vbaryon, rh_TF, rand, f, false, bbshift); @@ -944,18 +951,16 @@ int main(int argc, const char *argv[]) if (!do_baryons || !the_transfer_function_plugin->tf_has_velocities()) my_tf_type = total; - std::cout << "=============================================================\n"; + music::ilog << "===============================================================================" << std::endl; if (my_tf_type == total) { - std::cout << " COMPUTING VELOCITIES\n"; - music::ulog.Print("Computing velocities..."); + music::ilog << " COMPUTING VELOCITIES" << std::endl; } else { - std::cout << " COMPUTING DARK MATTER VELOCITIES\n"; - music::ulog.Print("Computing dark matter velocities..."); + music::ilog << " COMPUTING DARK MATTER VELOCITIES" << std::endl; } - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; GenerateDensityHierarchy(cf, the_transfer_function_plugin, my_tf_type, rh_TF, rand, f, false, false); coarsen_density(rh_Poisson, f, bspectral_sampling); @@ -980,16 +985,16 @@ int main(int argc, const char *argv[]) else f.deallocate(); - music::ilog.Print("Computing 2LPT term...."); + music::ilog.Print("- Computing 2LPT term...."); if (!kspace2LPT) compute_2LPT_source(u1, f2LPT, grad_order); else { - music::ulog.Print("computing term using FFT"); + music::ulog.Print(" computing term using FFT"); compute_2LPT_source_FFT(cf, u1, f2LPT); } - music::ilog.Print("Solving 2LPT Poisson equation"); + music::ilog.Print("- Solving 2LPT Poisson equation"); u2LPT = u1; u2LPT.zero(); the_poisson_solver->solve(f2LPT, u2LPT); @@ -1034,8 +1039,8 @@ int main(int argc, const char *argv[]) double maxv = compute_finest_absmax(data_forIO); music::ilog.Print("max of abs of %c-velocity of high-res particles is %f", 'x' + icoord, maxv); - std::cerr << " - velocity component " << icoord << " : sigma = " << sigv << std::endl; - std::cerr << " - velocity component " << icoord << " : mean = " << meanv << std::endl; + music::ilog << " - velocity component " << icoord << " : sigma = " << sigv << std::endl; + music::ilog << " - velocity component " << icoord << " : mean = " << meanv << std::endl; coarsen_density(rh_Poisson, data_forIO, false); @@ -1058,9 +1063,9 @@ int main(int argc, const char *argv[]) if (do_baryons && (the_transfer_function_plugin->tf_has_velocities() || bsph)) { - std::cout << "=============================================================\n"; - std::cout << " COMPUTING BARYON VELOCITIES\n"; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "===============================================================================" << std::endl; + music::ilog << " COMPUTING BARYON VELOCITIES" << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ulog.Print("Computing baryon displacements..."); GenerateDensityHierarchy(cf, the_transfer_function_plugin, vbaryon, rh_TF, rand, f, false, bbshift); @@ -1132,8 +1137,8 @@ int main(int argc, const char *argv[]) double maxv = compute_finest_absmax(data_forIO); music::ilog.Print("max of abs of %c-velocity of high-res baryons is %f", 'x' + icoord, maxv); - std::cerr << " - velocity component " << icoord << " : sigma = " << sigv << std::endl; - std::cerr << " - velocity component " << icoord << " : mean = " << meanv << std::endl; + music::ilog << " - velocity component " << icoord << " : sigma = " << sigv << std::endl; + music::ilog << " - velocity component " << icoord << " : mean = " << meanv << std::endl; coarsen_density(rh_Poisson, data_forIO, false); @@ -1147,9 +1152,9 @@ int main(int argc, const char *argv[]) u1.deallocate(); } - std::cout << "=============================================================\n"; - std::cout << " COMPUTING DARK MATTER DISPLACEMENTS\n"; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "===============================================================================" << std::endl; + music::ilog << " COMPUTING DARK MATTER DISPLACEMENTS" << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ulog.Print("Computing dark matter displacements..."); //... if baryons are enabled, the displacements have to be recomputed @@ -1254,9 +1259,9 @@ int main(int argc, const char *argv[]) if (do_baryons && !bsph) { - std::cout << "=============================================================\n"; - std::cout << " COMPUTING BARYON DENSITY\n"; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "===============================================================================" << std::endl; + music::ilog << " COMPUTING BARYON DENSITY" << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ulog.Print("Computing baryon density..."); GenerateDensityHierarchy(cf, the_transfer_function_plugin, baryon, rh_TF, rand, f, true, false); @@ -1297,9 +1302,9 @@ int main(int argc, const char *argv[]) } else if (do_baryons && bsph) { - std::cout << "=============================================================\n"; - std::cout << " COMPUTING BARYON DISPLACEMENTS\n"; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "===============================================================================" << std::endl; + music::ilog << " COMPUTING BARYON DISPLACEMENTS" << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ulog.Print("Computing baryon displacements..."); GenerateDensityHierarchy(cf, the_transfer_function_plugin, baryon, rh_TF, rand, f, false, bbshift); @@ -1385,11 +1390,10 @@ int main(int argc, const char *argv[]) bfatal = true; } - std::cout << "=============================================================\n"; - + music::ilog << "===============================================================================" << std::endl; if (!bfatal) { - std::cout << " - Wrote output file \'" << outfname << "\'\n using plugin \'" << outformat << "\'...\n"; + music::ilog << " - Wrote output file \'" << outfname << "\'\n using plugin \'" << outformat << "\'...\n"; music::ulog.Print("Wrote output file \'%s\'.", outfname.c_str()); } @@ -1405,8 +1409,7 @@ int main(int argc, const char *argv[]) //------------------------------------------------------------------------------ //... we are done ! //------------------------------------------------------------------------------ - std::cout << " - Done!" << std::endl - << std::endl; + music::ilog << " - Done!" << std::endl << std::endl; ltime = time(NULL); diff --git a/src/mesh.hh b/src/mesh.hh index aea1733..33b3bf1 100644 --- a/src/mesh.hh +++ b/src/mesh.hh @@ -1811,22 +1811,22 @@ public: //! write refinement hierarchy to stdout void output(void) const { - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; if (xshift_[0] != 0 || xshift_[1] != 0 || xshift_[2] != 0) - std::cout << " - Domain will be shifted by (" << xshift_[0] << ", " << xshift_[1] << ", " << xshift_[2] << ")\n" + music::ilog << " - Domain will be shifted by (" << xshift_[0] << ", " << xshift_[1] << ", " << xshift_[2] << ")\n" << std::endl; - std::cout << " - Grid structure:\n"; + music::ilog << " - Grid structure:\n"; for (unsigned ilevel = levelmin_; ilevel <= levelmax_; ++ilevel) { - std::cout + music::ilog << " Level " << std::setw(3) << ilevel << " : offset = (" << std::setw(5) << offsets_[ilevel][0] << ", " << std::setw(5) << offsets_[ilevel][1] << ", " << std::setw(5) << offsets_[ilevel][2] << ")\n" << " offset_abs = (" << std::setw(5) << absoffsets_[ilevel][0] << ", " << std::setw(5) << absoffsets_[ilevel][1] << ", " << std::setw(5) << absoffsets_[ilevel][2] << ")\n" << " size = (" << std::setw(5) << len_[ilevel][0] << ", " << std::setw(5) << len_[ilevel][1] << ", " << std::setw(5) << len_[ilevel][2] << ")\n"; } - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; } void output_log(void) const diff --git a/src/plugins/output_tipsy_resample.cc b/src/plugins/output_tipsy_resample.cc index 16b92f8..089166d 100644 --- a/src/plugins/output_tipsy_resample.cc +++ b/src/plugins/output_tipsy_resample.cc @@ -864,7 +864,7 @@ public: double rhom = 2.77519737e11; // h-1 M_o / (h-1 Mpc)**3 double cmass, bmass(0.0); - std::cout << "-------------------------------------------------------------" << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; music::ilog.Print("TIPSY: particle resampling is enabled"); music::ilog.Print("TIPSY: new high-res particles have the masses:"); if( with_baryons_ ) diff --git a/src/plugins/random_music.cc b/src/plugins/random_music.cc index ba3676e..39a71bd 100644 --- a/src/plugins/random_music.cc +++ b/src/plugins/random_music.cc @@ -601,7 +601,7 @@ void RNG_music::fill_grid(int ilevel, DensityGrid &A) delete mem_cache_[ilevel - levelmin_]; mem_cache_[ilevel - levelmin_] = NULL; } -}; +} namespace { diff --git a/src/poisson.cc b/src/poisson.cc index 038b1b7..38bb59e 100644 --- a/src/poisson.cc +++ b/src/poisson.cc @@ -59,8 +59,8 @@ real_t multigrid_poisson_plugin::solve(grid_hierarchy &f, grid_hierarchy &u) if (verbosity > 0) { - std::cout << "-------------------------------------------------------------\n"; - std::cout << " - Invoking multi-grid Poisson solver..." << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; + music::ilog << "- Invoking multi-grid Poisson solver..." << std::endl; } real_t acc = 1e-5, err; @@ -99,7 +99,7 @@ real_t multigrid_poisson_plugin::solve(grid_hierarchy &f, grid_hierarchy &u) real_t tstart, tend; -#ifndef SINGLETHREAD_FFTW +#if defined(_OPENMP) tstart = omp_get_wtime(); #else tstart = (real_t)clock() / CLOCKS_PER_SEC; @@ -132,7 +132,7 @@ real_t multigrid_poisson_plugin::solve(grid_hierarchy &f, grid_hierarchy &u) //------------------------------// -#ifndef SINGLETHREAD_FFTW +#if defined(_OPENMP) tend = omp_get_wtime(); if (verbosity > 1) std::cout << " - Poisson solver took " << tend - tstart << "s with " << omp_get_max_threads() << " threads." << std::endl; @@ -430,8 +430,8 @@ real_t fft_poisson_plugin::solve(grid_hierarchy &f, grid_hierarchy &u) if (verbosity > 0) { - std::cout << "-------------------------------------------------------------\n"; - std::cout << " - Invoking unigrid FFT Poisson solver..." << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; + music::ilog << " - Invoking unigrid FFT Poisson solver..." << std::endl; } int nx, ny, nz, nzp; @@ -882,7 +882,7 @@ void poisson_hybrid(T &f, int idir, int order, bool periodic, bool deconvolve_ci data = new real_t[(size_t)nxp * (size_t)nyp * (size_t)(nzp + 2)]; if (idir == 0) - std::cout << " - Performing hybrid Poisson step... (" << nxp << ", " << nyp << ", " << nzp << ")\n"; + music::ilog << " - Performing hybrid Poisson step... (" << nxp << ", " << nyp << ", " << nzp << ")" << std::endl; #pragma omp parallel for for (int i = 0; i < nxp; ++i) diff --git a/src/solver.hh b/src/solver.hh index aec5f37..51d506b 100644 --- a/src/solver.hh +++ b/src/solver.hh @@ -417,8 +417,8 @@ double solver::solve(GridHierarchy &uh, double acc, double h, bool if (verbose) { - std::cout << "--> Step No. " << std::setw(3) << niter << ", Max Err = " << err << std::endl; - std::cout << "-------------------------------------------------------------\n"; + music::ilog << "--> Step No. " << std::setw(3) << niter << ", Max Err = " << err << std::endl; + music::ilog << "-------------------------------------------------------------------------------" << std::endl; } if ((niter > 1) && ((err < acc) || (niter > 20))) @@ -429,9 +429,9 @@ double solver::solve(GridHierarchy &uh, double acc, double h, bool } if (err > acc) - std::cout << "Error : no convergence in Poisson solver" << std::endl; + music::elog << "Error : no convergence in Poisson solver" << std::endl; else if (verbose) - std::cout << " - Converged in " << niter << " steps to req. acc. of " << acc << std::endl; + music::ulog << " - Converged in " << niter << " steps to req. acc. of " << acc << std::endl; // uh = uhnew; //*m_pf = fsave;