Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed bug that caused a failure to braket the SFD slope when it is ne…
Browse files Browse the repository at this point in the history
…gative
  • Loading branch information
daminton committed Feb 23, 2023
1 parent 4437677 commit b55d703
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/fraggle/fraggle_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module subroutine fraggle_util_set_mass_dist(self, param)
!! Sets the mass of fragments based on the mass distribution returned by the regime calculation.
!! This subroutine must be run after the the setup routine has been run on the fragments
!!
use, intrinsic :: ieee_exceptions
implicit none
! Arguments
class(collision_fraggle), intent(inout) :: self !! Fraggle collision system object
Expand All @@ -101,6 +102,10 @@ module subroutine fraggle_util_set_mass_dist(self, param)
integer(I4B), dimension(:), allocatable :: ind
integer(I4B), parameter :: MAXLOOP = 20
logical :: flipper
logical, dimension(size(IEEE_ALL)) :: fpe_halting_modes

call ieee_get_halting_mode(IEEE_ALL,fpe_halting_modes) ! Save the current halting modes so we can turn them off temporarily
call ieee_set_halting_mode(IEEE_ALL,.false.)

associate(impactors => self%impactors, min_mfrag => self%min_mfrag)
! Get mass weighted mean of Ip and density
Expand Down Expand Up @@ -146,6 +151,7 @@ module subroutine fraggle_util_set_mass_dist(self, param)
fragments%density(1) = impactors%mass_dist(1) / volume(jtarg)
if (param%lrotation) fragments%Ip(:, 1) = impactors%Ip(:,1)
end associate
call ieee_set_halting_mode(IEEE_ALL,fpe_halting_modes)
return
case default
write(*,*) "fraggle_util_set_mass_dist_fragments error: Unrecognized regime code",impactors%regime
Expand Down Expand Up @@ -176,8 +182,8 @@ module subroutine fraggle_util_set_mass_dist(self, param)
y1 = y1 - (i-1)**(-x1/3.0_DP)
end do
if (y0*y1 < 0.0_DP) exit
x1 = x1 * 1.6_DP
x0 = x0 / 1.6_DP
x1 = x1 * 1.1_DP
x0 = x0 * 1.1_DP
end do

! Find the mass scaling factor with bisection
Expand Down Expand Up @@ -276,6 +282,7 @@ module subroutine fraggle_util_set_mass_dist(self, param)

end associate

call ieee_set_halting_mode(IEEE_ALL,fpe_halting_modes)
return
end subroutine fraggle_util_set_mass_dist

Expand Down

0 comments on commit b55d703

Please sign in to comment.