From d1fc6a2e673727e88728869dd10931adc065b4ba Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Tue, 3 Jan 2023 16:20:47 +0100 Subject: [PATCH] fix compiler error and warnings in clang --- include/HDF_IO.hh | 2 +- include/cosmology_calculator.hh | 4 ++-- include/grid_interpolate.hh | 5 +++-- include/math/vec3.hh | 15 +++++++++------ include/particle_plt.hh | 4 ++-- src/ic_generator.cc | 12 ++++++------ src/output_plugin.cc | 2 +- src/plugins/random_music.cc | 4 ++-- src/plugins/transfer_CLASS.cc | 2 +- src/random_plugin.cc | 2 +- src/transfer_function_plugin.cc | 2 +- 11 files changed, 29 insertions(+), 25 deletions(-) diff --git a/include/HDF_IO.hh b/include/HDF_IO.hh index b7a61ee..99f744f 100755 --- a/include/HDF_IO.hh +++ b/include/HDF_IO.hh @@ -226,7 +226,7 @@ template inline void HDFReadSelect( const std::string Filename, const std::string ObjName, const std::vector& ii, std::vector &Data ){ hid_t HDF_Type, HDF_FileID, HDF_DatasetID, HDF_DataspaceID, HDF_MemspaceID; - hsize_t HDF_StorageSize; +// hsize_t HDF_StorageSize; HDF_Type = GetDataType(); diff --git a/include/cosmology_calculator.hh b/include/cosmology_calculator.hh index dcd3e61..9ad5dcf 100644 --- a/include/cosmology_calculator.hh +++ b/include/cosmology_calculator.hh @@ -179,7 +179,7 @@ public: music::ilog << "Linear growth factors: D+_target = " << Dplus_target_ << ", D+_start = " << Dplus_start_ << std::endl; // set up transfer functions and compute normalisation - transfer_function_ = std::move(select_TransferFunction_plugin(cf, cosmo_param_)); + transfer_function_ = select_TransferFunction_plugin(cf, cosmo_param_); transfer_function_->intialise(); if( !transfer_function_->tf_isnormalised_ ){ cosmo_param_.set("pnorm", this->compute_pnorm_from_sigma8() ); @@ -449,4 +449,4 @@ public: // return pow(6.0 * mass / M_PI * std::sqrt(rho) * std::pow(G, 1.5), 1.0 / 3.0); // } -} // namespace cosmology \ No newline at end of file +} // namespace cosmology diff --git a/include/grid_interpolate.hh b/include/grid_interpolate.hh index 5ede310..29560f1 100644 --- a/include/grid_interpolate.hh +++ b/include/grid_interpolate.hh @@ -175,13 +175,14 @@ struct grid_interpolate MPI_Alltoall(&sendcounts[0], 1, MPI_INT, &recvcounts[0], 1, MPI_INT, MPI_COMM_WORLD); - size_t tot_receive = recvcounts[0], tot_send = sendcounts[0]; + size_t tot_receive = recvcounts[0]; +// size_t tot_send = sendcounts[0]; for (int i = 1; i < MPI::get_size(); ++i) { sendoffsets[i] = sendcounts[i - 1] + sendoffsets[i - 1]; recvoffsets[i] = recvcounts[i - 1] + recvoffsets[i - 1]; tot_receive += recvcounts[i]; - tot_send += sendcounts[i]; +// tot_send += sendcounts[i]; } std::vector recvbuf(tot_receive/3,{0.,0.,0.}); diff --git a/include/math/vec3.hh b/include/math/vec3.hh index 593c725..c5ffe9f 100644 --- a/include/math/vec3.hh +++ b/include/math/vec3.hh @@ -45,12 +45,15 @@ public: : data_(std::move(v.data_)), x(data_[0]), y(data_[1]), z(data_[2]){} //! construct vec3_t from initializer list - template - vec3_t(E&&...e) - : data_{{std::forward(e)...}}, x{data_[0]}, y{data_[1]}, z{data_[2]} - {} - // vec3_t( T a, T b, T c ) - // : data_{{a,b,c}}, x(data_[0]), y(data_[1]), z(data_[2]){} +// template +// vec3_t(E&&...e) +// : data_{{std::forward(e)...}}, x{data_[0]}, y{data_[1]}, z{data_[2]} +// {} + vec3_t( T a, T b, T c ) + : data_{{a,b,c}}, x(data_[0]), y(data_[1]), z(data_[2]){} + + explicit vec3_t( T a) + : data_{{a,a,a}}, x(data_[0]), y(data_[1]), z(data_[2]){} //! bracket index access to vector components T &operator[](size_t i) noexcept{ return data_[i];} diff --git a/include/particle_plt.hh b/include/particle_plt.hh index dd75600..ecb81ed 100644 --- a/include/particle_plt.hh +++ b/include/particle_plt.hh @@ -421,7 +421,7 @@ private: if( !is_in(i,j,k,mat_invrecip) ){ auto average_lv = [&]( const auto& t1, const auto& t2, const auto& t3, vec3_t& v, vec3_t& l ) { - v = real_t(0.0); l = real_t(0.0); + v = vec3_t(0.0); l = vec3_t(0.0); int count(0); auto add_lv = [&]( auto it ) -> void { @@ -586,4 +586,4 @@ public: }; -} \ No newline at end of file +} diff --git a/src/ic_generator.cc b/src/ic_generator.cc index 9e5e907..72bdecf 100644 --- a/src/ic_generator.cc +++ b/src/ic_generator.cc @@ -62,9 +62,9 @@ std::unique_ptr the_cosmo_calc; */ int initialise( config_file& the_config ) { - the_random_number_generator = std::move(select_RNG_plugin(the_config)); + the_random_number_generator = select_RNG_plugin(the_config); the_cosmo_calc = std::make_unique(the_config); - the_output_plugin = std::move(select_output_plugin(the_config, the_cosmo_calc)); + the_output_plugin = select_output_plugin(the_config, the_cosmo_calc); return 0; } @@ -150,12 +150,12 @@ int run( config_file& the_config ) //-------------------------------------------------------------------------------------------------------- //! add beyond box tidal field modes following Schmidt et al. (2018) [https://arxiv.org/abs/1803.03274] bool bAddExternalTides = the_config.contains_key("cosmology", "LSS_aniso_lx") - & the_config.contains_key("cosmology", "LSS_aniso_ly") - & the_config.contains_key("cosmology", "LSS_aniso_lz"); + && the_config.contains_key("cosmology", "LSS_aniso_ly") + && the_config.contains_key("cosmology", "LSS_aniso_lz"); if( bAddExternalTides && !( the_config.contains_key("cosmology", "LSS_aniso_lx") - | the_config.contains_key("cosmology", "LSS_aniso_ly") - | the_config.contains_key("cosmology", "LSS_aniso_lz") )) + || the_config.contains_key("cosmology", "LSS_aniso_ly") + || the_config.contains_key("cosmology", "LSS_aniso_lz") )) { music::elog << "Not all dimensions of LSS_aniso_l{x,y,z} specified! Will ignore external tidal field!" << std::endl; bAddExternalTides = false; diff --git a/src/output_plugin.cc b/src/output_plugin.cc index cfad290..e27d7fc 100644 --- a/src/output_plugin.cc +++ b/src/output_plugin.cc @@ -74,7 +74,7 @@ std::unique_ptr select_output_plugin( config_file& cf, std::uniqu music::ilog << std::setw(32) << std::left << "Output plugin" << " : " << formatname << std::endl; } - return std::move(the_output_plugin_creator->create( cf, pcc )); + return the_output_plugin_creator->create( cf, pcc ); } diff --git a/src/plugins/random_music.cc b/src/plugins/random_music.cc index 5b59fae..675c318 100644 --- a/src/plugins/random_music.cc +++ b/src/plugins/random_music.cc @@ -180,7 +180,7 @@ void RNG_music::parse_random_parameters(void) //... generate some dummy seed which only depends on the level, negative so we know it's not //... an actual seed and thus should not be used as a constraint for coarse levels // rngseeds_.push_back( -abs((unsigned)(ltemp-i)%123+(unsigned)(ltemp+827342523521*i)%123456789) ); - rngseeds_.push_back(-abs((long)(ltemp - i) % 123 + (long)(ltemp + 7342523521 * i) % 123456789)); + rngseeds_.push_back(-std::abs((long)(ltemp - i) % 123 + (long)(ltemp + 7342523521 * i) % 123456789)); else { if (ltemp <= 0) @@ -357,4 +357,4 @@ void RNG_music::compute_random_numbers(void) namespace { RNG_plugin_creator_concrete creator("MUSIC1"); -} \ No newline at end of file +} diff --git a/src/plugins/transfer_CLASS.cc b/src/plugins/transfer_CLASS.cc index f80bba0..f748e22 100644 --- a/src/plugins/transfer_CLASS.cc +++ b/src/plugins/transfer_CLASS.cc @@ -163,7 +163,7 @@ private: music::ilog << "Computing transfer function via ClassEngine..." << std::endl; double wtime = get_wtime(); - the_ClassEngine_ = std::move(std::make_unique(pars_, false)); + the_ClassEngine_ = std::make_unique(pars_, false); wtime = get_wtime() - wtime; music::ilog << "CLASS took " << wtime << " s." << std::endl; diff --git a/src/random_plugin.cc b/src/random_plugin.cc index 958b08b..489e0af 100644 --- a/src/random_plugin.cc +++ b/src/random_plugin.cc @@ -77,5 +77,5 @@ std::unique_ptr select_RNG_plugin(config_file &cf) music::ilog << std::setw(32) << std::left << "Random number generator plugin" << " : " << rngname << std::endl; } - return std::move(the_RNG_plugin_creator->Create(cf)); + return the_RNG_plugin_creator->Create(cf); } diff --git a/src/transfer_function_plugin.cc b/src/transfer_function_plugin.cc index 2dd4cef..b9f465a 100644 --- a/src/transfer_function_plugin.cc +++ b/src/transfer_function_plugin.cc @@ -75,5 +75,5 @@ std::unique_ptr select_TransferFunction_plugin(config_f music::ilog << std::setw(32) << std::left << "Transfer function plugin" << " : " << tfname << std::endl; } - return std::move(the_TransferFunction_plugin_creator->create(cf, cosmo_param)); + return the_TransferFunction_plugin_creator->create(cf, cosmo_param); }