aboutsummaryrefslogtreecommitdiff
path: root/src/RecoverGH.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/RecoverGH.c')
-rw-r--r--src/RecoverGH.c74
1 files changed, 36 insertions, 38 deletions
diff --git a/src/RecoverGH.c b/src/RecoverGH.c
index 5c6f314..d1339f3 100644
--- a/src/RecoverGH.c
+++ b/src/RecoverGH.c
@@ -23,18 +23,22 @@
#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h"
#include "ioStreamedHDF5GH.h"
-
/* the rcs ID and its dummy function to use it */
static const char *rcsid = "$Id$";
CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_RecoverGH_c)
-/* prototypes of routines defined in this source file */
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
int IOStreamedHDF5_RecoverParameters (void);
-static int IOStreamedHDF5_OpenFile (cGH *GH,
- const char *basefilename,
- int called_from,
- fileinfo_t *fileinfo);
+
+
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
+static int OpenFile (cGH *GH, const char *basefilename, int called_from,
+ fileinfo_t *fileinfo);
/*@@
@@ -63,7 +67,7 @@ static int IOStreamedHDF5_OpenFile (cGH *GH,
@vio in
@endvar
- @calls IOStreamedHDF5_OpenFile
+ @calls OpenFile
IOHDF5Util_RecoverParameters
IOHDF5Util_RecoverVariables
IOHDF5Util_RecoverGHextensions
@@ -80,15 +84,14 @@ static int IOStreamedHDF5_OpenFile (cGH *GH,
@seeroutine IOHDF5Util_RecoverGHextensions
@endreturndesc
@@*/
-int IOStreamedHDF5_Recover (cGH *GH,
- const char *basefilename,
- int called_from)
+int IOStreamedHDF5_Recover (cGH *GH, const char *basefilename, int called_from)
{
- DECLARE_CCTK_PARAMETERS
int result;
ioStreamedHDF5GH *myGH;
static fileinfo_t fileinfo; /* this is static because info is passed from
CP_RECOVERY_PARAMETERS to CP_RECOVERY_DATA */
+ DECLARE_CCTK_PARAMETERS
+
/* start the recovery timer if we were called at CCTK_RECOVER */
myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
@@ -103,7 +106,7 @@ int IOStreamedHDF5_Recover (cGH *GH,
called_from == FILEREADER_DATA ||
(GH && (GH->cctk_levfac[0] > 1 || GH->cctk_convlevel > 0)))
{
- if (IOStreamedHDF5_OpenFile (GH, basefilename, called_from, &fileinfo) < 0)
+ if (OpenFile (GH, basefilename, called_from, &fileinfo) < 0)
{
return (-1);
}
@@ -161,7 +164,7 @@ int IOStreamedHDF5_Recover (cGH *GH,
fileinfo.filename);
}
}
- IOHDF5_ERROR (H5Fclose (fileinfo.file));
+ HDF5_ERROR (H5Fclose (fileinfo.file));
}
/* free the allocated filename */
@@ -225,8 +228,8 @@ int IOStreamedHDF5_Recover (cGH *GH,
@@*/
int IOStreamedHDF5_RecoverParameters (void)
{
- DECLARE_CCTK_PARAMETERS
int retval;
+ DECLARE_CCTK_PARAMETERS
if (CCTK_Equals (recover, "auto"))
@@ -244,11 +247,11 @@ int IOStreamedHDF5_RecoverParameters (void)
}
-/**************************************************************************/
-/* local routines */
-/**************************************************************************/
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
/*@@
- @routine IOStreamedHDF5_OpenFile
+ @routine OpenFile
@date Tue Oct 10 2000
@author Thomas Radke
@desc
@@ -286,25 +289,20 @@ int IOStreamedHDF5_RecoverParameters (void)
0 for success, -1 if file could not be opened
@endreturndesc
@@*/
-static int IOStreamedHDF5_OpenFile (cGH *GH,
- const char *basefilename,
- int called_from,
- fileinfo_t *fileinfo)
+static int OpenFile (cGH *GH, const char *basefilename, int called_from,
+ fileinfo_t *fileinfo)
{
- DECLARE_CCTK_PARAMETERS
- hid_t fapl;
- hid_t group, version_attr;
int nprocs, myproc;
- H5E_auto_t print_error_fn;
- void *print_error_fn_arg;
+ hid_t fapl, group, version_attr;
#ifdef CCTK_MPI
MPI_Comm comm;
CCTK_INT4 info[4];
#endif
+ DECLARE_CCTK_PARAMETERS
/* suppress compiler warnings about unused variables */
- called_from = called_from;
+ (void) (called_from + 0);
#ifdef CCTK_MPI
/* Get the communicator for broadcasting the info structure */
@@ -330,11 +328,11 @@ static int IOStreamedHDF5_OpenFile (cGH *GH,
}
/* set up file access property list and select Stream VFD */
- IOHDF5_ERROR (fapl = H5Pcreate (H5P_FILE_ACCESS));
- IOHDF5_ERROR (H5Pset_fapl_stream (fapl, NULL));
+ HDF5_ERROR (fapl = H5Pcreate (H5P_FILE_ACCESS));
+ HDF5_ERROR (H5Pset_fapl_stream (fapl, NULL));
fileinfo->file = H5Fopen (fileinfo->filename, H5F_ACC_RDONLY, fapl);
- IOHDF5_ERROR (H5Pclose (fapl));
+ HDF5_ERROR (H5Pclose (fapl));
if (fileinfo->file < 0)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
@@ -356,18 +354,18 @@ static int IOStreamedHDF5_OpenFile (cGH *GH,
/* check if there exists a version attribute
For this we temporarily turn off automatic error printing. */
- IOHDF5_ERROR (H5Eget_auto (&print_error_fn, &print_error_fn_arg));
- IOHDF5_ERROR (H5Eset_auto (NULL, NULL));
- version_attr = H5Aopen_name (group, "Cactus version");
- IOHDF5_ERROR (H5Eset_auto (print_error_fn, print_error_fn_arg));
+ H5E_BEGIN_TRY
+ {
+ version_attr = H5Aopen_name (group, "Cactus version");
+ } H5E_END_TRY;
fileinfo->has_version = version_attr >= 0;
if (version_attr >= 0)
{
- IOHDF5_ERROR (H5Aclose (version_attr));
+ HDF5_ERROR (H5Aclose (version_attr));
}
- IOHDF5_ERROR (H5Gclose (group));
+ HDF5_ERROR (H5Gclose (group));
/* If we recover from chunked file(s) the number of
* writing processors must match the number of reading
@@ -427,6 +425,6 @@ static int IOStreamedHDF5_OpenFile (cGH *GH,
fileinfo->has_version = info[3];
#endif
- /* Return 0 for success otherwise negative */
+ /* return 0 for success otherwise negative */
return (fileinfo->is_HDF5_file ? 0 : -1);
}