aboutsummaryrefslogtreecommitdiff
path: root/src/RecoverGH.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/RecoverGH.c')
-rw-r--r--src/RecoverGH.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/src/RecoverGH.c b/src/RecoverGH.c
index 4732cea..e80f6ab 100644
--- a/src/RecoverGH.c
+++ b/src/RecoverGH.c
@@ -2,7 +2,7 @@
@file RecoverGH.c
@date Fri Jun 19 09:14:22 1998
@author Tom Goodale
- @desc
+ @desc
Contains the routines to recover from a HDF5 checkpoint file.
Currently can recover from:
@@ -10,7 +10,7 @@
(2) Multiple unrecombined files, where the current
number of processors and IO processors
match those used to write the files.
- @enddesc
+ @enddesc
@version $Id$
@@*/
@@ -47,11 +47,11 @@ static int OpenFile (cGH *GH, const char *basefilename, int called_from,
@routine IOHDF5_Recover
@date Fri Jun 19 09:22:52 1998
@author Tom Goodale
- @desc
+ @desc
Recovers a GH from an HDF5 file.
This routine is registered with IOUtil
as IOHDF5's recovery routine.
- @enddesc
+ @enddesc
@var GH
@vdesc Pointer to CCTK grid hierarchy
@vtype cGH
@@ -120,7 +120,7 @@ int IOHDF5_Recover (cGH *GH, const char *basefilename, int called_from)
else
{
/* This is the case for CP_RECOVER_DATA.
- CCTK_RECOVER_PARAMETERS must have been called before
+ CCTK_RECOVER_PARAMETERS must have been called before
and set up the file info structure. */
if (! fileinfo.is_HDF5_file)
{
@@ -187,12 +187,10 @@ int IOHDF5_Recover (cGH *GH, const char *basefilename, int called_from)
strdup (fileinfo.filename);
}
}
-
+
/* free the allocated filename */
- if (fileinfo.filename)
- {
- free (fileinfo.filename);
- }
+ free (fileinfo.filename);
+ fileinfo.filename = NULL;
/* stop total recovery timer and print timing info */
if (called_from == CP_RECOVER_DATA && myGH->print_timing_info)
@@ -258,8 +256,8 @@ int IOHDF5_RecoverParameters (void)
@desc
Open a HDF5 file given by its basefilename.
The basefilename is expanded into a full filename by calling
- IOUtil_PrepareFilename. Both chunked and unchunked filenames
- are tested.
+ IOUtil_AssembleFilename(). Both chunked and unchunked
+ filenames are tested.
If a file of that name could be opened it checks whether
we can recover from that file.
The file information is then broadcasted by the IO processor(s)
@@ -298,8 +296,7 @@ static int OpenFile (cGH *GH, const char *basefilename, int called_from,
{
int nprocs, myproc;
hid_t group, version_attr;
- /* FIXME: want dynamic allocation of the filename */
- char filename[256];
+ char *filename;
#ifdef CCTK_MPI
MPI_Comm comm;
CCTK_INT4 info[4];
@@ -331,9 +328,8 @@ static int OpenFile (cGH *GH, const char *basefilename, int called_from,
we need to try both file names. */
/* at first try with unchunked mode */
fileinfo->unchunked = 1;
- IOUtil_PrepareFilename (GH, basefilename, filename, called_from, 0,
- fileinfo->unchunked);
- strcat (filename, ".h5");
+ filename = IOUtil_AssembleFilename (GH, basefilename, "", ".h5", called_from,
+ 0, fileinfo->unchunked);
if (myproc == 0)
{
@@ -357,9 +353,9 @@ static int OpenFile (cGH *GH, const char *basefilename, int called_from,
/* now try with chunked mode */
fileinfo->unchunked = 0;
- IOUtil_PrepareFilename (GH, basefilename, filename, called_from, 0,
- fileinfo->unchunked);
- strcat (filename, ".h5");
+ free (filename);
+ filename = IOUtil_AssembleFilename (GH, basefilename, "", ".h5",
+ called_from, 0,fileinfo->unchunked);
if (CCTK_Equals (verbose, "full"))
{
@@ -411,7 +407,7 @@ static int OpenFile (cGH *GH, const char *basefilename, int called_from,
HDF5_ERROR (H5Gclose (group));
/* If we recover from multiple files the number of
- * writing processors must match the number of reading
+ * writing processors must match the number of reading
* processors, and the total number of processors must match.
*/
if ((fileinfo->ioproc_every == nprocs && nprocs > 1) ||
@@ -473,10 +469,9 @@ static int OpenFile (cGH *GH, const char *basefilename, int called_from,
/* Determine the IO processors for each node and the corresponding
checkpoint file */
fileinfo->ioproc = myproc - (myproc % fileinfo->ioproc_every);
- IOUtil_PrepareFilename (GH, basefilename, filename, called_from,
- fileinfo->ioproc / fileinfo->ioproc_every,
- fileinfo->unchunked);
- strcat (filename, ".h5");
+ filename = IOUtil_AssembleFilename (GH, basefilename, "", ".h5",called_from,
+ fileinfo->ioproc/fileinfo->ioproc_every,
+ fileinfo->unchunked);
/* Open chunked files on other IO processors */
if (myproc == fileinfo->ioproc && myproc != 0)
@@ -506,7 +501,7 @@ static int OpenFile (cGH *GH, const char *basefilename, int called_from,
}
/* set the filename in the info structure */
- fileinfo->filename = strdup (filename);
+ fileinfo->filename = filename;
/* return 0 for success otherwise negative */
return (fileinfo->is_HDF5_file ? 0 : -1);