obc_match_constituent Function

public 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.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: omega

Return Value integer


Called by

proc~~obc_match_constituent~~CalledByGraph proc~obc_match_constituent obc_match_constituent proc~configure_obc_edge_nodal configure_obc_edge_nodal proc~configure_obc_edge_nodal->proc~obc_match_constituent proc~obc_tide_nodal_fill obc_tide_nodal_fill proc~configure_obc_edge_nodal->proc~obc_tide_nodal_fill proc~obc_tide_nodal_fill->proc~obc_match_constituent proc~configure_ocean_bc configure_ocean_bc proc~configure_ocean_bc->proc~configure_obc_edge_nodal proc~engine_setup engine_setup proc~engine_setup->proc~configure_ocean_bc proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~rdb_ocean_create_finalize rdb_ocean_create_finalize proc~rdb_ocean_create_finalize->proc~complete_ocean_create proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~complete_ocean_create

Variables

Type Visibility Attributes Name Initial
integer, private :: best_c
real(kind=wp), private :: best_rel
integer, private :: c
real(kind=wp), private :: rel

Source Code

   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