Skip to content

Commit 25cb9fe

Browse files
Update begrun.cpp
1 parent 9d4611c commit 25cb9fe

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

src/begrun.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ int main(int argc, char **argv) {
4545
MPI_Init(&argc, &argv);
4646
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
4747
MPI_Comm_size(MPI_COMM_WORLD, &size);
48-
log_once(rank, "MPI mode enabled (" + std::to_string(size) + " ranks)");
4948
#endif
5049

5150
H5Eset_auto(H5E_DEFAULT, nullptr, nullptr);
@@ -63,17 +62,25 @@ int main(int argc, char **argv) {
6362

6463
omp_set_num_threads(args.threads);
6564

66-
log_once(rank, BANNER);
67-
log_once(rank, " Threads: " + std::to_string(args.threads));
65+
// Only rank 0 prints startup info
66+
if (rank == 0 && omp_get_thread_num() == 0) {
67+
#ifdef NEXT_MPI
68+
std::cout << "MPI mode enabled (" << size << " ranks)" << std::endl;
69+
#endif
70+
std::cout << BANNER << std::endl;
71+
std::cout << " Threads: " << args.threads << std::endl;
6872
#ifdef NEXT_FP64
69-
log_once(rank, " Precision: FP64");
73+
std::cout << " Precision: FP64" << std::endl;
7074
#elif defined(NEXT_FP32)
71-
log_once(rank, " Precision: FP32");
75+
std::cout << " Precision: FP32" << std::endl;
7276
#endif
77+
}
7378

7479
// Load particles
7580
Particle particles = LoadParticlesFromFile(args.input_file);
76-
log_once(rank, " Particles: " + std::to_string(particles.size()));
81+
if (rank == 0 && omp_get_thread_num() == 0) {
82+
std::cout << " Particles: " << particles.size() << std::endl;
83+
}
7784

7885
real simTime = 0;
7986
real nextDump = 0;
@@ -94,9 +101,10 @@ int main(int argc, char **argv) {
94101
case OutputFormat::HDF5: out += ".hdf5"; SaveHDF5(particles, out); break;
95102
}
96103

97-
log_once(rank, "[Dump " + std::to_string(step) +
98-
"] t = " + std::to_string(simTime) +
99-
", file: " + out);
104+
if (rank == 0 && omp_get_thread_num() == 0) {
105+
std::cout << "[Dump " << step << "] t = " << simTime
106+
<< ", file: " << out << std::endl;
107+
}
100108

101109
nextDump += args.dump_interval;
102110
step++;
@@ -106,7 +114,9 @@ int main(int argc, char **argv) {
106114
if (std::cin.rdbuf()->in_avail() > 0) {
107115
std::cin >> command;
108116
if (command == 'q' || command == 'Q') {
109-
log_once(rank, "Exiting...");
117+
if (rank == 0 && omp_get_thread_num() == 0) {
118+
std::cout << "Exiting..." << std::endl;
119+
}
110120
break;
111121
}
112122
}

0 commit comments

Comments
 (0)