ocean_hvisc_set_aniso_direction Subroutine

public pure subroutine ocean_hvisc_set_aniso_direction(this, n1, n2)

Precompute the constant Smith & McWilliams (2003) direction- tensor factors from the anisotropy direction vector (n1,n2) (grid-relative i,j components). Normalises by n1²+n2² so the caller need not pass a unit vector:

n1n2          = 2·n1·n2 / (n1²+n2²)
n1n1_m_n2n2   = (n1²−n2²) / (n1²+n2²)

The default grid-i direction (1,0) gives n1n2 = 0, n1n1_m_n2n2 = 1 — the cross terms vanish and only the tension coefficient picks up kh_aniso. A degenerate (0,0) vector leaves the factors at their defaults (n1n2=0, n1n1_m_n2n2=1), i.e. grid-i.

Arguments

Type IntentOptional Attributes Name
class(ocean_horizontal_viscosity_t), intent(inout) :: this
real(kind=wp), intent(in) :: n1
real(kind=wp), intent(in) :: n2

Called by

proc~~ocean_hvisc_set_aniso_direction~~CalledByGraph proc~ocean_hvisc_set_aniso_direction ocean_hvisc_set_aniso_direction proc~configure_ocean_forcing configure_ocean_forcing proc~configure_ocean_forcing->proc~ocean_hvisc_set_aniso_direction proc~engine_setup engine_setup proc~engine_setup->proc~configure_ocean_forcing 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
real(kind=wp), private :: recip_norm

Source Code

   pure subroutine ocean_hvisc_set_aniso_direction(this, n1, n2)
      !! Precompute the constant Smith & McWilliams (2003) direction-
      !! tensor factors from the anisotropy direction vector `(n1,n2)`
      !! (grid-relative i,j components).  Normalises by `n1²+n2²` so the
      !! caller need not pass a unit vector:
      !!
      !!     n1n2          = 2·n1·n2 / (n1²+n2²)
      !!     n1n1_m_n2n2   = (n1²−n2²) / (n1²+n2²)
      !!
      !! The default grid-i direction `(1,0)` gives `n1n2 = 0`,
      !! `n1n1_m_n2n2 = 1` — the cross terms vanish and only the tension
      !! coefficient picks up `kh_aniso`.  A degenerate `(0,0)` vector
      !! leaves the factors at their defaults (`n1n2=0`,
      !! `n1n1_m_n2n2=1`), i.e. grid-i.
      class(ocean_horizontal_viscosity_t), intent(inout) :: this
      real(wp), intent(in) :: n1, n2
      real(wp) :: recip_norm
      recip_norm = (n1*n1) + (n2*n2)
      if (recip_norm > 0.0_wp) then
         recip_norm = 1.0_wp/recip_norm
         this%aniso_n1n2 = 2.0_wp*(n1*n2)*recip_norm
         this%aniso_n1n1_m_n2n2 = ((n1*n1) - (n2*n2))*recip_norm
      else
         this%aniso_n1n2 = 0.0_wp
         this%aniso_n1n1_m_n2n2 = 1.0_wp
      end if
   end subroutine ocean_hvisc_set_aniso_direction