@@ -59,6 +59,8 @@ module MOM_energetic_PBL
59
59
! ! self-consistent mixed layer depth. Otherwise use the false position
60
60
! ! after a maximum and minimum bound have been evaluated and the
61
61
! ! returned value from the previous guess or bisection before this.
62
+ logical :: MLD_iter_bug ! < If true use buggy logic that gives the wrong bounds for the next
63
+ ! ! iteration when successive guesses increase by exactly EPBL_MLD_TOLERANCE.
62
64
integer :: max_MLD_its ! < The maximum number of iterations that can be used to find a
63
65
! ! self-consistent mixed layer depth with Use_MLD_iteration.
64
66
real :: MixLenExponent ! < Exponent in the mixing length shape-function [nondim].
@@ -1516,14 +1518,27 @@ subroutine ePBL_column(h, dz, u, v, T0, S0, dSV_dT, dSV_dS, SpV_dt, TKE_forcing,
1516
1518
! is now dependent on the ML, and therefore the ML needs to be estimated
1517
1519
! more precisely than the grid spacing.
1518
1520
1519
- ! New method uses ML_DEPTH as computed in ePBL routine
1521
+ ! New method uses ML_DEPTH as computed in ePBL routine
1520
1522
MLD_found = MLD_output
1521
- if (MLD_found - MLD_guess > CS% MLD_tol) then
1522
- min_MLD = MLD_guess ; dMLD_min = MLD_found - MLD_guess
1523
- elseif (abs (MLD_found - MLD_guess) < CS% MLD_tol) then
1524
- OBL_converged = .true. ! Break convergence loop
1525
- else ! We know this guess was too deep
1526
- max_MLD = MLD_guess ; dMLD_max = MLD_found - MLD_guess ! < -CS%MLD_tol
1523
+
1524
+ ! Find out whether to do another iteration and the new bounds on it.
1525
+ if (CS% MLD_iter_bug) then
1526
+ ! There is a bug in the logic here if (MLD_found - MLD_guess == CS%MLD_tol).
1527
+ if (MLD_found - MLD_guess > CS% MLD_tol) then
1528
+ min_MLD = MLD_guess ; dMLD_min = MLD_found - MLD_guess
1529
+ elseif (abs (MLD_found - MLD_guess) < CS% MLD_tol) then
1530
+ OBL_converged = .true. ! Break convergence loop
1531
+ else ! We know this guess was too deep
1532
+ max_MLD = MLD_guess ; dMLD_max = MLD_found - MLD_guess ! < -CS%MLD_tol
1533
+ endif
1534
+ else
1535
+ if (abs (MLD_found - MLD_guess) < CS% MLD_tol) then
1536
+ OBL_converged = .true. ! Break convergence loop
1537
+ elseif (MLD_found > MLD_guess) then ! This guess was too shallow
1538
+ min_MLD = MLD_guess ; dMLD_min = MLD_found - MLD_guess
1539
+ else ! We know this guess was too deep
1540
+ max_MLD = MLD_guess ; dMLD_max = MLD_found - MLD_guess ! < -CS%MLD_tol
1541
+ endif
1527
1542
endif
1528
1543
1529
1544
if (.not. OBL_converged) then ; if (CS% MLD_bisection) then
@@ -2276,6 +2291,10 @@ subroutine energetic_PBL_init(Time, G, GV, US, param_file, diag, CS)
2276
2291
" mixed layer depth. Otherwise use the false position after a maximum and minimum " // &
2277
2292
" bound have been evaluated and the returned value or bisection before this." , &
2278
2293
default= .false. , do_not_log= .not. CS% Use_MLD_iteration)
2294
+ call get_param(param_file, mdl, " EPBL_MLD_ITER_BUG" , CS% MLD_iter_bug, &
2295
+ " If true, use buggy logic that gives the wrong bounds for the next iteration " // &
2296
+ " when successive guesses increase by exactly EPBL_MLD_TOLERANCE." , &
2297
+ default= .true. , do_not_log= .not. CS% Use_MLD_iteration) ! The default should be changed to .false.
2279
2298
call get_param(param_file, mdl, " EPBL_MLD_MAX_ITS" , CS% max_MLD_its, &
2280
2299
" The maximum number of iterations that can be used to find a self-consistent " // &
2281
2300
" mixed layer depth. If EPBL_MLD_BISECTION is true, the maximum number " // &
0 commit comments