aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetIOScalar
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2006-09-17 21:19:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2006-09-17 21:19:00 +0000
commit2b96b73d219b854b790362ecc223a3920cd513b4 (patch)
treefe59126c8547d74447170444d8f597fbd2e52287 /Carpet/CarpetIOScalar
parentd3e7f2ba86afb69c742adfcfb8fa08d3a55e4c06 (diff)
CarpetIOScalar: 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:20060917211949-dae7b-cdc20278ee2c0fbe39e7348d65414a32003bb7c0.gz
Diffstat (limited to 'Carpet/CarpetIOScalar')
-rw-r--r--Carpet/CarpetIOScalar/src/ioscalar.cc28
1 files changed, 17 insertions, 11 deletions
diff --git a/Carpet/CarpetIOScalar/src/ioscalar.cc b/Carpet/CarpetIOScalar/src/ioscalar.cc
index ad5c9a1a4..ebe0924a3 100644
--- a/Carpet/CarpetIOScalar/src/ioscalar.cc
+++ b/Carpet/CarpetIOScalar/src/ioscalar.cc
@@ -42,7 +42,13 @@ namespace CarpetIOScalar {
};
- // Registered functions
+
+ // Begin a new line without flushing the output buffer
+ char const * const eol = "\n";
+
+
+
+ // Registered functions
static void* SetupGH (tFleshConfig* fc, int convLevel, cGH* cctkGH);
static int OutputGH (const cGH* cctkGH);
static int OutputVarAs (const cGH* cctkGH, const char* varname, const char* alias);
@@ -295,7 +301,7 @@ namespace CarpetIOScalar {
} else {
CCTK_WARN (0, "internal error");
}
- file << "# Scalar ASCII output created by CarpetIOScalar" << endl;
+ file << "# Scalar ASCII output created by CarpetIOScalar" << eol;
if (want_date) {
char run_host [1000];
Util_GetHostName (run_host, sizeof run_host);
@@ -311,30 +317,30 @@ namespace CarpetIOScalar {
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
= static_cast<char const *> (UniqueSimulationID (cctkGH));
- file << "# Simulation ID: " << job_id << endl;
+ file << "# Simulation ID: " << job_id << eol;
}
}
- file << "#" << endl;
+ file << "#" << eol;
if (want_labels) {
- file << "# " << varname << " (" << alias << ")" << endl;
- file << "# 1:iteration 2:time 3:data" << endl;
+ file << "# " << varname << " (" << alias << ")" << eol;
+ file << "# 1:iteration 2:time 3:data" << eol;
int col = 3;
if (one_file_per_group) {
file << "# data columns:";
@@ -344,7 +350,7 @@ namespace CarpetIOScalar {
file << " " << col << ":" << CCTK_VarName(n);
col += CarpetSimpleMPIDatatypeLength (vartype);
}
- file << endl;
+ file << eol;
}
}
}
@@ -412,7 +418,7 @@ namespace CarpetIOScalar {
} // for n
if (CCTK_MyProc(cctkGH)==0) {
- file << endl;
+ file << eol;
assert (file.good());
}