aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a>2004-11-17 18:42:19 +0000
committertradke <tradke@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a>2004-11-17 18:42:19 +0000
commitb978abe58fd2ea8fd41e4759a449d7d2025913bb (patch)
tree0fd9b24c5c168da482b9518b75d94a997af935b9
parenta70b5e44c20c115954634bce7287c63875ada576 (diff)
Provide an aliased function IO_TruncateOutputFiles() for other I/O thorns
to check whether or not to truncate existing output files. The default is to not truncate after recovering. This can be overwritten by the new boolean parameter IO::truncate_files_after_recovering. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@219 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a
-rw-r--r--doc/documentation.tex11
-rw-r--r--interface.ccl8
-rw-r--r--param.ccl7
-rw-r--r--src/Startup.c61
4 files changed, 87 insertions, 0 deletions
diff --git a/doc/documentation.tex b/doc/documentation.tex
index 3ce359f..bbf1dad 100644
--- a/doc/documentation.tex
+++ b/doc/documentation.tex
@@ -423,6 +423,8 @@ parameters. The most important ones are:
method used to recover from the recovery file.
\item {\tt IO::recover\_dir}\\
directory where the recovery file is located
+ \item {\tt IO::truncate\_files\_after\_recovering}\\
+ whether or not to truncate already existing output files after recovering
\end{itemize}
To checkpoint your simulation, you need to enable checkpointing by setting
@@ -463,6 +465,15 @@ file(s) to create a single file with unchunked data.
Note that Cactus checkpoint files are platform independent so you can restart
from your checkpoint file on a different machine/architecture.
+By default, existing output files will be appended to rather than truncated after
+successful recovery. If you don't want this, you can force I/O methods to
+always truncate existing output files. Thorn {\bf IOUtil} provides an aliased
+function for other I/O thorns to call:
+\begin{verbatim}
+ CCTK_INT FUNCTION IO_TruncateOutputFiles (CCTK_POINTER_TO_CONST IN cctkGH)
+\end{verbatim}
+This function simply returns 1 or 0 if output files should or should not be truncated.
+
\vskip .5cm
\noindent{\bf WARNING:}
diff --git a/interface.ccl b/interface.ccl
index 40f0d99..8ffef18 100644
--- a/interface.ccl
+++ b/interface.ccl
@@ -11,3 +11,11 @@ CCTK_INT FUNCTION Coord_GetDefaultSystem \
CCTK_INT IN systemdim)
REQUIRES FUNCTION Coord_GetDefaultSystem
+
+
+CCTK_INT FUNCTION IO_TruncateOutputFiles \
+ (CCTK_POINTER_TO_CONST IN GH)
+
+PROVIDES FUNCTION IO_TruncateOutputFiles \
+ WITH IOUtil_TruncateOutputFiles \
+ LANGUAGE C
diff --git a/param.ccl b/param.ccl
index e6d0045..50277b8 100644
--- a/param.ccl
+++ b/param.ccl
@@ -296,3 +296,10 @@ INT out_xyplane_zi "z-index (from 0) for 2D planes in xy, overrrides IO::out_xyp
0:* :: "An index between [0, nz)"
-1: :: "Default to physical coordinate IO::out_xyplane_z"
} -1
+
+
+private:
+
+BOOLEAN truncate_files_after_recovering "Truncate existing output files after recovering ?" STEERABLE = RECOVER
+{
+} "no"
diff --git a/src/Startup.c b/src/Startup.c
index 44f82ef..4dc619c 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -80,6 +80,21 @@ static int DumpParameters (FILE *outfile);
CCTK_ParameterFilename
IOUtil_AdvertiseFile
@@*/
+typedef void (*signal_handler_t) (int sig);
+static signal_handler_t old_signal_handler[32];
+
+static void new_signal_handler (int sig)
+{
+ fprintf (stderr, "called new_signal_handler with signal %d calling %p\n", sig, old_signal_handler[sig]);
+ if (old_signal_handler[sig])
+ {
+ old_signal_handler[sig] (sig);
+ }
+ exit (0);
+}
+
+#include <signal.h>
+
void IOUtil_Startup (void)
{
char parfile[256];
@@ -87,6 +102,15 @@ void IOUtil_Startup (void)
DECLARE_CCTK_PARAMETERS
+#if 0
+{
+int i;
+for (i = 0; i < 32; i++)
+{
+ old_signal_handler[i] = signal (i, new_signal_handler);
+}
+}
+#endif
CCTK_RegisterGHExtensionSetupGH (CCTK_RegisterGHExtension ("IO"), SetupGH);
/* advertise the parameter file */
@@ -139,6 +163,43 @@ int IOUtil_UpdateParFile (const cGH *GH)
}
+ /*@@
+ @routine IOUtil_TruncateOutputFiles
+ @date Wed 17 November 2004
+ @author Thomas Radke
+ @desc
+ Aliased function 'IO_TruncateOutputFiles' which can be called
+ by I/O methods to check whether to truncate existing output
+ files or not.
+ @enddesc
+
+ @var GH
+ @vdesc pointer to grid hierarchy
+ @vtype const cGH *
+ @vio in
+ @endvar
+
+ @returntype CCTK_INT
+ @returndesc 1 or 0 for truncate or not
+ -1 in case of an error (wrong value for GH parameter)
+ @endreturndesc
+@@*/
+CCTK_INT IOUtil_TruncateOutputFiles (const CCTK_POINTER_TO_CONST GH)
+{
+ const ioGH *myGH;
+ DECLARE_CCTK_PARAMETERS
+
+
+ myGH = CCTK_GHExtension (GH, "IO");
+ if (! myGH)
+ {
+ return (-1);
+ }
+
+ return (! myGH->recovered || truncate_files_after_recovering);
+}
+
+
/********************************************************************
*********************** Local Functions ***********************
********************************************************************/