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
-1
View File
@@ -14,7 +14,6 @@
using namespace std; using namespace std;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
Simulation Sim; Simulation Sim;
clock_t start_time = clock(); clock_t start_time = clock();
Sim.doit(); Sim.doit();
+10 -1
View File
@@ -8,6 +8,8 @@
#include "simulation.hpp" #include "simulation.hpp"
#include <iomanip>
using namespace std; using namespace std;
const long int Simulation::seed = load_parameter("seed"); const long int Simulation::seed = load_parameter("seed");
@@ -84,7 +86,7 @@ std::string Simulation::calc_outfile_path() {
} }
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
std::stringstream filename; std::stringstream filename;
filename<<dirname<<"mc_electron_out_"<<mpi_rank<<".h5"; filename<<dirname<<"mc_electron_out_"<<create_number_extension()<<".h5";
return filename.str(); 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() { void Simulation::doit() {
do_cycle(popCalcDecays, popCalcStep, false); do_cycle(popCalcDecays, popCalcStep, false);
if (mpi_rank == 0) { if (mpi_rank == 0) {
+2
View File
@@ -10,6 +10,7 @@
#define simulation_hpp #define simulation_hpp
#include <mpi.h> #include <mpi.h>
#include "particle_looper.hpp" #include "particle_looper.hpp"
class Simulation { class Simulation {
@@ -47,6 +48,7 @@ private:
int calc_dir_number(); int calc_dir_number();
std::string build_dirname(int dir_number); std::string build_dirname(int dir_number);
void create_out_dir(std::string dirname); void create_out_dir(std::string dirname);
std::string create_number_extension();
public: public:
void doit(); void doit();