From e19e0bebc53c500ae4e703c8c94fa0ba52c32e36 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Tue, 25 Sep 2018 16:07:29 -0600 Subject: [PATCH 1/2] Avoid cvmix_get_kpp_real() calls cvmix_kpp_compute_unresolved_shear() is called every timestep (for every column) so we don't want to spend time looking up variables in CVmix_kpp_params_in... just hard-code the full name. (For readability, maybe we should use an associate statement?) --- src/shared/cvmix_kpp.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shared/cvmix_kpp.F90 b/src/shared/cvmix_kpp.F90 index d6339e459..0e74861bc 100644 --- a/src/shared/cvmix_kpp.F90 +++ b/src/shared/cvmix_kpp.F90 @@ -2280,12 +2280,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 From 185f0277dde2eb429c74a4f377d4b68b1e2f09ab Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Wed, 26 Sep 2018 16:25:43 -0600 Subject: [PATCH 2/2] Remove more cvmix_get_kpp_real calls --- src/shared/cvmix_kpp.F90 | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/shared/cvmix_kpp.F90 b/src/shared/cvmix_kpp.F90 index 0e74861bc..cf46c57d9 100644 --- a/src/shared/cvmix_kpp.F90 +++ b/src/shared/cvmix_kpp.F90 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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