diff options
author | tradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d> | 2002-04-23 14:58:49 +0000 |
---|---|---|
committer | tradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d> | 2002-04-23 14:58:49 +0000 |
commit | 497188bef8ce0f21851dd3fa6ae777d58008d713 (patch) | |
tree | fad899d18c78684cd8da47f0f4c12537deb064be | |
parent | 7109c2356053d465c8f920ff5fe9f82502200532 (diff) |
Code cleanup before moving into producion mode.
You must also update BetaThorns/IOHDF5Util now.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@124 4825ed28-b72c-4eae-9704-e50c059e567d
-rw-r--r-- | src/DumpGH.c | 31 | ||||
-rw-r--r-- | src/Output.c | 50 | ||||
-rw-r--r-- | src/RecoverGH.c | 32 | ||||
-rw-r--r-- | src/Startup.c | 33 | ||||
-rw-r--r-- | src/Write.c | 20 | ||||
-rw-r--r-- | src/ioHDF5GH.h | 8 |
6 files changed, 71 insertions, 103 deletions
diff --git a/src/DumpGH.c b/src/DumpGH.c index 1fb342d..b9d5674 100644 --- a/src/DumpGH.c +++ b/src/DumpGH.c @@ -36,15 +36,15 @@ CCTK_FILEVERSION(AlphaThorns_IOHDF5_DumpGH_c) /******************************************************************** ******************** External Routines ************************ ********************************************************************/ -void IOHDF5_InitialDataCheckpoint (cGH *GH); -void IOHDF5_EvolutionCheckpoint (cGH *GH); -void IOHDF5_TerminationCheckpoint (cGH *GH); +void IOHDF5_InitialDataCheckpoint (const cGH *GH); +void IOHDF5_EvolutionCheckpoint (const cGH *GH); +void IOHDF5_TerminationCheckpoint (const cGH *GH); /******************************************************************** ******************** Internal Routines ************************ ********************************************************************/ -static int Checkpoint (cGH *GH, int called_from); +static int Checkpoint (const cGH *GH, int called_from); /*@@ @@ -60,11 +60,11 @@ static int Checkpoint (cGH *GH, int called_from); @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * + @vtype const cGH * @vio in @endvar @@*/ -void IOHDF5_InitialDataCheckpoint (cGH *GH) +void IOHDF5_InitialDataCheckpoint (const cGH *GH) { DECLARE_CCTK_PARAMETERS @@ -89,11 +89,11 @@ void IOHDF5_InitialDataCheckpoint (cGH *GH) @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * + @vtype const cGH * @vio in @endvar @@*/ -void IOHDF5_EvolutionCheckpoint (cGH *GH) +void IOHDF5_EvolutionCheckpoint (const cGH *GH) { DECLARE_CCTK_PARAMETERS @@ -132,11 +132,11 @@ void IOHDF5_EvolutionCheckpoint (cGH *GH) @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * + @vtype const cGH * @vio in @endvar @@*/ -void IOHDF5_TerminationCheckpoint (cGH *GH) +void IOHDF5_TerminationCheckpoint (const cGH *GH) { DECLARE_CCTK_PARAMETERS @@ -166,7 +166,7 @@ void IOHDF5_TerminationCheckpoint (cGH *GH) @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * + @vtype const cGH * @vio in @endvar @var called_from @@ -182,7 +182,7 @@ void IOHDF5_TerminationCheckpoint (cGH *GH) or returncode of @seeroutine IOUtilHDF5_DumpGH @endreturndesc @@*/ -static int Checkpoint (cGH *GH, int called_from) +static int Checkpoint (const cGH *GH, int called_from) { hid_t file; int myproc; @@ -204,14 +204,13 @@ static int Checkpoint (cGH *GH, int called_from) file = -1; myproc = CCTK_MyProc (GH); - /* Get the GH extensions for IOUtil and IOHDF5 */ ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5"); - /* check if IOHDF5 was registered as IO method */ + /* check if IOHDF5 was registered as I/O method */ if (myGH == NULL) { - CCTK_WARN (2, "No IOHDF5 IO methods registered"); + CCTK_WARN (2, "No IOHDF5 I/O methods registered"); return (-1); } @@ -279,7 +278,7 @@ static int Checkpoint (cGH *GH, int called_from) if (file >= 0) { - IOHDF5_ERROR (H5Fclose (file)); + HDF5_ERROR (H5Fclose (file)); } /* delete the oldest checkpoint file if checkpoint_keep_all isn't set diff --git a/src/Output.c b/src/Output.c index 6b6ef2c..d66dc55 100644 --- a/src/Output.c +++ b/src/Output.c @@ -2,9 +2,9 @@ @file Output.c @date Tue Jan 9 1999 @author Gabrielle Allen - @desc + @desc Functions to deal with output of variables in HDF5 file format - @enddesc + @enddesc @version $Id$ @@*/ @@ -23,7 +23,7 @@ CCTK_FILEVERSION(AlphaThorns_IOHDF5_Output_c) /******************************************************************** ******************** Internal Routines ************************ ********************************************************************/ -static void CheckSteerableParameters (ioHDF5GH *myGH); +static void CheckSteerableParameters (const cGH *GH); /*@@ @@ -58,10 +58,9 @@ int IOHDF5_OutputGH (const cGH *GH) DECLARE_CCTK_PARAMETERS - /* Get the GH extension for IOHDF5 */ myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5"); - CheckSteerableParameters (myGH); + CheckSteerableParameters (GH); if (myGH->out_every <= 0) { @@ -71,7 +70,6 @@ int IOHDF5_OutputGH (const cGH *GH) /* loop over all variables */ for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { - if (IOHDF5_TimeFor (GH, vindex)) { name = CCTK_VarName (vindex); @@ -85,7 +83,7 @@ int IOHDF5_OutputGH (const cGH *GH) if (IOHDF5_OutputVarAs (GH, fullname, name) == 0) { - /* Register variable as having output this iteration */ + /* register variable as having output this iteration */ myGH->out_last[vindex] = GH->cctk_iteration; retval++; } @@ -142,24 +140,24 @@ int IOHDF5_OutputVarAs (const cGH *GH, const char *fullname, const char *alias) if (verbose) { CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_OutputVarAs: fullname, alias, " - "index = (%s, %s, %d)", fullname, alias, vindex); + "index = (%s, %s, %d)", fullname, alias, vindex); } /* check whether the variable already has an I/O request entry */ myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5"); - oneshot = myGH->out_geo[vindex] == NULL; + oneshot = myGH->slablist[vindex] == NULL; if (oneshot) { - IOHDF5Util_ParseVarsForOutput (fullname, myGH->out_geo); + IOHDF5Util_ParseVarsForOutput (GH, fullname, myGH->slablist); } /* do the output */ retval = IOHDF5_Write (GH, vindex, alias); - if (oneshot && myGH->out_geo[vindex]) + if (oneshot && myGH->slablist[vindex]) { - free (myGH->out_geo[vindex]); - myGH->out_geo[vindex] = NULL; + free (myGH->slablist[vindex]); + myGH->slablist[vindex] = NULL; } return (retval); } @@ -200,13 +198,11 @@ int IOHDF5_TimeFor (const cGH *GH, int vindex) char *fullname; - /* get the GH extension for IOHDF5 */ - myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5"); - - CheckSteerableParameters (myGH); + CheckSteerableParameters (GH); /* check if this variable should be output */ - retval = myGH->out_every > 0 && myGH->out_geo[vindex] && + myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5"); + retval = myGH->out_every > 0 && myGH->slablist[vindex] && GH->cctk_iteration % myGH->out_every == 0; if (retval) { @@ -301,20 +297,23 @@ int IOHDF5_TriggerOutput (const cGH *GH, int vindex) @calls IOHDF5Util_ParseVarsForOutput - @var myGH - @vdesc Pointer to IOHDF5 GH - @vtype ioHDF5GH * + @var GH + @vdesc Pointer to CCTK grid hierarchy + @vtype const cGH * @vio in @endvar @@*/ -static void CheckSteerableParameters (ioHDF5GH *myGH) +static void CheckSteerableParameters (const cGH *GH) { int times_set; + ioHDF5GH *myGH; static int out_vars_lastset = -1, user_was_warned = 0; DECLARE_CCTK_PARAMETERS - /* How often to output */ + myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5"); + + /* how often to output */ if (out_every >= 0 || outHDF5_every >= 0) { if (out_every < 0) @@ -336,15 +335,14 @@ static void CheckSteerableParameters (ioHDF5GH *myGH) { myGH->out_every = *(const CCTK_INT *) CCTK_ParameterGet ("out_every", - CCTK_ImplementationThorn ("IO"), - NULL); + CCTK_ImplementationThorn ("IO"), NULL); } /* re-parse the 'IOHDF5::out_vars' parameter if it was changed */ times_set = CCTK_ParameterQueryTimesSet ("out_vars", CCTK_THORNSTRING); if (times_set != out_vars_lastset) { - IOHDF5Util_ParseVarsForOutput (out_vars, myGH->out_geo); + IOHDF5Util_ParseVarsForOutput (GH, out_vars, myGH->slablist); /* Save the last setting of 'out_vars' parameter */ out_vars_lastset = times_set; diff --git a/src/RecoverGH.c b/src/RecoverGH.c index a6854bf..e8c4b8d 100644 --- a/src/RecoverGH.c +++ b/src/RecoverGH.c @@ -39,10 +39,8 @@ int IOHDF5_RecoverParameters (void); /******************************************************************** ******************** Internal Routines ************************ ********************************************************************/ -static int IOHDF5_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); /*@@ @@ -72,7 +70,7 @@ static int IOHDF5_OpenFile (cGH *GH, @vio in @endvar - @calls IOHDF5_OpenFile + @calls OpenFile IOHDF5Util_RecoverParameters IOHDF5Util_RecoverVariables IOHDF5Util_RecoverGHextensions @@ -114,7 +112,7 @@ int IOHDF5_Recover (cGH *GH, const char *basefilename, int called_from) called_from == FILEREADER_DATA || (GH && (GH->cctk_levfac[0] > 1 || GH->cctk_convlevel > 0))) { - if (IOHDF5_OpenFile (GH, basefilename, called_from, &fileinfo) < 0) + if (OpenFile (GH, basefilename, called_from, &fileinfo) < 0) { return (-1); } @@ -175,7 +173,7 @@ int IOHDF5_Recover (cGH *GH, const char *basefilename, int called_from) fileinfo.filename); } } - IOHDF5_ERROR (H5Fclose (fileinfo.file)); + HDF5_ERROR (H5Fclose (fileinfo.file)); if (called_from == CP_RECOVER_DATA && recover_and_remove) { @@ -250,11 +248,11 @@ int IOHDF5_RecoverParameters (void) } -/**************************************************************************/ -/* local routines */ -/**************************************************************************/ +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ /*@@ - @routine IOHDF5_OpenFile + @routine OpenFile @date Tue Oct 10 2000 @author Thomas Radke @desc @@ -295,10 +293,8 @@ int IOHDF5_RecoverParameters (void) 0 for success, -1 if file could not be opened @endreturndesc @@*/ -static int IOHDF5_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) { int nprocs, myproc; hid_t group, version_attr; @@ -409,10 +405,10 @@ static int IOHDF5_OpenFile (cGH *GH, 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 multiple files the number of * writing processors must match the number of reading @@ -512,6 +508,6 @@ static int IOHDF5_OpenFile (cGH *GH, /* set the filename in the info structure */ fileinfo->filename = strdup (filename); - /* Return 0 for success otherwise negative */ + /* return 0 for success otherwise negative */ return (fileinfo->is_HDF5_file ? 0 : -1); } diff --git a/src/Startup.c b/src/Startup.c index b213adf..15dc785 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -33,9 +33,7 @@ void IOHDF5_Startup (void); /******************************************************************** ******************** Internal Routines ************************ ********************************************************************/ -static void *IOHDF5_SetupGH (tFleshConfig *config, - int convergence_level, - cGH *GH); +static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH); /*@@ @@ -53,17 +51,7 @@ static void *IOHDF5_SetupGH (tFleshConfig *config, @@*/ void IOHDF5_Startup (void) { - /* check that thorn IOHDF5Util was activated */ - if (CCTK_GHExtensionHandle ("IOHDF5Util") >= 0) - { - CCTK_RegisterGHExtensionSetupGH (CCTK_RegisterGHExtension ("IOHDF5"), - IOHDF5_SetupGH); - } - else - { - CCTK_WARN (1, "Thorn IOHDF5Util was not activated. " - "No IOHDF5 IO methods will be registered."); - } + CCTK_RegisterGHExtensionSetupGH (CCTK_RegisterGHExtension ("IOHDF5"),SetupGH); } @@ -71,7 +59,7 @@ void IOHDF5_Startup (void) ******************** Internal Routines ************************ ********************************************************************/ /*@@ - @routine IOHDF5_SetupGH + @routine SetupGH @date Mon Jun 19 2000 @author Thomas Radke @desc @@ -93,7 +81,7 @@ void IOHDF5_Startup (void) @vtype tFleshConfig * @vio usused @endvar - @var convergence_level + @var conv_level @vdesc the convergence level @vtype int @vio unused @@ -109,9 +97,7 @@ void IOHDF5_Startup (void) pointer to the new GH extension structure @endreturndesc @@*/ -static void *IOHDF5_SetupGH (tFleshConfig *config, - int convergence_level, - cGH *GH) +static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) { int i, numvars; ioHDF5GH *myGH; @@ -125,16 +111,16 @@ static void *IOHDF5_SetupGH (tFleshConfig *config, /* suppress compiler warnings about unused variables */ (void) (config + 0); - (void) (convergence_level + 0); + (void) (conv_level + 0); - /* Register the IOHDF5 routines as a new IO method */ + /* register the IOHDF5 routines as a new I/O method */ i = CCTK_RegisterIOMethod ("IOHDF5"); CCTK_RegisterIOMethodOutputGH (i, IOHDF5_OutputGH); CCTK_RegisterIOMethodOutputVarAs (i, IOHDF5_OutputVarAs); CCTK_RegisterIOMethodTimeToOutput (i, IOHDF5_TimeFor); CCTK_RegisterIOMethodTriggerOutput (i, IOHDF5_TriggerOutput); - /* Register the IOHDF5 recovery routine with thorn IOUtil */ + /* register the IOHDF5 recovery routine with thorn IOUtil */ if (IOUtil_RegisterRecover ("IOHDF5 recovery", IOHDF5_Recover) < 0) { CCTK_WARN (1, "Failed to register IOHDF5 recovery routine"); @@ -144,8 +130,7 @@ static void *IOHDF5_SetupGH (tFleshConfig *config, numvars = CCTK_NumVars (); myGH = (ioHDF5GH *) malloc (sizeof (ioHDF5GH)); myGH->out_last = (int *) malloc (numvars * sizeof (int)); - myGH->out_geo = (ioHDF5Geo_t **) calloc (numvars, sizeof (ioHDF5Geo_t *)); - myGH->check_exisiting_objects = (char *) calloc (numvars, 1); + myGH->slablist = (ioSlab **) calloc (numvars, sizeof (ioSlab *)); myGH->cp_filename_list = (char **) calloc (checkpoint_keep, sizeof (char *)); myGH->cp_filename_index = 0; diff --git a/src/Write.c b/src/Write.c index a390385..b1e8f20 100644 --- a/src/Write.c +++ b/src/Write.c @@ -78,7 +78,6 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias) DECLARE_CCTK_PARAMETERS - /* Get the handles for IO and IOHDF5 extensions */ ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); myGH = (ioHDF5GH *) CCTK_GHExtension (GH, "IOHDF5"); @@ -121,12 +120,12 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias) is_new_file ? "Opening" : "Appending", filename); } - IOHDF5_ERROR (plist = H5Pcreate (H5P_FILE_ACCESS)); + HDF5_ERROR (plist = H5Pcreate (H5P_FILE_ACCESS)); #ifdef CCTK_MPI #ifdef H5_HAVE_PARALLEL if (ioUtilGH->unchunked) { - IOHDF5_ERROR (H5Pset_fapl_mpio (plist, PUGH_pGH (GH)->PUGH_COMM_WORLD, + HDF5_ERROR (H5Pset_fapl_mpio (plist, PUGH_pGH (GH)->PUGH_COMM_WORLD, MPI_INFO_NULL)); } #endif @@ -134,12 +133,12 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias) if (is_new_file) { - IOHDF5_ERROR (file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, + HDF5_ERROR (file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist)); } else { - IOHDF5_ERROR (file = H5Fopen (filename, H5F_ACC_RDWR, plist)); + HDF5_ERROR (file = H5Fopen (filename, H5F_ACC_RDWR, plist)); } if (file < 0) { @@ -148,7 +147,7 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias) is_new_file ? "create" : "open", filename); } - IOHDF5_ERROR (H5Pclose (plist)); + HDF5_ERROR (H5Pclose (plist)); } /* output global attributes */ @@ -165,8 +164,7 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias) } /* output the data */ - retval = IOHDF5Util_DumpVar (GH, vindex, 0, myGH->out_geo[vindex], file, - myGH->check_exisiting_objects[vindex]); + retval = IOHDF5Util_DumpVar (GH, myGH->slablist[vindex], file); /* close the file */ if (file >= 0) @@ -175,7 +173,7 @@ int IOHDF5_Write (const cGH *GH, int vindex, const char *alias) { CCTK_INFO ("Closing HDF5 output file from this iteration"); } - IOHDF5_ERROR (H5Fclose (file)); + HDF5_ERROR (H5Fclose (file)); } /* free the filename if it was not registered for re-opening @@ -356,10 +354,6 @@ static char *IOHDF5_GetFilename (const cGH *GH, { *is_new_file = H5Fis_hdf5 (filename) <= 0; } H5E_END_TRY; - if (! *is_new_file) - { - myGH->check_exisiting_objects[vindex] = 1; - } } else { diff --git a/src/ioHDF5GH.h b/src/ioHDF5GH.h index 087926c..4af80f4 100644 --- a/src/ioHDF5GH.h +++ b/src/ioHDF5GH.h @@ -29,18 +29,14 @@ typedef struct /* filename database for opened files */ pNamedData *open_output_files; - /* for restart from recovery: flags indicating whether to check for already - existing groups/datasets to delete before creating them anew */ - char *check_exisiting_objects; - /* timer array for checkpointing/recovery */ int timers[IOHDF5_NUM_TIMERS]; /* flag to indicate request for timer output */ int print_timing_info; - /* geometry information (downsampling, zooming, etc.) */ - ioHDF5Geo_t **out_geo; + /* hyperslab description list (for all variables) */ + ioSlab **slablist; /* ring buffer for list of successfully created cp files */ int cp_filename_index; |