aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2002-05-27 08:27:23 +0000
committertradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2002-05-27 08:27:23 +0000
commitf47de8d88998ed5b0fd4eb211dfa29745177852e (patch)
tree401000ed75a4f34ee21c33f73064eb95c5f88e4c
parent8721b2e2b1e533c3cbf400b5f6bf6417f635195e (diff)
Use key/value tables to parse option strings in the IOBasic::out*_vars
parameter. The only allowed option is "reductions = 'reduction list'". Note that the syntax for specifying reductions for individual variables slightly changed (see the thorn documentation for details). git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@129 b589c3ab-70e8-4b4d-a09f-cba2dd200880
-rw-r--r--src/Startup.c63
1 files changed, 51 insertions, 12 deletions
diff --git a/src/Startup.c b/src/Startup.c
index ab26165..069c0aa 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -14,6 +14,7 @@
#include "cctk.h"
#include "cctk_Parameters.h"
+#include "util_Table.h"
#include "CactusBase/IOUtil/src/ioutil_Utils.h"
#include "iobasicGH.h"
@@ -148,9 +149,7 @@ static void *IOBasic_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
/* get the name of IOBasic's output directory */
if (*out_dir == 0)
{
- out_dir = *(const char **)
- CCTK_ParameterGet ("out_dir", CCTK_ImplementationThorn ("IO"),
- NULL);
+ out_dir = io_out_dir;
}
/* skip the directory pathname if output goes into current directory */
@@ -221,9 +220,11 @@ static void *IOBasic_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
@@*/
void IOBasic_AssignReductionList (int vindex, const char *optstring, void *arg)
{
+ int table, iterator, reduction_handle;
+ char key[128];
+ CCTK_INT type, nelems;
const char *string_start, *string_end;
- char *reduction_op, *reduction_op_list;
- int reduction_handle;
+ char *fullname, *reduction_op, *reduction_op_list;
iobasic_reductionlist_t *list;
iobasic_reduction_t **new_reduction;
const iobasic_parseinfo_t *info;
@@ -269,18 +270,56 @@ void IOBasic_AssignReductionList (int vindex, const char *optstring, void *arg)
if (optstring)
{
- if (strncmp (optstring, "reductions=<", 12) == 0 &&
- optstring[strlen (optstring) - 1] == '>')
+ reduction_op_list = NULL;
+ fullname = CCTK_FullName (vindex);
+
+ table = Util_TableCreateFromString (optstring);
+ if (table >= 0)
{
- reduction_op_list = strdup (optstring + 12);
- reduction_op_list[strlen (reduction_op_list) - 1] = 0;
+ if (Util_TableQueryValueInfo (table, &type, &nelems, "reductions") > 0)
+ {
+ if (type == CCTK_VARIABLE_CHAR && nelems > 0)
+ {
+ reduction_op_list = malloc (nelems + 1);
+ Util_TableGetString (table, nelems + 1, reduction_op_list,
+ "reductions");
+ }
+ else
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Key 'reductions' in option string '%s' for variable "
+ "'%s' must have a non-empty string value",
+ optstring, fullname);
+ }
+ Util_TableDeleteKey (table, "reductions");
+ }
+
+ /* warn about other options */
+ iterator = Util_TableItCreate (table);
+ for (iterator = Util_TableItCreate (table);
+ Util_TableItQueryIsNonNull (iterator) > 0 &&
+ Util_TableItQueryKeyValueInfo (iterator, sizeof(key), key, 0, 0) > 0;
+ Util_TableItAdvance (iterator))
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Option with key '%s' in option string '%s' for variable "
+ "'%s' not recognized", key, optstring, fullname);
+ }
+ Util_TableItDestroy (iterator);
+
+ Util_TableDestroy (table);
}
else
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOBasic_AssignReductionList: invalid syntax for option list "
- "'%s'", optstring);
- return;
+ "Option string '%s' for variable '%s' couldn't be parsed",
+ optstring, fullname);
+ }
+ free (fullname);
+
+ if (! reduction_op_list)
+ {
+ reduction_op_list = strdup (info->reductions_string);
}
}
else