aboutsummaryrefslogtreecommitdiff
path: root/src/Write1D.c
diff options
context:
space:
mode:
authortradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2000-09-21 13:31:31 +0000
committertradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2000-09-21 13:31:31 +0000
commite14a88126cbb2f8f9e2770272d9b1fb7b02c821f (patch)
tree60f69c38d1e0536880139622cb7b13276502c3b2 /src/Write1D.c
parentf20f4213f484a18ff8fad38f0228d01fda4d48e3 (diff)
Include ioutil_AdvertisedFiles.h and ioutil_CheckpointRecovery.h
instead of ioGH.h. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@24 94b1c47f-dcfd-45ef-a468-0854c0e9e350
Diffstat (limited to 'src/Write1D.c')
-rw-r--r--src/Write1D.c65
1 files changed, 34 insertions, 31 deletions
diff --git a/src/Write1D.c b/src/Write1D.c
index 48ad403..ff79e93 100644
--- a/src/Write1D.c
+++ b/src/Write1D.c
@@ -48,8 +48,9 @@
#include "cctk.h"
#include "cctk_Parameters.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
#include "CactusPUGH/PUGHSlab/src/PUGHSlab.h"
+#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h"
+#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h"
#include "ioASCIIGH.h"
/* the rcs ID and its dummy function to use it */
@@ -77,7 +78,7 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c)
{ \
for (i = 0; i < hsize; i++) \
fprintf (file, format, \
- (double) (i), \
+ (double) i, \
(c_type) cctk_extract_fn (typed_data [i])); \
} \
}
@@ -123,7 +124,6 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
{
DECLARE_CCTK_PARAMETERS
asciiioGH *myGH; /* IOASCII extension handle */
- ioGH *ioUtilGH; /* IOUtil extension handle */
int Do_it [4]; /* flags indicating actual work */
int coord_index [3]; /* x,y,z coordinate variable indices */
int is_cubic; /* true if variable lives on cubic grid */
@@ -139,25 +139,26 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
const char *data_fmt_real; /* data format string for float types */
FILE *file [8]; /* fds for x,y,z,d output (also COMPLEX)*/
+
/* get the variable's group information */
groupindex = CCTK_GroupIndexFromVarI (index);
CCTK_GroupData (groupindex, &groupinfo);
- /* check if variable is of dimension 3 and has storage assigned */
+ /* check if variable has storage assigned */
if (! CCTK_QueryGroupStorageI (GH, groupindex))
{
char *fullname = CCTK_FullName (index);
+
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOASCII_Write1D: No IOASCII_1D output for '%s' (no storage)", fullname);
+ "IOASCII_Write1D: No IOASCII_1D output for '%s' (no storage)",
+ fullname);
free (fullname);
return;
}
- /* Get the handles for IOUtil and IOASCII extensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- myGH = (asciiioGH *) GH->extensions
- [CCTK_GHExtensionHandle ("IOASCII")];
+ /* Get the handle for IOASCII extensions */
+ myGH = (asciiioGH *) GH->extensions[CCTK_GHExtensionHandle ("IOASCII")];
/* see what slices should be output */
Do_it [0] = out1D_x && groupinfo.dim >= 1;
@@ -196,39 +197,27 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
{
if (CCTK_Equals (out_style, "gnuplot"))
{
- header_fmt = "\n\n#Time = %f\n";
- }
- else
- {
- header_fmt = "\n\n\"Time = %f\n";
- }
- if (groupinfo.grouptype == CCTK_GF)
- {
- data_fmt_int = "%f\t\t%d\n";
- data_fmt_real = "%f\t\t%.13f\n";
+ header_fmt = "\n\n#Time = %f\n";
}
else
{
- data_fmt_int = "%d\t\t%d\n";
- data_fmt_real = "%f\t\t%.13f\n";
+ header_fmt = "\n\n\"Time = %f\n";
}
+ data_fmt_int = "%f\t\t%d\n";
+ data_fmt_real = "%f\t\t%.13f\n";
}
else
{
if (CCTK_Equals (out_style, "gnuplot"))
- header_fmt = "\n\n#Time = %e\n";
- else
- header_fmt = "\n\n\"Time = %e\n";
- if (groupinfo.grouptype == CCTK_GF)
{
- data_fmt_int = "%e\t\t%d\n";
- data_fmt_real = "%e\t\t%.13e\n";
+ header_fmt = "\n\n#Time = %e\n";
}
else
{
- data_fmt_int = "%d\n";
- data_fmt_real = "%.13e\n";
+ header_fmt = "\n\n\"Time = %e\n";
}
+ data_fmt_int = "%e\t\t%d\n";
+ data_fmt_real = "%e\t\t%.13e\n";
}
#ifdef DEBUG_IOASCII
@@ -289,10 +278,14 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
{
/* if restart from recovery, all existing files are opened
in append mode */
- if (ioUtilGH->recovered)
+ if (IOUtil_RestartFromRecovery (GH))
+ {
openmode = stat (filename, &fileinfo) == 0 ? "a" : "w";
+ }
else
+ {
openmode = "w";
+ }
/* just store a non-NULL pointer in database */
StoreNamedData (&myGH->filenameList1D, filename, (void *) 1);
@@ -313,7 +306,7 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
/* advertise new files for downloading */
if (*openmode == 'w')
{
- IOUtil_AdvertisedFileDesc_t advertisedFile;
+ ioAdvertisedFileDesc advertisedFile;
advertisedFile.slice = (char *) extensions [i];
@@ -379,7 +372,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
/* get the current time level */
timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1;
if (timelevel > 0)
+ {
timelevel--;
+ }
/* OK so actually do the I/O in each direction */
for (dir = 0; dir < 4; dir++)
@@ -397,7 +392,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
/* skip empty slices */
if (! Do_it [dir])
+ {
continue;
+ }
if (groupinfo.grouptype == CCTK_GF)
{
@@ -416,7 +413,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
/* get the current time level for the coordinates */
coord_timelevel = CCTK_NumTimeLevelsFromVarI (coord_index [dir]) - 1;
if (coord_timelevel > 0)
+ {
coord_timelevel--;
+ }
if (Hyperslab_GetHyperslab (GH, 0, coord_index [dir],
coord_timelevel, 1, origin, directions,
@@ -461,7 +460,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
/* set the direction vector for the 1D line */
for (i = 0; i < 3; i++)
+ {
directions [i] = (dir == i || dir == 3) ? 1 : 0;
+ }
/* no coordinates are needed for arrays */
coord_data = NULL;
@@ -478,7 +479,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias)
"variable '%s'", fullname);
free (fullname);
if (coord_data)
+ {
free (coord_data);
+ }
continue;
}