aboutsummaryrefslogtreecommitdiff
path: root/src/Write.c
diff options
context:
space:
mode:
authortradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46>2000-10-12 11:53:20 +0000
committertradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46>2000-10-12 11:53:20 +0000
commit8297b39029c9314bc4e4691c9965b318c610fb3c (patch)
tree1bf238922da24615203954bb62a0e5c3686fcedc /src/Write.c
parentedfc67c37108ac3d583b794cf4930b7482c62417 (diff)
Added checkpoint/recovery functionality.
Moved a lot of code into IOHDF5Util and inherit from this thorn. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@44 0888f3d4-9f52-45d2-93bc-d00801ff5e46
Diffstat (limited to 'src/Write.c')
-rw-r--r--src/Write.c168
1 files changed, 85 insertions, 83 deletions
diff --git a/src/Write.c b/src/Write.c
index 5ea8c65..0ce149a 100644
--- a/src/Write.c
+++ b/src/Write.c
@@ -1,146 +1,148 @@
/*@@
@file Write.c
- @date Fri May 21 1999
+ @date Tue Oct 10 2000
@author Thomas Radke
@desc
- Output and trigger routines for FiberBundle output into HDF5 files
+ File handling routines for IOStreamedHDF5.
@enddesc
- @history
- @hauthor Thomas Radke @hdate May 21 1999
- @hdesc Just copied from thorn FlexIO.
- @hendhistory
+ @version $Id$
@@*/
-#include <stdio.h>
#include <stdlib.h>
#include "cctk.h"
#include "cctk_Parameters.h"
#include "StoreNamedData.h"
#include "CactusBase/IOUtil/src/ioGH.h"
-#include "StreamedHDF5GH.h"
+#include "BetaThorns/IOHDF5Util/src/ioHDF5UtilGH.h"
+#include "ioStreamedHDF5GH.h"
-
-/* local function prototypes */
-void StreamedHDF5i_DumpParameters (cGH *GH, hid_t group);
-void StreamedHDF5i_DumpGHExtensions (cGH *GH, hid_t group);
+/* the rcs ID and its dummy function to use it */
+static char *rcsid = "$Id$";
+CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_Write_c)
/*@@
- @routine Write
- @author Paul Walker
- @date Feb 1997
- @calledby StreamedHDF5_OutputVarAs, StreamedHDF5_TriggerOutput
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable to output
- @vtype int
- @vio in
- @vcomment
- @endvar
- @var alias
- @vdesc alias name of variable to output
- @vtype const char *
- @vio in
- @vcomment
- @endvar
+ @routine IOStreamedHDF5_Write
+ @date Tue Oct 10 2000
+ @author Thomas Radke
+ @desc
+ Opens the HDF5 output file, calls the dump routine,
+ and closes it again.
+ @enddesc
+
+ @calls IOHDF5Util_DumpVar
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype cGH *
+ @vio in
+ @endvar
+ @var index
+ @vdesc index of variable
+ @vtype int
+ @vio in
+ @endvar
+ @var alias
+ @vdesc alias name of variable to output
+ @vtype const char *
+ @vio in
+ @endvar
@@*/
-void StreamedHDF5_Write (cGH *GH, int index, const char *alias)
+void IOStreamedHDF5_Write (cGH *GH,
+ int index,
+ const char *alias)
{
DECLARE_CCTK_PARAMETERS
- int vtype;
int timelevel;
- StreamedHDF5GH *myGH;
- hid_t fid, plist;
+ int old_ioproc;
+ int old_nioprocs;
+ int old_ioproc_every;
+ char *fullname;
+ ioGH *ioUtilGH;
+ ioStreamedHDF5GH *myGH;
+ hid_t file, plist;
H5FD_stream_fapl_t fapl;
-#if 0
- hid_t group;
-#endif
/* first, check if variable has storage assigned */
if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index)))
{
- char *fullname = CCTK_FullName (index);
+ fullname = CCTK_FullName (index);
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No StreamedHDF5 output for '%s' (no storage)", fullname);
+ "No IOStreamedHDF5 output for '%s' (no storage)", fullname);
free (fullname);
return;
}
- /* check if variable is of type GF or ARRAY */
- vtype = CCTK_GroupTypeFromVarI (index);
- if (vtype != CCTK_GF && vtype != CCTK_ARRAY)
+ /* 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" */
+ if (ioUtilGH->nioprocs != 1)
{
- char *fullname = CCTK_FullName (index);
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No StreamedHDF5 output for '%s' (not an array type)", fullname);
- free (fullname);
- return;
+ CCTK_WARN (2, "Output into multiple chunked files not yet implemented. "
+ "Switching to IO mode \"oneproc\".");
}
-
- /* Get the handles for IO and StreamedHDF5 extensions */
- myGH = (StreamedHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("StreamedHDF5")];
-
- fid = -1;
- if (CCTK_MyProc (GH) == 0)
+ old_ioproc = ioUtilGH->ioproc;
+ ioUtilGH->ioproc = 0;
+ old_nioprocs = ioUtilGH->nioprocs;
+ ioUtilGH->nioprocs = 1;
+ old_ioproc_every = ioUtilGH->ioproc_every;
+ ioUtilGH->ioproc_every = CCTK_nProcs (GH);
+
+ file = -1;
+ if (CCTK_MyProc (GH) == 0 && myGH->data_socket >= 0)
{
- /* filename is not used if we pass a socket descriptor
- but it must not be NULL or an empty string */
- static const char *filename = "bla";
-
-
if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "Opening HDF5 output file on port %d",
- port);
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Opening HDF5 output file "
+ "on data output port %d", data_port);
+ }
/* set file access property list to use the Stream VFD
and open the file */
fapl.increment = 0;
- fapl.socket = myGH->socket;
+ fapl.socket = myGH->data_socket;
fapl.do_socket_io = 1;
fapl.backlog = 5;
fapl.broadcast_fn = NULL;
fapl.broadcast_arg = NULL;
- CACTUS_IOHDF5_ERROR (plist = H5Pcreate (H5P_FILE_ACCESS));
- CACTUS_IOHDF5_ERROR (H5Pset_fapl_stream (plist, &fapl));
- CACTUS_IOHDF5_ERROR (fid = H5Fcreate (filename, H5F_ACC_TRUNC,
- H5P_DEFAULT, plist));
- CACTUS_IOHDF5_ERROR (H5Pclose (plist));
-
-#if 0
- /* output global attributes */
- if (verbose)
- CCTK_INFO ("Dumping GH extensions ...");
-
- CACTUS_IOHDF5_ERROR (group = H5Gcreate (fid, GHEXTENSIONS_GROUP, 0));
- StreamedHDF5i_DumpGHExtensions (GH, group);
- CACTUS_IOHDF5_ERROR (H5Gclose (group));
-#endif
+ IOHDF5_ERROR (plist = H5Pcreate (H5P_FILE_ACCESS));
+ IOHDF5_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,
+ plist));
+ IOHDF5_ERROR (H5Pclose (plist));
}
/* get the current timelevel */
timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1;
if (timelevel > 0)
+ {
timelevel--;
+ }
/* output the data */
- StreamedHDF5_DumpVar (GH, index, timelevel, fid);
+ IOHDF5Util_DumpVar (GH, index, timelevel, &myGH->geo_output[index], file, 0);
/* close the file */
- if (fid >= 0)
+ if (file >= 0)
{
if (verbose)
+ {
CCTK_INFO ("Closing HDF5 output file from this iteration");
- CACTUS_IOHDF5_ERROR (H5Fclose (fid));
+ }
+ IOHDF5_ERROR (H5Fclose (file));
}
+ /* restore original IO mode */
+ ioUtilGH->ioproc = old_ioproc;
+ ioUtilGH->nioprocs = old_nioprocs;
+ ioUtilGH->ioproc_every = old_ioproc_every;
}