aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2002-04-15 12:28:07 +0000
committertradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2002-04-15 12:28:07 +0000
commita335af5b0eebc54d33d027e3c470ec656518a561 (patch)
treefa5ab1db867536f09f4fbb84680e061739488a6e
parent5876f3c0fa5d4806fa09537e66f644eee2b4c5ec (diff)
Removed calls to IOUtil_RestartFromRecovery(). Now the recovery info is taken
from IOUtil's GH extension. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@120 b589c3ab-70e8-4b4d-a09f-cba2dd200880
-rw-r--r--src/WriteScalar.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/WriteScalar.c b/src/WriteScalar.c
index 272a9fe..e2856bf 100644
--- a/src/WriteScalar.c
+++ b/src/WriteScalar.c
@@ -16,8 +16,8 @@
#include "cctk.h"
#include "cctk_Parameters.h"
+#include "CactusBase/IOUtil/src/ioGH.h"
#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h"
-#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h"
#include "iobasicGH.h"
static const char *rcsid = "$Header$";
@@ -371,39 +371,34 @@ static FILE *OpenScalarFile (const cGH *GH,
const char *description,
const char *aliasname)
{
- DECLARE_CCTK_PARAMETERS
+ int first_time_through;
FILE *file;
+ iobasicGH *myGH;
+ const ioGH *ioUtilGH;
+ char *fullname;
char comment_char, buffer[128];
ioAdvertisedFileDesc advertised_file;
- iobasicGH *myGH;
- char *openmode, *fullname;
- struct stat fileinfo;
+ DECLARE_CCTK_PARAMETERS
- /* get the GH extension handle for IOBasic */
+ /* get the GH extension handles for IOUtil and IOBasic */
myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic");
+ ioUtilGH = (const ioGH *) CCTK_GHExtension (GH, "IO");
/* get the variable's full name */
fullname = CCTK_FullName (vindex);
- /* see if output files for this alias name were already created */
- if (GetNamedData (myGH->filenameListScalar, filename) == NULL)
+ /* create the output file the first time through
+ If restart from recovery, existing files are opened in append mode. */
+ first_time_through = GetNamedData (myGH->filenameListScalar, filename)==NULL;
+ file = fopen (filename,
+ ioUtilGH->recovered || ! first_time_through ? "a" : "w");
+ if (! file)
{
- /* if restart from recovery, all existing files are opened
- in append mode */
- if (IOUtil_RestartFromRecovery (GH))
- openmode = stat (filename, &fileinfo) == 0 ? "a" : "w";
- else
- openmode = "w";
- }
- else
- {
- openmode = "a";
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "OpenScalarFile: Cannot open output file '%s'", filename);
}
-
- /* open the output file with the given mode */
- file = fopen (filename, openmode);
- if (file && *openmode == 'w')
+ else if (first_time_through)
{
if (CCTK_Equals (outScalar_style, "gnuplot"))
{