aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <schnetter@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2004-01-19 09:48:15 +0000
committerschnetter <schnetter@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2004-01-19 09:48:15 +0000
commit9f571db8c35923dff20723cd7ada7ff85ea6f317 (patch)
treeeaa0ebcdf79086399ae129e2b179b9827c27229b
parentfb75f270b21126d954d5da1119a038b881ba537d (diff)
Add mechanism to select output by coordinate time.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@147 b589c3ab-70e8-4b4d-a09f-cba2dd200880
-rw-r--r--doc/documentation.tex43
-rw-r--r--interface.ccl2
-rw-r--r--param.ccl29
-rw-r--r--schedule.ccl10
-rw-r--r--src/OutputInfo.c183
-rw-r--r--src/OutputScalar.c188
-rw-r--r--src/Startup.c25
-rw-r--r--src/WriteScalar.c6
-rw-r--r--src/iobasicGH.h5
9 files changed, 385 insertions, 106 deletions
diff --git a/doc/documentation.tex b/doc/documentation.tex
index a68b972..d5ff0a9 100644
--- a/doc/documentation.tex
+++ b/doc/documentation.tex
@@ -52,10 +52,20 @@ The I/O methods differ in the destination the output is written to:
%
Parameters to control the {\tt Scalar} I/O method are:
\begin{itemize}
+ \item {\tt IOBasic::outScalar\_criterion} (steerable)\\
+ The criterion that decides when to {\tt Scalar} output. If
+ this parameter is set in the parameter file, it will override
+ the setting of the shared {\tt IO::out\_criterion} parameter.
\item {\tt IOBasic::outScalar\_every} (steerable)\\
- How often to do {\tt Scalar} output. If this parameter is set in the
+ How often, in terms of iterations, to do {\tt Scalar} output.
+ If this parameter is set in the
parameter file, it will override the setting of the shared
{\tt IO::out\_every} parameter.
+ \item {\tt IOBasic::outScalar\_dt} (steerable)\\
+ How often, in terms of simulation time, to do {\tt Scalar}
+ output. If this parameter is set in the parameter file, it
+ will override the setting of the shared {\tt IO::out\_dt}
+ parameter.
\item {\tt IOBasic::out\_dir}\\
The directory in which to place the {\tt Scalar} ASCII output files.
If the directory doesn't exist at startup it will be created.\\
@@ -74,9 +84,11 @@ Parameters to control the {\tt Scalar} I/O method are:
\item {\tt IOBasic::outScalar\_vars} (steerable)\\
The list of variables to output into individual ASCII files.\\
The variables must be given by their fully qualified variable or group
- name. The special keyword {\it all} requests {\tt Scalar} output for all
+ name. The special keyword {\it all} requests {\tt Scalar}
+ output for all
variables. Multiple variables must be separated by spaces.
- For CCTK\_GF and CCTK\_ARRAY variables, an option string can be appended
+ For CCTK\_GF and CCTK\_ARRAY variables, an option string can
+ be appended
in square brackets to the name of the variable. The only option
supported so far is an individual list of reductions for that variable
which would take precedence over the default reduction operations to
@@ -92,16 +104,27 @@ Parameters to control the {\tt Scalar} I/O method are:
%
Parameters to control the {\tt Info} I/O method are:
\begin{itemize}
+ \item {\tt IOBasic::outInfo\_criterion} (steerable)\\
+ The criterion that decides when to {\tt Info} output. If
+ this parameter is set in the parameter file, it will override
+ the setting of the shared {\tt IO::out\_criterion} parameter.
\item {\tt IOBasic::outInfo\_every} (steerable)\\
- How often to do {\tt Info} output. If this parameter is set in the
+ How often, in terms of iterations, to do {\tt Info} output.
+ If this parameter is set in the
parameter file, it will override the setting of the shared
{\tt IO::out\_every} parameter.
+ \item {\tt IOBasic::outInfo\_dt} (steerable)\\
+ How often, in terms of simulation time, to do {\tt Info}
+ output. If this parameter is set in the parameter file, it
+ will override the setting of the shared {\tt IO::out\_dt}
+ parameter.
\item {\tt IOBasic::outInfo\_vars} (steerable)\\
The list of variables to output to screen.\\
The variables must be given by their fully qualified variable or group
name. The special keyword {\it all} requests {\tt Info} output for all
variables. Multiple variables must be separated by spaces.\\
- For CCTK\_GF and CCTK\_ARRAY variables, an option string can be appended
+ For CCTK\_GF and CCTK\_ARRAY variables, an option string can
+ be appended
in square brackets to the name of the variable. The only option
supported so far is an individual list of reductions for that variable
which would take precedence over the default reduction operations to
@@ -120,15 +143,19 @@ All of the above parameters marked as steerable can be changed at runtime.
\subsection {Example for {\tt Info} Output}
%
The following parameter settings request info output for variables {\tt
-grid::r, wavetoy::phi} (both are CCTK grid functions) and {\tt mythorn::complex}
+grid::r, wavetoy::phi} (both are CCTK grid functions) and {\tt
+mythorn::complex}
(a complex CCTK scalar) at every other iteration.
The minimum and maximum of {\tt grid::r} is printed according to the list
-of default reductions for info output (parameter {\tt IOBasic::outInfo\_reductions}). This list is overridden for {\tt wavetoy::phi} where only the L2 norm
+of default reductions for info output (parameter {\tt
+IOBasic::outInfo\_reductions}). This list is overridden for {\tt
+wavetoy::phi} where only the L2 norm
is output as specified in the option string for this variable. You can also
add other reduction operators within the $<>$ braces.
-For the scalar variable {\tt mythorn::complex} both the real and imaginary part are printed.
+For the scalar variable {\tt mythorn::complex} both the real and
+imaginary part are printed.
\begin{verbatim}
IOBasic::outInfo_every = 2
IOBasic::outInfo_vars = "grid::r
diff --git a/interface.ccl b/interface.ccl
index 224f56b..03ccc7e 100644
--- a/interface.ccl
+++ b/interface.ccl
@@ -3,3 +3,5 @@
implements: IOBasic
+real next_info_output_time type=scalar
+real next_scalar_output_time type=scalar
diff --git a/param.ccl b/param.ccl
index 28fca78..477dc6e 100644
--- a/param.ccl
+++ b/param.ccl
@@ -47,18 +47,45 @@ STRING outScalar_reductions "List of reductions to output into files" STEERABLE
########################
# How often to do output
########################
+KEYWORD outInfo_criterion "Criterion to select Info output intervals"
+{
+ "never" :: "Never output"
+ "iteration" :: "Output every so many iterations"
+ "time" :: "Output every that much coordinate time"
+} "iteration"
INT outInfo_every "How often to do Info output" STEERABLE = ALWAYS
{
1:* :: "Every so many iterations"
0: :: "Disable Info output"
-1: :: "Default to IO::out_every"
} -1
+REAL outInfo_dt "How often to do Info output" STEERABLE = ALWAYS
+{
+ (0:* :: "In intervals of that much coordinate time"
+ 0 :: "As often as possible"
+ -1 :: "Disable output"
+ -2 :: "Default to IO::out_dt"
+} -2
+
+KEYWORD outScalar_criterion "Criterion to select Scalar output intervals"
+{
+ "never" :: "Never output"
+ "iteration" :: "Output every so many iterations"
+ "time" :: "Output every that much coordinate time"
+} "iteration"
INT outScalar_every "How often to do Scalar output" STEERABLE = ALWAYS
{
1:* :: "Every so many iterations"
0: :: "Disable Scalar output"
-1: :: "Default to IO::out_every"
} -1
+REAL outScalar_dt "How often to do Scalar output" STEERABLE = ALWAYS
+{
+ (0:* :: "In intervals of that much coordinate time"
+ 0 :: "As often as possible"
+ -1 :: "Disable output"
+ -2 :: "Default to IO::out_dt"
+} -2
#####################
@@ -82,7 +109,9 @@ STRING out_format "Which format for Scalar floating-point number output" STEERAB
shares: IO
USES STRING out_dir AS io_out_dir
+USES KEYWORD out_criterion
USES INT out_every
+USES REAL out_dt
USES KEYWORD verbose
USES BOOLEAN new_filename_scheme
diff --git a/schedule.ccl b/schedule.ccl
index ccd2ecf..4ed57da 100644
--- a/schedule.ccl
+++ b/schedule.ccl
@@ -8,3 +8,13 @@ schedule IOBasic_Startup at STARTUP after IOUtil_Startup
{
LANG:C
} "Startup routine"
+
+
+########################################################################
+### register IOBasic routines
+########################################################################
+storage: next_info_output_time next_scalar_output_time
+schedule IOBasic_Init at INITIAL
+{
+ LANG:C
+} "Initialisation routine"
diff --git a/src/OutputInfo.c b/src/OutputInfo.c
index 524b426..c704ac2 100644
--- a/src/OutputInfo.c
+++ b/src/OutputInfo.c
@@ -8,11 +8,14 @@
@version $Id$
@@*/
+#include <assert.h>
#include <math.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cctk.h"
+#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
#include "util_String.h"
#include "iobasicGH.h"
@@ -56,6 +59,68 @@ CCTK_FILEVERSION(CactusBase_IOBasic_OutputInfo_c)
********************************************************************/
static void CheckSteerableParameters (iobasicGH *myGH);
static void PrintHeader (iobasicGH *myGH, int num_vars);
+static int TimeForOutput (const cGH *cctkGH);
+
+
+static int TimeForOutput (const cGH *cctkGH)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+ iobasicGH *myGH;
+
+ /* get the GH extensions for IOBasic */
+ myGH = CCTK_GHExtension (cctkGH, "IOBasic");
+
+ /* check if steerable parameters changed */
+ CheckSteerableParameters (myGH);
+
+ /* how to decide when to output? */
+ /* (return if no output is required) */
+ if (CCTK_EQUALS(outInfo_criterion, "never"))
+ {
+ return 0;
+ }
+ else if (CCTK_EQUALS(outInfo_criterion, "iteration"))
+ {
+ if (myGH->outInfo_every <= 0 || cctk_iteration % myGH->outInfo_every)
+ {
+ return 0;
+ }
+ }
+ else if (CCTK_EQUALS(outInfo_criterion, "time"))
+ {
+ if (myGH->outInfo_dt < 0)
+ {
+ return 0;
+ }
+ if (myGH->outInfo_dt > 0)
+ {
+ static int output_iteration = -1;
+ static int output_this_iteration;
+ assert (cctk_iteration >= output_iteration);
+ if (cctk_iteration > output_iteration)
+ {
+ output_iteration = cctk_iteration;
+ output_this_iteration
+ = cctk_time >= *next_info_output_time - 1.0e-12 * cctk_delta_time;
+ if (output_this_iteration)
+ {
+ *next_info_output_time += myGH->outInfo_dt;
+ }
+ }
+ if (! output_this_iteration)
+ {
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ assert (0);
+ }
+
+ return 1;
+}
/*@@
@@ -86,7 +151,6 @@ int IOBasic_InfoOutputGH (const cGH *GH)
int vindex, num_vars, retval;
iobasic_reduction_t *reduction;
iobasicGH *myGH;
- DECLARE_CCTK_PARAMETERS
/* get the GH extensions for IOBasic */
@@ -95,11 +159,9 @@ int IOBasic_InfoOutputGH (const cGH *GH)
/* check if steerable parameters changed */
CheckSteerableParameters (myGH);
- /* return if no output is required */
- if (myGH->outInfo_every <= 0 || GH->cctk_iteration % myGH->outInfo_every)
- {
- return (0);
- }
+ if (! TimeForOutput(GH)) return 0;
+
+ retval = 0;
/* print header if neccessary */
num_vars = CCTK_NumVars ();
@@ -119,7 +181,7 @@ int IOBasic_InfoOutputGH (const cGH *GH)
}
/* loop over all variables */
- for (vindex = retval = 0; vindex < num_vars; vindex++)
+ for (vindex = 0; vindex < num_vars; vindex++)
{
/* check this variable should be output */
if (myGH->info_reductions[vindex].num_reductions == 0)
@@ -190,35 +252,35 @@ int IOBasic_InfoOutputGH (const cGH *GH)
@@*/
int IOBasic_TimeForInfoOutput (const cGH *GH, int vindex)
{
- int retval;
char *fullname;
iobasicGH *myGH;
- DECLARE_CCTK_PARAMETERS
- /* check if steerable parameters changed */
+ /* get the GH extensions for IOBasic */
myGH = CCTK_GHExtension (GH, "IOBasic");
+
+ /* check if steerable parameters changed */
CheckSteerableParameters (myGH);
- /* check if this variable should be output */
- retval = myGH->outInfo_every > 0 &&
- (GH->cctk_iteration % myGH->outInfo_every == 0) &&
- myGH->info_reductions[vindex].num_reductions > 0;
- if (retval)
+ if (myGH->info_reductions[vindex].num_reductions == 0)
{
- /* check if variable was not already output this iteration */
- if (myGH->outInfo_last[vindex] == GH->cctk_iteration)
- {
- fullname = CCTK_FullName (vindex);
- CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Already done Info output for '%s' in current iteration "
- "(probably via triggers)", fullname);
- free (fullname);
- retval = 0;
- }
+ return 0;
}
- return (retval);
+ if (! TimeForOutput(GH)) return 0;
+
+ /* check if variable was not already output this iteration */
+ if (myGH->outInfo_last[vindex] == GH->cctk_iteration)
+ {
+ fullname = CCTK_FullName (vindex);
+ CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Already done Info output for '%s' in current iteration "
+ "(probably via triggers)", fullname);
+ free (fullname);
+ return 0;
+ }
+
+ return 1;
}
@@ -251,7 +313,6 @@ int IOBasic_TriggerInfoOutput (const cGH *GH, int vindex)
{
int retval;
iobasicGH *myGH;
- DECLARE_CCTK_PARAMETERS
/* get the GH extension for IOBasic */
@@ -268,7 +329,7 @@ int IOBasic_TriggerInfoOutput (const cGH *GH, int vindex)
if (retval == 0)
{
- /* gegister variable as having Info output at this iteration */
+ /* register variable as having Info output at this iteration */
myGH->outInfo_last[vindex] = GH->cctk_iteration;
}
@@ -301,6 +362,7 @@ int IOBasic_TriggerInfoOutput (const cGH *GH, int vindex)
static void CheckSteerableParameters (iobasicGH *myGH)
{
int vindex, out_old, times_set, update_reductions_list;
+ CCTK_REAL outdt_old;
iobasic_reduction_t *reduction, *next;
static int outInfo_vars_lastset = -1;
static int outInfo_reductions_lastset = -1;
@@ -308,28 +370,65 @@ static void CheckSteerableParameters (iobasicGH *myGH)
DECLARE_CCTK_PARAMETERS
- /* how often to output */
- out_old = myGH->outInfo_every;
- myGH->outInfo_every = outInfo_every >= 0 ? outInfo_every : out_every;
-
- /* report if frequency changed */
- if (myGH->outInfo_every != out_old && ! CCTK_Equals (verbose, "none"))
+ if (CCTK_EQUALS(outInfo_criterion, "never"))
+ {
+ return ;
+ }
+ else if (CCTK_EQUALS(outInfo_criterion, "iteration"))
{
- if (myGH->outInfo_every > 0)
+ /* how often to output */
+ out_old = myGH->outInfo_every;
+ myGH->outInfo_every = outInfo_every >= 0 ? outInfo_every : out_every;
+
+ /* report if frequency changed */
+ if (myGH->outInfo_every != out_old && ! CCTK_Equals (verbose, "none"))
{
- CCTK_VInfo (CCTK_THORNSTRING, "Info: Periodic output every %d iterations",
- myGH->outInfo_every);
+ if (myGH->outInfo_every > 0)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Info: Periodic output every %d iterations",
+ myGH->outInfo_every);
+ }
+ else
+ {
+ CCTK_INFO ("Info: Periodic output turned off");
+ }
}
- else
+
+ /* return if there's nothing to do */
+ if (myGH->outInfo_every <= 0)
{
- CCTK_INFO ("Info: Periodic output turned off");
+ return;
}
}
+ else if (CCTK_EQUALS(outInfo_criterion, "time"))
+ {
+ /* how often to output */
+ outdt_old = myGH->outInfo_dt;
+ myGH->outInfo_dt = outInfo_dt >= 0 ? outInfo_dt : out_dt;
- /* return if there's nothing to do */
- if (myGH->outInfo_every <= 0)
+ /* report if frequency changed */
+ if (myGH->outInfo_dt != outdt_old && ! CCTK_Equals (verbose, "none"))
+ {
+ if (myGH->outInfo_dt >= 0)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Info: Periodic output dt %g",
+ (double)myGH->outInfo_dt);
+ }
+ else
+ {
+ CCTK_INFO ("Info: Periodic output turned off");
+ }
+ }
+
+ /* return if there's nothing to do */
+ if (myGH->outInfo_dt < 0)
+ {
+ return;
+ }
+ }
+ else
{
- return;
+ assert (0);
}
/* check if the 'outInfo_reductions' parameter if it was changed */
diff --git a/src/OutputScalar.c b/src/OutputScalar.c
index 4ac6c5f..e83a065 100644
--- a/src/OutputScalar.c
+++ b/src/OutputScalar.c
@@ -9,11 +9,13 @@
/* #define IOBASIC_DEBUG 1 */
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cctk.h"
+#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
#include "util_String.h"
#include "iobasicGH.h"
@@ -26,14 +28,75 @@ CCTK_FILEVERSION(CactusBase_IOBasic_OutputScalar_c)
/********************************************************************
******************** Static Variables ************************
********************************************************************/
-/* flag whether CheckSteerableParameters() needs to be called */
-static int check_steerable_parameters = 1;
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
static void CheckSteerableParameters (iobasicGH *myGH);
+static int TimeForOutput (const cGH *cctkGH);
+
+
+static int TimeForOutput (const cGH *cctkGH)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+ iobasicGH *myGH;
+
+
+ /* get the GH extensions for IOBasic */
+ myGH = CCTK_GHExtension (cctkGH, "IOBasic");
+
+ /* check if steerable parameters changed */
+ CheckSteerableParameters (myGH);
+
+ /* how to decide when to output? */
+ /* (return if no output is required) */
+ if (CCTK_EQUALS(outScalar_criterion, "never"))
+ {
+ return 0;
+ }
+ else if (CCTK_EQUALS(outScalar_criterion, "iteration"))
+ {
+ if (myGH->outScalar_every <= 0 || cctk_iteration % myGH->outScalar_every)
+ {
+ return 0;
+ }
+ }
+ else if (CCTK_EQUALS(outScalar_criterion, "time"))
+ {
+ if (myGH->outScalar_dt < 0)
+ {
+ return 0;
+ }
+ if (myGH->outScalar_dt > 0)
+ {
+ static int output_iteration = -1;
+ static int output_this_iteration;
+ assert (cctk_iteration >= output_iteration);
+ if (cctk_iteration > output_iteration)
+ {
+ output_iteration = cctk_iteration;
+ output_this_iteration
+ = cctk_time >= *next_scalar_output_time - 1.0e-12 * cctk_delta_time;
+ if (output_this_iteration)
+ {
+ *next_scalar_output_time += myGH->outScalar_dt;
+ }
+ }
+ if (! output_this_iteration)
+ {
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ assert (0);
+ }
+
+ return 1;
+}
/********************************************************************
@@ -67,21 +130,16 @@ int IOBasic_ScalarOutputGH (const cGH *GH)
iobasicGH *myGH;
- /* check if any steerable parameters have changed */
+ /* get the GH extensions for IOBasic */
myGH = CCTK_GHExtension (GH, "IOBasic");
+
+ /* check if steerable parameters changed */
CheckSteerableParameters (myGH);
- /* return if no output is required */
- if (myGH->outScalar_every <= 0)
- {
- return (0);
- }
+ if (! TimeForOutput(GH)) return 0;
retval = 0;
- /* disable the check for steerable parameters during the following loop */
- check_steerable_parameters = 0;
-
/* loop over all variables */
for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--)
{
@@ -94,9 +152,6 @@ int IOBasic_ScalarOutputGH (const cGH *GH)
}
}
- /* enable the check for steerable parameters for following calls */
- check_steerable_parameters = 1;
-
return (retval);
}
@@ -227,41 +282,38 @@ int IOBasic_OutputVarAs (const cGH *GH, const char *fullname, const char *alias)
@@*/
int IOBasic_TimeForScalarOutput (const cGH *GH, int vindex)
{
- int retval;
char *fullname;
iobasicGH *myGH;
- /* Get the GH extension for IOBasic */
+ /* get the GH extensions for IOBasic */
myGH = CCTK_GHExtension (GH, "IOBasic");
- /* only need to check steerable parameters if this flag is set */
- if (check_steerable_parameters)
+ /* check if steerable parameters changed */
+ CheckSteerableParameters (myGH);
+
+ if (myGH->scalar_reductions[vindex].num_reductions == 0)
{
- CheckSteerableParameters (myGH);
+ return 0;
}
- /* check if any output was requested */
- if (myGH->outScalar_every <= 0 || GH->cctk_iteration % myGH->outScalar_every
- || myGH->scalar_reductions[vindex].num_reductions == 0)
+ if (! TimeForOutput(GH))
{
- retval = 0;
+ return 0;
}
- else
+
+ /* Check if variable wasn't already output this iteration */
+ if (myGH->outScalar_last[vindex] == GH->cctk_iteration)
{
- /* Check if variable wasn't already output this iteration */
- retval = myGH->outScalar_last[vindex] != GH->cctk_iteration;
- if (! retval)
- {
- fullname = CCTK_FullName (vindex);
- CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Already done scalar output for '%s' in current iteration "
- "(probably via triggers)", fullname);
- free (fullname);
- }
+ fullname = CCTK_FullName (vindex);
+ CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Already done scalar output for '%s' in current iteration "
+ "(probably via triggers)", fullname);
+ free (fullname);
+ return 0;
}
- return (retval);
+ return 1;
}
@@ -344,6 +396,7 @@ int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex)
static void CheckSteerableParameters (iobasicGH *myGH)
{
int vindex, out_old, times_set, update_reductions_list, num_vars;
+ CCTK_REAL outdt_old;
iobasic_reduction_t *reduction, *next;
static int outScalar_vars_lastset = -1;
static int outScalar_reductions_lastset = -1;
@@ -352,28 +405,65 @@ static void CheckSteerableParameters (iobasicGH *myGH)
DECLARE_CCTK_PARAMETERS
- /* how often to output */
- out_old = myGH->outScalar_every;
- myGH->outScalar_every = outScalar_every >= 0 ? outScalar_every : out_every;
-
- /* report if frequency changed */
- if (myGH->outScalar_every != out_old && ! CCTK_Equals (verbose, "none"))
+ if (CCTK_EQUALS(outScalar_criterion, "never"))
{
- if (myGH->outScalar_every > 0)
+ return ;
+ }
+ else if (CCTK_EQUALS(outScalar_criterion, "iteration"))
+ {
+ /* how often to output */
+ out_old = myGH->outScalar_every;
+ myGH->outScalar_every = outScalar_every >= 0 ? outScalar_every : out_every;
+
+ /* report if frequency changed */
+ if (myGH->outScalar_every != out_old && ! CCTK_Equals (verbose, "none"))
{
- CCTK_VInfo (CCTK_THORNSTRING, "Scalar: Periodic output every %d "
- "iterations", myGH->outScalar_every);
+ if (myGH->outScalar_every > 0)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Scalar: Periodic output every %d iterations",
+ myGH->outScalar_every);
+ }
+ else
+ {
+ CCTK_INFO ("Scalar: Periodic output turned off");
+ }
}
- else
+
+ /* return if there's nothing to do */
+ if (myGH->outScalar_every <= 0)
{
- CCTK_INFO ("Scalar: Periodic output turned off");
+ return;
}
}
+ else if (CCTK_EQUALS(outScalar_criterion, "time"))
+ {
+ /* how often to output */
+ outdt_old = myGH->outScalar_dt;
+ myGH->outScalar_dt = outScalar_dt >= 0 ? outScalar_dt : out_dt;
+
+ /* report if frequency changed */
+ if (myGH->outScalar_dt != outdt_old && ! CCTK_Equals (verbose, "none"))
+ {
+ if (myGH->outScalar_dt >= 0)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Scalar: Periodic output dt %g",
+ (double)myGH->outScalar_dt);
+ }
+ else
+ {
+ CCTK_INFO ("Scalar: Periodic output turned off");
+ }
+ }
- /* return if there's nothing to do */
- if (myGH->outScalar_every <= 0)
+ /* return if there's nothing to do */
+ if (myGH->outScalar_dt < 0)
+ {
+ return;
+ }
+ }
+ else
{
- return;
+ assert (0);
}
/* check if the 'outScalar_reductions' parameter if it was changed */
diff --git a/src/Startup.c b/src/Startup.c
index d862003..7101634 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -8,11 +8,14 @@
@version $Id$
@@*/
+#include <assert.h>
+#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "cctk.h"
+#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
#include "util_Table.h"
#include "CactusBase/IOUtil/src/ioutil_Utils.h"
@@ -27,6 +30,7 @@ CCTK_FILEVERSION(CactusBase_IOBasic_Startup_c)
******************** External Routines ************************
********************************************************************/
void IOBasic_Startup (void);
+void IOBasic_Init (CCTK_ARGUMENTS);
/********************************************************************
@@ -60,6 +64,22 @@ void IOBasic_Startup (void)
}
+ /*@@
+ @routine IOBasic_Init
+ @date Tue 30 Dec 2003
+ @author Erik Schnetter
+ @desc
+ Initialise the next_*_output_time variables.
+ @enddesc
+@@*/
+void IOBasic_Init (CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ *next_info_output_time = cctk_time;
+ *next_scalar_output_time = cctk_time;
+}
+
+
/****************************************************************************/
/* local routines */
/****************************************************************************/
@@ -103,6 +123,7 @@ static void *IOBasic_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
int i;
iobasicGH *myGH;
const char *my_out_dir;
+ char dirname[1000];
DECLARE_CCTK_PARAMETERS
@@ -148,9 +169,9 @@ static void *IOBasic_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
to the current parameter values
this forces info output about periodic output */
myGH->outInfo_every = outInfo_every >= 0 ? outInfo_every : out_every;
- myGH->outInfo_every--;
myGH->outScalar_every = outScalar_every >= 0 ? outScalar_every : out_every;
- myGH->outScalar_every--;
+ myGH->outInfo_dt = outInfo_dt >= 0 ? outInfo_dt : out_dt;
+ myGH->outScalar_dt = outScalar_dt >= 0 ? outScalar_dt : out_dt;
memset (myGH->outInfo_last, -1, 2 * i * sizeof (int));
diff --git a/src/WriteScalar.c b/src/WriteScalar.c
index 235f8bb..02e64b8 100644
--- a/src/WriteScalar.c
+++ b/src/WriteScalar.c
@@ -40,7 +40,7 @@ static FILE *OpenScalarFile (const cGH *GH,
@author Thomas Radke
@desc
Write a scalar value of a CCTK variable into an ASCII file
- suitable for postprocessing by either gluplot or xgraph.
+ suitable for postprocessing by either gnuplot or xgraph.
This routine just calls the appropriate output routine
according to the variable type.
@enddesc
@@ -110,7 +110,7 @@ int IOBasic_WriteScalar (const cGH *GH, int vindex, const char *alias)
@desc
Apply the given reduction operators on the CCTK_ARRAY or
CCTK_GF variable and output the result into a text file
- suitable for postprocessing by either gluplot or xgraph.
+ suitable for postprocessing by either gnuplot or xgraph.
@enddesc
@calls CCTK_Reduce
@@ -246,7 +246,7 @@ static int IOBasic_WriteScalarGA (const cGH *GH, int vindex, const char *alias)
@author Thomas Radke
@desc
Output the value of a CCTK_SCALAR variable into an ASCII file
- suitable for postprocessing by either gluplot or xgraph.
+ suitable for postprocessing by either gnuplot or xgraph.
@enddesc
@calls CCTK_MyProc
diff --git a/src/iobasicGH.h b/src/iobasicGH.h
index a77cb0c..5c3cb99 100644
--- a/src/iobasicGH.h
+++ b/src/iobasicGH.h
@@ -38,8 +38,9 @@ typedef struct IOBASIC_PARSEINFO
typedef struct IOBASIC_GH
{
/* how often to output */
- int outScalar_every, outInfo_every;
- char info_reductions_changed;
+ int outScalar_every, outInfo_every;
+ CCTK_REAL outScalar_dt, outInfo_dt;
+ char info_reductions_changed;
/* directory in which to place scalar output */
char *out_dir;