aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2006-06-14 18:29:46 +0000
committerschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2006-06-14 18:29:46 +0000
commit6ef9a668200bbe058d75b4da9ad9a87b5a10513b (patch)
treee94bcdd3c00b72bc17adf865887527b6d87b2eb6
parent4f7cb5b9a1ba8ece2f1d5a6ad6411e107c806b9f (diff)
Make things work when CCTK_REAL is not double and when CCTK_INT is not
int. Rename field "simulation id" to "jobid" when writing to a file. This makes the field name consistent with thorn Announce. Announce field "jobid" with RDF. git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@84 83718e91-0e4f-0410-abf4-91180603181f
-rw-r--r--src/file.cc24
-rw-r--r--src/file.hh4
-rw-r--r--src/multistorage.cc4
-rw-r--r--src/multistorage.hh86
-rw-r--r--src/portal.cc16
-rw-r--r--src/portal.hh4
-rw-r--r--src/rdf.cc19
-rw-r--r--src/rdf.hh4
-rw-r--r--src/storage.hh6
9 files changed, 141 insertions, 26 deletions
diff --git a/src/file.cc b/src/file.cc
index 522ba98..b88d548 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -34,7 +34,7 @@ namespace Formaline
if (get_state() == initial)
{
- store ("simulation id", id);
+ store ("jobid", id);
}
}
@@ -73,7 +73,7 @@ namespace Formaline
void file::
store (char const * const key,
- int const value)
+ CCTK_INT const value)
{
assert (key);
@@ -92,18 +92,28 @@ namespace Formaline
void file::
store (char const * const key,
- double const value)
+ CCTK_REAL const value)
{
assert (key);
-
+
+#if defined CCTK_REAL_PRECISION_4
+ int const prec = 6;
+#elif defined CCTK_REAL_PRECISION_8
+ int const prec = 15;
+#elif defined CCTK_REAL_PRECISION_16
+ int const prec = 30;
+#else
+ int const prec = 15;
+#endif
+
ostringstream keybuf;
keybuf << key;
ostringstream valuebuf;
- valuebuf << setprecision(15) << value;
-
+ valuebuf << setprecision(prec) << value;
+
ostringstream buf;
buf << clean (keybuf.str()) << "=" << clean (valuebuf.str()) << endl;
-
+
write (buf.str());
}
diff --git a/src/file.hh b/src/file.hh
index e9b8af3..cbbcd3c 100644
--- a/src/file.hh
+++ b/src/file.hh
@@ -33,11 +33,11 @@ namespace Formaline
virtual void
store (char const * key,
- int value);
+ CCTK_INT value);
virtual void
store (char const * key,
- double value);
+ CCTK_REAL value);
virtual void
store (char const * key,
diff --git a/src/multistorage.cc b/src/multistorage.cc
index 96bbcc7..6d7e041 100644
--- a/src/multistorage.cc
+++ b/src/multistorage.cc
@@ -63,7 +63,7 @@ namespace Formaline
void multistorage::
- store (char const * const key, int const value)
+ store (char const * const key, CCTK_INT const value)
const
{
for (list<storage *>::const_iterator it = stores.begin();
@@ -77,7 +77,7 @@ namespace Formaline
void multistorage::
- store (char const * const key, double const value)
+ store (char const * const key, CCTK_REAL const value)
const
{
for (list<storage *>::const_iterator it = stores.begin();
diff --git a/src/multistorage.hh b/src/multistorage.hh
index 4614864..7311290 100644
--- a/src/multistorage.hh
+++ b/src/multistorage.hh
@@ -5,6 +5,8 @@
#include <list>
+#include "cctk.h"
+
#include "storage.hh"
@@ -43,16 +45,96 @@ namespace Formaline
const;
void
- store (char const * key, int value)
+ store (char const * key, CCTK_INT value)
const;
void
- store (char const * key, double value)
+ store (char const * key, CCTK_REAL value)
const;
void
store (char const * key, char const * value)
const;
+
+
+
+#ifdef HAVE_CCTK_INT1
+# ifndef CCTK_INTEGER_PRECISION_1
+ void
+ store (char const * key, CCTK_INT1 value)
+ const
+ {
+ store (key, static_cast<CCTK_INT> (value));
+ }
+# endif
+#endif
+
+#ifdef HAVE_CCTK_INT2
+# ifndef CCTK_INTEGER_PRECISION_2
+ void
+ store (char const * key, CCTK_INT2 value)
+ const
+ {
+ store (key, static_cast<CCTK_INT> (value));
+ }
+# endif
+#endif
+
+#ifdef HAVE_CCTK_INT4
+# ifndef CCTK_INTEGER_PRECISION_4
+ void
+ store (char const * key, CCTK_INT4 value)
+ const
+ {
+ store (key, static_cast<CCTK_INT> (value));
+ }
+# endif
+#endif
+
+#ifdef HAVE_CCTK_INT8
+# ifndef CCTK_INTEGER_PRECISION_8
+ void
+ store (char const * key, CCTK_INT8 value)
+ const
+ {
+ store (key, static_cast<CCTK_INT> (value));
+ }
+# endif
+#endif
+
+#ifdef HAVE_CCTK_REAL4
+# ifndef CCTK_REAL_PRECISION_4
+ void
+ store (char const * key, CCTK_REAL4 value)
+ const
+ {
+ store (key, static_cast<CCTK_REAL> (value));
+ }
+# endif
+#endif
+
+#ifdef HAVE_CCTK_REAL8
+# ifndef CCTK_REAL_PRECISION_8
+ void
+ store (char const * key, CCTK_REAL8 value)
+ const
+ {
+ store (key, static_cast<CCTK_REAL> (value));
+ }
+# endif
+#endif
+
+#ifdef HAVE_CCTK_REAL16
+# ifndef CCTK_REAL_PRECISION_16
+ void
+ store (char const * key, CCTK_REAL16 value)
+ const
+ {
+ store (key, static_cast<CCTK_REAL> (value));
+ }
+# endif
+#endif
+
};
diff --git a/src/portal.cc b/src/portal.cc
index be5aab4..83e26fb 100644
--- a/src/portal.cc
+++ b/src/portal.cc
@@ -359,7 +359,7 @@ namespace Formaline
void portal::
store (char const * const key,
- int const value)
+ CCTK_INT const value)
{
assert (key);
@@ -378,14 +378,24 @@ namespace Formaline
void portal::
store (char const * const key,
- double const value)
+ CCTK_REAL const value)
{
assert (key);
+
+#if defined CCTK_REAL_PRECISION_4
+ int const prec = 6;
+#elif defined CCTK_REAL_PRECISION_8
+ int const prec = 15;
+#elif defined CCTK_REAL_PRECISION_16
+ int const prec = 30;
+#else
+ int const prec = 15;
+#endif
ostringstream keybuf;
keybuf << key;
ostringstream valuebuf;
- valuebuf << setprecision(15) << value;
+ valuebuf << setprecision(prec) << value;
msgbuf << "<member>"
<< "<name>" << clean (keybuf.str()) << "</name>"
diff --git a/src/portal.hh b/src/portal.hh
index a91fa6d..009dda7 100644
--- a/src/portal.hh
+++ b/src/portal.hh
@@ -34,11 +34,11 @@ namespace Formaline
virtual void
store (char const * key,
- int value);
+ CCTK_INT value);
virtual void
store (char const * key,
- double value);
+ CCTK_REAL value);
virtual void
store (char const * key,
diff --git a/src/rdf.cc b/src/rdf.cc
index 40d9233..6add0a2 100644
--- a/src/rdf.cc
+++ b/src/rdf.cc
@@ -65,7 +65,8 @@ namespace Formaline
<< " xmlns:form=\"&form;\"" << endl
<< ">" << endl
<< endl
-<< "<form:Simulation>" << endl;
+<< "<form:Simulation>" << endl
+<< "<form:jobid>" << clean (string (id)) << "</form:jobid>" << endl;
}
@@ -337,7 +338,7 @@ namespace Formaline
void rdf::
store (char const * const key,
- int const value)
+ CCTK_INT const value)
{
assert (key);
@@ -367,14 +368,24 @@ namespace Formaline
void rdf::
store (char const * const key,
- double const value)
+ CCTK_REAL const value)
{
assert (key);
+
+#if defined CCTK_REAL_PRECISION_4
+ int const prec = 6;
+#elif defined CCTK_REAL_PRECISION_8
+ int const prec = 15;
+#elif defined CCTK_REAL_PRECISION_16
+ int const prec = 30;
+#else
+ int const prec = 15;
+#endif
ostringstream keybuf;
keybuf << key;
ostringstream valuebuf;
- valuebuf << setprecision(15) << value;
+ valuebuf << setprecision(prec) << value;
list<string> const keys = parse (keybuf.str());
diff --git a/src/rdf.hh b/src/rdf.hh
index 610842f..a0fde28 100644
--- a/src/rdf.hh
+++ b/src/rdf.hh
@@ -34,11 +34,11 @@ namespace Formaline
virtual void
store (char const * key,
- int value);
+ CCTK_INT value);
virtual void
store (char const * key,
- double value);
+ CCTK_REAL value);
virtual void
store (char const * key,
diff --git a/src/storage.hh b/src/storage.hh
index b78fc1f..1564f60 100644
--- a/src/storage.hh
+++ b/src/storage.hh
@@ -3,6 +3,8 @@
#ifndef FORMALINE_STORAGE_HH
#define FORMALINE_STORAGE_HH
+#include "cctk.h"
+
namespace Formaline
@@ -38,12 +40,12 @@ namespace Formaline
virtual void
store (char const * key,
- int value)
+ CCTK_INT value)
= 0;
virtual void
store (char const * key,
- double value)
+ CCTK_REAL value)
= 0;
virtual void