Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions components/elm/src/biogeophys/SoilStateType.F90
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ subroutine InitCold(this, bounds)
use SharedParamsMod , only : ParamsShareInst
use FuncPedotransferMod , only : pedotransf, get_ipedof
use RootBiophysMod , only : init_vegrootfr
use, intrinsic :: ieee_exceptions
!
! !ARGUMENTS:
class(soilstate_type) :: this
Expand Down Expand Up @@ -468,10 +469,13 @@ subroutine InitCold(this, bounds)
! Try to read soil information from the file.
call ncd_io(ncid=ncid, varname='ZSOI', flag='read', data=zsoifl, dim1name=grlnd, readvar=readvar)
if (.not. readvar ) then
! Variable ZSOI not found, use the ELM parameters.
if (ieee_support_halting(ieee_inexact)) then
call ieee_set_flag(ieee_all,.false.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line turns off ALL floating point trapping which would override our DEBUG settings. This would have to be wrapped in an #ifdef CPRNIVIDIA if you really want this.

call ieee_set_halting_mode(ieee_inexact, .false.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will turn off ieee_inexact trapping for everything that runs after this making it a global setting, not just for the land (unless the land is running on its own tasks). If we want to set these things globally, it should be done in the driver. Or you should set it back to "on".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ieee_inexact trappings are already off for everything. None of our code could work if not the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is essentially a no-op except for this nvida on perlmutter, which i can only hazard is a bug in the compiler or runtime.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh because ieee_support_halting(ieee_inexact) will be False everywhere except NVIDIA?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's even false with nvidia ! From the nvidia docs our current flag only captures inv, divz, ovf. iexact is really never used because all transcendental functions are inexact. I have verified this by calling ieee_get_halting_mode(ieee_inexact, halt) which is .false. wherever i call it.

The special flag -Ktrap=none is used to preserve FPEs during compilation without unmasking any of them at runtime.

The inv, divz, and ovf flags are often the most interesting, as they signify abnormal floating-point behavior in the program. These can be enabled with the useful shorthand -Ktrap=fp.

it seems to be a bug in the code gen or AVX2 exp runtime. Found a similar issue of random inexact being tripped in 25.9 https://forums.developer.nvidia.com/t/nvfortran-25-9-spurious-floating-point-exception/346604

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry not the support halting but the actual halting flag is false

end if
do j = 1, nlevsoifl
zsoifl(j) = scalez*(exp(zecoeff*(j-0.5_r8))-1._r8) !node depths
end do
zsoifl(j) = scalez*(exp(zecoeff*(dble(j)-0.5_r8))-1._r8) !node depths
enddo
end if

dzsoifl(1) = 0.5_r8*(zsoifl(1)+zsoifl(2)) !thickness b/n two interfaces
Expand Down
8 changes: 7 additions & 1 deletion components/elm/src/main/initVerticalMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module initVerticalMod

!------------------------------------------------------------------------
subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
use, intrinsic :: ieee_exceptions
!
! !ARGUMENTS:
type(bounds_type) , intent(in) :: bounds
Expand Down Expand Up @@ -170,8 +171,13 @@ subroutine initVertical(bounds, snow_depth, thick_wall, thick_roof)
! Soil layers not available from the input, and no additional layers needed. Use the
! default soil thickness settings.
! -----------------------------------------------------------------
if (ieee_support_halting(ieee_inexact)) then
call ieee_set_flag(ieee_all,.false.)
call ieee_set_halting_mode(ieee_inexact, .false.)
end if

do j = 1, nlevgrnd
zsoi(j) = scalez*(exp(zecoeff*(j-0.5_r8))-1._r8) !node depths
zsoi(j) = scalez*(exp(zecoeff*(dble(j)-0.5_r8))-1._r8) !node depths
enddo
end if
deallocate(zsoi_in)
Expand Down