Skip to content

Commit

Permalink
Merge pull request #73 from mnlevy1981/enhancement/OBL_depth_performance
Browse files Browse the repository at this point in the history
Performance enhancement: replace cvmix_get_kpp_real calls with direct access of datatype.
  • Loading branch information
mnlevy1981 authored Oct 15, 2018
2 parents 534fc38 + 185f027 commit 919a3a2
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/shared/cvmix_kpp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1375,8 +1375,7 @@ subroutine cvmix_kpp_compute_OBL_depth_low(Ri_bulk, zw_iface, OBL_depth, &
lstable = (surf_buoy.gt.cvmix_zero)

if (lstable) then
MoninObukhov = surf_fric**3/(surf_buoy*cvmix_get_kpp_real('vonkarman',&
CVmix_kpp_params_in))
MoninObukhov = surf_fric**3/(surf_buoy*CVmix_kpp_params_in%vonkarman)
else
MoninObukhov = abs(zt_cntr(nlev))
end if
Expand Down Expand Up @@ -1985,7 +1984,7 @@ subroutine cvmix_kpp_compute_turbulent_scales_1d_sigma(sigma_coord, &
do kw=1,n_sigma
! Compute (u*/phi_m)^3 [this is where the zeros in numerator and
! denominator cancel when u* = 0]
w_m(kw) = -cvmix_get_kpp_real('c_m', CVmix_kpp_params_in) * &
w_m(kw) = -CVmix_kpp_params_in%c_m * &
min(surf_layer_ext, sigma_coord(kw)) * OBL_depth * &
vonkar * surf_buoy_force
! w_m = vonkar * u* / phi_m
Expand All @@ -2004,7 +2003,7 @@ subroutine cvmix_kpp_compute_turbulent_scales_1d_sigma(sigma_coord, &
do kw=1,n_sigma
! Compute (u*/phi_s)^3 [this is where the zeros in numerator and
! denominator cancel when u* = 0]
w_s(kw) = -cvmix_get_kpp_real('c_s', CVmix_kpp_params_in) * &
w_s(kw) = -CVmix_kpp_params_in%c_s * &
min(surf_layer_ext, sigma_coord(kw)) * OBL_depth * &
vonkar * surf_buoy_force
! w_s = vonkar * u* / phi_s
Expand Down Expand Up @@ -2155,7 +2154,7 @@ subroutine cvmix_kpp_compute_turbulent_scales_1d_OBL(sigma_coord, &
else
! Compute (u*/phi_m)^3 [this is where the zeros in numerator and
! denominator cancel when u* = 0]
w_m(kw) = -cvmix_get_kpp_real('c_m', CVmix_kpp_params_in) * &
w_m(kw) = -CVmix_kpp_params_in%c_m * &
min(surf_layer_ext, sigma_coord) * OBL_depth(kw) * &
vonkar * surf_buoy_force(kw)
! w_m = vonkar * u* / phi_m
Expand All @@ -2175,7 +2174,7 @@ subroutine cvmix_kpp_compute_turbulent_scales_1d_OBL(sigma_coord, &
! Unstable forcing, Eqs. (13) and (B1e) reduce to following
! Compute (u*/phi_s)^3 [this is where the zeros in numerator and
! denominator cancel when u* = 0]
w_s(kw) = -cvmix_get_kpp_real('c_s', CVmix_kpp_params_in) * &
w_s(kw) = -CVmix_kpp_params_in%c_s * &
min(surf_layer_ext, sigma_coord) * OBL_depth(kw) * &
vonkar * surf_buoy_force(kw)
! w_s = vonkar * u* / phi_s
Expand Down Expand Up @@ -2280,12 +2279,12 @@ function cvmix_kpp_compute_unresolved_shear(zt_cntr, ws_cntr, N_iface, &
end if

! From LMD 94, Vtc = sqrt(-beta_T/(c_s*eps))/kappa^2
Vtc = sqrt(0.2_cvmix_r8/(cvmix_get_kpp_real('c_s', CVmix_kpp_params_in) * &
cvmix_get_kpp_real('surf_layer_ext', CVmix_kpp_params_in))) / &
(cvmix_get_kpp_real('vonkarman', CVmix_kpp_params_in)**2)
Vtc = sqrt(0.2_cvmix_r8/(CVmix_kpp_params_in%c_s * &
CVmix_kpp_params_in%surf_layer_ext)) / &
(CVmix_kpp_params_in%vonkarman**2)
do kt=1,nlev
if (CVmix_kpp_params_in%lscalar_Cv) then
Cv = cvmix_get_kpp_real('Cv', CVmix_kpp_params_in)
Cv = CVmix_kpp_params_in%Cv
else
! Cv computation comes from Danabasoglu et al., 2006
if (N_cntr(kt).lt.0.002_cvmix_r8) then
Expand Down Expand Up @@ -2343,11 +2342,11 @@ function compute_phi_inv(zeta, CVmix_kpp_params_in, lphi_m, lphi_s)
if (zeta.ge.cvmix_zero) then
! Stable region
compute_phi_inv = cvmix_one/(cvmix_one + real(5,cvmix_r8)*zeta)
else if (zeta.ge.cvmix_get_kpp_real('zeta_m', CVmix_kpp_params_in)) then
else if (zeta.ge.CVmix_kpp_params_in%zeta_m) then
compute_phi_inv = (cvmix_one - real(16,cvmix_r8)*zeta)**0.25_cvmix_r8
else
compute_phi_inv = (cvmix_get_kpp_real('a_m', CVmix_kpp_params_in) - &
cvmix_get_kpp_real('c_m', CVmix_kpp_params_in)*zeta)** &
compute_phi_inv = (CVmix_kpp_params_in%a_m - &
CVmix_kpp_params_in%c_m*zeta)** &
(cvmix_one/real(3,cvmix_r8))
end if
end if
Expand All @@ -2356,11 +2355,11 @@ function compute_phi_inv(zeta, CVmix_kpp_params_in, lphi_m, lphi_s)
if (zeta.ge.cvmix_zero) then
! Stable region
compute_phi_inv = cvmix_one/(cvmix_one + real(5,cvmix_r8)*zeta)
else if (zeta.ge.cvmix_get_kpp_real('zeta_s', CVmix_kpp_params_in)) then
else if (zeta.ge.CVmix_kpp_params_in%zeta_s) then
compute_phi_inv = (cvmix_one - real(16,cvmix_r8)*zeta)**0.5_cvmix_r8
else
compute_phi_inv = (cvmix_get_kpp_real('a_s', CVmix_kpp_params_in) - &
cvmix_get_kpp_real('c_s', CVmix_kpp_params_in)*zeta)** &
compute_phi_inv = (CVmix_kpp_params_in%a_s - &
CVmix_kpp_params_in%c_s*zeta)** &
(cvmix_one/real(3,cvmix_r8))
end if
end if
Expand Down

0 comments on commit 919a3a2

Please sign in to comment.