Copy a pre-filled cell-centre Coriolis magnitude |f| (1/s) onto
the slot (mirror of ocean_meke_set_f_centre — the caller
builds f_centre via fill_coriolis_centre /
metrics_fill_coriolis, which handles beta-plane AND
planetary/spherical), and fill the static beta_centre =
|grad f| field with the SAME centred-difference stencil
meke_length_scales uses (edge rows/columns left at 0 -> the
extratropical Rd = cg1/|f| branch there).
Divergence note (documented, not fixed here): this takes the
gradient of f_centre, which is |f| (matching the VarMix /
MEKE house idiom) rather than the signed Coriolis field, so
|grad|f|| has a kink at the equator where |grad f| would be
smooth. Shared pre-existing divergence with VarMix/MEKE — not
fixed by this PR (see docs/CLOSURE_MATRIX.md).
Host loops only — these are static (functions of geometry +
planetary f) and never change with time. Call after init,
AFTER the metrics are filled + finalized, BEFORE enter_data.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_wave_speed_t), | intent(inout) | :: | this | |||
| type(hgrid_t), | intent(in) | :: | grid | |||
| type(ocean_metrics_t), | intent(in) | :: | metrics | |||
| real(kind=wp), | intent(in) | :: | f_centre(grid%nx_total,grid%ny_total) |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private | :: | dfdx | ||||
| real(kind=wp), | private | :: | dfdy | ||||
| integer, | private | :: | i | ||||
| integer, | private | :: | j | ||||
| integer, | private | :: | nx | ||||
| integer, | private | :: | ny |
subroutine ocean_wave_speed_build_static(this, grid, metrics, f_centre) !! Copy a pre-filled cell-centre Coriolis magnitude |f| (1/s) onto !! the slot (mirror of `ocean_meke_set_f_centre` — the caller !! builds `f_centre` via `fill_coriolis_centre` / !! `metrics_fill_coriolis`, which handles beta-plane AND !! planetary/spherical), and fill the static `beta_centre = !! |grad f|` field with the SAME centred-difference stencil !! `meke_length_scales` uses (edge rows/columns left at 0 -> the !! extratropical `Rd = cg1/|f|` branch there). !! !! Divergence note (documented, not fixed here): this takes the !! gradient of `f_centre`, which is `|f|` (matching the VarMix / !! MEKE house idiom) rather than the signed Coriolis field, so !! `|grad|f||` has a kink at the equator where `|grad f|` would be !! smooth. Shared pre-existing divergence with VarMix/MEKE — not !! fixed by this PR (see docs/CLOSURE_MATRIX.md). !! !! Host loops only — these are static (functions of geometry + !! planetary f) and never change with time. Call after `init`, !! AFTER the metrics are filled + finalized, BEFORE `enter_data`. class(ocean_wave_speed_t), intent(inout) :: this type(hgrid_t), intent(in) :: grid type(ocean_metrics_t), intent(in) :: metrics real(wp), intent(in) :: f_centre(grid%nx_total, grid%ny_total) integer :: i, j, nx, ny real(wp) :: dfdx, dfdy if (.not. allocated(this%f_centre)) return nx = grid%nx_total ny = grid%ny_total do j = 1, ny do i = 1, nx this%f_centre(i, j) = f_centre(i, j) end do end do do j = 1, ny do i = 1, nx dfdx = 0.0_wp dfdy = 0.0_wp if (i > 1 .and. i < nx) then dfdx = 0.5_wp*(f_centre(i + 1, j) - f_centre(i - 1, j))*metrics%idxT(i, j) end if if (j > 1 .and. j < ny) then dfdy = 0.5_wp*(f_centre(i, j + 1) - f_centre(i, j - 1))*metrics%idyT(i, j) end if this%beta_centre(i, j) = sqrt(dfdx*dfdx + dfdy*dfdy) end do end do end subroutine ocean_wave_speed_build_static