aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <schnetter@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a>2009-12-05 03:05:34 +0000
committerschnetter <schnetter@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a>2009-12-05 03:05:34 +0000
commit2b1ab2af92b8c90e90600fa9883f4bee05599bc0 (patch)
tree94aa61fb638955ba61fcd5cba7f59b217fc670ed
parent7a6d82df527b83c66d8e053a5edd6778b3907011 (diff)
IOUtil: Update parsing API to allow output by simulation time
Update the parsing API to allow output by simulation time (out_dt) in addition to output by iteration (out_every). This adds an additional parameter to IOUtil_ParseVarsForOutput. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@274 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a
-rw-r--r--src/Utils.c67
-rw-r--r--src/ioutil_Utils.h13
2 files changed, 71 insertions, 9 deletions
diff --git a/src/Utils.c b/src/Utils.c
index 10de8c8..f23d1ae 100644
--- a/src/Utils.c
+++ b/src/Utils.c
@@ -43,6 +43,7 @@ typedef struct
const char *method_name;
const char *parameter_name;
int out_every_default;
+ CCTK_REAL out_dt_default;
} info_t;
@@ -95,6 +96,11 @@ static void SetOutputVar (int vindex, const char *optstring, void *arg);
@vtype int
@vio in
@endvar
+ @var out_dt_default
+ @vdesc default output frequency to set the I/O request to
+ @vtype CCTK_REAL
+ @vio in
+ @endvar
@var request_list
@vdesc list of I/O requests to fill out
@vtype ioRequest *[]
@@ -104,7 +110,8 @@ static void SetOutputVar (int vindex, const char *optstring, void *arg);
void IOUtil_ParseVarsForOutput (const cGH *GH, const char *method_name,
const char *parameter_name,
int stop_on_parse_errors,
- const char *out_vars, int out_every_default,
+ const char *out_vars,
+ int out_every_default, CCTK_REAL out_dt_default,
ioRequest *request_list[])
{
int i;
@@ -126,6 +133,7 @@ void IOUtil_ParseVarsForOutput (const cGH *GH, const char *method_name,
info.method_name = method_name;
info.parameter_name = parameter_name;
info.out_every_default = out_every_default;
+ info.out_dt_default = out_dt_default;
if (CCTK_TraverseString (out_vars, SetOutputVar, &info, CCTK_GROUP_OR_VAR)<0)
{
CCTK_VWarn (stop_on_parse_errors ? 0 : 1,
@@ -164,7 +172,8 @@ void IOUtil_FreeIORequest (ioRequest **request)
@author Thomas Radke
@desc
Parses the option string for a given variable for the
- 'out_every' option and sets its output frequency.
+ 'out_every' and 'out_dt' options and sets its output
+ frequency.
@enddesc
@calls Util_TableCreateFromString
@@ -200,12 +209,18 @@ void IOUtil_FreeIORequest (ioRequest **request)
@vtype int *
@vio out
@endvar
+ @var out_dt_ptr
+ @vdesc pointer to the variable's output frequency flag
+ @vtype CCTK_REAL *
+ @vio out
+ @endvar
@@*/
void IOUtil_ParseOutputFrequency (const char *method_name,
const char *parameter_name,
int stop_on_parse_errors,
int vindex, const char *optstring,
- CCTK_INT *out_every_ptr)
+ CCTK_INT *out_every_ptr,
+ CCTK_REAL *out_dt_ptr)
{
int table, iterator, warnlevel;
char key[128];
@@ -238,6 +253,25 @@ void IOUtil_ParseOutputFrequency (const char *method_name,
Util_TableDeleteKey (table, "out_every");
}
+ if (Util_TableQueryValueInfo (table, &type, &nelems, "out_dt") > 0)
+ {
+ if (type == CCTK_VARIABLE_REAL && nelems == 1)
+ {
+ Util_TableGetReal (table, out_dt_ptr, "out_dt");
+ }
+ else
+ {
+ CCTK_VWarn (warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Invalid value for option 'out_dt' in option string "
+ "'%s' in parameter '%s' (must be real)",
+ optstring, parameter_name);
+ CCTK_VWarn (warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Option will be ignored for %s output of variable '%s'",
+ method_name, fullname);
+ }
+ Util_TableDeleteKey (table, "out_dt");
+ }
+
/* warn about other options */
iterator = Util_TableItCreate (table);
for (iterator = Util_TableItCreate (table);
@@ -804,7 +838,8 @@ static void SetOutputVar (int vindex, const char *optstring, void *arg)
/* allocate a new I/O request structure and initialize it with defaults */
- request = IOUtil_DefaultIORequest (info->GH, vindex, info->out_every_default);
+ request = IOUtil_DefaultIORequest
+ (info->GH, vindex, info->out_every_default, info->out_dt_default);
if (! optstring)
{
@@ -837,6 +872,26 @@ static void SetOutputVar (int vindex, const char *optstring, void *arg)
Util_TableDeleteKey (table, "out_every");
}
+ /* check for option 'out_dt' */
+ if (Util_TableQueryValueInfo (table, &type, &nelems, "out_dt") > 0)
+ {
+ if (type == CCTK_VARIABLE_REAL && nelems == 1)
+ {
+ Util_TableGetReal (table, &request->out_dt, "out_dt");
+ }
+ else
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Invalid value for option 'out_dt' in option string "
+ "'%s' in parameter '%s' (must be real)",
+ optstring, info->parameter_name);
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Option 'out_dt' will be ignored for %s output of "
+ "variable '%s'", info->method_name, fullname);
+ }
+ Util_TableDeleteKey (table, "out_dt");
+ }
+
/* check for boolean option 'out_unchunked' */
if (Util_TableQueryValueInfo (table, &type, &nelems, "out_unchunked") > 0)
{
@@ -1095,7 +1150,8 @@ static void SetOutputVar (int vindex, const char *optstring, void *arg)
/* return the default I/O request description structure for a variable */
ioRequest *IOUtil_DefaultIORequest (const cGH *GH, int vindex,
- int out_every_default)
+ int out_every_default,
+ CCTK_REAL out_dt_default)
{
int vdim;
int *extent_int;
@@ -1121,6 +1177,7 @@ ioRequest *IOUtil_DefaultIORequest (const cGH *GH, int vindex,
request->timelevel = 0;
request->check_exist = myGH->recovered;
request->out_every = out_every_default;
+ request->out_dt = out_dt_default;
request->out_unchunked = out_unchunked;
request->reductions = NULL;
request->with_ghostzones = 0;
diff --git a/src/ioutil_Utils.h b/src/ioutil_Utils.h
index 3840e65..59db60e 100644
--- a/src/ioutil_Utils.h
+++ b/src/ioutil_Utils.h
@@ -22,6 +22,7 @@ typedef struct
{
/* output frequency */
CCTK_INT out_every;
+ CCTK_REAL out_dt;
/* index and timelevel of the variable */
int vindex, timelevel;
@@ -67,19 +68,23 @@ typedef struct
void IOUtil_ParseVarsForOutput (const cGH *GH, const char *method_name,
const char *parameter_name,
int stop_on_parse_errors,
- const char *out_vars, int out_every_default,
+ const char *out_vars,
+ int out_every_default, CCTK_REAL out_dt_default,
ioRequest *request_list[]);
-/* parse a given I/O parameter option string for the 'out_every' option */
+/* parse a given I/O parameter option string for the 'out_every' and
+ 'out_dt' options */
void IOUtil_ParseOutputFrequency (const char *method_name,
const char *parameter_name,
int stop_on_parse_errors,
int vindex, const char *optstring,
- CCTK_INT *out_every);
+ CCTK_INT *out_every,
+ CCTK_REAL *out_dt);
/* return the default I/O request description structure for a variable */
ioRequest *IOUtil_DefaultIORequest (const cGH *GH, int vindex,
- int out_every_default);
+ int out_every_default,
+ CCTK_REAL out_dt_default);
/* free an I/O request description */
void IOUtil_FreeIORequest (ioRequest **request);