From f6cd14089f886957b548e17ccd176a7edeccd6e3 Mon Sep 17 00:00:00 2001 From: eschnett <> Date: Thu, 15 Mar 2001 22:28:00 +0000 Subject: Put ASCII I/O into its own namespace. darcs-hash:20010315222833-f6438-e2daba09ae2a3804816011d1c257fe0d863d9ed2.gz --- Carpet/CarpetIOASCII/src/ioascii.cc | 62 +++++++++++--------- Carpet/CarpetIOASCII/src/ioascii.hh | 114 +++++++++++++++++------------------- 2 files changed, 88 insertions(+), 88 deletions(-) (limited to 'Carpet/CarpetIOASCII') diff --git a/Carpet/CarpetIOASCII/src/ioascii.cc b/Carpet/CarpetIOASCII/src/ioascii.cc index 5b4d10bfc..9226656f5 100644 --- a/Carpet/CarpetIOASCII/src/ioascii.cc +++ b/Carpet/CarpetIOASCII/src/ioascii.cc @@ -1,5 +1,3 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.6 2001/03/13 17:40:37 eschnett Exp $ - #include #include #include @@ -21,15 +19,25 @@ #include "ioascii.hh" +static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.7 2001/03/15 23:28:33 eschnett Exp $"; + + + +using namespace Carpet; + + + +static bool CheckForVariable (cGH* const cgh, + const char* const varlist, const int vindex); +static void SetFlag (int index, const char* optstring, void* arg); + -namespace Carpet { - int CarpetIOASCIIStartup() { - IOASCII<1>::Startup(); - IOASCII<2>::Startup(); - IOASCII<3>::Startup(); + CarpetIOASCII<1>::Startup(); + CarpetIOASCII<2>::Startup(); + CarpetIOASCII<3>::Startup(); return 0; } @@ -37,15 +45,15 @@ int CarpetIOASCIIStartup() // Definition of static members -template int IOASCII::GHExtension; -template int IOASCII::IOMethod; -template vector IOASCII::do_truncate; -template vector IOASCII::last_output; +template int CarpetIOASCII::GHExtension; +template int CarpetIOASCII::IOMethod; +template vector CarpetIOASCII::do_truncate; +template vector CarpetIOASCII::last_output; template -int IOASCII::Startup() +int CarpetIOASCII::Startup() { char msg[1000]; sprintf (msg, "AMR %dD ASCII I/O provided by CarpetIOASCII", outdim); @@ -70,7 +78,7 @@ int IOASCII::Startup() template -void* IOASCII::SetupGH (tFleshConfig* const fc, +void* CarpetIOASCII::SetupGH (tFleshConfig* const fc, const int convLevel, cGH* const cgh) { DECLARE_CCTK_PARAMETERS; @@ -89,7 +97,7 @@ void* IOASCII::SetupGH (tFleshConfig* const fc, template -int IOASCII::OutputGH (cGH* const cgh) { +int CarpetIOASCII::OutputGH (cGH* const cgh) { for (int vindex=0; vindex::OutputGH (cGH* const cgh) { return 0; } + + template -int IOASCII::OutputVarAs (cGH* const cgh, const char* const varname, +int CarpetIOASCII::OutputVarAs (cGH* const cgh, const char* const varname, const char* const alias) { DECLARE_CCTK_PARAMETERS; @@ -111,7 +121,7 @@ int IOASCII::OutputVarAs (cGH* const cgh, const char* const varname, assert (n0>=0 && n0=0 && var::OutputVarAs (cGH* const cgh, const char* const varname, template -int IOASCII::TimeToOutput (cGH* const cgh, const int vindex) { +int CarpetIOASCII::TimeToOutput (cGH* const cgh, const int vindex) { DECLARE_CCTK_PARAMETERS; assert (vindex>=0 && vindex<(int)last_output.size()); @@ -425,7 +435,7 @@ int IOASCII::TimeToOutput (cGH* const cgh, const int vindex) { template -int IOASCII::TriggerOutput (cGH* const cgh, const int vindex) { +int CarpetIOASCII::TriggerOutput (cGH* const cgh, const int vindex) { assert (vindex>=0 && vindex::TriggerOutput (cGH* const cgh, const int vindex) { template -int IOASCII::GetGridOffset (cGH* cgh, int dir, +int CarpetIOASCII::GetGridOffset (cGH* cgh, int dir, const char* itempl, const char* iglobal, const char* ctempl, const char* cglobal, CCTK_REAL cfallback) @@ -500,7 +510,7 @@ int IOASCII::GetGridOffset (cGH* cgh, int dir, template -int IOASCII::CoordToOffset (cGH* cgh, int dir, CCTK_REAL coord) +int CarpetIOASCII::CoordToOffset (cGH* cgh, int dir, CCTK_REAL coord) { CCTK_REAL lower, upper; CCTK_CoordRange (cgh, &lower, &upper, dir, 0, "cart3d"); @@ -517,7 +527,7 @@ int IOASCII::CoordToOffset (cGH* cgh, int dir, CCTK_REAL coord) template -const char* IOASCII::GetStringParameter +const char* CarpetIOASCII::GetStringParameter (const char* const parametertemplate, const char* const fallback) { char parametername[1000]; @@ -538,7 +548,7 @@ const char* IOASCII::GetStringParameter template -int IOASCII::GetIntParameter (const char* const parametertemplate, +int CarpetIOASCII::GetIntParameter (const char* const parametertemplate, int fallback) { char parametername[1000]; @@ -583,8 +593,6 @@ void SetFlag (int index, const char* optstring, void* arg) // Explicit instantiation for all output dimensions -template IOASCII<1>; -template IOASCII<2>; -template IOASCII<3>; - -} // namespace Carpet +template CarpetIOASCII<1>; +template CarpetIOASCII<2>; +template CarpetIOASCII<3>; diff --git a/Carpet/CarpetIOASCII/src/ioascii.hh b/Carpet/CarpetIOASCII/src/ioascii.hh index 8a6d379e7..f56555c5a 100644 --- a/Carpet/CarpetIOASCII/src/ioascii.hh +++ b/Carpet/CarpetIOASCII/src/ioascii.hh @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.hh,v 1.2 2001/03/05 14:30:27 eschnett Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.hh,v 1.3 2001/03/15 23:28:33 eschnett Exp $ #include @@ -6,65 +6,57 @@ -namespace Carpet { +// scheduled functions +extern "C" { + int CarpetIOASCIIStartup(); +} + + + +// Everything is a template class, so that it can easily be +// instantiated for all output dimensions. + +template +struct CarpetIOASCII { + + // handle from CCTK_RegisterGHExtension + static int GHExtension; + + // handles from CCTK_RegisterIOMethed + static int IOMethod; + + + + // Do truncate the output files for a variable + static vector do_truncate; + + // Last iteration on which a variable was output (-1 for none) + static vector last_output; + + // scheduled functions - extern "C" { - int CarpetIOASCIIStartup(); - } - - - - // Everything is a template class, so that it can easily be - // instantiated for all output dimensions. - - template - struct IOASCII { - - // handle from CCTK_RegisterGHExtension - static int GHExtension; - - // handles from CCTK_RegisterIOMethed - static int IOMethod; - - - - // Do truncate the output files for a variable - static vector do_truncate; - - // Last iteration on which a variable was output (-1 for none) - static vector last_output; - - - - // scheduled functions - static int Startup(); - - - - // registered functions - - static void* SetupGH (tFleshConfig* fc, int convLevel, cGH* cgh); - - static int OutputGH (cGH* cgh); - static int OutputVarAs (cGH* cgh, const char* varname, const char* alias); - static int TimeToOutput (cGH* cgh, int vindex); - static int TriggerOutput (cGH* cgh, int vindex); - - static int GetGridOffset (cGH* cgh, int dir, - const char* itempl, const char* iglobal, - const char* ctempl, const char* cglobal, - double cfallback); - static int CoordToOffset (cGH* cgh, int dir, double coord); - - static const char* GetStringParameter - (const char* parametertemplate, const char* fallback); - static int GetIntParameter (const char* parametertemplate, int fallback); - - }; - - bool CheckForVariable (cGH* const cgh, - const char* const varlist, const int vindex); - void SetFlag (int index, const char* optstring, void* arg); - -} // namespace Carpet + static int Startup(); + + + + // registered functions + + static void* SetupGH (tFleshConfig* fc, int convLevel, cGH* cgh); + + static int OutputGH (cGH* cgh); + static int OutputVarAs (cGH* cgh, const char* varname, const char* alias); + static int TimeToOutput (cGH* cgh, int vindex); + static int TriggerOutput (cGH* cgh, int vindex); + + static int GetGridOffset (cGH* cgh, int dir, + const char* itempl, const char* iglobal, + const char* ctempl, const char* cglobal, + CCTK_REAL cfallback); + static int CoordToOffset (cGH* cgh, int dir, CCTK_REAL coord); + + static const char* GetStringParameter + (const char* parametertemplate, const char* fallback); + static int GetIntParameter (const char* parametertemplate, int fallback); + +}; -- cgit v1.2.3