[cig-commits] [commit] master: only open log.txt on processor 0 (cc8c302)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Sep 10 08:12:40 PDT 2014
Repository : https://github.com/geodynamics/aspect
On branch : master
Link : https://github.com/geodynamics/aspect/compare/191964f86b581bdaff380c71954ccc486e534a7f...d6cb37df5cdcac509136f55e118aabc0cb3569b9
>---------------------------------------------------------------
commit cc8c3029cbfaa210910153c1ca5bdbc1ed505c15
Author: Timo Heister <timo.heister at gmail.com>
Date: Wed Sep 10 10:28:46 2014 -0400
only open log.txt on processor 0
Only processor 0 will be writing into the file output/log.txt anyway, so
we only need to open it there. This might also fix some filesystem race
conditions.
>---------------------------------------------------------------
cc8c3029cbfaa210910153c1ca5bdbc1ed505c15
source/simulator/core.cc | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/source/simulator/core.cc b/source/simulator/core.cc
index 327986b..c9e68a3 100644
--- a/source/simulator/core.cc
+++ b/source/simulator/core.cc
@@ -173,15 +173,17 @@ namespace aspect
rebuild_stokes_matrix (true),
rebuild_stokes_preconditioner (true)
{
- if (parameters.resume_computation)
- log_file_stream.open((parameters.output_directory + "log.txt").c_str(), std::ios_base::app);
- else
- log_file_stream.open((parameters.output_directory + "log.txt").c_str());
-
- // we already printed the header to the screen, so here we just dump it
- // into the logfile.
if (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
- print_aspect_header(log_file_stream);
+ {
+ // only open the logfile on processor 0, the other processors won't be
+ // writing into the stream anyway
+ log_file_stream.open((parameters.output_directory + "log.txt").c_str(),
+ parameters.resume_computation ? std::ios_base::app : std::ios_base::out);
+
+ // we already printed the header to the screen, so here we just dump it
+ // into the logfile.
+ print_aspect_header(log_file_stream);
+ }
computing_timer.enter_section("Initialization");
More information about the CIG-COMMITS
mailing list