[Commits] [svn:einsteintoolkit] SphericalHarmonicRecon/trunk/src/ (Rev. 14)
yosef at astro.rit.edu
yosef at astro.rit.edu
Mon Jul 30 13:58:54 CDT 2012
User: zlochower
Date: 2012/07/30 01:58 PM
Modified:
/trunk/src/
Recon.cc
Log:
check for hdf5 IO errors and abort
File Changes:
Directory: /trunk/src/
======================
File [modified]: Recon.cc
Delta lines: +28 -9
===================================================================
--- trunk/src/Recon.cc 2012-07-21 10:47:40 UTC (rev 13)
+++ trunk/src/Recon.cc 2012-07-30 18:58:53 UTC (rev 14)
@@ -16,6 +16,22 @@
#include <hdf5.h>
#include <hdf5_hl.h>
+static int hdf5_warn_level = CCTK_WARN_ABORT;
+
+#define HDF5_ERROR(fn_call) \
+ do { \
+ int _error_code = fn_call; \
+ \
+ \
+ if (_error_code < 0) \
+ { \
+ CCTK_VWarn (hdf5_warn_level, __LINE__, __FILE__, CCTK_THORNSTRING, \
+ "HDF5 call '%s' returned error code %d", \
+ #fn_call, _error_code); \
+ } \
+ } while (0)
+
+
#undef SPHERICALHARMONICRECON_DEBUG
#define BUFFSIZE 1024
@@ -197,23 +213,22 @@
}
else
{
- status = H5LTget_attribute_int(file_id,"/metadata/","spin",&spin);
- status = H5LTget_attribute_int(file_id,"/metadata/","dim",dim);
- status = H5LTget_attribute_double(file_id,"/metadata/","Rin",&Rin);
- status = H5LTget_attribute_double(file_id,"/metadata/","Rout",&Rout);
+ HDF5_ERROR(status = H5LTget_attribute_int(file_id,"/metadata/","spin",&spin));
+ HDF5_ERROR(status = H5LTget_attribute_int(file_id,"/metadata/","dim",dim));
+ HDF5_ERROR(status = H5LTget_attribute_double(file_id,"/metadata/","Rin",&Rin));
+ HDF5_ERROR(status = H5LTget_attribute_double(file_id,"/metadata/","Rout",&Rout));
}
nn = dim[0];
na = dim[1];
nl = static_cast<int>(round(sqrt(double(na+spin*spin))-abs(double(spin))));
- status = H5LTget_attribute_double(file_id,"/0/", "Time", &time0);
- status = H5LTget_attribute_double(file_id,"/1/", "Time", &dtime);
-
+ HDF5_ERROR(status = H5LTget_attribute_double(file_id,"/0/", "Time", &time0));
+ HDF5_ERROR(status = H5LTget_attribute_double(file_id,"/1/", "Time", &dtime));
dtime -= time0;
- status = H5Fclose(file_id);
+ HDF5_ERROR(status = H5Fclose(file_id));
}
const int root = 0; /* proc 0 sends the data to everyone else */
@@ -314,7 +329,7 @@
CCTK_WARN(CCTK_WARN_ABORT, "order not implemented");
}
- status = H5Fclose(file_id);
+ HDF5_ERROR(status = H5Fclose(file_id));
}
@@ -597,6 +612,7 @@
if (status)
{
cerr << "Could not read data from " << buff << endl;
+ CCTK_WARN(CCTK_WARN_ABORT, "Dataset read failure");
}
snprintf(buff, BUFFSIZE-1, "/%d/%s/im", it, gfname[comp]);
@@ -605,6 +621,7 @@
if (status)
{
cerr << "Could not read data from " << buff << endl;
+ CCTK_WARN(CCTK_WARN_ABORT, "Dataset read failure");
}
if (read_dt)
@@ -614,6 +631,7 @@
if (status)
{
cerr << "Could not read data from " << buff << endl;
+ CCTK_WARN(CCTK_WARN_ABORT, "Dataset read failure");
}
snprintf(buff, BUFFSIZE-1, "/%d/%s/dt_im", it, gfname[comp]);
@@ -622,6 +640,7 @@
if (status)
{
cerr << "Could not read data from " << buff << endl;
+ CCTK_WARN(CCTK_WARN_ABORT, "Dataset read failure");
}
}
More information about the Commits
mailing list