From a4587ec295e073276c1f4ef6b27b6664b712adf5 Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 1 Jul 2002 13:07:33 +0000 Subject: Extended the routine registered as IOHDF5's filereader to select variables with a specific iteration number (see IOUtil's thorn documentation for an example). You must also update thorn IOUtil now. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@73 7842ec3a-9562-4be5-9c5b-06ba18f2b668 --- src/RecoverVar.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/RecoverVar.c b/src/RecoverVar.c index fbe3db6..b0d80bc 100644 --- a/src/RecoverVar.c +++ b/src/RecoverVar.c @@ -43,6 +43,7 @@ typedef struct int ioproc_every; int unchunked; int has_version; + int num_recovered; } iterate_info_t; typedef struct @@ -82,7 +83,7 @@ static herr_t processDataset (hid_t group, const char *datasetname, void *arg); @returntype int @returndesc - 0 for success + the total number of recovered variables @endreturndesc @@*/ int IOHDF5Util_RecoverVariables (cGH *GH, const fileinfo_t *fileinfo) @@ -103,6 +104,7 @@ int IOHDF5Util_RecoverVariables (cGH *GH, const fileinfo_t *fileinfo) info.unchunked = fileinfo->unchunked; info.ioproc_every = fileinfo->ioproc_every; info.has_version = fileinfo->has_version; + info.num_recovered = 0; #ifdef CCTK_MPI pughGH = PUGH_pGH (GH); @@ -172,7 +174,7 @@ int IOHDF5Util_RecoverVariables (cGH *GH, const fileinfo_t *fileinfo) } #endif /* CCTK_MPI */ - return (0); + return (info.num_recovered); } @@ -337,6 +339,7 @@ int IOHDF5Util_RecoverParameters (const fileinfo_t *fileinfo) - group type - variable type - ntimelevels + - iteration - sizes (rank, dimensions) according to chunking mode If there is a mismatch a warning (warning level 2) is printed and @@ -351,6 +354,7 @@ static int GetCommonAttributes (cGH *GH, int *vindex, int *grouptype, int *timelevel, + int *iteration, int is_group, int has_version) { @@ -368,7 +372,7 @@ static int GetCommonAttributes (cGH *GH, /* decompose the datasetname, ignore the iteration number */ if (sscanf (datasetname, "%[^ ] timelevel %d at iteration %d", - fullvarname, timelevel, &i) != 3) + fullvarname, timelevel, iteration) != 3) { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "Cannot parse datasetname '%s'", datasetname); @@ -717,7 +721,7 @@ static herr_t processDataset (hid_t group, const char *datasetname, void *arg) { ioGH *ioUtilGH; ioHDF5UtilGH *myGH; - int vindex, vtype, gtype, timelevel, is_group; + int vindex, vtype, gtype, timelevel, iteration, is_group; iterate_info_t *it_info = (iterate_info_t *) arg; recover_info_t rec_info; hid_t dataset; @@ -747,7 +751,7 @@ static herr_t processDataset (hid_t group, const char *datasetname, void *arg) /* read in the dataset's attributes and verify them */ if (GetCommonAttributes (it_info->GH, dataset, datasetname, it_info->unchunked, &vindex, >ype, &timelevel, - is_group, it_info->has_version) < 0) + &iteration, is_group, it_info->has_version) < 0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Ignoring dataset '%s'", datasetname); @@ -758,15 +762,15 @@ static herr_t processDataset (hid_t group, const char *datasetname, void *arg) myGH = (ioHDF5UtilGH *) CCTK_GHExtension (it_info->GH, "IOHDF5Util"); /* if we read in initial data via the file reader interface - check whether the user wants to have this variable restored */ - if (ioUtilGH->do_inVars && ! ioUtilGH->do_inVars[vindex]) + check whether the user wants to have this variable with a specific + iteration number restored */ + if (ioUtilGH->do_inVars && ioUtilGH->do_inVars[vindex] >= 0 && + ioUtilGH->do_inVars[vindex] != iteration + 1) { if (CCTK_Equals (verbose, "full")) { - fullname = CCTK_FullName (vindex); - CCTK_VInfo (CCTK_THORNSTRING, "Ignoring variable '%s' for file reader " - "recovery", fullname); - free (fullname); + CCTK_VInfo (CCTK_THORNSTRING, "Ignoring dataset '%s' for file reader " + "recovery", datasetname); } return (0); } @@ -822,5 +826,8 @@ static herr_t processDataset (hid_t group, const char *datasetname, void *arg) HDF5_ERROR (H5Dclose (dataset)); } + /* increment counter for total number of recovered variables */ + it_info->num_recovered++; + return (0); } -- cgit v1.2.3