aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2004-11-17 18:44:04 +0000
committertradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2004-11-17 18:44:04 +0000
commit89d5bba31d2f3d933a9453735cec1d658a51502e (patch)
tree8d0da37a3d5e69c3a223d7052b168b764657c50e
parenta1866295732a3302b5f11cdca2f880b271ca30ba (diff)
Use aliased function IO_TruncateOutputFiles() to check whether or not
to truncate existing output files. You must also update CactusBase/IOUtil now. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@186 94b1c47f-dcfd-45ef-a468-0854c0e9e350
-rw-r--r--interface.ccl5
-rw-r--r--src/Write1D.c11
-rw-r--r--src/Write2D.c9
-rw-r--r--src/Write3D.c15
4 files changed, 18 insertions, 22 deletions
diff --git a/interface.ccl b/interface.ccl
index d0cbb25..38c8a4d 100644
--- a/interface.ccl
+++ b/interface.ccl
@@ -43,6 +43,11 @@ REQUIRES FUNCTION Hyperslab_GetList
REQUIRES FUNCTION Hyperslab_GlobalMappingByIndex
REQUIRES FUNCTION Hyperslab_FreeMapping
+CCTK_INT FUNCTION IO_TruncateOutputFiles \
+ (CCTK_POINTER_TO_CONST IN GH)
+
+REQUIRES FUNCTION IO_TruncateOutputFiles
+
CCTK_INT FUNCTION Coord_GroupSystem \
(CCTK_POINTER_TO_CONST IN GH, \
CCTK_STRING IN groupname)
diff --git a/src/Write1D.c b/src/Write1D.c
index 008e9e3..779a3da 100644
--- a/src/Write1D.c
+++ b/src/Write1D.c
@@ -23,7 +23,6 @@
#include "cctk.h"
#include "cctk_Parameters.h"
#include "util_Table.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h"
#include "ioASCIIGH.h"
@@ -164,7 +163,7 @@ int IOASCII_Write1D (const cGH *GH, int vindex, const char *alias)
return (-1);
}
- /* get the handle for IOASCII extensions */
+ /* get the handle for IOASCII extension */
myGH = CCTK_GHExtension (GH, "IOASCII");
/* get the variable's group information */
@@ -461,7 +460,6 @@ static void OpenFile (const cGH *GH,
{
int i, dir, upper, lower, first_time_through;
asciiioGH *myGH;
- const ioGH *ioUtilGH;
char comment_char;
char *filename, *type_extension;
const char *file_extension;
@@ -472,9 +470,8 @@ static void OpenFile (const cGH *GH,
DECLARE_CCTK_PARAMETERS
- /* get handles for IOUtil and IOASCII extensions */
+ /* get handle for IOASCII extension */
myGH = CCTK_GHExtension (GH, "IOASCII");
- ioUtilGH = CCTK_GHExtension (GH, "IO");
/* set comment character and file extension */
if (CCTK_Equals (out1D_style, "xgraph"))
@@ -576,7 +573,7 @@ static void OpenFile (const cGH *GH,
If restart from recovery, existing files are opened in append mode. */
first_time_through = GetNamedData (myGH->filenameList1D, filename) == NULL;
file[i] = fopen (filename,
- ioUtilGH->recovered || ! first_time_through ? "a" : "w");
+ IO_TruncateOutputFiles (GH) && first_time_through ? "w" : "a");
if (! file[i])
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
@@ -598,7 +595,7 @@ static void OpenFile (const cGH *GH,
/* mark a restart point with an empty line in the output file,
so that gnuplot/xgraph don't try to connect the last output
before the abort and the first output after the restart */
- if (ioUtilGH->recovered)
+ if (! IO_TruncateOutputFiles (GH))
{
fputc ('\n', file[i]);
}
diff --git a/src/Write2D.c b/src/Write2D.c
index 5ddb038..e430a62 100644
--- a/src/Write2D.c
+++ b/src/Write2D.c
@@ -15,7 +15,6 @@
#include "cctk.h"
#include "cctk_Parameters.h"
#include "util_Table.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h"
#include "ioASCIIGH.h"
@@ -163,7 +162,7 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias)
return (-1);
}
- /* get the handle for IOASCII extensions */
+ /* get the handle for IOASCII extension */
myGH = CCTK_GHExtension (GH, "IOASCII");
/* get the number of slices to output */
@@ -393,16 +392,14 @@ static FILE **OpenFile (const cGH *GH,
FILE **fileset;
char *filename;
asciiioGH *myGH;
- const ioGH *ioUtilGH;
ioAdvertisedFileDesc advertised_file;
char slicename[30], zlabel_fmt_string[30], buffer[128];
const char *extensions[] = {"xy", "xz", "yz"};
DECLARE_CCTK_PARAMETERS
- /* get handles for IOUtil and IOASCII extensions */
+ /* get handle for IOASCII extension */
myGH = CCTK_GHExtension (GH, "IOASCII");
- ioUtilGH = CCTK_GHExtension (GH, "IO");
/* see if we are the first time through */
fileset = (FILE **) GetNamedData (myGH->fileList_2D, alias);
@@ -448,7 +445,7 @@ static FILE **OpenFile (const cGH *GH,
}
/* if restart from recovery, try to open an existing file ... */
- fileset[dir] = fopen (filename, ioUtilGH->recovered ? "a" : "w");
+ fileset[dir] = fopen (filename, IO_TruncateOutputFiles (GH) ? "w" : "a");
if (! fileset[dir])
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
diff --git a/src/Write3D.c b/src/Write3D.c
index 9664e41..235cb85 100644
--- a/src/Write3D.c
+++ b/src/Write3D.c
@@ -15,7 +15,6 @@
#include "cctk.h"
#include "cctk_Parameters.h"
#include "util_Table.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h"
#include "ioASCIIGH.h"
@@ -334,30 +333,28 @@ static FILE *OpenFile (const cGH *GH, const char *fullname, const char *alias)
char *filename;
char buffer[128];
asciiioGH *myGH;
- const ioGH *ioUtilGH;
ioAdvertisedFileDesc advertised_file;
DECLARE_CCTK_PARAMETERS
- /* get handles for IOUtil and IOASCII extensions */
- myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII");
- ioUtilGH = (const ioGH *) CCTK_GHExtension (GH, "IO");
+ /* get handle for IOASCII extension */
+ myGH = CCTK_GHExtension (GH, "IOASCII");
/* see if we are the first time through */
- file = (FILE **) GetNamedData (myGH->fileList_3D, alias);
+ file = GetNamedData (myGH->fileList_3D, alias);
if (file)
{
return (*file);
}
- file = (FILE **) malloc (sizeof (FILE *));
- filename = (char *) malloc (strlen (myGH->out3D_dir) + strlen (alias) + 9);
+ file = malloc (sizeof (FILE *));
+ filename = malloc (strlen (myGH->out3D_dir) + strlen (alias) + 9);
/* open/create the file */
sprintf (filename, "%s%s_3D.asc", myGH->out3D_dir, alias);
/* if restart from recovery, try to open an existing file ... */
- *file = fopen (filename, ioUtilGH->recovered ? "a" : "w");
+ *file = fopen (filename, IO_TruncateOutputFiles (GH) ? "w" : "a");
if (! *file)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,