aboutsummaryrefslogtreecommitdiff
path: root/src/Write2D.c
diff options
context:
space:
mode:
authortradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2000-04-18 12:56:25 +0000
committertradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2000-04-18 12:56:25 +0000
commitee28234767b04fb1cbd05c95378bc8f440ebd8a5 (patch)
tree7bef127550ed3f3b28addc79e0b2d0ab8298d798 /src/Write2D.c
parentb0ed0e3770c1dfad68bef66a4a01ec530fc32fa6 (diff)
Several things which I missed to commit individually but rather do it in
one go now: - checkpoint/recover parameters as a single string which could also be used for writing a parameter file - added routine to be scheduled at CCTK_RECOVER_PARAMETERS - automatically select the latest checkpoint file for recovery if IO::recover = "auto" was set - Use IOFlexIO::reuse_filehandles with a different meaning now: By default all IEEEIO output files are kept open all the time. This is the most efficient method for writing data. If you run out of system file handles you can enable this parameter then to use the pause/resume scheme of the IEEEIO lib. - automatically append data sets to already exisiting output files after restart from recovery; duplicate timesteps are **NOT** removed from the output files because IEEEIO lib cannot delete/overwrite individual data sets So the reader has to handle this, it should always choose the latest data set of a given timestep. - fixed rcsid warnings - use CCTK_Info() rather than printf() for giving verbose output git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@107 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src/Write2D.c')
-rw-r--r--src/Write2D.c86
1 files changed, 46 insertions, 40 deletions
diff --git a/src/Write2D.c b/src/Write2D.c
index 45d568a..e78dac8 100644
--- a/src/Write2D.c
+++ b/src/Write2D.c
@@ -20,7 +20,6 @@
@version $Id$
@@*/
-static char *rcsid = "$Id$";
#include <stdio.h>
#include <assert.h>
@@ -32,6 +31,10 @@ static char *rcsid = "$Id$";
#include "CactusBase/IOUtil/src/ioGH.h"
#include "ioFlexGH.h"
+static char *rcsid = "$Id$";
+CCTK_FILEVERSION (CactusPUGHIO_IOFlexIO_Write2D_c);
+
+
/* MPI message tag */
#define BASE 1234
@@ -117,9 +120,6 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
if (verbose) {
printf ("<><><><><><><><><><><><><><><><><>\n");
printf ("2D Slice for [%s]\n", alias);
-#if 0
- cactus_memtrace ();
-#endif
}
variable_type = CCTK_VarTypeI (index);
@@ -168,40 +168,48 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
strlen (pughGH->identity_string) + 20);
assert (IEEEfile_2D && fname);
- /* Create files (open mode "w") */
- sprintf (fname, "%s/%s_2d_yz%s.ieee", myGH->outdir2D, alias,
- pughGH->identity_string);
- IEEEfile_2D [0] = IEEEopen (fname, "w");
- if (! IOisValid (IEEEfile_2D [0]))
+ /* Open/Create files */
+ for (i = 0; i < 3; i++)
{
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot open 2D output file '%s'", fname);
- return;
+ const char *extensions [3] = {"yz", "xz", "xy"};
+
+ sprintf (fname, "%s/%s_2d_%s%s.ieee", myGH->outdir2D, alias,
+ extensions [i], pughGH->identity_string);
+
+ /* if restart from recovery, try to open an exisiting file ... */
+ IEEEfile_2D [i] = NULL;
+ if (ioUtilGH->recovered)
+ IEEEfile_2D [i] = IEEEopen (fname, "a");
+
+ /* otherwise or if that failed, create a new one */
+ if (! IOisValid (IEEEfile_2D [i]))
+ IEEEfile_2D [i] = IEEEopen (fname, "w");
+ if (! IOisValid (IEEEfile_2D [i]))
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cannot open 2D output file '%s'", fname);
+ return;
+ }
}
- sprintf (fname, "%s/%s_2d_xz%s.ieee", myGH->outdir2D, alias,
- pughGH->identity_string);
- IEEEfile_2D [1] = IEEEopen (fname, "w");
- if (! IOisValid (IEEEfile_2D [1])) {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot open 2D output file '%s'", fname);
- return;
- }
-
- sprintf (fname, "%s/%s_2d_xy%s.ieee", myGH->outdir2D, alias,
- pughGH->identity_string);
- IEEEfile_2D [2] = IEEEopen (fname, "w");
- if (! IOisValid (IEEEfile_2D [2])) {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot open 2D output file '%s'", fname);
- return;
- }
-
/* store file desriptors in database */
StoreNamedData (&myGH->filenameList2D, alias, IEEEfile_2D);
free (fname);
}
+
+ if (reuse_filehandles)
+ {
+ /* resume the files (reopen descriptors)
+ This allows descriptor reuse without requiring expensive destruction
+ and reallocation of the associated data structures */
+ if (verbose)
+ CCTK_VInfo (CCTK_THORNSTRING, "Resuming 2D output files for variable "
+ "'%s'", CCTK_VarName (index));
+
+ for (dir = 0; dir < 3; dir++)
+ CACTUS_IEEEIO_ERROR (IOresume (IEEEfile_2D [dir]));
+ }
}
nrempoints = (CCTK_INT *) malloc (nprocs * sizeof (CCTK_INT));
@@ -209,9 +217,7 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1;
if (timelevel > 0)
- {
timelevel--;
- }
/* Get the GA for this index */
GA = ((pGA ***)pughGH->variables)[index][timelevel];
@@ -542,15 +548,15 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
free (nrempoints);
-#if 0
- if (verbose)
+ if (reuse_filehandles && myproc == 0)
{
- cactus_memtrace();
- }
-#endif
+ /* pause the files (close system descriptors) */
+ if (verbose)
+ CCTK_VInfo (CCTK_THORNSTRING, "Pausing 2D output files for variable '%s'",
+ CCTK_VarName (index));
-
+ for (dir = 0; dir < 3; dir++)
+ CACTUS_IEEEIO_ERROR (IOpause (IEEEfile_2D [dir]));
+ }
}
-
-