aboutsummaryrefslogtreecommitdiff
path: root/src/WriteGF.c
diff options
context:
space:
mode:
authortradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2000-04-12 14:13:21 +0000
committertradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2000-04-12 14:13:21 +0000
commitd0868bde35d7b95243f04b12acacb806052de6da (patch)
tree39d1fb9d91cc08feed7ab135fabe78483c859f64 /src/WriteGF.c
parent51345f7a1f6f664e85cf40d6f92d8f7946a220fd (diff)
After successful recovery, already existing output files are opened
in append mode (and not truncated as it was before) to keep the old data. Note that there may exist multiple data entries for the same timestep now if the restart from recovery is earlier than the last timestep of the output. You'll see that in gnuplot and xgraph as a straight line. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@49 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src/WriteGF.c')
-rw-r--r--src/WriteGF.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/WriteGF.c b/src/WriteGF.c
index 2e7e073..73be217 100644
--- a/src/WriteGF.c
+++ b/src/WriteGF.c
@@ -15,15 +15,18 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h> /* access(2) */
#include "cctk.h"
#include "cctk_Parameters.h"
+#include "CactusBase/IOUtil/src/ioGH.h"
#include "iobasicGH.h"
void IOBasic_WriteGF (cGH *GH, int index, const char *alias)
{
DECLARE_CCTK_PARAMETERS
int i;
+ ioGH *ioUtilGH;
iobasicGH *myGH;
FILE *file;
char *openmode;
@@ -69,6 +72,7 @@ void IOBasic_WriteGF (cGH *GH, int index, const char *alias)
else
title_start_char = 34; /* this is for xgraph */
+ ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")];
/* the extra characters should be sufficient
@@ -99,9 +103,14 @@ void IOBasic_WriteGF (cGH *GH, int index, const char *alias)
reductions [i].extension);
/* see if output files for this alias name were already created */
- if (GetNamedData (myGH->filenameListScalar, filename) == NULL)
- openmode = "w";
- else
+ if (GetNamedData (myGH->filenameListScalar, filename) == NULL) {
+ /* if restart from recovery, all existing files are opened
+ in append mode */
+ if (ioUtilGH->recovered)
+ openmode = access (filename, F_OK) == 0 ? "a" : "w";
+ else
+ openmode = "w";
+ } else
openmode = "a";
file = fopen (filename, openmode);