Bugfix: offset calculation has been corrected

This commit is contained in:
2026-11-24 10:29:48 +01:00
parent 5f866c04b4
commit 444ca56108
+5 -3
View File
@@ -250,8 +250,10 @@ void MpiParticleReader::readParticles(
// calculate offset from particles read by other processes in this io_group
std::uint64_t this_offset = cpu_header.file_offset;
this_offset += io_rank*particle_number*sizeof(particle::SerializedParticle);
this_offset = io_rank < overflow ? this_offset + io_rank*particle_number*sizeof(particle::SerializedParticle)
: this_offset + overflow*particle_number*sizeof(particle::SerializedParticle);
// fprintf(stdout, "<%d>: offset: %ld, numpart: %ld\n", MpiCommunication::mpiRank(), this_offset, particle_number);
this_offset = io_rank < overflow ? this_offset + io_rank*sizeof(particle::SerializedParticle)
: this_offset + overflow*sizeof(particle::SerializedParticle);
// fprintf(stdout, "<%d>: offset: %ld, sizeof(SerializedParticle): %ld\n", MpiCommunication::mpiRank(), this_offset, sizeof(particle::SerializedParticle));
// correct number of particles for this proc
particle_number = (io_rank < overflow) ? particle_number + 1 : particle_number;
@@ -259,7 +261,7 @@ void MpiParticleReader::readParticles(
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
{
std::stringstream out;
out << io_rank << ": trying to read " << particle_number;
out << io_rank << ": trying to read " << cpu_header.num_particles;
out << " many particles";
DEBUG_LEVEL_1(out.str());
}