aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2004-02-04 13:44:42 +0000
committertradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2004-02-04 13:44:42 +0000
commite31f3f860ae1e4163dda2325db239b4c39614e50 (patch)
treefb8f0e4867dd3f3fd38b03ef0d82b88e8d9295c9
parent8324407bddd5fc1a2bfc5bf53a09000511904c01 (diff)
Write all the Cactus parameters into a dataset rather than a single string
attribute. This fixes a problem with very many parameters to dump as HDF5 has a 16k size limit on attributes. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@106 7842ec3a-9562-4be5-9c5b-06ba18f2b668
-rw-r--r--src/DumpUtils.c22
-rw-r--r--src/RecoverVar.c44
2 files changed, 48 insertions, 18 deletions
diff --git a/src/DumpUtils.c b/src/DumpUtils.c
index a37bb93..fd9c389 100644
--- a/src/DumpUtils.c
+++ b/src/DumpUtils.c
@@ -286,8 +286,13 @@ void IOHDF5Util_DumpCommonAttributes (const cGH *GH, const ioRequest *request,
@author Thomas Radke
@desc
Collects the parameters of all active implementations
- into a single string and writes it as an attribute
- attached to the CACTUS_PARAMETERS_GROUP group in the HDF5 file.
+ into a single string and writes it as a single dataset
+ into the CACTUS_PARAMETERS_GROUP group in the HDF5 file.
+
+ Note that we used to write the parameters string as a single
+ attribute attached to the CACTUS_PARAMETERS_GROUP group.
+ This caused problems with very long strings (HDF5 has a 16k-limit
+ on the total size of attributes).
@enddesc
@var GH
@vdesc pointer to CCTK grid hierarchy
@@ -310,7 +315,8 @@ void IOHDF5Util_DumpParameters (const cGH *GH, int all, hid_t file)
{
ioHDF5UtilGH *myGH;
char *parameters;
- hid_t group;
+ hid_t group, dataspace, dataset;
+ hsize_t size;
DECLARE_CCTK_PARAMETERS
@@ -325,9 +331,15 @@ void IOHDF5Util_DumpParameters (const cGH *GH, int all, hid_t file)
if (parameters)
{
myGH = CCTK_GHExtension (GH, "IOHDF5Util");
+ size = strlen (parameters) + 1;
HDF5_ERROR (group = H5Gcreate (file, CACTUS_PARAMETERS_GROUP, 0));
- WRITE_ATTRIBUTE (ALL_PARAMETERS, parameters, group, myGH, 0,
- myGH->HDF5_STRING);
+ HDF5_ERROR (dataspace = H5Screate_simple (1, &size, NULL));
+ HDF5_ERROR (dataset = H5Dcreate (group, ALL_PARAMETERS, H5T_NATIVE_UCHAR,
+ dataspace, H5P_DEFAULT));
+ HDF5_ERROR (H5Dwrite (dataset, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, parameters));
+ HDF5_ERROR (H5Dclose (dataset));
+ HDF5_ERROR (H5Sclose (dataspace));
HDF5_ERROR (H5Gclose (group));
free (parameters);
diff --git a/src/RecoverVar.c b/src/RecoverVar.c
index 8724f7b..f8e63da 100644
--- a/src/RecoverVar.c
+++ b/src/RecoverVar.c
@@ -247,14 +247,14 @@ int IOHDF5Util_RecoverGHextensions (cGH *GH, const fileinfo_t *fileinfo)
(don't have subcommunicators yet) */
int IOHDF5Util_RecoverParameters (const fileinfo_t *fileinfo)
{
- hid_t group, attr, atype;
+ hid_t group, attr, dataset, atype;
char *parameters;
CCTK_INT4 parameterSize;
DECLARE_CCTK_PARAMETERS
/* To make the compiler happy */
- group = attr = 0;
+ group = attr = dataset = -1;
parameters = NULL;
parameterSize = 0;
@@ -267,21 +267,35 @@ int IOHDF5Util_RecoverParameters (const fileinfo_t *fileinfo)
}
/* the parameters are stored in the CACTUS_PARAMETERS_GROUP group
- in the attribute ALL_PARAMETERS */
+ in the attribute (old style) or dataset (new style) ALL_PARAMETERS */
group = H5Gopen (fileinfo->file, CACTUS_PARAMETERS_GROUP);
if (group > 0)
{
- attr = H5Aopen_name (group, ALL_PARAMETERS);
+ H5E_BEGIN_TRY
+ {
+ attr = H5Aopen_name (group, ALL_PARAMETERS);
+ dataset = H5Dopen (group, ALL_PARAMETERS);
+ } H5E_END_TRY
}
- if (group > 0 && attr > 0)
+ if (group >= 0 && (attr >= 0 || dataset >= 0))
{
- HDF5_ERROR (atype = H5Aget_type (attr));
- parameterSize = H5Tget_size (atype);
- parameters = malloc (parameterSize + 1);
- HDF5_ERROR (H5Aread (attr, atype, parameters));
- parameters[parameterSize] = 0;
- HDF5_ERROR (H5Tclose (atype));
+ if (attr >= 0)
+ {
+ HDF5_ERROR (atype = H5Aget_type (attr));
+ parameterSize = H5Tget_size (atype);
+ parameters = malloc (parameterSize + 1);
+ HDF5_ERROR (H5Aread (attr, atype, parameters));
+ parameters[parameterSize] = 0;
+ HDF5_ERROR (H5Tclose (atype));
+ }
+ else
+ {
+ parameterSize = H5Dget_storage_size (dataset);
+ parameters = malloc (parameterSize);
+ HDF5_ERROR (H5Dread (dataset, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, parameters));
+ }
}
else
{
@@ -289,11 +303,15 @@ int IOHDF5Util_RecoverParameters (const fileinfo_t *fileinfo)
"Is this really a Cactus HDF5 checkpoint file ?");
}
- if (attr > 0)
+ if (attr >= 0)
{
HDF5_ERROR (H5Aclose (attr));
}
- if (group > 0)
+ if (dataset >= 0)
+ {
+ HDF5_ERROR (H5Dclose (dataset));
+ }
+ if (group >= 0)
{
HDF5_ERROR (H5Gclose (group));
}