aboutsummaryrefslogtreecommitdiff
path: root/CarpetDev/CarpetIOF5/src/IOF5.cc
diff options
context:
space:
mode:
Diffstat (limited to 'CarpetDev/CarpetIOF5/src/IOF5.cc')
-rw-r--r--CarpetDev/CarpetIOF5/src/IOF5.cc42
1 files changed, 10 insertions, 32 deletions
diff --git a/CarpetDev/CarpetIOF5/src/IOF5.cc b/CarpetDev/CarpetIOF5/src/IOF5.cc
index 83389906a..c21332adb 100644
--- a/CarpetDev/CarpetIOF5/src/IOF5.cc
+++ b/CarpetDev/CarpetIOF5/src/IOF5.cc
@@ -2,6 +2,7 @@
#include <cassert>
#include <cmath>
#include <cstdlib>
+#include <cstring>
#include <iomanip>
#include <sstream>
#include <string>
@@ -57,9 +58,6 @@ namespace CarpetIOF5 {
char const * options,
void * ptr);
- static int
- base_10_digits (int number);
-
static int
@@ -181,21 +179,6 @@ namespace CarpetIOF5 {
int
- base_10_digits (int number)
- {
- number = abs (number);
- int digits = 1;
- while (number >= 10)
- {
- number /= 10;
- ++ digits;
- }
- return digits;
- }
-
-
-
- int
TimeToOutput (cGH const * const cctkGH,
int const variable)
{
@@ -386,23 +369,18 @@ namespace CarpetIOF5 {
extending_t extending (cctkGH);
- ostringstream filenamebuf;
- bool const use_IO_out_dir = strcmp (out_dir, "") == 0;
- int const digits = base_10_digits (CCTK_nProcs (cctkGH) - 1);
- filenamebuf << (use_IO_out_dir ? IO_out_dir : out_dir)
- << "/"
- << alias
- << "."
- << setw (digits) << setfill ('0') << CCTK_MyProc (cctkGH)
- << out_extension;
- string const filename = filenamebuf.str();
-
- bool const did_truncate = extending.get_did_truncate (filename);
+ bool const use_IO_out_dir = std::strcmp (out_dir, "") == 0;
+ string const basename
+ = (use_IO_out_dir ? IO_out_dir : out_dir) + string ("/") + alias;
+ bool const want_metafile = CCTK_MyProc (cctkGH) == 0;
+
+ bool const did_truncate = extending.get_did_truncate (basename);
bool const do_truncate
= not did_truncate and IO_TruncateOutputFiles (cctkGH);
- extending.set_did_truncate (filename);
+ extending.set_did_truncate (basename);
- F5::file_t file (cctkGH, filename, do_truncate);
+ F5::file_t file (cctkGH, basename, string (out_extension),
+ want_metafile, do_truncate);
writer_t writer (cctkGH, variable);
writer.write (file);