Fixed outputfile numeration:

Adding leading 0 to match length of file_endings.
MPI_RANK 9 with MPI_SIZE 100 -> '009'
This commit is contained in:
Christian
2019-07-23 15:42:22 +02:00
parent 1338b18aed
commit b3633ce956
3 changed files with 12 additions and 2 deletions
+10 -1
View File
@@ -8,6 +8,8 @@
#include "simulation.hpp"
#include <iomanip>
using namespace std;
const long int Simulation::seed = load_parameter("seed");
@@ -84,7 +86,7 @@ std::string Simulation::calc_outfile_path() {
}
MPI_Barrier(MPI_COMM_WORLD);
std::stringstream filename;
filename<<dirname<<"mc_electron_out_"<<mpi_rank<<".h5";
filename<<dirname<<"mc_electron_out_"<<create_number_extension()<<".h5";
return filename.str();
}
@@ -115,6 +117,13 @@ void Simulation::create_out_dir(std::string dirname) {
}
}
std::string Simulation::create_number_extension() {
int digits = to_string(mpi_size).length();
std::stringstream ss;
ss << std::setw(digits) << std::setfill('0') << mpi_rank;
return ss.str();
}
void Simulation::doit() {
do_cycle(popCalcDecays, popCalcStep, false);
if (mpi_rank == 0) {