diff options
author | tradke <tradke@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a> | 2004-11-17 18:42:19 +0000 |
---|---|---|
committer | tradke <tradke@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a> | 2004-11-17 18:42:19 +0000 |
commit | b978abe58fd2ea8fd41e4759a449d7d2025913bb (patch) | |
tree | 0fd9b24c5c168da482b9518b75d94a997af935b9 /src | |
parent | a70b5e44c20c115954634bce7287c63875ada576 (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
Diffstat (limited to 'src')
-rw-r--r-- | src/Startup.c | 61 |
1 files changed, 61 insertions, 0 deletions
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 *********************** ********************************************************************/ |