]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Explicitly open HDF5 and then clear its floating-point exceptions. 16876/head
authorDavid Wells <drwells@email.unc.edu>
Tue, 9 Apr 2024 23:13:57 +0000 (19:13 -0400)
committerDavid Wells <drwells@email.unc.edu>
Tue, 9 Apr 2024 23:20:25 +0000 (19:20 -0400)
New versions of HDF5 detect the floating-point environment by doing several
things which trigger floating point exceptions, i.e., programs in the test suite
now abort in H5open(). Work around that by explicitly setting up HDF5 before we
turn on the 'abort on floating point exceptions' code.

tests/tests.h

index 8aca9bdf8b642bdbb182f9af0c004c1ad3c525aa..fc476f2f34b670dc401396441f52d82af6108901 100644 (file)
 #  include <cfenv>
 #endif
 
+#if defined(DEAL_II_WITH_HDF5)
+#  include <hdf5.h>
+#endif
+
 
 // silence extra diagnostics in the testsuite
 #ifdef DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
@@ -846,6 +850,15 @@ struct EnableFPE
   EnableFPE()
   {
 #if defined(DEBUG) && defined(DEAL_II_HAVE_FP_EXCEPTIONS)
+#  if defined(DEAL_II_WITH_HDF5)
+    // Modern versions of HDF5 detect the floating-point environment by
+    // performing several operations which trigger floating-point exceptions.
+    // Hence we need to set up HDF5's global state before calling
+    // feenableexcept().
+    const int ierr = H5open();
+    AssertThrow(ierr == 0, ExcInternalError());
+    feclearexcept(FE_ALL_EXCEPT);
+#  endif
     // enable floating point exceptions
     feenableexcept(FE_DIVBYZERO | FE_INVALID);
 #endif

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.