Skip to content

Commit

Permalink
Disable FP checks for a certain LAPACK routine, by using ieee_excepti…
Browse files Browse the repository at this point in the history
…ons module

to turn off FP trapping that is enabled by -fpe0.
Only for DEBUG builds, only for cori-knl, and only for Intel compiler.
Fixes #1183
[BFB]
  • Loading branch information
ndkeen committed Apr 24, 2017
1 parent 007af33 commit 96dea91
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cime/config/acme/machines/config_compilers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ for mct, etc.
<ADD_SLIBS> -L$(NETCDF_DIR) -lnetcdff -Wl,--as-needed,-L$(NETCDF_DIR)/lib -lnetcdff -lnetcdf </ADD_SLIBS>
<ADD_SLIBS> -mkl -lpthread -lm </ADD_SLIBS>
<ADD_GPTL_CPPDEFS> -DHAVE_PAPI </ADD_GPTL_CPPDEFS>
<ADD_CPPDEFS> -DHAVE_SLASHPROC </ADD_CPPDEFS>
<!--ADD_CPPDEFS> -DHAVE_NANOTIME -DBIT64 -DHAVE_VPRINTF -DHAVE_BACKTRACE -DHAVE_SLASHPROC -DHAVE_COMM_F2C -DHAVE_TIMES -DHAVE_GETTIMEOFDAY </ADD_CPPDEFS> -->
<ADD_CPPDEFS> -DARCH_MIC_KNL -DHAVE_SLASHPROC </ADD_CPPDEFS>
<MPIFC> ftn </MPIFC>
<MPICC> cc </MPICC>
<MPICXX> CC </MPICXX>
Expand Down
20 changes: 18 additions & 2 deletions components/cam/src/physics/clubb/lapack_wrap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ subroutine tridag_solve &

use clubb_precision, only: &
core_rknd ! Variable(s)

#ifndef NDEBUG
#if defined(ARCH_MIC_KNL) && defined(CPRINTEL)
use, intrinsic :: ieee_exceptions
#endif
#endif
implicit none

! External
Expand Down Expand Up @@ -268,8 +272,20 @@ subroutine tridag_solve &
!-----------------------------------------------------------------------

if ( kind( diag(1) ) == dp ) then
call dgtsv( ndim, nrhs, subd(2:ndim), diag, supd(1:ndim-1), &
#ifndef NDEBUG
#if defined(ARCH_MIC_KNL) && defined(CPRINTEL)
! when floating-point exceptions are turned on, this call was failing with a div-by-zero on KNL with Intel/MKL. Solution
! was to turn off exceptions only here at this call (and only for machine with ARCH_MIC_KNL defined) (github 1183)
call ieee_set_halting_mode(IEEE_DIVIDE_BY_ZERO, .false.) ! Turn off stopping on div-by-zero only
#endif
#endif
call dgtsv( ndim, nrhs, subd(2:ndim), diag, supd(1:ndim-1), &
rhs, ndim, info )
#ifndef NDEBUG
#if defined(ARCH_MIC_KNL) && defined(CPRINTEL)
call ieee_set_halting_mode(IEEE_DIVIDE_BY_ZERO, .true.) ! Turn back on stopping on div-by-zero only
#endif
#endif

else if ( kind( diag(1) ) == sp ) then
call sgtsv( ndim, nrhs, subd(2:ndim), diag, supd(1:ndim-1), &
Expand Down

0 comments on commit 96dea91

Please sign in to comment.