aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetIOScalar
diff options
context:
space:
mode:
authorschnetter <>2004-06-14 04:59:00 +0000
committerschnetter <>2004-06-14 04:59:00 +0000
commitd44bafa509a3f58cbee314cf22477969c0166647 (patch)
treef6e1ba45ab2273ac940c60c6e2ab51280100bd59 /Carpet/CarpetIOScalar
parente106ac0d11874816e3cd2934ef9af3a1ff818931 (diff)
Clean up.
darcs-hash:20040614045926-07bb3-90db59b26f31de1e3b8c2b8f678164c05db91e00.gz
Diffstat (limited to 'Carpet/CarpetIOScalar')
-rw-r--r--Carpet/CarpetIOScalar/param.ccl9
-rw-r--r--Carpet/CarpetIOScalar/src/ioscalar.cc193
2 files changed, 104 insertions, 98 deletions
diff --git a/Carpet/CarpetIOScalar/param.ccl b/Carpet/CarpetIOScalar/param.ccl
index 8f8ce119e..bc3ee7c6c 100644
--- a/Carpet/CarpetIOScalar/param.ccl
+++ b/Carpet/CarpetIOScalar/param.ccl
@@ -1,5 +1,5 @@
# Parameter definitions for thorn CarpetIOScalar
-# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOScalar/param.ccl,v 1.1 2004/06/11 17:41:51 schnetter Exp $
+# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOScalar/param.ccl,v 1.2 2004/06/14 06:59:26 schnetter Exp $
@@ -19,8 +19,9 @@ private:
CCTK_STRING outScalar_dir "Name of scalar output directory, overrides out_dir" STEERABLE = ALWAYS
{
- ".*" :: "A regex which matches everything"
-} "."
+ "^$" :: "Empty: use IO::out_dir"
+ ".+" :: "Not empty: directory name"
+} ""
CCTK_STRING outScalar_vars "Variables to output in scalar form" STEERABLE = ALWAYS
{
@@ -30,7 +31,7 @@ CCTK_STRING outScalar_vars "Variables to output in scalar form" STEERABLE = ALWA
CCTK_STRING outScalar_reductions "List of reductions to output in scalar form" STEERABLE = ALWAYS
{
".*" :: "A regex which matches everything"
-} ""
+} "count minimum maximum sum average norm1 norm2 norm_inf"
diff --git a/Carpet/CarpetIOScalar/src/ioscalar.cc b/Carpet/CarpetIOScalar/src/ioscalar.cc
index c9c05cd7c..0ae33441a 100644
--- a/Carpet/CarpetIOScalar/src/ioscalar.cc
+++ b/Carpet/CarpetIOScalar/src/ioscalar.cc
@@ -2,6 +2,7 @@
#include <cstdlib>
#include <fstream>
#include <iomanip>
+#include <list>
#include <sstream>
#include <string>
#include <vector>
@@ -17,7 +18,7 @@
extern "C" {
- static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOScalar/src/ioscalar.cc,v 1.1 2004/06/11 17:41:51 schnetter Exp $";
+ static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOScalar/src/ioscalar.cc,v 1.2 2004/06/14 06:59:26 schnetter Exp $";
CCTK_FILEVERSION(Carpet_CarpetIOScalar_ioscalar_cc);
}
@@ -93,14 +94,11 @@ namespace CarpetIOScalar {
extern "C" void
CarpetIOScalarStartup ()
{
- ostringstream msg;
CCTK_RegisterBanner ("AMR scalar I/O provided by CarpetIOScalar");
- ostringstream extension_name;
GHExtension = CCTK_RegisterGHExtension("CarpetIOScalar");
CCTK_RegisterGHExtensionSetupGH (GHExtension, SetupGH);
- ostringstream method_name;
IOMethod = CCTK_RegisterIOMethod ("CarpetIOScalar");
CCTK_RegisterIOMethodOutputGH (IOMethod, OutputGH);
CCTK_RegisterIOMethodOutputVarAs (IOMethod, OutputVarAs);
@@ -186,10 +184,9 @@ namespace CarpetIOScalar {
return 0;
}
- const int grouptype = CCTK_GroupTypeI(group);
- if (grouptype != CCTK_GF) assert (reflevel==0);
+ assert (do_global_mode);
- const int vartype = CCTK_VarTypeI(var);
+ const int vartype = CCTK_VarTypeI(n);
assert (vartype >= 0);
// Get grid hierarchy extentsion from IOUtil
@@ -205,106 +202,110 @@ namespace CarpetIOScalar {
CCTK_CreateDirectory (0755, myoutdir);
}
- // If it is time to do global mode output
- if (do_global_mode) {
-
- // Find the set of desired reductions
- list<info const> reductions;
- char const * p = outScalar_reductions;
- while (*p) {
- while (*p && isspace(*p)) ++p;
- if (!*p) break;
- char const * const start = p;
- while (*p && !isspace(*p)) ++p;
- char const * const end = p;
- string const reduction (start, end);
- int const handle = CCTK_ReductionHandle (reduction.c_str());
- if (handle < 0) {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Reduction operator \"%s\" does not exist (maybe there is no reduction thorn active?)",
- reduction.c_str());
- } else {
- info i;
- i.reduction = reduction;
- i.handle = handle;
- reductions.push_back (i);
- }
+ // Find the set of desired reductions
+ list<info> reductions;
+ char const * p = outScalar_reductions;
+ while (*p) {
+ while (*p && isspace(*p)) ++p;
+ if (!*p) break;
+ char const * const start = p;
+ while (*p && !isspace(*p)) ++p;
+ char const * const end = p;
+ string const reduction (start, end);
+ int const handle = CCTK_ReductionHandle (reduction.c_str());
+ if (handle < 0) {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Reduction operator \"%s\" does not exist (maybe there is no reduction thorn active?)",
+ reduction.c_str());
+ } else {
+ info i;
+ i.reduction = reduction;
+ i.handle = handle;
+ reductions.push_back (i);
}
+ }
+
+ // Output in global mode
+ BEGIN_GLOBAL_MODE(cctkGH) {
- // Output in global mode
- BEGIN_GLOBAL_MODE(cctkGH) {
+ for (list<info>::const_iterator ireduction = reductions.begin();
+ ireduction != reductions.end();
+ ++ireduction)
+ {
+ string const reduction = ireduction->reduction;
- for (list<info const>::const_iterator ireduction = reductions.begin();
- ireduction != reductions.end();
- ++ireduction)
- {
- string const reduction = ireduction->reduction;
-
- ofstream file;
- if (CCTK_MyProc(cctkGH)==0) {
-
- // Invent a file name
- ostringstream filenamebuf;
- filenamebuf << myoutdir << "/" << alias << "." << reduction
- << ".asc";
- // we need a persistent temporary here
- string filenamestr = filenamebuf.str();
- const char* const filename = filenamestr.c_str();
-
- // If this is the first time, then write a nice header
- if (do_truncate.at(n) && ! iogh->recovered) {
- file.open (filename, ios::out | ios::trunc);
- file << "# " << varname << " (" << alias << ")" << endl;
- file << "# iteration time data" << endl;
- } else {
- file.open (filename, ios::out | ios::app);
- }
- if (! file.good()) {
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Could not open output file \"%s\" for variable \"%s\"",
- filename, varname);
- }
-
- file << setprecision(15);
- assert (file.good());
-
- } // if on the root processor
+ ofstream file;
+ if (CCTK_MyProc(cctkGH)==0) {
- int const handle = ireduction->handle;
+ // Invent a file name
+ ostringstream filenamebuf;
+ filenamebuf << myoutdir << "/" << alias << "." << reduction
+ << ".asc";
+ // we need a persistent temporary here
+ string filenamestr = filenamebuf.str();
+ const char* const filename = filenamestr.c_str();
- if (CCTK_MyProc(cctkGH)==0) {
- file << cctk_iteration << " " << cctk_time << " ";
+ // If this is the first time, then write a nice header
+ if (do_truncate.at(n) && ! iogh->recovered) {
+ file.open (filename, ios::out | ios::trunc);
+ file << "# " << varname << " (" << alias << ")" << endl;
+ file << "# iteration time data" << endl;
+ } else {
+ file.open (filename, ios::out | ios::app);
+ }
+ if (! file.good()) {
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Could not open output file \"%s\" for variable \"%s\"",
+ filename, varname);
}
- switch (vartype) {
+ assert (file.is_open());
+
+ file << setprecision(15);
+ assert (file.good());
+
+ } // if on the root processor
+
+ int const handle = ireduction->handle;
+
+ if (CCTK_MyProc(cctkGH)==0) {
+ file << cctk_iteration << " " << cctk_time << " ";
+ }
+
+ switch (vartype) {
#define TYPECASE(N,T) \
- case N: { \
- T result; \
- int const ierr \
- = CCTK_Reduce (cctkGH, 0, handle, 1, vartype, &result, 1, var); \
- assert (! ierr); \
+ case N: { \
+ T result; \
+ int const ierr \
+ = CCTK_Reduce (cctkGH, 0, handle, 1, vartype, &result, 1, n); \
+ assert (! ierr); \
\
- if (CCTK_MyProc(cctkGH)==0) { \
- file << result; \
- } \
- break; \
- }
+ if (CCTK_MyProc(cctkGH)==0) { \
+ file << result; \
+ } \
+ break; \
+ }
#include "Carpet/Carpet/src/typecase"
#undef TYPECASE
- default:
- UnsupportedVarType (n);
- }
-
- if (CCTK_MyProc(cctkGH)==0) {
- file << endl;
- assert (file.good());
- }
-
- } // for reductions
+ default:
+ UnsupportedVarType (n);
+ }
+
+ if (CCTK_MyProc(cctkGH)==0) {
+ file << endl;
+ assert (file.good());
+ }
+
+ if (CCTK_MyProc(cctkGH)==0) {
+ file.close();
+ assert (file.good());
+ }
+
+ assert (! file.is_open());
- } END_GLOBAL_MODE;
+ } // for reductions
- } // if do_global_mode
+ } END_GLOBAL_MODE;
// Don't truncate again
do_truncate.at(n) = false;
@@ -324,6 +325,10 @@ namespace CarpetIOScalar {
+ if (! do_global_mode) return 0;
+
+
+
// check whether to output at this iteration
bool output_this_iteration;