aboutsummaryrefslogtreecommitdiff
path: root/CarpetDev/CarpetIOF5/src/file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'CarpetDev/CarpetIOF5/src/file.cc')
-rw-r--r--CarpetDev/CarpetIOF5/src/file.cc89
1 files changed, 75 insertions, 14 deletions
diff --git a/CarpetDev/CarpetIOF5/src/file.cc b/CarpetDev/CarpetIOF5/src/file.cc
index 55c00a124..f200277b5 100644
--- a/CarpetDev/CarpetIOF5/src/file.cc
+++ b/CarpetDev/CarpetIOF5/src/file.cc
@@ -8,6 +8,7 @@
#include <hdf5.h>
#include "cctk.h"
+#include "cctk_Parameters.h"
#include "file.hh"
@@ -23,16 +24,17 @@ namespace CarpetIOF5 {
file_t (cGH const * const cctkGH,
string const basename,
string const extension,
- bool const want_metafile,
bool const do_truncate)
: m_cctkGH (cctkGH),
- m_have_metafile (want_metafile),
m_basename (basename),
m_extension (extension)
{
assert (cctkGH);
int const proc = CCTK_MyProc (cctkGH);
+ m_have_metafile = determine_want_metafile (proc);
+ m_output_processor = determine_output_processor (proc);
+
m_metafilename = make_metafilename ();
m_filename = make_filename (proc);
@@ -92,17 +94,51 @@ namespace CarpetIOF5 {
+ bool file_t::
+ determine_want_metafile (int const proc)
+ const
+ {
+ DECLARE_CCTK_PARAMETERS;
+
+ if (CCTK_EQUALS (out_mode, "proc") or
+ CCTK_EQUALS (out_mode, "np"))
+ {
+ return proc == 0;
+ }
+ else if (CCTK_EQUALS (out_mode, "onefile"))
+ {
+ return false;
+ }
+ else
+ {
+ assert (0);
+ }
+ }
+
+
+
int file_t::
- base_10_digits (int number)
+ determine_output_processor (int const proc)
+ const
{
- number = abs (number);
- int digits = 1;
- while (number >= 10)
+ DECLARE_CCTK_PARAMETERS;
+
+ if (CCTK_EQUALS (out_mode, "proc"))
+ {
+ return proc;
+ }
+ else if (CCTK_EQUALS (out_mode, "np"))
+ {
+ return proc / out_proc_every * out_proc_every;
+ }
+ else if (CCTK_EQUALS (out_mode, "onefile"))
{
- number /= 10;
- ++ digits;
+ return 0;
+ }
+ else
+ {
+ assert (0);
}
- return digits;
}
@@ -120,12 +156,28 @@ namespace CarpetIOF5 {
make_filename (int const proc)
const
{
- int const digits = base_10_digits (CCTK_nProcs (m_cctkGH) - 1);
+ DECLARE_CCTK_PARAMETERS;
+
ostringstream filenamebuf;
- filenamebuf << m_basename
- << "."
- << setw (digits) << setfill ('0') << proc
- << m_extension;
+
+ filenamebuf << m_basename;
+
+ if (CCTK_EQUALS (out_mode, "proc") or
+ CCTK_EQUALS (out_mode, "np"))
+ {
+ filenamebuf << ".p" << setw (processor_digits) << setfill ('0') << proc;
+ }
+ else if (CCTK_EQUALS (out_mode, "onefile"))
+ {
+ // do nothing
+ }
+ else
+ {
+ assert (0);
+ }
+
+ filenamebuf << m_extension;
+
return filenamebuf.str();
}
@@ -149,6 +201,15 @@ namespace CarpetIOF5 {
+ int file_t::
+ get_output_processor ()
+ const
+ {
+ return m_output_processor;
+ }
+
+
+
string file_t::
get_filename (int const proc)
const