diff options
author | tradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d> | 2001-08-01 13:02:08 +0000 |
---|---|---|
committer | tradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d> | 2001-08-01 13:02:08 +0000 |
commit | 8abb85ea33b6822f2185abb2095434bbfe35b252 (patch) | |
tree | b7e5d14994264d52c3ccef4cda9066319a9367bc | |
parent | 942deba81b17b0812e6aae4dd4cea12a5a49dfc7 (diff) |
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/IOHDF5/trunk@69 4825ed28-b72c-4eae-9704-e50c059e567d
-rw-r--r-- | src/RecoverGH.c | 47 | ||||
-rw-r--r-- | src/ioHDF5GH.h | 2 |
2 files changed, 32 insertions, 17 deletions
diff --git a/src/RecoverGH.c b/src/RecoverGH.c index cfe07d4..e2dbbbd 100644 --- a/src/RecoverGH.c +++ b/src/RecoverGH.c @@ -33,7 +33,7 @@ CCTK_FILEVERSION(CactusPUGHIO_IOHDF5_RecoverGH_c) /* prototypes of routines defined in this source file */ int IOHDF5_RecoverParameters (void); static int IOHDF5_OpenFile (cGH *GH, - const char *basename, + const char *basefilename, int called_from, fileinfo_t *fileinfo); @@ -52,8 +52,8 @@ static int IOHDF5_OpenFile (cGH *GH, @vtype cGH @vio in @endvar - @var basename - @vdesc the basename of the file to recover from + @var basefilename + @vdesc the basefilename of the file to recover from The file suffix is appended by the routine. @vtype const char * @vio in @@ -83,7 +83,7 @@ static int IOHDF5_OpenFile (cGH *GH, @endreturndesc @@*/ int IOHDF5_Recover (cGH *GH, - const char *basename, + const char *basefilename, int called_from) { DECLARE_CCTK_PARAMETERS @@ -107,7 +107,7 @@ int IOHDF5_Recover (cGH *GH, called_from == FILEREADER_DATA || (GH && (GH->cctk_levfac[0] > 1 || GH->cctk_convlevel > 0))) { - if (IOHDF5_OpenFile (GH, basename, called_from, &fileinfo) < 0) + if (IOHDF5_OpenFile (GH, basefilename, called_from, &fileinfo) < 0) { return (-1); } @@ -247,8 +247,8 @@ int IOHDF5_RecoverParameters (void) @date Tue Oct 10 2000 @author Thomas Radke @desc - Open a HDF5 file given by its basename. - The basename is expanded into a full filename by calling + 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. If a file of that name could be opened it checks whether @@ -262,8 +262,8 @@ int IOHDF5_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 @@ -285,21 +285,21 @@ int IOHDF5_RecoverParameters (void) @endreturndesc @@*/ static int IOHDF5_OpenFile (cGH *GH, - const char *basename, + const char *basefilename, int called_from, fileinfo_t *fileinfo) { DECLARE_CCTK_PARAMETERS int nprocs; int myproc; - hid_t group; + hid_t group, version_attr; /* FIXME: want dynamic allocation of the filename */ char filename[256]; 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 @@ -327,7 +327,7 @@ static int IOHDF5_OpenFile (cGH *GH, we need to try both file names. */ /* at first try with unchunked mode */ fileinfo->unchunked = 1; - IOUtil_PrepareFilename (GH, basename, filename, called_from, 0, + IOUtil_PrepareFilename (GH, basefilename, filename, called_from, 0, fileinfo->unchunked); strcat (filename, ".h5"); @@ -355,7 +355,7 @@ static int IOHDF5_OpenFile (cGH *GH, /* now try with chunked mode */ fileinfo->unchunked = 0; - IOUtil_PrepareFilename (GH, basename, filename, called_from, 0, + IOUtil_PrepareFilename (GH, basefilename, filename, called_from, 0, fileinfo->unchunked); strcat (filename, ".h5"); @@ -395,6 +395,19 @@ static int IOHDF5_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 multiple files the number of @@ -446,10 +459,12 @@ static int IOHDF5_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 if (fileinfo->is_HDF5_file) @@ -458,7 +473,7 @@ static int IOHDF5_OpenFile (cGH *GH, /* Determine the IO processors for each node and the corresponding checkpoint file */ fileinfo->ioproc = myproc - (myproc % fileinfo->ioproc_every); - IOUtil_PrepareFilename (GH, basename, filename, called_from, + IOUtil_PrepareFilename (GH, basefilename, filename, called_from, fileinfo->ioproc / fileinfo->ioproc_every, fileinfo->unchunked); strcat (filename, ".h5"); diff --git a/src/ioHDF5GH.h b/src/ioHDF5GH.h index dd1c921..dd0acea 100644 --- a/src/ioHDF5GH.h +++ b/src/ioHDF5GH.h @@ -58,7 +58,7 @@ int IOHDF5_OutputGH (cGH *GH); int IOHDF5_TriggerOutput (cGH *GH, int); int IOHDF5_TimeFor (cGH *GH, int); int IOHDF5_OutputVarAs (cGH *GH, const char *var, const char *alias); -int IOHDF5_Recover (cGH *GH, const char *basename, int called_from); +int IOHDF5_Recover (cGH *GH, const char *basefilename, int called_from); /* other function prototypes */ void IOHDF5_Write (cGH *GH, int vindex, const char *alias); |