From a3bc135fc0b9dd1eedaa6a32c38d398a7c67281a Mon Sep 17 00:00:00 2001 From: yye00 Date: Thu, 12 Aug 2004 22:12:13 +0000 Subject: assert fix git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@201 4825ed28-b72c-4eae-9704-e50c059e567d --- src/util/hdf5_convert_from_ieeeio.c | 43 ++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/util/hdf5_convert_from_ieeeio.c b/src/util/hdf5_convert_from_ieeeio.c index bd0d62c..a9613f3 100644 --- a/src/util/hdf5_convert_from_ieeeio.c +++ b/src/util/hdf5_convert_from_ieeeio.c @@ -14,7 +14,7 @@ #include #include -#include + /* Cactus includes (defines CCTK_FILEVERSION) */ #include "cctk.h" @@ -72,28 +72,35 @@ int main (int argc, char **argv) /* add a dummy GLOBAL_ATTRIBUTES_GROUP so that the HDF5 file is recognized as unchunked Cactus data */ group = H5Gcreate (outfile, GLOBAL_ATTRIBUTES_GROUP, 0); - assert (group >= 0); + if (group < 0) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "group is out of bounds"); attrDataspace = H5Screate (H5S_SCALAR); attribute = H5Acreate (group, "nprocs", H5T_NATIVE_INT, attrDataspace, H5P_DEFAULT); - assert (attribute >= 0); + if (attribute < 0) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "attribute is out of bounds"); i = 1; - assert (H5Awrite (attribute, H5T_NATIVE_INT, &i) >= 0); + if(! (H5Awrite (attribute, H5T_NATIVE_INT, &i) >= 0)) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "error returned from H5Awrite"); H5Aclose (attribute); attribute = H5Acreate (group, "ioproc_every", H5T_NATIVE_INT, attrDataspace, H5P_DEFAULT); - assert (attribute >= 0); + if (attribute < 0) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "attribute is out of bounds"); i = 1; - assert (H5Awrite (attribute, H5T_NATIVE_INT, &i) >= 0); + if(! (H5Awrite (attribute, H5T_NATIVE_INT, &i) >= 0)) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "error returned from function H5Awrite"); H5Aclose (attribute); attribute = H5Acreate (group, "unchunked", H5T_NATIVE_INT, attrDataspace, H5P_DEFAULT); - assert (attribute >= 0); + if (attribute < 0) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "attribute is out of bounds"); i = 1; - assert (H5Awrite (attribute, H5T_NATIVE_INT, &i) >= 0); + if(! (H5Awrite (attribute, H5T_NATIVE_INT, &i) >= 0)) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "error returned from function H5Awrite"); H5Aclose (attribute); H5Sclose (attrDataspace); @@ -184,13 +191,15 @@ int main (int argc, char **argv) hdf5Dims[j] = dims[rank - j - 1]; } dataspace = H5Screate_simple (rank, hdf5Dims, NULL); - assert (dataspace >= 0); + if (dataspace < 0) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5","dataspace is out of bounds"); sprintf (hdf5DatasetName, "/%s timelevel %d at iteration %d", ieeeDatasetName, timelevel, iteration); dataset = H5Dcreate (outfile, hdf5DatasetName, hdf5Datatype, dataspace, H5P_DEFAULT); - assert (dataset >= 0); + if (dataset < 0) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5","dataset is out of bounds"); data = malloc (IOnBytes (ieeeDatatype, rank, dims)); if (data == NULL) @@ -200,8 +209,9 @@ int main (int argc, char **argv) return (-1); } IOread (infile, data); - assert (H5Dwrite (dataset, hdf5Datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data) >= 0); + if(! (H5Dwrite (dataset, hdf5Datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, + data) >= 0)) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5","error returned from function H5Dwrite"); nAttributes = IOnAttributes (infile); printf ("Processing dataset '%s' with %d attributes\n", @@ -262,7 +272,8 @@ int main (int argc, char **argv) continue; } - assert (attrDataspace >= 0); + if (attrDataspace < 0) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "attrDataspace is out of bounds"); /* turn off error messages about an already existing attribute */ H5E_BEGIN_TRY @@ -272,8 +283,10 @@ int main (int argc, char **argv) attribute = H5Acreate (dataset, attrName, hdf5Datatype, attrDataspace, H5P_DEFAULT); - assert (attribute >= 0); - assert (H5Awrite (attribute, hdf5Datatype, attrData) >= 0); + if (attribute < 0) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "attribute is out of bounds"); + if(! (H5Awrite (attribute, hdf5Datatype, attrData) >= 0)) + CCTK_VWarn ( 0, __LINE__, __FILE__, "IOHDF5", "error returned from function H5Awrite"); H5Sclose (attrDataspace); H5Aclose (attribute); -- cgit v1.2.3