diff options
author | rhaas <rhaas@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a> | 2012-06-11 18:35:24 +0000 |
---|---|---|
committer | rhaas <rhaas@b32723a9-ab3a-4a60-88e2-2e5d99d7c17a> | 2012-06-11 18:35:24 +0000 |
commit | 928b224243e765d0fc700e84f42d7c0f2204fe3d (patch) | |
tree | 5d1e065a9717a57e7814527ef2bfbbd39110268d | |
parent | c393be9824383f44bec91c337e0ff7c6ce3e3cfc (diff) |
IOUtil: abort IOUtil_TruncateOutputFiles if called too early
currently when called before the grid extension for IOUtil has been registered
(which is when IOUtils learns if the is a checkpoint recovery run or not), the
routine returns -1. However the documentation in the thorn guide states that
Thorn IOUtil provides an aliased function for other I/O thorns to call:
CCTK_INT FUNCTION IO_TruncateOutputFiles (CCTK_POINTER_TO_CONST IN cctkGH)
This function simply returns 1 or 0 if output files should or should not be
truncated.
Since there are thorns out there that take this to heart and test for
IO_TruncateOutputFiles() being true (ie non-zero) these thorns always overwrite
data during a recovery when calling IOUtils too early. This happened to Carpet
in ticket #908.
The attached patch makes IOUtil abort instead which seems better than silently
returning the wrong (since undocumented) answer. No actual user thorn should be
affected.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@289 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a
-rw-r--r-- | src/Startup.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Startup.c b/src/Startup.c index 5a50fce..8a66e7d 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -162,7 +162,6 @@ void IOUtil_UpdateParFile (CCTK_ARGUMENTS) @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) @@ -174,7 +173,8 @@ CCTK_INT IOUtil_TruncateOutputFiles (const CCTK_POINTER_TO_CONST GH) myGH = CCTK_GHExtension (GH, "IO"); if (! myGH) { - return (-1); + CCTK_WARN (CCTK_WARN_ABORT, + "IOUtil_TruncateOutputFiles called before being fully initialized. Please make sure to only call me after the STARTUP bin has finished and the driver called CCTKi_InitGHExtensions."); } return (myGH->recovered ? truncate_files_after_recovering : truncate_files); |