diff options
author | 2023-06-21 10:06:31 -0700 | |
---|---|---|
committer | 2023-06-21 17:06:31 +0000 | |
commit | 089f0e08c4c5bded20ca5830f5fd44d56bcc491a (patch) | |
tree | 6b50e7f4f7318ad9ecde1ae5b3b143eb9c3772f2 /Source/Diagnostics/ReducedDiags/FieldProbe.cpp | |
parent | 7228c0349e1211d2cfd88f47b9bb6dff75ff9261 (diff) | |
download | WarpX-089f0e08c4c5bded20ca5830f5fd44d56bcc491a.tar.gz WarpX-089f0e08c4c5bded20ca5830f5fd44d56bcc491a.tar.zst WarpX-089f0e08c4c5bded20ca5830f5fd44d56bcc491a.zip |
Fixes to remove compilation warnings (#4015)
* Fixes to remove compilation warnings
* Further cleanup in FieldProbe.cpp
* Fix Bug, Use Assign
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Diagnostics/ReducedDiags/FieldProbe.cpp')
-rw-r--r-- | Source/Diagnostics/ReducedDiags/FieldProbe.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp index 6b10a731b..3f37c4902 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp @@ -630,8 +630,7 @@ void FieldProbe::ComputeDiags (int step) long total_data_size = 0; amrex::Vector<int> displs_vector; if (amrex::ParallelDescriptor::IOProcessor()) { - displs_vector.resize(mpisize, 0); - displs_vector[0] = 0; + displs_vector.assign(mpisize, 0); total_data_size += length_vector[0]; for (int i=1; i<mpisize; i++) { displs_vector[i] = (displs_vector[i-1] + length_vector[i-1]); @@ -658,11 +657,11 @@ void FieldProbe::WriteToFile (int step) const if (!(ProbeInDomain() && amrex::ParallelDescriptor::IOProcessor())) return; // loop over num valid particles to find the lowest particle ID for later sorting - long int first_id = m_data_out[0]; - for (int i = 0; i < m_valid_particles; i++) + long int first_id = static_cast<long int>(m_data_out[0]); + for (long int i = 0; i < m_valid_particles; i++) { if (m_data_out[i*noutputs] < first_id) - first_id = m_data_out[i*noutputs]; + first_id = static_cast<long int>(m_data_out[i*noutputs]); } // Create a new array to store probe data ordered by id, which will be printed to file. @@ -671,10 +670,10 @@ void FieldProbe::WriteToFile (int step) const // loop over num valid particles and write data into the appropriately // sorted location - for (int i = 0; i < m_valid_particles; i++) + for (long int i = 0; i < m_valid_particles; i++) { - const int idx = m_data_out[i*noutputs] - first_id; - for (int k = 0; k < noutputs; k++) + const long int idx = static_cast<long int>(m_data_out[i*noutputs]) - first_id; + for (long int k = 0; k < noutputs; k++) { sorted_data[idx * noutputs + k] = m_data_out[i * noutputs + k]; } @@ -685,7 +684,7 @@ void FieldProbe::WriteToFile (int step) const std::ofstream::out | std::ofstream::app}; // loop over num valid particles and write - for (int i = 0; i < m_valid_particles; i++) + for (long int i = 0; i < m_valid_particles; i++) { ofs << std::fixed << std::defaultfloat; ofs << step + 1; |