Formatting

This commit is contained in:
2026-11-24 10:01:23 +01:00
parent 776de1f593
commit 5f866c04b4
4 changed files with 41 additions and 34 deletions
+10 -10
View File
@@ -20,7 +20,7 @@ blitz::Array<double, 3> Hdf5Reader::readD3Double(std::string path) {
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
@@ -50,7 +50,7 @@ blitz::Array<double, 2> Hdf5Reader::readD2Double(std::string path) {
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
@@ -79,7 +79,7 @@ blitz::Array<double, 1> Hdf5Reader::readD1Double(std::string path) {
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); // H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
@@ -109,7 +109,7 @@ double Hdf5Reader::readDouble(std::string path) {
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); // H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
@@ -139,7 +139,7 @@ int Hdf5Reader::readInt(std::string path) {
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); // H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
@@ -170,7 +170,7 @@ blitz::Array<double, 4> Hdf5Reader::readD4Double(std::string path) {
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
@@ -200,7 +200,7 @@ blitz::Array<double, 5> Hdf5Reader::readD5Double(std::string path) {
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
@@ -230,7 +230,7 @@ blitz::Array<long int, 4> Hdf5Reader::readD4LongInt(std::string path) {
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
@@ -260,7 +260,7 @@ blitz::Array<long int, 5> Hdf5Reader::readD5LongInt(std::string path) {
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
@@ -293,7 +293,7 @@ std::stringstream Hdf5Reader::readEngineString(std::string path) {
hid_t dataset = H5Dopen2(file, (path + "/string").c_str(), H5P_DEFAULT); hid_t dataset = H5Dopen2(file, (path + "/string").c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset); hid_t dataspace = H5Dget_space(dataset);
if (dataset < 0) { if (dataset < 0) {
ERROR("The given dataset could not be opened"); ERROR("The given dataset could not be opened " + path);
} }
// turn error report back onby hdf5 because of check H5Dopen2 // turn error report back onby hdf5 because of check H5Dopen2
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); // H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
+13 -12
View File
@@ -162,8 +162,10 @@ void MpiParticleReader::readParticles(
io_group_size += 1; io_group_size += 1;
} }
#ifdef debug_level3
fprintf(stdout, "<%d>: io_group: %d, io_rank: %d, io_group_size: %d\n", fprintf(stdout, "<%d>: io_group: %d, io_rank: %d, io_group_size: %d\n",
MpiCommunication::mpiRank(), io_group, io_rank, io_group_size); MpiCommunication::mpiRank(), io_group, io_rank, io_group_size);
#endif
#ifdef debug #ifdef debug
@@ -239,14 +241,6 @@ void MpiParticleReader::readParticles(
} }
storage_queue.reserve(cpu_header.num_particles); storage_queue.reserve(cpu_header.num_particles);
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
{
std::stringstream out;
out << io_rank << ": trying to read " << cpu_header.num_particles;
out << " many particles";
DEBUG_LEVEL_1(out.str());
}
#endif
// particle number if they were equally distributed across procs // particle number if they were equally distributed across procs
size_t particle_number = cpu_header.num_particles / io_group_size; size_t particle_number = cpu_header.num_particles / io_group_size;
@@ -260,10 +254,16 @@ void MpiParticleReader::readParticles(
: this_offset + overflow*particle_number*sizeof(particle::SerializedParticle); : this_offset + overflow*particle_number*sizeof(particle::SerializedParticle);
// correct number of particles for this proc // correct number of particles for this proc
particle_number = (io_rank < overflow) ? particle_number = (io_rank < overflow) ? particle_number + 1 : particle_number;
particle_number + 1 : particle_number;
fprintf(stdout, "<%d>: pn: %ld, thisoffset: %ld\n",MpiCommunication::mpiRank(), particle_number, this_offset - cpu_header.file_offset); #if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
{
std::stringstream out;
out << io_rank << ": trying to read " << particle_number;
out << " many particles";
DEBUG_LEVEL_1(out.str());
}
#endif
// set file view to the part where the particles are stored // set file view to the part where the particles are stored
status = MPI_File_set_view(file, this_offset, MPI_DOUBLE, status = MPI_File_set_view(file, this_offset, MPI_DOUBLE,
@@ -282,8 +282,9 @@ void MpiParticleReader::readParticles(
")!"); ")!");
} }
#ifdef debug #ifdef debug_level3
{ {
// print first and last loaded particle to check if the alignment is sensible (i.e. no two processes load the same particle)
std::stringstream out; std::stringstream out;
out << "group: " << io_group << ", rank: "<< io_rank; out << "group: " << io_group << ", rank: "<< io_rank;
out << ": number of particles in queue: " << storage_queue.size(); out << ": number of particles in queue: " << storage_queue.size();
+17 -10
View File
@@ -51,23 +51,30 @@ void Restart::restart(
SIM_INFO("Restarting from earlier state."); SIM_INFO("Restarting from earlier state.");
if(process_number_old_ < MpiCommunication::mpiSize()) { if(process_number_old_ < MpiCommunication::mpiSize()) {
#ifdef debug_level1 SIM_INFO("Warning: Restarting from a state with fewer processes. (#old: " +
std::to_string(process_number_old_) +
", #now: " +
std::to_string(MpiCommunication::mpiSize()) + ")");
#ifdef debug_level1
DEBUG_LEVEL_1("Restarting rng"); DEBUG_LEVEL_1("Restarting rng");
#endif #endif
restartRandomNumbers(random_numbers, process_number_old_); restartRandomNumbers(random_numbers, process_number_old_);
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
DEBUG_LEVEL_1("Reloading particles."); DEBUG_LEVEL_1("Reloading particles.");
#endif #endif
particle_reader_.readParticles(storage_queue, process_number_old_); particle_reader_.readParticles(storage_queue, process_number_old_);
} else { } else {
#ifdef debug_level1 #ifdef debug_level1
DEBUG_LEVEL_1("Restarting rng"); DEBUG_LEVEL_1("Restarting rng");
#endif #endif
restartRandomNumbers(random_numbers); restartRandomNumbers(random_numbers);
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
DEBUG_LEVEL_1("Reloading particles."); DEBUG_LEVEL_1("Reloading particles.");
#endif #endif
particle_reader_.readParticles(storage_queue); particle_reader_.readParticles(storage_queue);
} }
@@ -136,12 +143,12 @@ void Restart::restartRandomNumbers(RandomNumbers* random, int nold) {
// draw the next value of the current engine // draw the next value of the current engine
size_t seed = (*engine)(); size_t seed = (*engine)();
fprintf(stdout, "<%d>: io_group: %d, seed: %ld\n", MpiCommunication::mpiRank(), io_group, seed); // fprintf(stdout, "<%d>: io_group: %d, seed: %ld\n", MpiCommunication::mpiRank(), io_group, seed);
// use this value as a seed and create a temporary mt19937 object // use this value as a seed and create a temporary mt19937 object
std::mt19937 tmp(seed); std::mt19937 tmp(seed);
// serialize and de-serialize it to set the pointer of the actual engine // serialize and de-serialize it to set the pointer of the actual engine (likely not the best implementation)
engine_state << tmp; engine_state << tmp;
engine_state >> *engine; engine_state >> *engine;
} }
+1 -2
View File
@@ -82,12 +82,11 @@ void SimulationOutput::writeMetaData(
// find occurance of last slash in the path of the parameter // find occurance of last slash in the path of the parameter
size_t slshidx = parameter_file_path.rfind("/"); size_t slshidx = parameter_file_path.rfind("/");
// if its a relative path append a slash otherwise use the substring from the last slash onwards
std::string hdf5path = (slshidx == std::string::npos) ? std::string hdf5path = (slshidx == std::string::npos) ?
"/" + parameter_file_path : "/" + parameter_file_path :
parameter_file_path.substr(slshidx); parameter_file_path.substr(slshidx);
SIM_INFO("blubb: " + hdf5path);
writer.write(file.str(), hdf5path); writer.write(file.str(), hdf5path);
} }
} }