aboutsummaryrefslogtreecommitdiff
path: root/src/announce.cc
diff options
context:
space:
mode:
authorschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2005-05-31 12:21:07 +0000
committerschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2005-05-31 12:21:07 +0000
commitb291165dca900822bb22d9d08c3c2b51be925580 (patch)
tree86035fb56934ed5ee378b09fe95d97ad892c164a /src/announce.cc
parentf8fedd5ec017e3ad6d00e9845f0631e2cb64e2cf (diff)
Put everything into a namespace.
Include <fstream> once more, maybe it helps. Correct a few errors that gcc pointed out. git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@26 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/announce.cc')
-rw-r--r--src/announce.cc1022
1 files changed, 524 insertions, 498 deletions
diff --git a/src/announce.cc b/src/announce.cc
index 24639fc..9f62540 100644
--- a/src/announce.cc
+++ b/src/announce.cc
@@ -6,6 +6,7 @@
#include <cstdlib>
#include <cstring>
#include <ctime>
+#include <fstream>
#include <iomanip>
#include <list>
#include <sstream>
@@ -29,682 +30,707 @@
#include "multistorage.hh"
#include "portal.hh"
-using namespace std;
+namespace Formaline
+{
+
+ using namespace std;
+
-extern "C" char const * Formaline_BuildID ();
+ extern "C" char const build_id[];
-static char * jobid = 0;
+
+ static char * jobid = 0;
// Create a unique job id
-static void
-create_jobid (CCTK_ARGUMENTS)
-{
- DECLARE_CCTK_ARGUMENTS;
- DECLARE_CCTK_PARAMETERS;
+ static void
+ create_jobid (CCTK_ARGUMENTS)
+ {
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
- ostringstream jobidbuf;
- jobidbuf << "job-";
+ ostringstream jobidbuf;
+ jobidbuf << "job-";
- char run_host [1000];
- Util_GetHostName (run_host, sizeof run_host);
- jobidbuf << run_host;
+ char run_host [1000];
+ Util_GetHostName (run_host, sizeof run_host);
+ jobidbuf << run_host;
- jobidbuf << "-";
+ jobidbuf << "-";
#if 0
- char const * const run_user = CCTK_RunUser();
+ char const * const run_user = CCTK_RunUser();
#else
- char const * const run_user = getenv ("USER");
+ char const * const run_user = getenv ("USER");
#endif
- jobidbuf << run_user;
+ jobidbuf << run_user;
- jobidbuf << "-";
+ jobidbuf << "-";
- time_t const tim = time (0);
- struct tm * const ptm = gmtime (& tim);
- jobidbuf << setfill ('0')
- << setw(4) << ptm->tm_year
- << setw(2) << ptm->tm_mon
- << setw(2) << ptm->tm_mday
- << "-"
- << setw(2) << ptm->tm_hour
- << setw(2) << ptm->tm_min
- << setw(2) << ptm->tm_sec;
+ time_t const tim = time (0);
+ struct tm * const ptm = gmtime (& tim);
+ jobidbuf << setfill ('0')
+ << setw(4) << ptm->tm_year
+ << setw(2) << ptm->tm_mon
+ << setw(2) << ptm->tm_mday
+ << "-"
+ << setw(2) << ptm->tm_hour
+ << setw(2) << ptm->tm_min
+ << setw(2) << ptm->tm_sec;
- jobidbuf << "-";
+ jobidbuf << "-";
- pid_t const pid = getpid();
- jobidbuf << pid;
+ pid_t const pid = getpid();
+ jobidbuf << pid;
- string const jobidstr = jobidbuf.str();
- jobid = strdup (jobidstr.c_str());
-}
+ string const jobidstr = jobidbuf.str();
+ jobid = strdup (jobidstr.c_str());
+ }
-extern "C"
-void
-Formaline_AnnounceInitial (CCTK_ARGUMENTS)
-{
- DECLARE_CCTK_ARGUMENTS;
- DECLARE_CCTK_PARAMETERS;
+ extern "C"
+ void
+ Formaline_AnnounceInitial (CCTK_ARGUMENTS)
+ {
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
- // Only store from the root processor
- if (CCTK_MyProc (cctkGH) != 0) return;
+ // Only store from the root processor
+ if (CCTK_MyProc (cctkGH) != 0) return;
- create_jobid (cctkGH);
+ create_jobid (cctkGH);
- multistorage stores;
+ multistorage stores;
- if (announce_to_portal)
- {
- stores.add_storage (new portal (jobid, storage::initial));
- }
+ if (announce_to_portal)
+ {
+ stores.add_storage (new portal (jobid, storage::initial));
+ }
- if (store_into_file)
- {
- stores.add_storage (new file (jobid, storage::initial));
- }
+ if (store_into_file)
+ {
+ stores.add_storage (new file (jobid, storage::initial));
+ }
- if (stores.num_storages() == 0) return;
+ if (stores.num_storages() == 0) return;
- // Information in the Portal/Announce format
- {
- // Don't know what this is for
- stores.store ("jobtype", "default");
- }
- {
- int type;
- void const * const ptr
- = CCTK_ParameterGet ("cctk_run_title", "Cactus", & type);
- assert (type == PARAMETER_STRING);
- char const * const run_title = * static_cast<char const * const *> (ptr);
- stores.store ("app_title", run_title);
- }
- {
- char run_date [1000];
- Util_CurrentDate (sizeof run_date, run_date);
- char run_time [1000];
- Util_CurrentTime (sizeof run_time, run_time);
- ostringstream timebuf;
- timebuf << run_date << " " << run_time;
- string const timestr = timebuf.str();
- stores.store ("start_time", timestr.c_str());
- }
- {
- // Don't know what this is for
- stores.store ("project_name", "");
- }
- {
- stores.store ("output_files", out_dir);
- }
- {
- char run_host [1000];
- Util_GetHostName (run_host, sizeof run_host);
- stores.store ("host", run_host);
- }
- {
- unsigned long http_port;
-#ifdef __HTTP_CONTENT_H__
- if (CCTK_IsThornActive ("HTTPD"))
+ // Information in the Portal/Announce format
{
- // Thorn is compiled in and active, ask it
- http_port = HTTP_Port();
+ // Don't know what this is for
+ stores.store ("jobtype", "default");
}
- else
{
- // Thorn is compiled in but not active, ignore it
- http_port = 0;
+ int type;
+ void const * const ptr
+ = CCTK_ParameterGet ("cctk_run_title", "Cactus", & type);
+ assert (type == PARAMETER_STRING);
+ char const * const run_title = * static_cast<char const * const *> (ptr);
+ stores.store ("app_title", run_title);
+ }
+ {
+ char run_date [1000];
+ Util_CurrentDate (sizeof run_date, run_date);
+ char run_time [1000];
+ Util_CurrentTime (sizeof run_time, run_time);
+ ostringstream timebuf;
+ timebuf << run_date << " " << run_time;
+ string const timestr = timebuf.str();
+ stores.store ("start_time", timestr.c_str());
+ }
+ {
+ // Don't know what this is for
+ stores.store ("project_name", "");
+ }
+ {
+ stores.store ("output_files", out_dir);
}
-#else
{
- // Thorn is not compiled in, ignore it
- http_port = 0;
+ char run_host [1000];
+ Util_GetHostName (run_host, sizeof run_host);
+ stores.store ("host", run_host);
}
+ {
+ unsigned long http_port;
+#ifdef __HTTP_CONTENT_H__
+ if (CCTK_IsThornActive ("HTTPD"))
+ {
+ // Thorn is compiled in and active, ask it
+ http_port = HTTP_Port();
+ }
+ else
+ {
+ // Thorn is compiled in but not active, ignore it
+ http_port = 0;
+ }
+#else
+ {
+ // Thorn is not compiled in, ignore it
+ http_port = 0;
+ }
#endif
- stores.store ("port", (int) http_port);
- }
- {
- stores.store ("portal_username", portal_username);
- }
- {
+ stores.store ("port", (int) http_port);
+ }
+ {
+ stores.store ("portal_username", portal_username);
+ }
+ {
#if 0
- char const * const run_user = CCTK_RunUser();
+ char const * const run_user = CCTK_RunUser();
#else
- char const * const run_user = getenv ("USER");
+ char const * const run_user = getenv ("USER");
#endif
- stores.store ("local_username", run_user);
- }
- {
- char parameter_filename [10000];
- CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename);
- stores.store ("parameter_file", parameter_filename);
- }
- {
- char ** argv;
- int argc;
- int n;
- CCTK_CommandLine (& argv);
- for (argc = 0; argv [argc]; ++ argc);
- stores.store ("executable", argc == 0 ? "" : argv[0]);
- }
- {
- // Don't know what this is for
- stores.store ("data_directory", "");
- }
- {
- // Could also be "private"
- stores.store ("app_visibility", "public");
- }
- {
- // Could apparently be none, register, update, deregister
- stores.store ("notification_reports", "");
- }
- {
- // Could apparently be none, email, im, sms
- stores.store ("notification_methods", "");
- }
+ stores.store ("local_username", run_user);
+ }
+ {
+ char parameter_filename [10000];
+ CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename);
+ stores.store ("parameter_file", parameter_filename);
+ }
+ {
+ char ** argv;
+ int argc;
+ CCTK_CommandLine (& argv);
+ for (argc = 0; argv [argc]; ++ argc);
+ stores.store ("executable", argc == 0 ? "" : argv[0]);
+ }
+ {
+ // Don't know what this is for
+ stores.store ("data_directory", "");
+ }
+ {
+ // Could also be "private"
+ stores.store ("app_visibility", "public");
+ }
+ {
+ // Could apparently be none, register, update, deregister
+ stores.store ("notification_reports", "");
+ }
+ {
+ // Could apparently be none, email, im, sms
+ stores.store ("notification_methods", "");
+ }
- // Cactus
+ // Cactus
- {
- char const * const cactus_version = CCTK_FullVersion();
- stores.store ("Cactus version", cactus_version);
- }
+ {
+ char const * const cactus_version = CCTK_FullVersion();
+ stores.store ("Cactus version", cactus_version);
+ }
- // Compiling
+ // Compiling
- {
- char const * const build_id = Formaline_BuildID();
- stores.store ("build id", build_id);
- }
+ {
+ stores.store ("build id", build_id);
+ }
#if 0
- {
- char const * const compile_user = CCTK_CompileUser();
- stores.store ("compile user", compile_user);
- }
+ {
+ char const * const compile_user = CCTK_CompileUser();
+ stores.store ("compile user", compile_user);
+ }
#endif
- {
- char const * const compile_date = CCTK_CompileDate();
- stores.store ("compile date", compile_date);
- }
+ {
+ char const * const compile_date = CCTK_CompileDate();
+ stores.store ("compile date", compile_date);
+ }
- {
- char const * const compile_time = CCTK_CompileTime();
- stores.store ("compile time", compile_time);
- }
+ {
+ char const * const compile_time = CCTK_CompileTime();
+ stores.store ("compile time", compile_time);
+ }
- // Running
+ // Running
#if 0
- {
- char const * const run_user = CCTK_RunUser();
- stores.store ("run user", run_user);
- }
+ {
+ char const * const run_user = CCTK_RunUser();
+ stores.store ("run user", run_user);
+ }
#else
- {
- char const * const run_user = getenv ("USER");
- stores.store ("run user", run_user);
- }
+ {
+ char const * const run_user = getenv ("USER");
+ stores.store ("run user", run_user);
+ }
#endif
- {
- char run_date [1000];
- Util_CurrentDate (sizeof run_date, run_date);
- stores.store ("run date", run_date);
- }
+ {
+ char run_date [1000];
+ Util_CurrentDate (sizeof run_date, run_date);
+ stores.store ("run date", run_date);
+ }
- {
- char run_time [1000];
- Util_CurrentTime (sizeof run_time, run_time);
- stores.store ("run time", run_time);
- }
+ {
+ char run_time [1000];
+ Util_CurrentTime (sizeof run_time, run_time);
+ stores.store ("run time", run_time);
+ }
- {
- char run_host [1000];
- Util_GetHostName (run_host, sizeof run_host);
- stores.store ("run host", run_host);
- }
+ {
+ char run_host [1000];
+ Util_GetHostName (run_host, sizeof run_host);
+ stores.store ("run host", run_host);
+ }
- {
- int type;
- void const * const ptr
- = CCTK_ParameterGet ("cctk_run_title", "Cactus", & type);
- assert (type == PARAMETER_STRING);
- char const * const run_title = * static_cast<char const * const *> (ptr);
- stores.store ("run title", run_title);
- }
+ {
+ int type;
+ void const * const ptr
+ = CCTK_ParameterGet ("cctk_run_title", "Cactus", & type);
+ assert (type == PARAMETER_STRING);
+ char const * const run_title = * static_cast<char const * const *> (ptr);
+ stores.store ("run title", run_title);
+ }
- // Command line arguments
+ // Command line arguments
- {
- char ** argv;
- int argc;
- int n;
- CCTK_CommandLine (& argv);
- for (argc = 0; argv [argc]; ++ argc);
- stores.store ("argc", argc);
- for (n = 0; n < argc; ++ n)
- {
- char buffer [1000];
- snprintf (buffer, sizeof buffer, "argv[%d]", n);
- stores.store (buffer, argv[n]);
+ {
+ char ** argv;
+ int argc;
+ int n;
+ CCTK_CommandLine (& argv);
+ for (argc = 0; argv [argc]; ++ argc);
+ stores.store ("argc", argc);
+ for (n = 0; n < argc; ++ n)
+ {
+ char buffer [1000];
+ snprintf (buffer, sizeof buffer, "argv[%d]", n);
+ stores.store (buffer, argv[n]);
+ }
}
- }
- {
- char parameter_filename [10000];
- CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename);
- stores.store ("parameter filename", parameter_filename);
- }
+ {
+ char parameter_filename [10000];
+ CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename);
+ stores.store ("parameter filename", parameter_filename);
+ }
- // This is superfluous, and it does not look nice
+ // This is superfluous, and it does not look nice
#if 0
- {
- char parameter_filename [10000];
- char parameter_file [1000000];
- size_t count;
- FILE * file;
- CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename);
- file = fopen (parameter_filename, "r");
- count = fread (parameter_file, 1, sizeof parameter_file - 1, file);
- fclose (file);
- assert (count < sizeof parameter_file - 1);
- parameter_file [count] = '\0';
- stores.store ("parameter file", parameter_file);
- }
+ {
+ char parameter_filename [10000];
+ char parameter_file [1000000];
+ size_t count;
+ FILE * file;
+ CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename);
+ file = fopen (parameter_filename, "r");
+ count = fread (parameter_file, 1, sizeof parameter_file - 1, file);
+ fclose (file);
+ assert (count < sizeof parameter_file - 1);
+ parameter_file [count] = '\0';
+ stores.store ("parameter file", parameter_file);
+ }
#endif
- {
- int type;
- void const * const ptr
- = CCTK_ParameterGet ("out_dir", "IOUtil", & type);
- assert (type == PARAMETER_STRING);
- char const * const out_dir = * static_cast<char const * const *> (ptr);
- stores.store ("out dir", out_dir);
- }
+ {
+ stores.store ("out dir", out_dir);
+ }
- {
- int nprocs;
- nprocs = CCTK_nProcs (cctkGH);
- stores.store ("nprocs", nprocs);
- }
+ {
+ int nprocs;
+ nprocs = CCTK_nProcs (cctkGH);
+ stores.store ("nprocs", nprocs);
+ }
- // All Cactus thorns
+ // All Cactus thorns
- {
- int const numthorns = CCTK_NumCompiledThorns ();
- for (int thorn = 0; thorn < numthorns; ++ thorn)
{
- char const * const thornname = CCTK_CompiledThorn (thorn);
+ int const numthorns = CCTK_NumCompiledThorns ();
+ for (int thorn = 0; thorn < numthorns; ++ thorn)
+ {
+ char const * const thornname = CCTK_CompiledThorn (thorn);
- ostringstream keybuf;
- keybuf << "thorns/" << thornname;
- string const keystr = keybuf.str();
- char const * const key = keystr.c_str();
+ ostringstream keybuf;
+ keybuf << "thorns/" << thornname;
+ string const keystr = keybuf.str();
+ char const * const key = keystr.c_str();
- if (CCTK_IsThornActive (thornname))
- {
- stores.store (key, "active");
- }
- else
- {
- stores.store (key, "inactive");
+ if (CCTK_IsThornActive (thornname))
+ {
+ stores.store (key, "active");
+ }
+ else
+ {
+ stores.store (key, "inactive");
+ }
}
}
- }
- // All Cactus parameters
+ // All Cactus parameters
- {
- typedef pair<string, cParamData const *> param;
-
- // Collect all parameters into a list
- // (A list allows efficient inserting)
- list<param> paramlist;
- for (int first = 1; ; first = 0)
{
- cParamData const * parameter_data;
- char * parameter_fullname;
+ typedef pair<string, cParamData const *> param;
+
+ // Collect all parameters into a list
+ // (A list allows efficient inserting)
+ list<param> paramlist;
+ for (int first = 1; ; first = 0)
+ {
+ cParamData const * parameter_data;
+ char * parameter_fullname;
- int const ierr
- = CCTK_ParameterWalk (first, 0,
- & parameter_fullname, & parameter_data);
- if (ierr > 0) break;
- assert (ierr >= 0);
+ int const ierr
+ = CCTK_ParameterWalk (first, 0,
+ & parameter_fullname, & parameter_data);
+ if (ierr > 0) break;
+ assert (ierr >= 0);
- // Skip parameters that belong to inactive thorns
- if (CCTK_IsThornActive (parameter_data->thorn))
- {
- paramlist.push_back (param (string (parameter_fullname),
- parameter_data));
- }
+ // Skip parameters that belong to inactive thorns
+ if (CCTK_IsThornActive (parameter_data->thorn))
+ {
+ paramlist.push_back (param (string (parameter_fullname),
+ parameter_data));
+ }
- free (parameter_fullname);
- }
+ free (parameter_fullname);
+ }
- // Copy the list into a vector
- // (A vector allows efficient sorting)
- vector<param> paramvector;
- paramvector.insert (paramvector.begin(),
- paramlist.begin(), paramlist.end());
+ // Copy the list into a vector
+ // (A vector allows efficient sorting)
+ vector<param> paramvector;
+ paramvector.insert (paramvector.begin(),
+ paramlist.begin(), paramlist.end());
- // Sort the parameters
- sort (paramvector.begin(), paramvector.end());
+ // Sort the parameters
+ sort (paramvector.begin(), paramvector.end());
- // Store the parameters
- for (vector<param>::const_iterator parameter = paramvector.begin();
- parameter != paramvector.end();
- ++ parameter)
- {
- char const * const parameter_fullname = parameter->first.c_str();
- cParamData const * const parameter_data = parameter->second;
+ // Store the parameters
+ for (vector<param>::const_iterator parameter = paramvector.begin();
+ parameter != paramvector.end();
+ ++ parameter)
+ {
+ char const * const parameter_fullname = parameter->first.c_str();
+ cParamData const * const parameter_data = parameter->second;
- ostringstream keybuf;
- keybuf << "parameters/" << parameter_fullname;
- string const keystr = keybuf.str();
- char const * const key = keystr.c_str();
+ ostringstream keybuf;
+ keybuf << "parameters/" << parameter_fullname;
+ string const keystr = keybuf.str();
+ char const * const key = keystr.c_str();
- int type;
- void const * const parameter_value
- = CCTK_ParameterGet (parameter_data->name, parameter_data->thorn,
- & type);
- assert (parameter_value != 0);
- assert (type == parameter_data->type);
+ int type;
+ void const * const parameter_value
+ = CCTK_ParameterGet (parameter_data->name, parameter_data->thorn,
+ & type);
+ assert (parameter_value != 0);
+ assert (type == parameter_data->type);
- int const times_set
- = CCTK_ParameterQueryTimesSet (parameter_data->name,
- parameter_data->thorn);
+ int const times_set
+ = CCTK_ParameterQueryTimesSet (parameter_data->name,
+ parameter_data->thorn);
- switch (type)
- {
- case PARAMETER_BOOLEAN:
+ switch (type)
{
- CCTK_INT default_value;
- int const ierr
- = CCTK_SetBoolean (& default_value, parameter_data->defval);
- assert (! ierr);
- CCTK_INT const value
- = * static_cast<CCTK_INT const *> (parameter_value);
- if (times_set > 0 or value != default_value)
+ case PARAMETER_BOOLEAN:
{
- stores.store (key, (bool) value);
- }
- }
- break;
- case PARAMETER_INT:
- {
- CCTK_INT const default_value
- = strtol (parameter_data->defval, 0, 0);
- CCTK_INT const value
- = * static_cast<CCTK_INT const *> (parameter_value);
- if (times_set > 0 or value != default_value)
- {
- stores.store (key, value);
+ CCTK_INT default_value;
+ int const ierr
+ = CCTK_SetBoolean (& default_value, parameter_data->defval);
+ assert (! ierr);
+ CCTK_INT const value
+ = * static_cast<CCTK_INT const *> (parameter_value);
+ if (times_set > 0 or value != default_value)
+ {
+ stores.store (key, (bool) value);
+ }
}
- }
- break;
- case PARAMETER_REAL:
- {
- char * const default_string = strdup (parameter_data->defval);
- assert (default_string);
- // Convert "d" and "D" to "e" and "E", because this is what
- // strtod expects
- for (char * p = default_string; * p; ++ p)
+ break;
+ case PARAMETER_INT:
{
- switch (* p)
+ CCTK_INT const default_value
+ = strtol (parameter_data->defval, 0, 0);
+ CCTK_INT const value
+ = * static_cast<CCTK_INT const *> (parameter_value);
+ if (times_set > 0 or value != default_value)
{
- case 'd': * p = 'e'; break;
- case 'D': * p = 'E'; break;
+ stores.store (key, value);
}
}
- CCTK_INT const default_value = strtod (default_string, 0);
- free (default_string);
- CCTK_REAL const value
- = * static_cast<CCTK_REAL const *> (parameter_value);
- if (times_set > 0 or value != default_value)
+ break;
+ case PARAMETER_REAL:
{
- stores.store (key, value);
+ char * const default_string = strdup (parameter_data->defval);
+ assert (default_string);
+ // Convert "d" and "D" to "e" and "E", because this is what
+ // strtod expects
+ for (char * p = default_string; * p; ++ p)
+ {
+ switch (* p)
+ {
+ case 'd': * p = 'e'; break;
+ case 'D': * p = 'E'; break;
+ }
+ }
+ CCTK_REAL const default_value = strtod (default_string, 0);
+ free (default_string);
+ CCTK_REAL const value
+ = * static_cast<CCTK_REAL const *> (parameter_value);
+ if (times_set > 0 or value != default_value)
+ {
+ stores.store (key, value);
+ }
}
- }
- break;
- case PARAMETER_KEYWORD:
- {
- char const * const value
- = * static_cast<char const * const *> (parameter_value);
- if (times_set > 0
- or Util_StrCmpi (parameter_data->defval, value) != 0)
+ break;
+ case PARAMETER_KEYWORD:
{
- stores.store (key, value);
+ char const * const value
+ = * static_cast<char const * const *> (parameter_value);
+ if (times_set > 0
+ or Util_StrCmpi (parameter_data->defval, value) != 0)
+ {
+ stores.store (key, value);
+ }
}
- }
- break;
- case PARAMETER_STRING:
- {
- char const * const value
- = * static_cast<char const * const *> (parameter_value);
- if (times_set > 0 or strcmp (parameter_data->defval, value) != 0)
+ break;
+ case PARAMETER_STRING:
{
- stores.store (key, value);
+ char const * const value
+ = * static_cast<char const * const *> (parameter_value);
+ if (times_set > 0 or strcmp (parameter_data->defval, value) != 0)
+ {
+ stores.store (key, value);
+ }
}
+ break;
+ default:
+ assert (0);
}
- break;
- default:
- assert (0);
- }
- } // for all parameters
- }
+ } // for all parameters
+ }
- // Simulation state
+ // Simulation state
- {
- stores.store ("cctk_iteration", cctk_iteration);
+ {
+ stores.store ("cctk_iteration", cctk_iteration);
+ }
}
-}
-extern "C"
-void
-Formaline_AnnounceUpdate (CCTK_ARGUMENTS)
-{
- DECLARE_CCTK_ARGUMENTS;
- DECLARE_CCTK_PARAMETERS;
+ extern "C"
+ void
+ Formaline_AnnounceUpdate (CCTK_ARGUMENTS)
+ {
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
- // Only store from the root processor
- if (CCTK_MyProc (cctkGH) != 0) return;
+ // Only store from the root processor
+ if (CCTK_MyProc (cctkGH) != 0) return;
- multistorage stores;
+ multistorage stores;
- if (announce_to_portal)
- {
- stores.add_storage (new portal (jobid, storage::update));
- }
+ if (announce_to_portal)
+ {
+ stores.add_storage (new portal (jobid, storage::update));
+ }
- if (store_into_file)
- {
- stores.add_storage (new file (jobid, storage::update));
- }
+ if (store_into_file)
+ {
+ stores.add_storage (new file (jobid, storage::update));
+ }
- if (stores.num_storages() == 0) return;
+ if (stores.num_storages() == 0) return;
- // Simulation state
+ // Simulation state
- {
- stores.store ("cctk_iteration", cctk_iteration);
- stores.store ("cctk_time", cctk_time);
- }
+ {
+ stores.store ("cctk_iteration", cctk_iteration);
+ stores.store ("cctk_time", cctk_time);
+ }
- // Groups and variables
+ // Groups and variables
- {
- struct args {
- cGH * cctkGH;
- multistorage * stores;
- char const * reductions;
+ {
+ struct args {
+ cGH * cctkGH;
+ multistorage * stores;
+ char const * reductions;
- static void
- output_variable (int const varindex,
- char const * const options,
- void * const theargs0)
- {
- args * const theargs = (args *) theargs0;
- cGH * const cctkGH = theargs->cctkGH;
- multistorage & stores = * theargs->stores;
- char const * const reductions = theargs->reductions;
+ static void
+ output_variable (int const varindex,
+ char const * const options,
+ void * const theargs0)
+ {
+ args * const theargs = (args *) theargs0;
+ cGH * const cctkGH = theargs->cctkGH;
+ multistorage & stores = * theargs->stores;
+ char const * const reductions = theargs->reductions;
- int const groupindex = CCTK_GroupIndexFromVarI (varindex);
- assert (groupindex >= 0);
- cGroup group;
- int const ierr = CCTK_GroupData (groupindex, & group);
- assert (! ierr);
+ int const groupindex = CCTK_GroupIndexFromVarI (varindex);
+ assert (groupindex >= 0);
+ cGroup group;
+ int const ierr = CCTK_GroupData (groupindex, & group);
+ assert (! ierr);
- ostringstream keybuf, valbuf;
- char * const fullname = CCTK_FullName (varindex);
- assert (fullname);
- keybuf << "variables/" << fullname;
- free (fullname);
- string const keystr = keybuf.str();
- char const * const key = keystr.c_str();
+ ostringstream keybuf, valbuf;
+ char * const fullname = CCTK_FullName (varindex);
+ assert (fullname);
+ keybuf << "variables/" << fullname;
+ free (fullname);
+ string const keystr = keybuf.str();
+ char const * const key = keystr.c_str();
- void const * const varptr
- = CCTK_VarDataPtrI (cctkGH, 0, varindex);
- if (! varptr) {
- // No storage -- do nothing
- // TODO: output warning
- return;
- }
+ void const * const varptr
+ = CCTK_VarDataPtrI (cctkGH, 0, varindex);
+ if (! varptr) {
+ // No storage -- do nothing
+ // TODO: output warning
+ return;
+ }
- switch (group.grouptype)
- {
- case CCTK_SCALAR:
- switch (group.vartype)
+ switch (group.grouptype)
{
- case CCTK_VARIABLE_INT:
- {
- CCTK_INT const val = * (CCTK_INT const *) varptr;
- stores.store (key, val);
- }
- break;
- case CCTK_VARIABLE_REAL:
+ case CCTK_SCALAR:
+ switch (group.vartype)
{
- CCTK_REAL const val = * (CCTK_REAL const *) varptr;
- stores.store (key, val);
- }
- break;
- case CCTK_VARIABLE_COMPLEX:
- {
- CCTK_COMPLEX const val = * (CCTK_COMPLEX const *) varptr;
+ case CCTK_VARIABLE_INT:
{
- ostringstream keyrebuf;
- keyrebuf << key << ".Re";
- string const keyrestr = keyrebuf.str();
- char const * const keyre = keyrestr.c_str();
- stores.store (keyre, val.Re);
+ CCTK_INT const val = * (CCTK_INT const *) varptr;
+ stores.store (key, val);
}
+ break;
+ case CCTK_VARIABLE_REAL:
{
- ostringstream keyimbuf;
- keyimbuf << key << ".Im";
- string const keyimstr = keyimbuf.str();
- char const * const keyim = keyimstr.c_str();
- stores.store (keyim, val.Im);
+ CCTK_REAL const val = * (CCTK_REAL const *) varptr;
+ stores.store (key, val);
}
+ break;
+ case CCTK_VARIABLE_COMPLEX:
+ {
+ CCTK_COMPLEX const val = * (CCTK_COMPLEX const *) varptr;
+ {
+ ostringstream keyrebuf;
+ keyrebuf << key << ".Re";
+ string const keyrestr = keyrebuf.str();
+ char const * const keyre = keyrestr.c_str();
+ stores.store (keyre, val.Re);
+ }
+ {
+ ostringstream keyimbuf;
+ keyimbuf << key << ".Im";
+ string const keyimstr = keyimbuf.str();
+ char const * const keyim = keyimstr.c_str();
+ stores.store (keyim, val.Im);
+ }
+ }
+ break;
+ default:
+ ;
+ // not supported yet
+ // TODO: output warning
}
break;
- default:
- ;
+ case CCTK_ARRAY:
+ case CCTK_GF:
// not supported yet
// TODO: output warning
+ break;
+ default:
+ CCTK_WARN (0, "internal error");
}
+ }
+ } theargs;
+
+ theargs.cctkGH = cctkGH;
+ theargs.stores = & stores;
+ theargs.reductions = out_reductions;
+
+ int const icnt
+ = CCTK_TraverseString (out_vars, theargs.output_variable, & theargs,
+ CCTK_GROUP_OR_VAR);
+ if (icnt < 0)
+ {
+ switch (icnt)
+ {
+ case -1:
+ CCTK_WARN (0, "no callback routine was given");
break;
- case CCTK_ARRAY:
- case CCTK_GF:
- // not supported yet
- // TODO: output warning
+ case -2:
+ CCTK_WARN (2, "option string is not associated with a group or variable");
+ break;
+ case -3:
+ CCTK_WARN (2, "unterminated option string");
+ break;
+ case -4:
+ CCTK_WARN (2, "garbage found at end of option string");
+ break;
+ case -5:
+ CCTK_WARN (2, "invalid token in traversed string found");
break;
default:
- CCTK_WARN (0, "internal error");
+ CCTK_WARN (1, "error while traversing output variables");
}
}
- } theargs;
-
- theargs.cctkGH = cctkGH;
- theargs.stores = & stores;
- theargs.reductions = out_reductions;
-
- int const ierr
- = CCTK_TraverseString (out_vars, theargs.output_variable, & theargs,
- CCTK_GROUP_OR_VAR);
+ }
}
-}
-extern "C"
-void
-Formaline_AnnounceFinal (CCTK_ARGUMENTS)
-{
- DECLARE_CCTK_ARGUMENTS;
- DECLARE_CCTK_PARAMETERS;
+ extern "C"
+ void
+ Formaline_AnnounceFinal (CCTK_ARGUMENTS)
+ {
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
- // Only store from the root processor
- if (CCTK_MyProc (cctkGH) != 0) return;
+ // Only store from the root processor
+ if (CCTK_MyProc (cctkGH) != 0) return;
- multistorage stores;
+ multistorage stores;
- if (announce_to_portal)
- {
- stores.add_storage (new portal (jobid, storage::final));
- }
+ if (announce_to_portal)
+ {
+ stores.add_storage (new portal (jobid, storage::final));
+ }
- if (store_into_file)
- {
- stores.add_storage (new file (jobid, storage::final));
- }
+ if (store_into_file)
+ {
+ stores.add_storage (new file (jobid, storage::final));
+ }
- if (stores.num_storages() == 0) return;
+ if (stores.num_storages() == 0) return;
- // Simulation state
+ // Simulation state
- {
- stores.store ("cctk_iteration", cctk_iteration);
+ {
+ stores.store ("cctk_iteration", cctk_iteration);
+ }
}
-}
+
+
+
+} // namespace Formaline