From d2f7ae5b466456824fd28b1c907c45b88e1505a7 Mon Sep 17 00:00:00 2001 From: tradke Date: Wed, 1 Aug 2001 13:01:44 +0000 Subject: Check for file version attribute already when opening the file. Fixed compiler warnings about a parameter named 'basename' which shadows a global symbol of the same name. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@73 0888f3d4-9f52-45d2-93bc-d00801ff5e46 --- src/RecoverGH.c | 41 +++++++++++++++++++++++++++++------------ src/ioStreamedHDF5GH.h | 2 +- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/RecoverGH.c b/src/RecoverGH.c index 010e858..90a91c2 100644 --- a/src/RecoverGH.c +++ b/src/RecoverGH.c @@ -32,7 +32,7 @@ CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_RecoverGH_c) /* prototypes of routines defined in this source file */ int IOStreamedHDF5_RecoverParameters (void); static int IOStreamedHDF5_OpenFile (cGH *GH, - const char *basename, + const char *basefilename, int called_from, fileinfo_t *fileinfo); @@ -51,8 +51,8 @@ static int IOStreamedHDF5_OpenFile (cGH *GH, @vtype cGH * @vio in @endvar - @var basename - @vdesc the basename containing the 'host:port' of the sending process + @var basefilename + @vdesc the basefilename containing the 'host:port' of the sending process @vtype const char * @vio in @endvar @@ -81,7 +81,7 @@ static int IOStreamedHDF5_OpenFile (cGH *GH, @endreturndesc @@*/ int IOStreamedHDF5_Recover (cGH *GH, - const char *basename, + const char *basefilename, int called_from) { DECLARE_CCTK_PARAMETERS @@ -103,7 +103,7 @@ int IOStreamedHDF5_Recover (cGH *GH, called_from == FILEREADER_DATA || (GH && (GH->cctk_levfac[0] > 1 || GH->cctk_convlevel > 0))) { - if (IOStreamedHDF5_OpenFile (GH, basename, called_from, &fileinfo) < 0) + if (IOStreamedHDF5_OpenFile (GH, basefilename, called_from, &fileinfo) < 0) { return (-1); } @@ -256,8 +256,8 @@ int IOStreamedHDF5_RecoverParameters (void) @vtype cGH * @vio in @endvar - @var basename - @vdesc basename of the HDF5 file to recover from + @var basefilename + @vdesc basefilename of the HDF5 file to recover from For streamed files this should be of format 'host:port'. @vtype int @vio in @@ -279,17 +279,19 @@ int IOStreamedHDF5_RecoverParameters (void) @endreturndesc @@*/ static int IOStreamedHDF5_OpenFile (cGH *GH, - const char *basename, + const char *basefilename, int called_from, fileinfo_t *fileinfo) { DECLARE_CCTK_PARAMETERS hid_t fapl; - hid_t group; + hid_t group, version_attr; int nprocs, myproc; + H5E_auto_t print_error_fn; + void *print_error_fn_arg; #ifdef CCTK_MPI MPI_Comm comm; - CCTK_INT4 info[3]; + CCTK_INT4 info[4]; #endif @@ -309,7 +311,7 @@ static int IOStreamedHDF5_OpenFile (cGH *GH, myproc = CCTK_MyProc (GH); /* use the basename (which should be of format 'host:port') as the filename */ - fileinfo->filename = strdup (basename); + fileinfo->filename = strdup (basefilename); if (myproc == 0) { @@ -344,6 +346,19 @@ static int IOStreamedHDF5_OpenFile (cGH *GH, READ_ATTRIBUTE (group, "ioproc_every", H5T_NATIVE_INT, &fileinfo->ioproc_every); + /* 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)); + + fileinfo->has_version = version_attr >= 0; + if (version_attr >= 0) + { + IOHDF5_ERROR (H5Aclose (version_attr)); + } + IOHDF5_ERROR (H5Gclose (group)); /* If we recover from chunked file(s) the number of @@ -396,10 +411,12 @@ static int IOStreamedHDF5_OpenFile (cGH *GH, info[0] = fileinfo->is_HDF5_file; info[1] = fileinfo->unchunked; info[2] = fileinfo->ioproc_every; - CACTUS_MPI_ERROR (MPI_Bcast (info, 3, PUGH_MPI_INT4, 0, comm)); + info[3] = fileinfo->has_version; + CACTUS_MPI_ERROR (MPI_Bcast (info, 4, PUGH_MPI_INT4, 0, comm)); fileinfo->is_HDF5_file = info[0]; fileinfo->unchunked = info[1]; fileinfo->ioproc_every = info[2]; + fileinfo->has_version = info[3]; #endif /* Return 0 for success otherwise negative */ diff --git a/src/ioStreamedHDF5GH.h b/src/ioStreamedHDF5GH.h index d770bb6..4abc6f8 100644 --- a/src/ioStreamedHDF5GH.h +++ b/src/ioStreamedHDF5GH.h @@ -54,7 +54,7 @@ int IOStreamedHDF5_OutputGH (cGH *GH); int IOStreamedHDF5_TriggerOutput (cGH *GH, int); int IOStreamedHDF5_TimeFor (cGH *GH, int); int IOStreamedHDF5_OutputVarAs (cGH *GH, const char *var, const char *alias); -int IOStreamedHDF5_Recover (cGH *GH, const char *basename, int called_from); +int IOStreamedHDF5_Recover (cGH *GH, const char *basefilename, int called_from); /* other function prototypes */ void IOStreamedHDF5_Write (cGH *GH, int vindex, const char *alias); -- cgit v1.2.3