Resolve an OBC edge constituent’s angular frequency omega (rad/s)
to the tide catalog index (rdb_ocean_tide_astro::TIDE_OMEGA) whose
frequency matches within the relative tolerance OBC_TIDE_MATCH_TOL.
Returns 0 when no catalog entry is within tolerance (unknown
constituent) or when omega <= 0 — the caller (OBC setup) converts a
0 to a fail-loud error stop, keeping this function pure.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | omega |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | best_c | ||||
| real(kind=wp), | private | :: | best_rel | ||||
| integer, | private | :: | c | ||||
| real(kind=wp), | private | :: | rel |
pure function obc_match_constituent(omega) result(ic) !! Resolve an OBC edge constituent's angular frequency `omega` (rad/s) !! to the tide catalog index (`rdb_ocean_tide_astro::TIDE_OMEGA`) whose !! frequency matches within the relative tolerance `OBC_TIDE_MATCH_TOL`. !! Returns 0 when no catalog entry is within tolerance (unknown !! constituent) or when `omega <= 0` — the caller (OBC setup) converts a !! 0 to a fail-loud `error stop`, keeping this function `pure`. real(wp), intent(in) :: omega integer :: ic integer :: c, best_c real(wp) :: best_rel, rel ic = 0 if (omega <= 0.0_wp) return best_c = 0 best_rel = huge(1.0_wp) do c = 1, TIDES_CATALOG_SIZE rel = abs(omega - TIDE_OMEGA(c))/omega if (rel < best_rel) then best_rel = rel best_c = c end if end do if (best_rel <= OBC_TIDE_MATCH_TOL) ic = best_c end function obc_match_constituent