Flat-impl device fill (explicit-shape dummies). Loop-invariant
use_sal branch kept INSIDE the single do concurrent (one
launch, uniform branch is ~free). Off ⇒ pure copy of eta_eq
into eta_forcing ⇒ bit-identical. Contiguous index (i) innermost.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | nx | |||
| integer, | intent(in) | :: | ny | |||
| logical, | intent(in) | :: | use_sal | |||
| real(kind=wp), | intent(in) | :: | beta_sal | |||
| real(kind=wp), | intent(in) | :: | eta_current(nx,ny) | |||
| real(kind=wp), | intent(in) | :: | eta_eq(nx,ny) | |||
| real(kind=wp), | intent(inout) | :: | eta_sal(nx,ny) | |||
| real(kind=wp), | intent(out) | :: | eta_forcing(nx,ny) |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | i | ||||
| integer, | private | :: | j |
subroutine tides_update_eta_sal_impl(nx, ny, use_sal, beta_sal, eta_current, & eta_eq, eta_sal, eta_forcing) !! Flat-impl device fill (explicit-shape dummies). Loop-invariant !! `use_sal` branch kept INSIDE the single `do concurrent` (one !! launch, uniform branch is ~free). Off ⇒ pure copy of `eta_eq` !! into `eta_forcing` ⇒ bit-identical. Contiguous index (i) innermost. integer, intent(in) :: nx, ny logical, intent(in) :: use_sal real(wp), intent(in) :: beta_sal real(wp), intent(in) :: eta_current(nx, ny), eta_eq(nx, ny) real(wp), intent(inout) :: eta_sal(nx, ny) real(wp), intent(out) :: eta_forcing(nx, ny) integer :: i, j ! Write straight into the arrays (no `local` scalar): reading back ! `eta_sal(i,j)` in the same iteration is a within-iteration RAW ! (legal in do concurrent) and sidesteps the gfortran `local()` ! if/else codegen artefact that perturbs the product sub-ULP. do concurrent(j=1:ny, i=1:nx) if (use_sal) then eta_sal(i, j) = beta_sal*eta_current(i, j) eta_forcing(i, j) = eta_eq(i, j) + eta_sal(i, j) else eta_forcing(i, j) = eta_eq(i, j) end if end do end subroutine tides_update_eta_sal_impl