From 85354d0637128578474f00847d5b4fc43fc67bc2 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 17 Sep 2006 21:23:00 +0000 Subject: CarpetIOASCII: Do not flush output stream after each line Introduce a string constant eol that contains the newline character. Use eol instead of the endl manipulator. This avoids flushing the output stream at the end of each line, and should speed up output. Output files are automatically flushed when they are closed, which happens at each time step. darcs-hash:20060917212302-dae7b-efc7489bd3773f51e2dcd5e3adf66674a713523d.gz --- Carpet/CarpetIOASCII/src/ioascii.cc | 47 +++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'Carpet/CarpetIOASCII/src/ioascii.cc') diff --git a/Carpet/CarpetIOASCII/src/ioascii.cc b/Carpet/CarpetIOASCII/src/ioascii.cc index 52ce33c0a..18b1a960c 100644 --- a/Carpet/CarpetIOASCII/src/ioascii.cc +++ b/Carpet/CarpetIOASCII/src/ioascii.cc @@ -38,6 +38,13 @@ namespace CarpetIOASCII { using namespace std; using namespace Carpet; + + + // Begin a new line without flushing the output buffer + char const * const eol = "\n"; + + + static void GetVarIndex (int vindex, const char* optstring, void* arg); @@ -701,7 +708,7 @@ namespace CarpetIOASCII { } else { CCTK_WARN (0, "internal error"); } - file << "# "<< outdim << "D ASCII output created by CarpetIOASCII" << endl; + file << "# "<< outdim << "D ASCII output created by CarpetIOASCII" << eol; if (want_date) { char run_host [1000]; Util_GetHostName (run_host, sizeof run_host); @@ -717,26 +724,26 @@ namespace CarpetIOASCII { file << "# created on " << run_host << " by " << run_user << " on " << run_date - << " at " << run_time << endl; + << " at " << run_time << eol; } if (want_parfilename) { char parameter_filename [10000]; CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename); - file << "# parameter filename: \"" << parameter_filename << "\"" << endl; + file << "# parameter filename: \"" << parameter_filename << "\"" << eol; } if (want_other) { if (CCTK_IsFunctionAliased ("UniqueBuildID")) { char const * const build_id = (char const *) UniqueBuildID (cctkGH); - file << "# Build ID: " << build_id << endl; + file << "# Build ID: " << build_id << eol; } if (CCTK_IsFunctionAliased ("UniqueSimulationID")) { char const * const job_id = (char const *) UniqueSimulationID (cctkGH); - file << "# Simulation ID: " << job_id << endl; + file << "# Simulation ID: " << job_id << eol; } } - file << "#" << endl; + file << "#" << eol; if (want_labels) { if (one_file_per_group) { char* groupname = CCTK_GroupNameFromVarI(vindex); @@ -748,8 +755,8 @@ namespace CarpetIOASCII { for (int d=0; d=1 and dim<=3); @@ -1226,7 +1233,7 @@ namespace CarpetIOASCII { for (int d=0; d