diff options
author | eschnett <> | 2001-03-15 22:28:00 +0000 |
---|---|---|
committer | eschnett <> | 2001-03-15 22:28:00 +0000 |
commit | f6cd14089f886957b548e17ccd176a7edeccd6e3 (patch) | |
tree | d9e4351ab01f3643365ef2d0519057ffbb0c5d77 | |
parent | 404bb1e388fae0590f93df3879709272381c37e4 (diff) |
Put ASCII I/O into its own namespace.
darcs-hash:20010315222833-f6438-e2daba09ae2a3804816011d1c257fe0d863d9ed2.gz
-rw-r--r-- | Carpet/CarpetIOASCII/src/ioascii.cc | 62 | ||||
-rw-r--r-- | Carpet/CarpetIOASCII/src/ioascii.hh | 114 |
2 files changed, 88 insertions, 88 deletions
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 <cassert> #include <cstdio> #include <cstdlib> @@ -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 outdim> int IOASCII<outdim>::GHExtension; -template<int outdim> int IOASCII<outdim>::IOMethod; -template<int outdim> vector<bool> IOASCII<outdim>::do_truncate; -template<int outdim> vector<int> IOASCII<outdim>::last_output; +template<int outdim> int CarpetIOASCII<outdim>::GHExtension; +template<int outdim> int CarpetIOASCII<outdim>::IOMethod; +template<int outdim> vector<bool> CarpetIOASCII<outdim>::do_truncate; +template<int outdim> vector<int> CarpetIOASCII<outdim>::last_output; template<int outdim> -int IOASCII<outdim>::Startup() +int CarpetIOASCII<outdim>::Startup() { char msg[1000]; sprintf (msg, "AMR %dD ASCII I/O provided by CarpetIOASCII", outdim); @@ -70,7 +78,7 @@ int IOASCII<outdim>::Startup() template<int outdim> -void* IOASCII<outdim>::SetupGH (tFleshConfig* const fc, +void* CarpetIOASCII<outdim>::SetupGH (tFleshConfig* const fc, const int convLevel, cGH* const cgh) { DECLARE_CCTK_PARAMETERS; @@ -89,7 +97,7 @@ void* IOASCII<outdim>::SetupGH (tFleshConfig* const fc, template<int outdim> -int IOASCII<outdim>::OutputGH (cGH* const cgh) { +int CarpetIOASCII<outdim>::OutputGH (cGH* const cgh) { for (int vindex=0; vindex<CCTK_NumVars(); ++vindex) { if (TimeToOutput(cgh, vindex)) { TriggerOutput(cgh, vindex); @@ -98,8 +106,10 @@ int IOASCII<outdim>::OutputGH (cGH* const cgh) { return 0; } + + template<int outdim> -int IOASCII<outdim>::OutputVarAs (cGH* const cgh, const char* const varname, +int CarpetIOASCII<outdim>::OutputVarAs (cGH* const cgh, const char* const varname, const char* const alias) { DECLARE_CCTK_PARAMETERS; @@ -111,7 +121,7 @@ int IOASCII<outdim>::OutputVarAs (cGH* const cgh, const char* const varname, assert (n0>=0 && n0<CCTK_NumVars()); const int var = n - n0; assert (var>=0 && var<CCTK_NumVars()); - const int tl = 0; + const int tl = activetimelevel; switch (CCTK_GroupTypeI(group)) { @@ -382,7 +392,7 @@ int IOASCII<outdim>::OutputVarAs (cGH* const cgh, const char* const varname, template<int outdim> -int IOASCII<outdim>::TimeToOutput (cGH* const cgh, const int vindex) { +int CarpetIOASCII<outdim>::TimeToOutput (cGH* const cgh, const int vindex) { DECLARE_CCTK_PARAMETERS; assert (vindex>=0 && vindex<(int)last_output.size()); @@ -425,7 +435,7 @@ int IOASCII<outdim>::TimeToOutput (cGH* const cgh, const int vindex) { template<int outdim> -int IOASCII<outdim>::TriggerOutput (cGH* const cgh, const int vindex) { +int CarpetIOASCII<outdim>::TriggerOutput (cGH* const cgh, const int vindex) { assert (vindex>=0 && vindex<CCTK_NumVars()); char* varname = CCTK_FullName(vindex); @@ -440,7 +450,7 @@ int IOASCII<outdim>::TriggerOutput (cGH* const cgh, const int vindex) { template<int outdim> -int IOASCII<outdim>::GetGridOffset (cGH* cgh, int dir, +int CarpetIOASCII<outdim>::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<outdim>::GetGridOffset (cGH* cgh, int dir, template<int outdim> -int IOASCII<outdim>::CoordToOffset (cGH* cgh, int dir, CCTK_REAL coord) +int CarpetIOASCII<outdim>::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<outdim>::CoordToOffset (cGH* cgh, int dir, CCTK_REAL coord) template<int outdim> -const char* IOASCII<outdim>::GetStringParameter +const char* CarpetIOASCII<outdim>::GetStringParameter (const char* const parametertemplate, const char* const fallback) { char parametername[1000]; @@ -538,7 +548,7 @@ const char* IOASCII<outdim>::GetStringParameter template<int outdim> -int IOASCII<outdim>::GetIntParameter (const char* const parametertemplate, +int CarpetIOASCII<outdim>::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 <vector> @@ -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<int outdim> +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<bool> do_truncate; + + // Last iteration on which a variable was output (-1 for none) + static vector<int> 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<int outdim> - 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<bool> do_truncate; - - // Last iteration on which a variable was output (-1 for none) - static vector<int> 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); + +}; |