diff --git a/src/IO/hdf5_reader.cpp b/src/IO/hdf5_reader.cpp index 08aca1c..528b77b 100755 --- a/src/IO/hdf5_reader.cpp +++ b/src/IO/hdf5_reader.cpp @@ -20,7 +20,7 @@ blitz::Array Hdf5Reader::readD3Double(std::string path) { dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(dataset); 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 H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); @@ -50,7 +50,7 @@ blitz::Array Hdf5Reader::readD2Double(std::string path) { dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(dataset); 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 H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); @@ -79,7 +79,7 @@ blitz::Array Hdf5Reader::readD1Double(std::string path) { hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(dataset); 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 // 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 dataspace = H5Dget_space(dataset); 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 // 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 dataspace = H5Dget_space(dataset); 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 // H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); @@ -170,7 +170,7 @@ blitz::Array Hdf5Reader::readD4Double(std::string path) { dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(dataset); 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 H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); @@ -200,7 +200,7 @@ blitz::Array Hdf5Reader::readD5Double(std::string path) { dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(dataset); 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 H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); @@ -230,7 +230,7 @@ blitz::Array Hdf5Reader::readD4LongInt(std::string path) { dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(dataset); 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 H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); @@ -260,7 +260,7 @@ blitz::Array Hdf5Reader::readD5LongInt(std::string path) { dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(dataset); 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 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 dataspace = H5Dget_space(dataset); 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 // H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT); diff --git a/src/IO/mpi_particle_reader.cpp b/src/IO/mpi_particle_reader.cpp index 8b7f836..55733d5 100644 --- a/src/IO/mpi_particle_reader.cpp +++ b/src/IO/mpi_particle_reader.cpp @@ -162,8 +162,10 @@ void MpiParticleReader::readParticles( io_group_size += 1; } +#ifdef debug_level3 fprintf(stdout, "<%d>: io_group: %d, io_rank: %d, io_group_size: %d\n", MpiCommunication::mpiRank(), io_group, io_rank, io_group_size); +#endif #ifdef debug @@ -239,14 +241,6 @@ void MpiParticleReader::readParticles( } 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 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); // correct number of particles for this proc - particle_number = (io_rank < overflow) ? - particle_number + 1 : particle_number; + particle_number = (io_rank < overflow) ? 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 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; out << "group: " << io_group << ", rank: "<< io_rank; out << ": number of particles in queue: " << storage_queue.size(); diff --git a/src/IO/restart.cpp b/src/IO/restart.cpp index e401dfc..ec25cc5 100644 --- a/src/IO/restart.cpp +++ b/src/IO/restart.cpp @@ -51,23 +51,30 @@ void Restart::restart( SIM_INFO("Restarting from earlier state."); 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"); -#endif + #endif 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."); -#endif + #endif particle_reader_.readParticles(storage_queue, process_number_old_); } else { -#ifdef debug_level1 + #ifdef debug_level1 DEBUG_LEVEL_1("Restarting rng"); -#endif + #endif 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."); -#endif + #endif particle_reader_.readParticles(storage_queue); } @@ -136,12 +143,12 @@ void Restart::restartRandomNumbers(RandomNumbers* random, int nold) { // draw the next value of the current 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 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 >> *engine; } diff --git a/src/IO/simulation_output.cpp b/src/IO/simulation_output.cpp index 6d1bd1f..fca94e4 100755 --- a/src/IO/simulation_output.cpp +++ b/src/IO/simulation_output.cpp @@ -82,12 +82,11 @@ void SimulationOutput::writeMetaData( // find occurance of last slash in the path of the parameter 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) ? "/" + parameter_file_path : parameter_file_path.substr(slshidx); - SIM_INFO("blubb: " + hdf5path); - writer.write(file.str(), hdf5path); } }