Skip to content

Commit 919a3a2

Browse files
authored
Merge pull request #73 from mnlevy1981/enhancement/OBL_depth_performance
Performance enhancement: replace cvmix_get_kpp_real calls with direct access of datatype.
2 parents 534fc38 + 185f027 commit 919a3a2

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/shared/cvmix_kpp.F90

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,8 +1375,7 @@ subroutine cvmix_kpp_compute_OBL_depth_low(Ri_bulk, zw_iface, OBL_depth, &
13751375
lstable = (surf_buoy.gt.cvmix_zero)
13761376

13771377
if (lstable) then
1378-
MoninObukhov = surf_fric**3/(surf_buoy*cvmix_get_kpp_real('vonkarman',&
1379-
CVmix_kpp_params_in))
1378+
MoninObukhov = surf_fric**3/(surf_buoy*CVmix_kpp_params_in%vonkarman)
13801379
else
13811380
MoninObukhov = abs(zt_cntr(nlev))
13821381
end if
@@ -1985,7 +1984,7 @@ subroutine cvmix_kpp_compute_turbulent_scales_1d_sigma(sigma_coord, &
19851984
do kw=1,n_sigma
19861985
! Compute (u*/phi_m)^3 [this is where the zeros in numerator and
19871986
! denominator cancel when u* = 0]
1988-
w_m(kw) = -cvmix_get_kpp_real('c_m', CVmix_kpp_params_in) * &
1987+
w_m(kw) = -CVmix_kpp_params_in%c_m * &
19891988
min(surf_layer_ext, sigma_coord(kw)) * OBL_depth * &
19901989
vonkar * surf_buoy_force
19911990
! w_m = vonkar * u* / phi_m
@@ -2004,7 +2003,7 @@ subroutine cvmix_kpp_compute_turbulent_scales_1d_sigma(sigma_coord, &
20042003
do kw=1,n_sigma
20052004
! Compute (u*/phi_s)^3 [this is where the zeros in numerator and
20062005
! denominator cancel when u* = 0]
2007-
w_s(kw) = -cvmix_get_kpp_real('c_s', CVmix_kpp_params_in) * &
2006+
w_s(kw) = -CVmix_kpp_params_in%c_s * &
20082007
min(surf_layer_ext, sigma_coord(kw)) * OBL_depth * &
20092008
vonkar * surf_buoy_force
20102009
! w_s = vonkar * u* / phi_s
@@ -2155,7 +2154,7 @@ subroutine cvmix_kpp_compute_turbulent_scales_1d_OBL(sigma_coord, &
21552154
else
21562155
! Compute (u*/phi_m)^3 [this is where the zeros in numerator and
21572156
! denominator cancel when u* = 0]
2158-
w_m(kw) = -cvmix_get_kpp_real('c_m', CVmix_kpp_params_in) * &
2157+
w_m(kw) = -CVmix_kpp_params_in%c_m * &
21592158
min(surf_layer_ext, sigma_coord) * OBL_depth(kw) * &
21602159
vonkar * surf_buoy_force(kw)
21612160
! w_m = vonkar * u* / phi_m
@@ -2175,7 +2174,7 @@ subroutine cvmix_kpp_compute_turbulent_scales_1d_OBL(sigma_coord, &
21752174
! Unstable forcing, Eqs. (13) and (B1e) reduce to following
21762175
! Compute (u*/phi_s)^3 [this is where the zeros in numerator and
21772176
! denominator cancel when u* = 0]
2178-
w_s(kw) = -cvmix_get_kpp_real('c_s', CVmix_kpp_params_in) * &
2177+
w_s(kw) = -CVmix_kpp_params_in%c_s * &
21792178
min(surf_layer_ext, sigma_coord) * OBL_depth(kw) * &
21802179
vonkar * surf_buoy_force(kw)
21812180
! w_s = vonkar * u* / phi_s
@@ -2280,12 +2279,12 @@ function cvmix_kpp_compute_unresolved_shear(zt_cntr, ws_cntr, N_iface, &
22802279
end if
22812280

22822281
! From LMD 94, Vtc = sqrt(-beta_T/(c_s*eps))/kappa^2
2283-
Vtc = sqrt(0.2_cvmix_r8/(cvmix_get_kpp_real('c_s', CVmix_kpp_params_in) * &
2284-
cvmix_get_kpp_real('surf_layer_ext', CVmix_kpp_params_in))) / &
2285-
(cvmix_get_kpp_real('vonkarman', CVmix_kpp_params_in)**2)
2282+
Vtc = sqrt(0.2_cvmix_r8/(CVmix_kpp_params_in%c_s * &
2283+
CVmix_kpp_params_in%surf_layer_ext)) / &
2284+
(CVmix_kpp_params_in%vonkarman**2)
22862285
do kt=1,nlev
22872286
if (CVmix_kpp_params_in%lscalar_Cv) then
2288-
Cv = cvmix_get_kpp_real('Cv', CVmix_kpp_params_in)
2287+
Cv = CVmix_kpp_params_in%Cv
22892288
else
22902289
! Cv computation comes from Danabasoglu et al., 2006
22912290
if (N_cntr(kt).lt.0.002_cvmix_r8) then
@@ -2343,11 +2342,11 @@ function compute_phi_inv(zeta, CVmix_kpp_params_in, lphi_m, lphi_s)
23432342
if (zeta.ge.cvmix_zero) then
23442343
! Stable region
23452344
compute_phi_inv = cvmix_one/(cvmix_one + real(5,cvmix_r8)*zeta)
2346-
else if (zeta.ge.cvmix_get_kpp_real('zeta_m', CVmix_kpp_params_in)) then
2345+
else if (zeta.ge.CVmix_kpp_params_in%zeta_m) then
23472346
compute_phi_inv = (cvmix_one - real(16,cvmix_r8)*zeta)**0.25_cvmix_r8
23482347
else
2349-
compute_phi_inv = (cvmix_get_kpp_real('a_m', CVmix_kpp_params_in) - &
2350-
cvmix_get_kpp_real('c_m', CVmix_kpp_params_in)*zeta)** &
2348+
compute_phi_inv = (CVmix_kpp_params_in%a_m - &
2349+
CVmix_kpp_params_in%c_m*zeta)** &
23512350
(cvmix_one/real(3,cvmix_r8))
23522351
end if
23532352
end if
@@ -2356,11 +2355,11 @@ function compute_phi_inv(zeta, CVmix_kpp_params_in, lphi_m, lphi_s)
23562355
if (zeta.ge.cvmix_zero) then
23572356
! Stable region
23582357
compute_phi_inv = cvmix_one/(cvmix_one + real(5,cvmix_r8)*zeta)
2359-
else if (zeta.ge.cvmix_get_kpp_real('zeta_s', CVmix_kpp_params_in)) then
2358+
else if (zeta.ge.CVmix_kpp_params_in%zeta_s) then
23602359
compute_phi_inv = (cvmix_one - real(16,cvmix_r8)*zeta)**0.5_cvmix_r8
23612360
else
2362-
compute_phi_inv = (cvmix_get_kpp_real('a_s', CVmix_kpp_params_in) - &
2363-
cvmix_get_kpp_real('c_s', CVmix_kpp_params_in)*zeta)** &
2361+
compute_phi_inv = (CVmix_kpp_params_in%a_s - &
2362+
CVmix_kpp_params_in%c_s*zeta)** &
23642363
(cvmix_one/real(3,cvmix_r8))
23652364
end if
23662365
end if

0 commit comments

Comments
 (0)