Skip to content

Commit

Permalink
fix: split if statement, the compond logical condition does not get e…
Browse files Browse the repository at this point in the history
…ntered

and gives a 'Failed to converge for quantile' when quantile==0
see issue #709

Q. Is this a floating point comparison error? (plus short circuting the if statement)
  • Loading branch information
hkershaw-brown committed Sep 13, 2024
1 parent 680b19a commit ba3513e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions assimilation_code/modules/assimilation/normal_distribution_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,22 @@ function first_guess(quantile, p)
endif

! If the distribution is bounded, quantiles at the limits have values at the bounds
if(bounded_below .and. quantile == 0.0_r8) then
x = lower_bound
return
if(quantile == 0.0_r8) then
! The following statement is required to avoid a compiler bug in gcc 13.2.0
quantile = 0.0_r8
if(bounded_below) then
x = lower_bound
return
endif
endif
if(bounded_above .and. quantile == 1.0_r8) then
x = upper_bound
return

if(quantile == 1.0_r8) then
! The following statement is required to avoid a compiler bug in gcc 13.2.0
quantile = 1.0_r8
if(bounded_above) then
x = upper_bound
return
endif
endif

! If input quantiles are outside the numerically supported range, move them to the extremes
Expand Down

0 comments on commit ba3513e

Please sign in to comment.