Non-dimensional position in [0,1] where the interpolated density difference is zero. Guards the vanished/inverted (Ppos==Pneg) and degenerate (dRhoPos==dRhoNeg) cases device-safely (clamped values, no host I/O).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | dRhoNeg |
negative density difference |
||
| real(kind=wp), | intent(in) | :: | Pneg |
position of the negative difference |
||
| real(kind=wp), | intent(in) | :: | dRhoPos |
positive density difference |
||
| real(kind=wp), | intent(in) | :: | Ppos |
position of the positive difference |
pure function redi_interpolate_position(dRhoNeg, Pneg, dRhoPos, Ppos) result(pos) !$acc routine seq real(wp), intent(in) :: dRhoNeg !! negative density difference real(wp), intent(in) :: Pneg !! position of the negative difference real(wp), intent(in) :: dRhoPos !! positive density difference real(wp), intent(in) :: Ppos !! position of the positive difference real(wp) :: pos if ((Ppos > Pneg) .and. (dRhoPos - dRhoNeg >= 0.0_wp)) then if (dRhoPos - dRhoNeg > 0.0_wp) then pos = min(1.0_wp, max(0.0_wp, -dRhoNeg/(dRhoPos - dRhoNeg))) else ! dRhoPos - dRhoNeg == 0 if (dRhoNeg > 0.0_wp) then pos = 0.0_wp else if (dRhoNeg < 0.0_wp) then pos = 1.0_wp else pos = 0.5_wp end if end if else if (Ppos == Pneg) then ! vanished or inverted layers pos = 0.5_wp else ! (Ppos < Pneg) .or. (dRhoNeg > dRhoPos): MOM6 errors here; device-safe clamp pos = 0.5_wp end if end function redi_interpolate_position