aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46>2002-04-23 14:59:14 +0000
committertradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46>2002-04-23 14:59:14 +0000
commit90554ed957200a5cda3d52ff10f05ffda2b55565 (patch)
treeb2c1f264ca696e3cf255e5f499c78ebac35d610b
parentbc3503172ce53e24961101082aca66136b195b78 (diff)
Code cleanup before moving into producion mode.
You must also update BetaThorns/IOHDF5Util now. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@81 0888f3d4-9f52-45d2-93bc-d00801ff5e46
-rw-r--r--src/DumpGH.c84
-rw-r--r--src/Output.c109
-rw-r--r--src/RecoverGH.c74
-rw-r--r--src/Startup.c85
-rw-r--r--src/Write.c31
-rw-r--r--src/ioStreamedHDF5GH.h4
-rw-r--r--src/make.configuration.defn9
7 files changed, 189 insertions, 207 deletions
diff --git a/src/DumpGH.c b/src/DumpGH.c
index 4599a82..dcec1a4 100644
--- a/src/DumpGH.c
+++ b/src/DumpGH.c
@@ -35,11 +35,18 @@ static const char *rcsid = "$Id$";
CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_DumpGH_c)
-/* prototypes of routines defined in this source file */
-void IOStreamedHDF5_InitialDataCheckpoint (cGH *GH);
-void IOStreamedHDF5_EvolutionCheckpoint (cGH *GH);
-void IOStreamedHDF5_TerminationCheckpoint (cGH *GH);
-static int IOStreamedHDF5_Checkpoint (cGH *GH, int called_from);
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
+void IOStreamedHDF5_InitialDataCheckpoint (const cGH *GH);
+void IOStreamedHDF5_EvolutionCheckpoint (const cGH *GH);
+void IOStreamedHDF5_TerminationCheckpoint (const cGH *GH);
+
+
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
+static int Checkpoint (const cGH *GH, int called_from);
/*@@
@@ -51,22 +58,22 @@ static int IOStreamedHDF5_Checkpoint (cGH *GH, int called_from);
It checks if initial data should be checkpointed.
@enddesc
- @calls IOStreamedHDF5_Checkpoint
+ @calls Checkpoint
@var GH
@vdesc Pointer to CCTK grid hierarchy to be checkpointed
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@@*/
-void IOStreamedHDF5_InitialDataCheckpoint (cGH *GH)
+void IOStreamedHDF5_InitialDataCheckpoint (const cGH *GH)
{
DECLARE_CCTK_PARAMETERS
if (checkpoint && checkpoint_ID)
{
- IOStreamedHDF5_Checkpoint (GH, CP_INITIAL_DATA);
+ Checkpoint (GH, CP_INITIAL_DATA);
}
}
@@ -80,15 +87,15 @@ void IOStreamedHDF5_InitialDataCheckpoint (cGH *GH)
It periodically checks if it's time to checkpoint evolution data.
@enddesc
- @calls IOStreamedHDF5_Checkpoint
+ @calls Checkpoint
@var GH
@vdesc Pointer to CCTK grid hierarchy to be checkpointed
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@@*/
-void IOStreamedHDF5_EvolutionCheckpoint (cGH *GH)
+void IOStreamedHDF5_EvolutionCheckpoint (const cGH *GH)
{
DECLARE_CCTK_PARAMETERS
@@ -103,7 +110,7 @@ void IOStreamedHDF5_EvolutionCheckpoint (cGH *GH)
CCTK_VInfo (CCTK_THORNSTRING, "Dumping periodic checkpoint file at "
"iteration %d", GH->cctk_iteration);
}
- IOStreamedHDF5_Checkpoint (GH, CP_EVOLUTION_DATA);
+ Checkpoint (GH, CP_EVOLUTION_DATA);
/* reset the 'checkpoint_next' parameter */
if (checkpoint_next)
@@ -123,31 +130,31 @@ void IOStreamedHDF5_EvolutionCheckpoint (cGH *GH)
It checks if the last iteration should be checkpointed.
@enddesc
- @calls IOStreamedHDF5_Checkpoint
+ @calls Checkpoint
@var GH
@vdesc Pointer to CCTK grid hierarchy to be checkpointed
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@@*/
-void IOStreamedHDF5_TerminationCheckpoint (cGH *GH)
+void IOStreamedHDF5_TerminationCheckpoint (const cGH *GH)
{
DECLARE_CCTK_PARAMETERS
if (checkpoint && checkpoint_on_terminate)
{
- IOStreamedHDF5_Checkpoint (GH, CP_EVOLUTION_DATA);
+ Checkpoint (GH, CP_EVOLUTION_DATA);
}
}
-/*****************************************************************************/
-/* local routines */
-/*****************************************************************************/
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
/*@@
- @routine IOStreamedHDF5_Checkpoint
+ @routine Checkpoint
@date Fri Oct 6 2000
@author Thomas Radke
@desc
@@ -161,7 +168,7 @@ void IOStreamedHDF5_TerminationCheckpoint (cGH *GH)
@var GH
@vdesc Pointer to CCTK grid hierarchy to be checkpointed
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@var called_from
@@ -176,34 +183,34 @@ void IOStreamedHDF5_TerminationCheckpoint (cGH *GH)
or returncode of @seeroutine IOUtilHDF5_DumpGH
@endreturndesc
@@*/
-static int IOStreamedHDF5_Checkpoint (cGH *GH, int called_from)
+static int Checkpoint (const cGH *GH, int called_from)
{
- DECLARE_CCTK_PARAMETERS
hid_t file;
- int old_ioproc;
- int old_nioprocs;
- int old_ioproc_every;
+ int old_ioproc, old_nioprocs, old_ioproc_every;
fd_set readset;
struct timeval timeout;
ioGH *ioUtilGH;
ioStreamedHDF5GH *myGH;
CCTK_INT4 retval;
+ const char *timer_descriptions[3] = {"Time to dump parameters: ",
+ "Time to dump datasets: ",
+ "Total time to checkpoint:"};
+ DECLARE_CCTK_PARAMETERS
/* suppress compiler warning about unused variables */
- called_from = called_from;
+ (void) (called_from + 0);
retval = 0;
file = -1;
- /* Get the GH extensions for IOUtil and IOStreamedHDF5 */
ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO");
myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
- /* check if IOStreamedHDF5 was registered as IO method */
+ /* check if IOStreamedHDF5 was registered as I/O method */
if (myGH == NULL)
{
- CCTK_WARN (2, "No IOStreamedHDF5 IO method registered");
+ CCTK_WARN (2, "No IOStreamedHDF5 I/O method registered");
return (-1);
}
@@ -213,11 +220,11 @@ static int IOStreamedHDF5_Checkpoint (cGH *GH, int called_from)
CCTK_TimerStartI (myGH->timers[CP_TOTAL_TIMER]);
}
- /* for now we can only have IO mode "oneproc" */
+ /* for now we can only have I/O mode "oneproc" */
if (ioUtilGH->nioprocs != 1)
{
CCTK_WARN (2, "Output into multiple chunked files not yet implemented. "
- "Switching to IO mode \"oneproc\".");
+ "Switching to I/O mode \"oneproc\".");
}
old_ioproc = ioUtilGH->ioproc;
ioUtilGH->ioproc = 0;
@@ -226,7 +233,7 @@ static int IOStreamedHDF5_Checkpoint (cGH *GH, int called_from)
old_ioproc_every = ioUtilGH->ioproc_every;
ioUtilGH->ioproc_every = CCTK_nProcs (GH);
- /* Now open the file */
+ /* now open the file */
if (CCTK_MyProc (GH) == ioUtilGH->ioproc && myGH->checkpoint_socket >= 0)
{
if (verbose)
@@ -285,10 +292,10 @@ static int IOStreamedHDF5_Checkpoint (cGH *GH, int called_from)
CCTK_VInfo (CCTK_THORNSTRING, "Closing checkpoint file on port %d",
checkpoint_port);
}
- IOHDF5_ERROR (H5Fclose (file));
+ HDF5_ERROR (H5Fclose (file));
}
- /* restore original IO mode */
+ /* restore original I/O mode */
ioUtilGH->ioproc = old_ioproc;
ioUtilGH->nioprocs = old_nioprocs;
ioUtilGH->ioproc_every = old_ioproc_every;
@@ -296,11 +303,6 @@ static int IOStreamedHDF5_Checkpoint (cGH *GH, int called_from)
/* stop the CP_TOTAL_TIMER timer and print timing information */
if (myGH->print_timing_info)
{
- const char *timer_descriptions[3] = {"Time to dump parameters: ",
- "Time to dump datasets: ",
- "Total time to checkpoint:"};
-
-
CCTK_TimerStopI (myGH->timers[CP_TOTAL_TIMER]);
IOUtil_PrintTimings ("Timing information for checkpointing "
"with IOStreamedHDF5:",
diff --git a/src/Output.c b/src/Output.c
index 6e7e6f1..1a68fac 100644
--- a/src/Output.c
+++ b/src/Output.c
@@ -2,10 +2,10 @@
@file Output.c
@date Tue Jan 9 1999
@author Gabrielle Allen
- @desc
+ @desc
Functions to deal with streaming output of variables
in HDF5 format.
- @enddesc
+ @enddesc
@version $Id$
@@*/
@@ -24,7 +24,7 @@ CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_Output_c)
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static void CheckSteerableParameters (ioStreamedHDF5GH *myGH);
+static void CheckSteerableParameters (const cGH *GH);
/*@@
@@ -59,36 +59,33 @@ int IOStreamedHDF5_OutputGH (const cGH *GH)
DECLARE_CCTK_PARAMETERS
- /* Get the GH extension for IOStreamedHDF5 */
myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
- CheckSteerableParameters (myGH);
+ CheckSteerableParameters (GH);
if (myGH->out_every <= 0)
{
return (0);
}
- /* Loop over all variables */
+ /* loop over all variables */
for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++)
{
-
if (IOStreamedHDF5_TimeFor (GH, vindex))
{
-
name = CCTK_VarName (vindex);
fullname = CCTK_FullName (vindex);
if (verbose)
{
CCTK_VInfo (CCTK_THORNSTRING, "IOStreamedHDF5_OutputGH: "
- "output of variable (fullname / name) "
- "= ('%s' / '%s')", fullname, name);
+ "output of variable (fullname, name) = "
+ "('%s', '%s')", fullname, name);
}
if (IOStreamedHDF5_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++;
}
@@ -106,8 +103,8 @@ int IOStreamedHDF5_OutputGH (const cGH *GH)
@date Sat March 6 1999
@author Gabrielle Allen
@desc
- Unconditional output of a variable
- using the IOStreamedHDF5 output method.
+ Unconditional output of a variable using
+ the IOStreamedHDF5 I/O method.
@enddesc
@calls IOStreamedHDF5_Write
@@ -134,8 +131,7 @@ int IOStreamedHDF5_OutputGH (const cGH *GH)
return code of @seeroutine IOStreamedHDF5_Write
@endreturndesc
@@*/
-int IOStreamedHDF5_OutputVarAs (const cGH *GH,
- const char *fullname,
+int IOStreamedHDF5_OutputVarAs (const cGH *GH, const char *fullname,
const char *alias)
{
int vindex, retval;
@@ -147,11 +143,11 @@ int IOStreamedHDF5_OutputVarAs (const cGH *GH,
if (verbose)
{
CCTK_VInfo (CCTK_THORNSTRING, "IOStreamedHDF5_OutputVarAs: "
- "output of variable (fullname / alias) "
- "= ('%s' / '%s')", fullname, alias);
+ "output of variable (fullname, alias) = "
+ "('%s', '%s')", fullname, alias);
}
- /* Do the output */
+ /* do the output */
retval = IOStreamedHDF5_Write (GH, vindex, alias);
return (retval);
@@ -164,7 +160,7 @@ int IOStreamedHDF5_OutputVarAs (const cGH *GH,
@author Gabrielle Allen
@desc
Decides if it is time to output a variable
- using the IOStreamedHDF5 output method.
+ using the IOStreamedHDF5 I/O method.
@enddesc
@calls CheckSteerableParameters
@@ -182,41 +178,38 @@ int IOStreamedHDF5_OutputVarAs (const cGH *GH,
@returntype int
@returndesc
- 1 if output should take place
+ 1 if output should take place at this iteration, or<BR>
0 if not
@endreturndesc
@@*/
-int IOStreamedHDF5_TimeFor (const cGH *GH,
- int vindex)
+int IOStreamedHDF5_TimeFor (const cGH *GH, int vindex)
{
+ int retval;
+ char *fullname;
ioStreamedHDF5GH *myGH;
- /* Get the GH extension for IOStreamedHDF5 */
- myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
-
- CheckSteerableParameters (myGH);
-
- /* Check if any output was requested */
- if(myGH->out_every <= 0)
- {
- return (0);
- }
-
- /* Check this variable should be output */
- if (! (myGH->geo_output[vindex] && GH->cctk_iteration % myGH->out_every == 0))
- {
- return (0);
- }
+ CheckSteerableParameters (GH);
- /* Check variable not already output this iteration */
- if (myGH->out_last[vindex] == GH->cctk_iteration)
+ /* check if this variable should be output */
+ myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
+ retval = myGH->out_every > 0 && myGH->slablist[vindex] &&
+ GH->cctk_iteration % myGH->out_every == 0;
+ if (retval)
{
- CCTK_WARN (2, "Already done output in IOStreamedHDF5");
- return (0);
+ /* check if variable was not already output this iteration */
+ if (myGH->out_last[vindex] == GH->cctk_iteration)
+ {
+ fullname = CCTK_FullName (vindex);
+ CCTK_VWarn (6, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Already done IOStreamedHDF5 output for variable '%s' in "
+ "current iteration (probably via triggers)", fullname);
+ free (fullname);
+ retval = 0;
+ }
}
- return (1);
+ return (retval);
}
@@ -226,7 +219,7 @@ int IOStreamedHDF5_TimeFor (const cGH *GH,
@author Gabrielle Allen
@desc
Triggers the output of a variable
- using the IOStreamedHDF5 output.
+ using the IOStreamedHDF5 I/O method.
@enddesc
@calls IOStreamedHDF5_Write
@@ -247,8 +240,7 @@ int IOStreamedHDF5_TimeFor (const cGH *GH,
return code of @seeroutine IOStreamedHDF5_Write
@endreturndesc
@@*/
-int IOStreamedHDF5_TriggerOutput (const cGH *GH,
- int vindex)
+int IOStreamedHDF5_TriggerOutput (const cGH *GH, int vindex)
{
int retval;
ioStreamedHDF5GH *myGH;
@@ -265,17 +257,17 @@ int IOStreamedHDF5_TriggerOutput (const cGH *GH,
{
fullname = CCTK_FullName (vindex);
CCTK_VInfo (CCTK_THORNSTRING, "IOStreamedHDF5_TriggerOutput: "
- "output of (varname, fullname) "
- "= ('%s', '%s')", varname, fullname);
+ "output of (varname, fullname) = "
+ "('%s', '%s')", varname, fullname);
free (fullname);
}
- /* Do the output */
+ /* do the output */
retval = IOStreamedHDF5_Write (GH, vindex, varname);
if (retval == 0)
{
- /* Register variable as having output this iteration */
+ /* register variable as having output this iteration */
myGH->out_last[vindex] = GH->cctk_iteration;
}
@@ -297,20 +289,23 @@ int IOStreamedHDF5_TriggerOutput (const cGH *GH,
@calls IOHDF5Util_ParseVarsForOutput
- @var myGH
- @vdesc Pointer to IOStreamedHDF5 GH
- @vtype ioStreamedHDF5GH *
+ @var GH
+ @vdesc Pointer to CCTK grid hierarchy
+ @vtype const cGH *
@vio in
@endvar
@@*/
-static void CheckSteerableParameters (ioStreamedHDF5GH *myGH)
+static void CheckSteerableParameters (const cGH *GH)
{
- int type, times_set;
+ int times_set;
+ ioStreamedHDF5GH *myGH;
static int out_vars_lastset = -1, user_was_warned = 0;
DECLARE_CCTK_PARAMETERS
- /* How often to output */
+ myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
+
+ /* how often to output */
if (out_every >= 0 || outHDF5_every >= 0)
{
if (out_every < 0)
@@ -340,7 +335,7 @@ static void CheckSteerableParameters (ioStreamedHDF5GH *myGH)
times_set = CCTK_ParameterQueryTimesSet ("out_vars", CCTK_THORNSTRING);
if (times_set != out_vars_lastset)
{
- IOHDF5Util_ParseVarsForOutput (out_vars, myGH->geo_output);
+ 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 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);
}
diff --git a/src/Startup.c b/src/Startup.c
index 8e9ea7a..05bc401 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -28,12 +28,17 @@ static const char *rcsid = "$Id$";
CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_Startup_c)
-/* prototypes of routines defined in this source file */
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
void IOStreamedHDF5_Startup (void);
-void IOStreamedHDF5_Terminate (cGH *GH);
-static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
- int convergence_level,
- cGH *GH);
+void IOStreamedHDF5_Terminate (const cGH *GH);
+
+
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
+static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH);
/*@@
@@ -46,27 +51,13 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
along with its setup routine.
@enddesc
- @calls CCTK_RegisterGHExtensionSetupGH
+ @calls CCTK_RegisterGHExtension
+ CCTK_RegisterGHExtensionSetupGH
@@*/
void IOStreamedHDF5_Startup (void)
{
- /* check that thorn IOHDF5Util was activated */
- if (CCTK_GHExtensionHandle ("IOHDF5Util") < 0)
- {
- CCTK_WARN (1, "Thorn IOHDF5Util was not activated. "
- "No IOStreamedHDF5 IO methods will be registered.");
- return;
- }
-
- /* FIXME: this check can go as soon as the Stream VFD
- comes with the default HDF5 installation */
-#ifndef H5_HAVE_STREAM
- CCTK_WARN (1, "The Stream VFD was not configured in your HDF5 installation. "
- "No HDF5 streaming IO will be available !");
-#else
CCTK_RegisterGHExtensionSetupGH (CCTK_RegisterGHExtension ("IOStreamedHDF5"),
- IOStreamedHDF5_SetupGH);
-#endif
+ SetupGH);
}
@@ -83,11 +74,11 @@ void IOStreamedHDF5_Startup (void)
@var GH
@vdesc Pointer to CCTK grid hierarchy
- @vtype cGH *
+ @vtype const cGH *
@vio in
@endvar
@@*/
-void IOStreamedHDF5_Terminate (cGH *GH)
+void IOStreamedHDF5_Terminate (const cGH *GH)
{
int i;
ioStreamedHDF5GH *myGH;
@@ -125,11 +116,11 @@ void IOStreamedHDF5_Terminate (cGH *GH)
}
-/****************************************************************************/
-/* local routines */
-/****************************************************************************/
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
/*@@
- @routine IOStreamedHDF5_SetupGH
+ @routine SetupGH
@date Mon Jun 19 2000
@author Thomas Radke
@desc
@@ -154,7 +145,7 @@ void IOStreamedHDF5_Terminate (cGH *GH)
@vtype tFleshConfig *
@vio unused
@endvar
- @var convergence_level
+ @var conv_level
@vdesc the convergence level
@vtype int
@vio unused
@@ -170,47 +161,43 @@ void IOStreamedHDF5_Terminate (cGH *GH)
pointer to the allocated GH extension structure
@endreturndesc
@@*/
-static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
- int convergence_level,
- cGH *GH)
+static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
{
- DECLARE_CCTK_PARAMETERS
- int i;
- int myproc;
- int numvars;
+ int i, myproc, numvars;
char hostname[256];
ioStreamedHDF5GH *myGH;
+ H5FD_stream_fapl_t fapl;
FILE *advertised_file_fd;
ioAdvertisedFileDesc advertised_file;
const char *timer_names[4] = {"IOStreamedHDF5 time to dump parameters",
"IOStreamedHDF5 time to dump variables",
"IOStreamedHDF5 total time to checkpoint",
"IOStreamedHDF5 time to recover"};
+ DECLARE_CCTK_PARAMETERS
/* suppress compiler warnings about unused variables */
- config = config;
- convergence_level = convergence_level;
-
- myproc = CCTK_MyProc (GH);
+ (void) (config + 0);
+ (void) (conv_level + 0);
- /* Register IOStreamedHDF5 routines as output methods */
+ /* register IOStreamedHDF5 routines as a new I/O method */
i = CCTK_RegisterIOMethod ("IOStreamedHDF5");
CCTK_RegisterIOMethodOutputGH (i, IOStreamedHDF5_OutputGH);
CCTK_RegisterIOMethodOutputVarAs (i, IOStreamedHDF5_OutputVarAs);
CCTK_RegisterIOMethodTimeToOutput (i, IOStreamedHDF5_TimeFor);
CCTK_RegisterIOMethodTriggerOutput (i, IOStreamedHDF5_TriggerOutput);
- /* Register the IOStreamedHDF5 recovery routine to thorn IOUtil */
+ /* register the IOStreamedHDF5 recovery routine to thorn IOUtil */
if (IOUtil_RegisterRecover ("IOStreamedHDF5 recovery",
IOStreamedHDF5_Recover) < 0)
{
CCTK_WARN (1, "Failed to register IOStreamedHDF5 recovery routine");
}
+ /* allocate a new GH extension structure */
numvars = CCTK_NumVars ();
myGH = (ioStreamedHDF5GH *) malloc (sizeof (ioStreamedHDF5GH));
- myGH->geo_output = (ioHDF5Geo_t **) calloc (numvars, sizeof (ioHDF5Geo_t *));
+ myGH->slablist = (ioSlab **) calloc (numvars, sizeof (ioSlab *));
myGH->out_last = (int *) malloc (numvars * sizeof (int));
myGH->advertised_filename = NULL;
@@ -221,6 +208,7 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
/* only processor 0 is doing socket I/O */
myGH->data_socket = -1;
+ myproc = CCTK_MyProc (GH);
if (myproc == 0)
{
myGH->data_socket = Socket_TCPOpenServerSock (data_port);
@@ -310,9 +298,6 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
}
}
- /* FIXME: this check can go as soon as the Stream VFD
- comes with the default HDF5 installation */
-#ifdef H5_HAVE_STREAM
/* only processor 0 is doing socket I/O */
myGH->checkpoint_socket = -1;
myGH->checkpoint_fapl = -1;
@@ -335,9 +320,6 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
}
else
{
- H5FD_stream_fapl_t fapl;
-
-
/* setup file access property list and select Stream VFD */
fapl.increment = 0;
fapl.socket = myGH->checkpoint_socket;
@@ -345,8 +327,8 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
fapl.backlog = 5;
fapl.broadcast_fn = NULL;
fapl.broadcast_arg = NULL;
- IOHDF5_ERROR (myGH->checkpoint_fapl = H5Pcreate (H5P_FILE_ACCESS));
- IOHDF5_ERROR (H5Pset_fapl_stream (myGH->checkpoint_fapl, &fapl));
+ HDF5_ERROR (myGH->checkpoint_fapl = H5Pcreate (H5P_FILE_ACCESS));
+ HDF5_ERROR (H5Pset_fapl_stream (myGH->checkpoint_fapl, &fapl));
Util_GetHostName (hostname, sizeof (hostname));
CCTK_VInfo (CCTK_THORNSTRING,
@@ -355,7 +337,6 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
hostname, checkpoint_port);
}
}
-#endif
return (myGH);
}
diff --git a/src/Write.c b/src/Write.c
index 56b4bc5..addd5a0 100644
--- a/src/Write.c
+++ b/src/Write.c
@@ -2,9 +2,9 @@
@file Write.c
@date Tue Oct 10 2000
@author Thomas Radke
- @desc
+ @desc
File handling routines for IOStreamedHDF5.
- @enddesc
+ @enddesc
@version $Id$
@@*/
@@ -52,25 +52,23 @@ CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_Write_c)
@returntype int
@returndesc
- 0 for success, or<BR>
+ return code of @seeroutine IOHDF5Util_DumpVar, or<BR>
-1 if variable has no storage assigned
@endreturndesc
@@*/
int IOStreamedHDF5_Write (const cGH *GH, int vindex, const char *alias)
{
- DECLARE_CCTK_PARAMETERS
- int old_ioproc;
- int old_nioprocs;
- int old_ioproc_every;
+ int old_ioproc, old_nioprocs, old_ioproc_every, retval;
char *fullname;
ioGH *ioUtilGH;
ioStreamedHDF5GH *myGH;
hid_t file, plist;
H5FD_stream_fapl_t fapl;
+ DECLARE_CCTK_PARAMETERS
/* suppress compiler warnings about unused variables */
- alias = alias;
+ (void) (alias + 0);
/* first, check if variable has storage assigned */
if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex)))
@@ -82,11 +80,10 @@ int IOStreamedHDF5_Write (const cGH *GH, int vindex, const char *alias)
return (-1);
}
- /* Get the handles for IO and IOStreamedHDF5 extensions */
ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO");
myGH = (ioStreamedHDF5GH *) CCTK_GHExtension (GH, "IOStreamedHDF5");
- /* for now we can only have IO mode "oneproc" */
+ /* for now we can only have I/O mode "oneproc" */
if (ioUtilGH->nioprocs != 1)
{
CCTK_WARN (2, "Output into multiple chunked files not yet implemented. "
@@ -117,18 +114,18 @@ int IOStreamedHDF5_Write (const cGH *GH, int vindex, const char *alias)
fapl.broadcast_fn = NULL;
fapl.broadcast_arg = NULL;
- IOHDF5_ERROR (plist = H5Pcreate (H5P_FILE_ACCESS));
- IOHDF5_ERROR (H5Pset_fapl_stream (plist, &fapl));
+ HDF5_ERROR (plist = H5Pcreate (H5P_FILE_ACCESS));
+ HDF5_ERROR (H5Pset_fapl_stream (plist, &fapl));
/* filename is not used if we pass a plist
but it must not be NULL or an empty string */
- IOHDF5_ERROR (file = H5Fcreate ("unused", H5F_ACC_TRUNC, H5P_DEFAULT,
+ HDF5_ERROR (file = H5Fcreate ("unused", H5F_ACC_TRUNC, H5P_DEFAULT,
plist));
- IOHDF5_ERROR (H5Pclose (plist));
+ HDF5_ERROR (H5Pclose (plist));
}
/* output the data */
- IOHDF5Util_DumpVar (GH, vindex, 0, myGH->geo_output[vindex], file, 0);
+ retval = IOHDF5Util_DumpVar (GH, myGH->slablist[vindex], file);
/* close the file */
if (file >= 0)
@@ -137,7 +134,7 @@ int IOStreamedHDF5_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));
}
/* restore original IO mode */
@@ -145,5 +142,5 @@ int IOStreamedHDF5_Write (const cGH *GH, int vindex, const char *alias)
ioUtilGH->nioprocs = old_nioprocs;
ioUtilGH->ioproc_every = old_ioproc_every;
- return (0);
+ return (retval);
}
diff --git a/src/ioStreamedHDF5GH.h b/src/ioStreamedHDF5GH.h
index 823cfcc..ea8acba 100644
--- a/src/ioStreamedHDF5GH.h
+++ b/src/ioStreamedHDF5GH.h
@@ -23,7 +23,7 @@ typedef struct
/* FIXME: make this a linked list of requests
to allow for multiple requests per variable
(eg. with different hyperslab parameters) */
- ioHDF5Geo_t **geo_output;
+ ioSlab **slablist;
/* the last iteration output */
int *out_last;
@@ -49,7 +49,7 @@ extern "C"
{
#endif
-/* prototypes of functions to be registered as IOStreamedHDF5's IO method */
+/* prototypes of functions to be registered as IOStreamedHDF5's I/O method */
int IOStreamedHDF5_OutputGH (const cGH *GH);
int IOStreamedHDF5_TriggerOutput (const cGH *GH, int);
int IOStreamedHDF5_TimeFor (const cGH *GH, int);
diff --git a/src/make.configuration.defn b/src/make.configuration.defn
new file mode 100644
index 0000000..a8db886
--- /dev/null
+++ b/src/make.configuration.defn
@@ -0,0 +1,9 @@
+# make.configuration.defn for IOStreamedHDF5
+# $Header$
+
+# make sure that the HDF5 Stream Virtual File Driver is available
+stream_support := $(shell grep '\#define H5_HAVE_STREAM 1' $(HDF5_INC_DIRS)/H5pubconf.h)
+
+ifeq ($(strip $(stream_support)),)
+ $(error "IOStreamedHDF5 requires an HDF5 installation with built-in Stream Virtual File Driver. Please reconfigure with an appropriate HDF5 installation or remove IOStreamedHDF5 from ThornList !")
+endif