aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README4
-rw-r--r--src/announce.cc1022
-rw-r--r--src/file.cc199
-rw-r--r--src/file.hh65
-rw-r--r--src/make.configuration.deps6
-rw-r--r--src/multistorage.cc129
-rw-r--r--src/multistorage.hh71
-rw-r--r--src/output_source.c9
-rw-r--r--src/portal.cc451
-rw-r--r--src/portal.hh71
-rw-r--r--src/storage.cc40
-rw-r--r--src/storage.hh73
12 files changed, 1118 insertions, 1022 deletions
diff --git a/README b/README
index 6dffd0a..d624e48 100644
--- a/README
+++ b/README
@@ -42,3 +42,7 @@ register as output method
implement reductions
implement missing data types
output only if value has changed
+
+put stuff into namespace
+ (move from C to C++?)
+rename "file", "storage" do something more unique
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
diff --git a/src/file.cc b/src/file.cc
index e0e7527..bc61650 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -10,145 +10,152 @@
-using namespace std;
+namespace Formaline
+{
+ using namespace std;
-file::
-file (char const * const id,
- enum state const st)
- : storage (st)
-{
- DECLARE_CCTK_PARAMETERS;
+
+ file::
+ file (char const * const id,
+ enum state const st)
+ : storage (st)
+ {
+ DECLARE_CCTK_PARAMETERS;
- ostringstream filenamebuf;
- filenamebuf << out_dir << "/" << storage_filename;
- string const filenamestring = filenamebuf.str();
+ ostringstream filenamebuf;
+ filenamebuf << out_dir << "/" << storage_filename;
+ string const filenamestring = filenamebuf.str();
- ios::openmode const mode = get_state() == initial ? ios::trunc : ios::app;
- fil.open (filenamestring.c_str(), mode);
+ ios::openmode const mode = get_state() == initial ? ios::trunc : ios::app;
+ fil.open (filenamestring.c_str(), mode);
- if (get_state() == initial)
- {
- store ("simulation id", id);
+ if (get_state() == initial)
+ {
+ store ("simulation id", id);
+ }
}
-}
-file::
-~ file ()
-{
- if (get_state() == final)
+ file::
+ ~ file ()
{
- store ("simulation", "done");
+ if (get_state() == final)
+ {
+ store ("simulation", "done");
+ }
+ fil.close();
}
- fil.close();
-}
-void file::
-store (char const * const key,
- bool const value)
-{
- assert (key);
+ void file::
+ store (char const * const key,
+ bool const value)
+ {
+ assert (key);
- ostringstream keybuf;
- keybuf << key;
- ostringstream valuebuf;
- valuebuf << (value ? "yes" : "no");
+ ostringstream keybuf;
+ keybuf << key;
+ ostringstream valuebuf;
+ valuebuf << (value ? "yes" : "no");
- ostringstream buf;
- buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
+ ostringstream buf;
+ buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
- write (buf.str());
-}
+ write (buf.str());
+ }
-void file::
-store (char const * const key,
- int const value)
-{
- assert (key);
+ void file::
+ store (char const * const key,
+ int const value)
+ {
+ assert (key);
- ostringstream keybuf;
- keybuf << key;
- ostringstream valuebuf;
- valuebuf << value;
+ ostringstream keybuf;
+ keybuf << key;
+ ostringstream valuebuf;
+ valuebuf << value;
- ostringstream buf;
- buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
+ ostringstream buf;
+ buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
- write (buf.str());
-}
+ write (buf.str());
+ }
-void file::
-store (char const * const key,
- double const value)
-{
- assert (key);
+ void file::
+ store (char const * const key,
+ double const value)
+ {
+ assert (key);
- ostringstream keybuf;
- keybuf << key;
- ostringstream valuebuf;
- valuebuf << setprecision(15) << value;
+ ostringstream keybuf;
+ keybuf << key;
+ ostringstream valuebuf;
+ valuebuf << setprecision(15) << value;
- ostringstream buf;
- buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
+ ostringstream buf;
+ buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
- write (buf.str());
-}
+ write (buf.str());
+ }
-void file::
-store (char const * const key,
- char const * const value)
-{
- assert (key);
+ void file::
+ store (char const * const key,
+ char const * const value)
+ {
+ assert (key);
- ostringstream keybuf;
- keybuf << key;
- ostringstream valuebuf;
- valuebuf << value;
+ ostringstream keybuf;
+ keybuf << key;
+ ostringstream valuebuf;
+ valuebuf << value;
- ostringstream buf;
- buf << clean (keybuf.str()) << "="
- << "\"" << clean (valuebuf.str()) << "\"" << endl;
+ ostringstream buf;
+ buf << clean (keybuf.str()) << "="
+ << "\"" << clean (valuebuf.str()) << "\"" << endl;
- write (buf.str());
-}
+ write (buf.str());
+ }
-void file::
-write (std::string const & msg)
-{
- fil << msg;
-}
+ void file::
+ write (std::string const & msg)
+ {
+ fil << msg;
+ }
-string file::
-clean (string const & txt)
- const
-{
- ostringstream buf;
-
- for (string::const_iterator p = txt.begin(); p != txt.end(); ++ p)
+ string file::
+ clean (string const & txt)
+ const
{
- switch (* p)
+ ostringstream buf;
+
+ for (string::const_iterator p = txt.begin(); p != txt.end(); ++ p)
{
- case '=': buf << "\\="; break;
- case '"': buf << "\\\""; break;
- case '\\': buf << "\\\\"; break;
- default: buf << * p;
+ switch (* p)
+ {
+ case '=': buf << "\\="; break;
+ case '"': buf << "\\\""; break;
+ case '\\': buf << "\\\\"; break;
+ default: buf << * p;
+ }
}
- }
- return buf.str();
-}
+ return buf.str();
+ }
+
+
+
+} // namespace Formaline
diff --git a/src/file.hh b/src/file.hh
index 9da207f..e9b8af3 100644
--- a/src/file.hh
+++ b/src/file.hh
@@ -1,7 +1,7 @@
// $Header$
-#ifndef FILE_HH
-#define FILE_HH
+#ifndef FORMALINE_FILE_HH
+#define FORMALINE_FILE_HH
@@ -12,44 +12,51 @@
-class file : public storage
+namespace Formaline
{
- ofstream fil;
+
+ class file : public storage
+ {
+ std::ofstream fil;
-public:
+ public:
- file (char const * id,
- enum state st);
+ file (char const * id,
+ enum state st);
- virtual
- ~ file ();
+ virtual
+ ~ file ();
- virtual void
- store (char const * key,
- bool value);
+ virtual void
+ store (char const * key,
+ bool value);
- virtual void
- store (char const * key,
- int value);
+ virtual void
+ store (char const * key,
+ int value);
- virtual void
- store (char const * key,
- double value);
+ virtual void
+ store (char const * key,
+ double value);
- virtual void
- store (char const * key,
- char const * value);
+ virtual void
+ store (char const * key,
+ char const * value);
-private:
+ private:
- void
- write (std::string const & msg);
+ void
+ write (std::string const & msg);
- std::string
- clean (std::string const & txt)
- const;
-};
+ std::string
+ clean (std::string const & txt)
+ const;
+ };
+
+
+
+} // namespace Formaline
-#endif // ifndef FILE_HH
+#endif // ifndef FORMALINE_FILE_HH
diff --git a/src/make.configuration.deps b/src/make.configuration.deps
index 7cf7547..809a540 100644
--- a/src/make.configuration.deps
+++ b/src/make.configuration.deps
@@ -40,11 +40,7 @@ $(TARBALL_DIR)/build-id.c:
timestamp=`date +%Y%m%d-%H%M%S`; \
pid="$$$$"; \
id="build-$$hostname-$$USER-$$timestamp-$$pid"; \
- echo 'static char const build_id[] = "'$$id'";'; \
- echo 'char const * Formaline_BuildID (void)'; \
- echo '{'; \
- echo ' return build_id;'; \
- echo '}'; \
+ echo 'char const build_id[] = "'$$id'";'; \
} > $@
diff --git a/src/multistorage.cc b/src/multistorage.cc
index 374b667..6b16c75 100644
--- a/src/multistorage.cc
+++ b/src/multistorage.cc
@@ -2,97 +2,106 @@
#include "multistorage.hh"
-using namespace std;
-
-multistorage::
-multistorage ()
+namespace Formaline
{
-}
+ using namespace std;
-multistorage::
-~ multistorage ()
-{
- for (list<storage *>::const_iterator it = stores.begin();
- it != stores.end();
- ++ it)
+
+ multistorage::
+ multistorage ()
{
- delete * it;
}
-}
-void multistorage::
-add_storage (storage * const s)
-{
- stores.push_front (s);
-}
+ multistorage::
+ ~ multistorage ()
+ {
+ for (list<storage *>::const_iterator it = stores.begin();
+ it != stores.end();
+ ++ it)
+ {
+ delete * it;
+ }
+ }
-int multistorage::
-num_storages ()
- const
-{
- return stores.size();
-}
+ void multistorage::
+ add_storage (storage * const s)
+ {
+ stores.push_front (s);
+ }
-void multistorage::
-store (char const * const key, bool const value)
- const
-{
- for (list<storage *>::const_iterator it = stores.begin();
- it != stores.end();
- ++ it)
+ int multistorage::
+ num_storages ()
+ const
{
- (* it)->store (key, value);
+ return stores.size();
}
-}
-void multistorage::
-store (char const * const key, int const value)
- const
-{
- for (list<storage *>::const_iterator it = stores.begin();
- it != stores.end();
- ++ it)
+ void multistorage::
+ store (char const * const key, bool const value)
+ const
{
- (* it)->store (key, value);
+ for (list<storage *>::const_iterator it = stores.begin();
+ it != stores.end();
+ ++ it)
+ {
+ (* it)->store (key, value);
+ }
}
-}
-void multistorage::
-store (char const * const key, double const value)
- const
-{
- for (list<storage *>::const_iterator it = stores.begin();
- it != stores.end();
- ++ it)
+ void multistorage::
+ store (char const * const key, int const value)
+ const
{
- (* it)->store (key, value);
+ for (list<storage *>::const_iterator it = stores.begin();
+ it != stores.end();
+ ++ it)
+ {
+ (* it)->store (key, value);
+ }
}
-}
-void multistorage::
-store (char const * const key, char const * const value)
- const
-{
- for (list<storage *>::const_iterator it = stores.begin();
- it != stores.end();
- ++ it)
+ void multistorage::
+ store (char const * const key, double const value)
+ const
+ {
+ for (list<storage *>::const_iterator it = stores.begin();
+ it != stores.end();
+ ++ it)
+ {
+ (* it)->store (key, value);
+ }
+ }
+
+
+
+ void multistorage::
+ store (char const * const key, char const * const value)
+ const
{
- (* it)->store (key, value);
+ for (list<storage *>::const_iterator it = stores.begin();
+ it != stores.end();
+ ++ it)
+ {
+ (* it)->store (key, value);
+ }
}
-}
+
+
+
+} // namespace Formaline
diff --git a/src/multistorage.hh b/src/multistorage.hh
index 50ad470..4614864 100644
--- a/src/multistorage.hh
+++ b/src/multistorage.hh
@@ -1,55 +1,64 @@
// $Header$
-#ifndef MULTISTORAGE_HH
-#define MULTISTORAGE_HH
+#ifndef FORMALINE_MULTISTORAGE_HH
+#define FORMALINE_MULTISTORAGE_HH
#include <list>
#include "storage.hh"
-using namespace std;
-
-class multistorage
+namespace Formaline
{
- list<storage *> stores;
+
+ using namespace std;
+
+
+
+ class multistorage
+ {
+ list<storage *> stores;
- multistorage (multistorage const &);
+ multistorage (multistorage const &);
- multistorage
- operator= (multistorage const &);
+ multistorage
+ operator= (multistorage const &);
-public:
+ public:
- multistorage ();
+ multistorage ();
- ~ multistorage ();
+ ~ multistorage ();
- void
- add_storage (storage *);
+ void
+ add_storage (storage *);
- int
- num_storages ()
- const;
+ int
+ num_storages ()
+ const;
- void
- store (char const * key, bool value)
- const;
+ void
+ store (char const * key, bool value)
+ const;
- void
- store (char const * key, int value)
- const;
+ void
+ store (char const * key, int value)
+ const;
- void
- store (char const * key, double value)
- const;
+ void
+ store (char const * key, double value)
+ const;
- void
- store (char const * key, char const * value)
- const;
-};
+ void
+ store (char const * key, char const * value)
+ const;
+ };
+
+
+
+} // namespace Formaline
-#endif // ifndef MULTISTORAGE_HH
+#endif // ifndef FORMALINE_MULTISTORAGE_HH
diff --git a/src/output_source.c b/src/output_source.c
index d7529fc..d319f72 100644
--- a/src/output_source.c
+++ b/src/output_source.c
@@ -26,7 +26,12 @@ extern size_t const cactus_source_length;
int
-Formaline_OutputSource ()
+Formaline_OutputSource (void);
+
+
+
+int
+Formaline_OutputSource (void)
{
DECLARE_CCTK_PARAMETERS;
@@ -34,7 +39,7 @@ Formaline_OutputSource ()
FILE * file;
int count;
- if (CCTK_MyProc (0) != 0) return;
+ if (CCTK_MyProc (0) != 0) return 0;
{ CCTK_PRINTSEPARATOR }
CCTK_VInfo (CCTK_THORNSTRING,
diff --git a/src/portal.cc b/src/portal.cc
index a0bcdba..fe6b7bd 100644
--- a/src/portal.cc
+++ b/src/portal.cc
@@ -16,293 +16,300 @@
-using namespace std;
+namespace Formaline
+{
+ using namespace std;
-extern int h_errno;
+ extern "C" int h_errno;
-portal::
-portal (char const * const id,
- enum state const st)
- : storage (st),
- errorcount (0)
-{
- DECLARE_CCTK_PARAMETERS;
-
- sock = socket (PF_INET, SOCK_STREAM, 0);
- if (sock < 0)
+
+ portal::
+ portal (char const * const id,
+ enum state const st)
+ : storage (st),
+ errorcount (0)
{
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "%s", strerror (errno));
- }
+ DECLARE_CCTK_PARAMETERS;
- struct hostent * hostinfo;
- hostinfo = gethostbyname (portal_hostname);
- if (hostinfo == 0)
- {
- switch (h_errno)
+ sock = socket (PF_INET, SOCK_STREAM, 0);
+ if (sock < 0)
{
- case HOST_NOT_FOUND:
- CCTK_WARN (1, "The specified host is unknown.");
- break;
- case NO_ADDRESS:
- // case NO_DATA:
- CCTK_WARN (1, "The requested name is valid but does not have an IP address.");
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "%s", strerror (errno));
+ }
+
+ struct hostent * hostinfo;
+ hostinfo = gethostbyname (portal_hostname);
+ if (hostinfo == 0)
+ {
+ switch (h_errno)
+ {
+ case HOST_NOT_FOUND:
+ CCTK_WARN (1, "The specified host is unknown.");
+ break;
+ case NO_ADDRESS:
+ // case NO_DATA:
+ CCTK_WARN (1, "The requested name is valid but does not have an IP address.");
+ break;
+ case NO_RECOVERY:
+ CCTK_WARN (1, "A non-recoverable name server error occurred.");
+ break;
+ case TRY_AGAIN:
+ CCTK_WARN (1, "A temporary error occurred on an authoritative name server. Try again later.");
+ break;
+ default:
+ CCTK_WARN (1, "unknown error");
+ }
+ }
+
+ struct sockaddr_in addr;
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons (portal_port);
+ addr.sin_addr = * (struct in_addr *) hostinfo->h_addr;
+
+ int const ierr
+ = connect (sock, (struct sockaddr const *) (& addr), sizeof addr);
+ if (ierr < 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "%s", strerror (errno));
+ }
+
+ msgbuf << "<?xml version='1.0' ?>"
+ << "<methodCall><methodName>";
+ switch (get_state())
+ {
+ case initial:
+ msgbuf << "cactus.registerApplication";
break;
- case NO_RECOVERY:
- CCTK_WARN (1, "A non-recoverable name server error occurred.");
+ case update:
+ msgbuf << "cactus.updateApplication";
break;
- case TRY_AGAIN:
- CCTK_WARN (1, "A temporary error occurred on an authoritative name server. Try again later.");
+ case final:
+ msgbuf << "cactus.deregisterApplication";
break;
default:
- CCTK_WARN (1, "unknown error");
+ assert (0);
}
+ msgbuf << "</methodName>"
+ << "<params><param><value><struct>"
+ << "<member>"
+ << "<name>jobid</name>"
+ << "<value><string>" << clean (id) << "</string></value>"
+ << "</member>";
}
-
- struct sockaddr_in addr;
- addr.sin_family = AF_INET;
- addr.sin_port = htons (portal_port);
- addr.sin_addr = * (struct in_addr *) hostinfo->h_addr;
-
- int const ierr
- = connect (sock, (struct sockaddr const *) (& addr), sizeof addr);
- if (ierr < 0)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "%s", strerror (errno));
- }
-
- msgbuf << "<?xml version='1.0' ?>"
- << "<methodCall><methodName>";
- switch (get_state())
- {
- case initial:
- msgbuf << "cactus.registerApplication";
- break;
- case update:
- msgbuf << "cactus.updateApplication";
- break;
- case final:
- msgbuf << "cactus.deregisterApplication";
- break;
- default:
- assert (0);
- }
- msgbuf << "</methodName>"
- << "<params><param><value><struct>"
- << "<member>"
- << "<name>jobid</name>"
- << "<value><string>" << clean (id) << "</string></value>"
- << "</member>";
-}
-portal::
-~ portal ()
-{
- msgbuf << "</struct></value></param></params>";
- msgbuf << "</methodCall>";
- string const msgstr = msgbuf.str();
+ portal::
+ ~ portal ()
+ {
+ msgbuf << "</struct></value></param></params>";
+ msgbuf << "</methodCall>";
+ string const msgstr = msgbuf.str();
- ostringstream buf;
- buf << "POST HTTP/1.0 200\r\n"
- << "Content-Type: text/xml\r\n"
- << "Content-Length: " << msgstr.length() << "\r\n"
- << "\r\n"
- << msgstr << "\r\n"
- << "\r\n";
- write (buf.str());
+ ostringstream buf;
+ buf << "POST HTTP/1.0 200\r\n"
+ << "Content-Type: text/xml\r\n"
+ << "Content-Length: " << msgstr.length() << "\r\n"
+ << "\r\n"
+ << msgstr << "\r\n"
+ << "\r\n";
+ write (buf.str());
- CLOSESOCKET (sock);
-}
+ CLOSESOCKET (sock);
+ }
-void portal::
-store (char const * const key,
- bool const value)
-{
- assert (key);
+ void portal::
+ store (char const * const key,
+ bool const value)
+ {
+ assert (key);
- ostringstream keybuf;
- keybuf << key;
- ostringstream valuebuf;
- valuebuf << (value ? "true" : "false");
+ ostringstream keybuf;
+ keybuf << key;
+ ostringstream valuebuf;
+ valuebuf << (value ? "true" : "false");
- msgbuf << "<member>"
- << "<name>" << clean (keybuf.str()) << "</name>"
- << "<value><boolean>" << clean (valuebuf.str()) << "</boolean></value>"
- << "</member>";
-}
+ msgbuf << "<member>"
+ << "<name>" << clean (keybuf.str()) << "</name>"
+ << "<value><boolean>" << clean (valuebuf.str()) << "</boolean></value>"
+ << "</member>";
+ }
-void portal::
-store (char const * const key,
- int const value)
-{
- assert (key);
+ void portal::
+ store (char const * const key,
+ int const value)
+ {
+ assert (key);
- ostringstream keybuf;
- keybuf << key;
- ostringstream valuebuf;
- valuebuf << value;
+ ostringstream keybuf;
+ keybuf << key;
+ ostringstream valuebuf;
+ valuebuf << value;
- msgbuf << "<member>"
- << "<name>" << clean (keybuf.str()) << "</name>"
- << "<value><int>" << clean (valuebuf.str()) << "</int></value>"
- << "</member>";
-}
+ msgbuf << "<member>"
+ << "<name>" << clean (keybuf.str()) << "</name>"
+ << "<value><int>" << clean (valuebuf.str()) << "</int></value>"
+ << "</member>";
+ }
-void portal::
-store (char const * const key,
- double const value)
-{
- assert (key);
+ void portal::
+ store (char const * const key,
+ double const value)
+ {
+ assert (key);
- ostringstream keybuf;
- keybuf << key;
- ostringstream valuebuf;
- valuebuf << setprecision(15) << value;
+ ostringstream keybuf;
+ keybuf << key;
+ ostringstream valuebuf;
+ valuebuf << setprecision(15) << value;
- msgbuf << "<member>"
- << "<name>" << clean (keybuf.str()) << "</name>"
- << "<value><double>" << clean (valuebuf.str()) << "</double></value>"
- << "</member>";
-}
+ msgbuf << "<member>"
+ << "<name>" << clean (keybuf.str()) << "</name>"
+ << "<value><double>" << clean (valuebuf.str()) << "</double></value>"
+ << "</member>";
+ }
-void portal::
-store (char const * const key,
- char const * const value)
-{
- assert (key);
+ void portal::
+ store (char const * const key,
+ char const * const value)
+ {
+ assert (key);
- ostringstream keybuf;
- keybuf << key;
- ostringstream valuebuf;
- valuebuf << value;
+ ostringstream keybuf;
+ keybuf << key;
+ ostringstream valuebuf;
+ valuebuf << value;
- msgbuf << "<member>"
- << "<name>" << clean (keybuf.str()) << "</name>"
- << "<value><string>" << clean (valuebuf.str()) << "</string></value>"
- << "</member>";
-}
+ msgbuf << "<member>"
+ << "<name>" << clean (keybuf.str()) << "</name>"
+ << "<value><string>" << clean (valuebuf.str()) << "</string></value>"
+ << "</member>";
+ }
-void portal::
-write (string const & msg0)
-{
- // cout << "[" << msg0 << "]" << endl;
- string msg = msg0;
- for (;;)
+ void portal::
+ write (string const & msg0)
{
+ // cout << "[" << msg0 << "]" << endl;
+ string msg = msg0;
+ for (;;)
+ {
- char const * const cmsg = msg.c_str();
- size_t const len = msg.length();
+ char const * const cmsg = msg.c_str();
+ size_t const len = msg.length();
- // TODO: Make sure that we don't wait forever here. Maybe use
- // MSG_DONTWAIT.
- ssize_t const nelems = send (sock, cmsg, len, MSG_NOSIGNAL);
- if (nelems < 0)
- {
-#ifdef EMSGSIZE
- if (nelems == EMSGSIZE)
+ // TODO: Make sure that we don't wait forever here. Maybe use
+ // MSG_DONTWAIT.
+ ssize_t const nelems = send (sock, cmsg, len, MSG_NOSIGNAL);
+ if (nelems < 0)
{
- // The socket type requires that message be sent atomically,
- // and the size of the message to be sent made this
- // impossible.
- // Try to send the message as two smaller messages.
- if (len > 0)
+#ifdef EMSGSIZE
+ if (nelems == EMSGSIZE)
{
- string const msg1 = msg.substr (0, len/2);
- string const msg2 = msg.substr (len/2);
- write (msg1);
- write (msg2);
+ // The socket type requires that message be sent atomically,
+ // and the size of the message to be sent made this
+ // impossible.
+ // Try to send the message as two smaller messages.
+ if (len > 0)
+ {
+ string const msg1 = msg.substr (0, len/2);
+ string const msg2 = msg.substr (len/2);
+ write (msg1);
+ write (msg2);
+ }
+ else
+ {
+ // There is a limit. In order to not be too inefficient,
+ // just do nothing if even small messages cannot be sent.
+ }
}
else
- {
- // There is a limit. In order to not be too inefficient,
- // just do nothing if even small messages cannot be sent.
- }
- }
- else
#endif
- {
- int const maxerrors = 10;
- ++ errorcount;
- if (errorcount <= maxerrors)
{
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "%s", strerror (errno));
- if (errorcount == maxerrors)
+ int const maxerrors = 10;
+ ++ errorcount;
+ if (errorcount <= maxerrors)
{
- CCTK_WARN (1, "Too many errors. Suppressing further error messages.");
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "%s", strerror (errno));
+ if (errorcount == maxerrors)
+ {
+ CCTK_WARN (1, "Too many errors. Suppressing further error messages.");
+ }
}
}
+ return;
}
- return;
- }
- if (nelems == len) return;
+ if (nelems == len) return;
- // Wait until can write
- fd_set fds;
- FD_ZERO (& fds);
- assert (sock >= 0 and sock < FD_SETSIZE);
- FD_SET (sock, & fds);
- struct timeval timeout;
- timeout.tv_sec = 10; // wait no more than ten seconds
- timeout.tv_usec = 0;
- // TODO: Make sure that we don't wait forever here.
- int const icnt = select (FD_SETSIZE, 0, & fds, 0, & timeout);
- if (icnt == 0)
- {
- // There was a timeout
- CCTK_WARN (1, "Timeout: could not send message");
- return;
- }
- else if (icnt < 0)
- {
- // There was an error
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "%s", strerror (errno));
- return;
- }
+ // Wait until can write
+ fd_set fds;
+ FD_ZERO (& fds);
+ assert (sock >= 0 and sock < FD_SETSIZE);
+ FD_SET (sock, & fds);
+ struct timeval timeout;
+ timeout.tv_sec = 10; // wait no more than ten seconds
+ timeout.tv_usec = 0;
+ // TODO: Make sure that we don't wait forever here.
+ int const icnt = select (FD_SETSIZE, 0, & fds, 0, & timeout);
+ if (icnt == 0)
+ {
+ // There was a timeout
+ CCTK_WARN (1, "Timeout: could not send message");
+ return;
+ }
+ else if (icnt < 0)
+ {
+ // There was an error
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "%s", strerror (errno));
+ return;
+ }
- // Remove the characters that have been sent
- assert (nelems < len);
- msg = msg.substr (nelems);
+ // Remove the characters that have been sent
+ assert (nelems < len);
+ msg = msg.substr (nelems);
+ }
}
-}
-string portal::
-clean (string const & txt)
- const
-{
- ostringstream buf;
-
- for (string::const_iterator p = txt.begin(); p != txt.end(); ++ p)
+ string portal::
+ clean (string const & txt)
+ const
{
- switch (* p)
+ ostringstream buf;
+
+ for (string::const_iterator p = txt.begin(); p != txt.end(); ++ p)
{
- case '<': buf << "&lt;"; break;
- case '&': buf << "&amp;"; break;
- default: buf << * p;
+ switch (* p)
+ {
+ case '<': buf << "&lt;"; break;
+ case '&': buf << "&amp;"; break;
+ default: buf << * p;
+ }
}
- }
- return buf.str();
-}
+ return buf.str();
+ }
+
+
+
+} // namespace Formaline
diff --git a/src/portal.hh b/src/portal.hh
index b763654..c6237a7 100644
--- a/src/portal.hh
+++ b/src/portal.hh
@@ -1,7 +1,7 @@
// $Header$
-#ifndef PORTAL_HH
-#define PORTAL_HH
+#ifndef FORMALINE_PORTAL_HH
+#define FORMALINE_PORTAL_HH
@@ -54,49 +54,58 @@
-class portal : public storage
+namespace Formaline
{
+
+
+
+ class portal : public storage
+ {
- SOCKET sock;
+ SOCKET sock;
- std::ostringstream msgbuf;
+ std::ostringstream msgbuf;
- int errorcount;
+ int errorcount;
-public:
+ public:
- portal (char const * id,
- enum state st);
+ portal (char const * id,
+ enum state st);
- virtual
- ~ portal ();
+ virtual
+ ~ portal ();
- virtual void
- store (char const * key,
- bool value);
+ virtual void
+ store (char const * key,
+ bool value);
- virtual void
- store (char const * key,
- int value);
+ virtual void
+ store (char const * key,
+ int value);
- virtual void
- store (char const * key,
- double value);
+ virtual void
+ store (char const * key,
+ double value);
- virtual void
- store (char const * key,
- char const * value);
+ virtual void
+ store (char const * key,
+ char const * value);
-private:
+ private:
- void
- write (std::string const & msg);
+ void
+ write (std::string const & msg);
- std::string
- clean (std::string const & txt)
- const;
-};
+ std::string
+ clean (std::string const & txt)
+ const;
+ };
+
+
+
+} // namespace Formaline
-#endif // ifndef PORTAL_HH
+#endif // ifndef FORMALINE_PORTAL_HH
diff --git a/src/storage.cc b/src/storage.cc
index dee2659..8ee6b6d 100644
--- a/src/storage.cc
+++ b/src/storage.cc
@@ -4,29 +4,37 @@
#include "storage.hh"
-using namespace std;
-
-storage::
-storage (enum state const st)
- : m_state (st)
+namespace Formaline
{
-}
+ using namespace std;
-storage::
-~ storage ()
-{
-}
+ storage::
+ storage (enum state const st)
+ : m_state (st)
+ {
+ }
+
+
+
+ storage::
+ ~ storage ()
+ {
+ }
+
+
+
+ enum storage::state storage::
+ get_state ()
+ const
+ {
+ return m_state;
+ }
-enum storage::state storage::
-get_state ()
- const
-{
- return m_state;
-}
+} // namespace Formaline
diff --git a/src/storage.hh b/src/storage.hh
index 00a9c43..b78fc1f 100644
--- a/src/storage.hh
+++ b/src/storage.hh
@@ -1,52 +1,61 @@
// $Header$
-#ifndef STORAGE_HH
-#define STORAGE_HH
+#ifndef FORMALINE_STORAGE_HH
+#define FORMALINE_STORAGE_HH
-class storage
+namespace Formaline
{
-public:
+
+
+
+ class storage
+ {
+ public:
- enum state { initial, update, final };
+ enum state { initial, update, final };
-private:
+ private:
- enum state m_state;
+ enum state m_state;
-public:
+ public:
- storage (enum state);
+ storage (enum state);
- virtual
- ~ storage ();
+ virtual
+ ~ storage ();
- enum state
- get_state ()
- const;
+ enum state
+ get_state ()
+ const;
- virtual void
- store (char const * key,
- bool value)
- = 0;
+ virtual void
+ store (char const * key,
+ bool value)
+ = 0;
- virtual void
- store (char const * key,
- int value)
- = 0;
+ virtual void
+ store (char const * key,
+ int value)
+ = 0;
- virtual void
- store (char const * key,
- double value)
- = 0;
+ virtual void
+ store (char const * key,
+ double value)
+ = 0;
- virtual void
- store (char const * key,
- char const * value)
- = 0;
-};
+ virtual void
+ store (char const * key,
+ char const * value)
+ = 0;
+ };
+
+
+
+} // namespace Formaline
-#endif // ifndef STORAGE_HH
+#endif // ifndef FORMALINE_STORAGE_HH