Skip to content

Commit 8f97b3d

Browse files
iangroomspjpegionJessica KenigsonJessica Kenigsonjkenigson
authored
Corrections to cell-averaged density computation (mom-ocean#213)
* initial hooks for stochastic EOS modifications * remove debug statements * add documentation * Change ampltiude from 0.39 to sqrt(.39) * remove global_indexing logic from stoch_eos_init * switch to using MOM_random and add restart capability * update random sequence to update each each time-step * remove tseed0 from MOM_random (leftover from debugging) * Added necessary submodules and S^2, T^2 diagnostics to MOM_diagnostics * Added diagnostics for outputting variables related to the stochastic parameterization. * Diagnostics in MOM_PressureForce_FV updated for stochastic (rather than deterministic) Stanley SGS T variance parameterization. * Added parentheses for reproducibility. * Changed diagnostics to account for possible absence of stoch_eos_pattern in MOM_PressureForce_FV, when deterministic parameterization is on. * remove mom6_da_hooks and geoKdTree from pkg * add stochastic compoment to MOM_thickness_diffuse * fix array size declaration and post_data * Corrected indexing of loops in MOM_calc_varT * Changed how parameterization of SGS T variance (deterministic and stochastic) is switched on in PGF and thickness diffusion codes * Corrected a few typos * Cleaned up indices, redundant diagnostic, printing * Fixed diagnostic IDs * Fixed diagnostics typo * Corrected indices in calculation of tv%varT * Minor index fix * Corrected bug in pressure in Stanley diagnostics * Fixed whitespace error * Stoch eos clock (#5) *Added a clock for the Stanley parameterization Co-authored-by: jkenigson <jkenigso@gmail.com> * add halo update to random pattern * Update MOM_stoch_eos.F90 Fix bug for looping over compute domain (is -> isc etc.) * Avoid unnessary computations on halo (MOM_stoch_eos) and code clean-up (MOM_thickness_diffuse) * Removed halo updates before determ param calc * Update MOM_stoch_eos.F90 Removed unnecessary code * Bug - indices are transposed * Changed Stanley stochastic coefficient from exp(X) to exp(aX) (mom-ocean#9) * Changed Stanley stochastic coefficient from exp(X) to exp(aX) * Extra spaces removed * Stoch eos init fix (mom-ocean#10) * Don't bother calculating tv%varT if stanley_coeff<0 * Missing then added * Merge Ian Grooms Tvar Discretization (mom-ocean#11) * Update MOM_stoch_eos.F90 In progress updating stencil for$ | dx \times \nabla T|^2$ calculation * New discretization of |dx\circ\nablaT|^2 Co-authored-by: Ian Grooms <ian.grooms@colorado.edu> * Multiplied tvar%SGS by grid cell thickness ratio * Added limiter for tv%varT * Stoch eos ncar linear disc (mom-ocean#12) * Update MOM_stoch_eos.F90 In progress updating stencil for$ | dx \times \nabla T|^2$ calculation * New discretization of |dx\circ\nablaT|^2 * AR1 timescale land mask Adds land mask to the computation of the AR1 decorrelation time * Update dt in call to MOM_stoch_eos_run The call to `MOM_stoch_eos_run` (which time steps the noise) is from within `step_MOM_dynamics`. `step_MOM_dynamics` advances on time step `dt` (per line 957), but the noise is updated using `dt_thermo`. It seems more appropriate to update the noise using `dt`, since it gets called from within `step_MOM_dynamics`. * Fixed the units for r_sm_H * Remove vestigial declarations The variables `hl`, `Tl`, `mn_T`, `mn_T2`, and `r_sm_H` are no longer used, so I removed their declarations and an OMP private clause Co-authored-by: Ian Grooms <ian.grooms@colorado.edu> * Update MOM_thickness_diffuse.F90 Changed index for soft convention * Update CVMix-src * Ensure use_varT, etc., initialized * Don't register stanley diagnostics if scheme is off * Stanley density second derivs at h pts (mom-ocean#15) * Change discretization of Stanley correction (drho_dT_dT at h points) * Limit Stanley noise, shrink limiting value * Revert t variance discretization * Reverted variable declarations * Stanley scheme in mixed_layer_restrat, vert_fill in stoch_eos, code cleanup (mom-ocean#19) * Test Stanley EOS param in mixed_layer_restrat * Fix size of TS cov, S var in Stanley calculate_density calls * Test move stanley scheme initialization * Added missing openMP directives * Revert Stanley tvar discretization (mom-ocean#18) * Perform vertical filling in calculation of T variance * Variable declaration syntax error, remove scaling from get_param * Fix call to vert_fill_TS * Code cleanup, whitespace cleanup Co-authored-by: Jessica Kenigson <jessicak@cheyenne1.cheyenne.ucar.edu> * Use Stanley (2020) variance; scheme off at coast * Comment clean-up * Remove factor of 0.5 in Tvar * Don't calculate Stanley diagnostics on halo * Change start indices in stanley_density_1d * Stanley param in MOM_isopycnal_slopes (mom-ocean#22) Stanley param in MOM_isopycnal_slopes and thickness diffuse index fix * Set eady flag to true if use_stored_slopes is true * Cleanup, docs, whitespace * Docs and whitespace * Docs and whitespace * Docs and whitespace * Whitespace cleanup * Whitespace cleanup * Clean up whitespace * Docs cleanup * use_stanley * Update MOM_lateral_mixing_coeffs.F90 * Adds link to another TEOS10 module * Set Stanley off for testing * Line continuation Co-authored-by: Phil Pegion <38869668+pjpegion@users.noreply.github.com> Co-authored-by: Philip Pegion <Philip.Pegion@noaa.gov> Co-authored-by: Jessica Kenigson <jessicak@cheyenne6.cheyenne.ucar.edu> Co-authored-by: Jessica Kenigson <jessicak@cheyenne3.cheyenne.ucar.edu> Co-authored-by: jkenigson <jkenigso@gmail.com> Co-authored-by: jskenigson <jessica.kenigson@colorado.edu> Co-authored-by: Jessica Kenigson <jessicak@cheyenne1.cheyenne.ucar.edu> Co-authored-by: Jessica Kenigson <jessicak@cheyenne5.cheyenne.ucar.edu> Co-authored-by: Philip Pegion <ppegion@Philips-MacBook-Pro.local> Co-authored-by: Jessica Kenigson <jessicak@cheyenne4.cheyenne.ucar.edu>
1 parent 2cd228f commit 8f97b3d

13 files changed

Lines changed: 515 additions & 182 deletions

.testing/tc2/MOM_input

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ BOUND_CORIOLIS = True ! [Boolean] default = False
297297
! v-points, and similarly at v-points. This option would
298298
! have no effect on the SADOURNY Coriolis scheme if it
299299
! were possible to use centered difference thickness fluxes.
300-
PGF_STANLEY_T2_DET_COEFF = 0.5 ! [nondim] default = -1.0
300+
PGF_STANLEY_T2_DET_COEFF = -1.0 ! [nondim] default = -1.0
301301
! The coefficient correlating SGS temperature variance with the mean temperature
302302
! gradient in the deterministic part of the Stanley form of the Brankart
303303
! correction. Negative values disable the scheme.
@@ -430,7 +430,7 @@ KHTH = 1.0 ! [m2 s-1] default = 0.0
430430
! The background horizontal thickness diffusivity.
431431
KHTH_MAX = 900.0 ! [m2 s-1] default = 0.0
432432
! The maximum horizontal thickness diffusivity.
433-
STANLEY_PRM_DET_COEFF = 0.5 ! [nondim] default = -1.0
433+
STANLEY_PRM_DET_COEFF = -1.0 ! [nondim] default = -1.0
434434
! The coefficient correlating SGS temperature variance with the mean temperature
435435
! gradient in the deterministic part of the Stanley parameterization. Negative
436436
! values disable the scheme.

src/core/MOM.F90

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ module MOM
108108
use MOM_shared_initialization, only : write_ocean_geometry_file
109109
use MOM_sponge, only : init_sponge_diags, sponge_CS
110110
use MOM_state_initialization, only : MOM_initialize_state
111+
use MOM_stoch_eos, only : MOM_stoch_eos_init,MOM_stoch_eos_run,MOM_stoch_eos_CS,mom_calc_varT
111112
use MOM_sum_output, only : write_energy, accumulate_net_input
112113
use MOM_sum_output, only : MOM_sum_output_init, MOM_sum_output_end
113114
use MOM_sum_output, only : sum_output_CS
@@ -242,6 +243,7 @@ module MOM
242243
logical :: use_ALE_algorithm !< If true, use the ALE algorithm rather than layered
243244
!! isopycnal/stacked shallow water mode. This logical is set by calling the
244245
!! function useRegridding() from the MOM_regridding module.
246+
type(MOM_stoch_eos_CS) :: stoch_eos_CS !< structure containing random pattern for stoch EOS
245247
logical :: alternate_first_direction !< If true, alternate whether the x- or y-direction
246248
!! updates occur first in directionally split parts of the calculation.
247249
real :: first_dir_restart = -1.0 !< A real copy of G%first_direction for use in restart files
@@ -444,6 +446,8 @@ module MOM
444446
integer :: id_clock_other
445447
integer :: id_clock_offline_tracer
446448
integer :: id_clock_unit_tests
449+
integer :: id_clock_stoch
450+
integer :: id_clock_varT
447451
!>@}
448452

449453
contains
@@ -1063,6 +1067,15 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
10631067
showCallTree = callTree_showQuery()
10641068

10651069
call cpu_clock_begin(id_clock_dynamics)
1070+
call cpu_clock_begin(id_clock_stoch)
1071+
if (CS%stoch_eos_CS%use_stoch_eos) call MOM_stoch_eos_run(G,u,v,dt,Time_local,CS%stoch_eos_CS,CS%diag)
1072+
call cpu_clock_end(id_clock_stoch)
1073+
call cpu_clock_begin(id_clock_varT)
1074+
if (CS%stoch_eos_CS%stanley_coeff >= 0.0) then
1075+
call MOM_calc_varT(G,GV,h,CS%tv,CS%stoch_eos_CS,dt)
1076+
call pass_var(CS%tv%varT, G%Domain,clock=id_clock_pass,halo=1)
1077+
endif
1078+
call cpu_clock_end(id_clock_varT)
10661079

10671080
if ((CS%t_dyn_rel_adv == 0.0) .and. CS%thickness_diffuse .and. CS%thickness_diffuse_first) then
10681081

@@ -1229,6 +1242,9 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
12291242
if (IDs%id_u > 0) call post_data(IDs%id_u, u, CS%diag)
12301243
if (IDs%id_v > 0) call post_data(IDs%id_v, v, CS%diag)
12311244
if (IDs%id_h > 0) call post_data(IDs%id_h, h, CS%diag)
1245+
if (CS%stoch_eos_CS%id_stoch_eos > 0) call post_data(CS%stoch_eos_CS%id_stoch_eos, CS%stoch_eos_CS%pattern, CS%diag)
1246+
if (CS%stoch_eos_CS%id_stoch_phi > 0) call post_data(CS%stoch_eos_CS%id_stoch_phi, CS%stoch_eos_CS%phi, CS%diag)
1247+
if (CS%stoch_eos_CS%id_tvar_sgs > 0) call post_data(CS%stoch_eos_CS%id_tvar_sgs, CS%tv%varT, CS%diag)
12321248
call disable_averaging(CS%diag)
12331249
call cpu_clock_end(id_clock_diagnostics) ; call cpu_clock_end(id_clock_other)
12341250

@@ -2765,6 +2781,8 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
27652781
call set_visc_init(Time, G, GV, US, param_file, diag, CS%visc, CS%set_visc_CSp, restart_CSp, CS%OBC)
27662782
call thickness_diffuse_init(Time, G, GV, US, param_file, diag, CS%CDp, CS%thickness_diffuse_CSp)
27672783

2784+
new_sim = is_new_run(restart_CSp)
2785+
call MOM_stoch_eos_init(G,Time,param_file,CS%stoch_eos_CS,restart_CSp,diag)
27682786
if (CS%split) then
27692787
allocate(eta(SZI_(G),SZJ_(G)), source=0.0)
27702788
call initialize_dyn_split_RK2(CS%u, CS%v, CS%h, CS%uh, CS%vh, eta, Time, &
@@ -2854,7 +2872,6 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
28542872
endif
28552873

28562874
! This subroutine initializes any tracer packages.
2857-
new_sim = is_new_run(restart_CSp)
28582875
call tracer_flow_control_init(.not.new_sim, Time, G, GV, US, CS%h, param_file, &
28592876
CS%diag, CS%OBC, CS%tracer_flow_CSp, CS%sponge_CSp, &
28602877
CS%ALE_sponge_CSp, CS%tv)
@@ -3065,6 +3082,7 @@ subroutine register_diags(Time, G, GV, US, IDs, diag)
30653082
v_extensive=.true.)
30663083
IDs%id_ssh_inst = register_diag_field('ocean_model', 'SSH_inst', diag%axesT1, &
30673084
Time, 'Instantaneous Sea Surface Height', 'm', conversion=US%Z_to_m)
3085+
30683086
end subroutine register_diags
30693087

30703088
!> Set up CPU clock IDs for timing various subroutines.
@@ -3097,6 +3115,8 @@ subroutine MOM_timing_init(CS)
30973115
if (CS%offline_tracer_mode) then
30983116
id_clock_offline_tracer = cpu_clock_id('Ocean offline tracers', grain=CLOCK_SUBCOMPONENT)
30993117
endif
3118+
id_clock_stoch = cpu_clock_id('(Stochastic EOS)', grain=CLOCK_MODULE)
3119+
id_clock_varT = cpu_clock_id('(SGS Temperature Variance)', grain=CLOCK_MODULE)
31003120

31013121
end subroutine MOM_timing_init
31023122

src/core/MOM_PressureForce_FV.F90

Lines changed: 44 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ module MOM_PressureForce_FV
5858
integer :: Recon_Scheme !< Order of the polynomial of the reconstruction of T & S
5959
!! for the finite volume pressure gradient calculation.
6060
!! By the default (1) is for a piecewise linear method
61-
real :: Stanley_T2_det_coeff !< The coefficient correlating SGS temperature variance with
62-
!! the mean temperature gradient in the deterministic part of
63-
!! the Stanley form of the Brankart correction.
61+
62+
logical :: use_stanley_pgf !< If true, turn on Stanley parameterization in the PGF
6463
integer :: id_e_tidal = -1 !< Diagnostic identifier
65-
integer :: id_tvar_sgs = -1 !< Diagnostic identifier
64+
integer :: id_rho_pgf = -1 !< Diagnostic identifier
65+
integer :: id_rho_stanley_pgf = -1 !< Diagnostic identifier
66+
integer :: id_p_stanley = -1 !< Diagnostic identifier
6667
type(tidal_forcing_CS), pointer :: tides_CSp => NULL() !< Tides control structure
6768
end type PressureForce_FV_CS
6869

@@ -167,7 +168,7 @@ subroutine PressureForce_FV_nonBouss(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_
167168
if (.not.CS%initialized) call MOM_error(FATAL, &
168169
"MOM_PressureForce_FV_nonBouss: Module must be initialized before it is used.")
169170

170-
if (CS%Stanley_T2_det_coeff>=0.) call MOM_error(FATAL, &
171+
if (CS%use_stanley_pgf) call MOM_error(FATAL, &
171172
"MOM_PressureForce_FV_nonBouss: The Stanley parameterization is not yet"//&
172173
"implemented in non-Boussinesq mode.")
173174

@@ -473,6 +474,13 @@ subroutine PressureForce_FV_Bouss(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm
473474
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: &
474475
S_t, S_b, T_t, T_b ! Top and bottom edge values for linear reconstructions
475476
! of salinity and temperature within each layer.
477+
real, dimension(SZI_(G),SZJ_(G),SZK_(G)) :: &
478+
rho_pgf, rho_stanley_pgf ! Density [kg m-3] from EOS with and without SGS T variance
479+
! in Stanley parameterization.
480+
real, dimension(SZI_(G),SZJ_(G),SZK_(G)) :: &
481+
p_stanley ! Pressure [Pa] estimated with Rho_0
482+
real :: rho_stanley_scalar ! Scalar quantity to hold density [kg m-3] in Stanley diagnostics.
483+
real :: p_stanley_scalar ! Scalar quantity to hold pressure [Pa] in Stanley diagnostics.
476484
real :: rho_in_situ(SZI_(G)) ! The in situ density [R ~> kg m-3].
477485
real :: p_ref(SZI_(G)) ! The pressure used to calculate the coordinate
478486
! density, [R L2 T-2 ~> Pa] (usually 2e7 Pa = 2000 dbar).
@@ -487,11 +495,6 @@ subroutine PressureForce_FV_Bouss(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm
487495
logical :: use_ALE ! If true, use an ALE pressure reconstruction.
488496
logical :: use_EOS ! If true, density is calculated from T & S using an equation of state.
489497
type(thermo_var_ptrs) :: tv_tmp! A structure of temporary T & S.
490-
real :: Tl(5) ! copy and T in local stencil [degC]
491-
real :: mn_T ! mean of T in local stencil [degC]
492-
real :: mn_T2 ! mean of T**2 in local stencil [degC2]
493-
real :: hl(5) ! Copy of local stencil of H [H ~> m]
494-
real :: r_sm_H ! Reciprocal of sum of H in local stencil [H-1 ~> m-1]
495498
real, parameter :: C1_6 = 1.0/6.0
496499
integer, dimension(2) :: EOSdom ! The i-computational domain for the equation of state
497500
integer :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz, nkmb
@@ -511,49 +514,6 @@ subroutine PressureForce_FV_Bouss(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm
511514
use_ALE = .false.
512515
if (associated(ALE_CSp)) use_ALE = CS%reconstruct .and. use_EOS
513516

514-
if (CS%Stanley_T2_det_coeff>=0.) then
515-
if (.not. associated(tv%varT)) call safe_alloc_ptr(tv%varT, G%isd, G%ied, G%jsd, G%jed, GV%ke)
516-
do k=1, nz ; do j=js-1,je+1 ; do i=is-1,ie+1
517-
! Strictly speaking we should estimate the *horizontal* grid-scale variance
518-
! but neither of the following blocks make a rotation to the horizontal
519-
! and instead work along coordinate.
520-
521-
! This block calculates a simple |delta T| along coordinates and does
522-
! not allow vanishing layer thicknesses or layers tracking topography
523-
!! SGS variance in i-direction [degC2]
524-
!dTdi2 = ( ( G%mask2dCu(I ,j) * G%IdxCu(I ,j) * ( tv%T(i+1,j,k) - tv%T(i,j,k) ) &
525-
! + G%mask2dCu(I-1,j) * G%IdxCu(I-1,j) * ( tv%T(i,j,k) - tv%T(i-1,j,k) ) &
526-
! ) * G%dxT(i,j) * 0.5 )**2
527-
!! SGS variance in j-direction [degC2]
528-
!dTdj2 = ( ( G%mask2dCv(i,J ) * G%IdyCv(i,J ) * ( tv%T(i,j+1,k) - tv%T(i,j,k) ) &
529-
! + G%mask2dCv(i,J-1) * G%IdyCv(i,J-1) * ( tv%T(i,j,k) - tv%T(i,j-1,k) ) &
530-
! ) * G%dyT(i,j) * 0.5 )**2
531-
!tv%varT(i,j,k) = CS%Stanley_T2_det_coeff * 0.5 * ( dTdi2 + dTdj2 )
532-
533-
! This block does a thickness weighted variance calculation and helps control for
534-
! extreme gradients along layers which are vanished against topography. It is
535-
! still a poor approximation in the interior when coordinates are strongly tilted.
536-
hl(1) = h(i,j,k) * G%mask2dT(i,j)
537-
hl(2) = h(i-1,j,k) * G%mask2dCu(I-1,j)
538-
hl(3) = h(i+1,j,k) * G%mask2dCu(I,j)
539-
hl(4) = h(i,j-1,k) * G%mask2dCv(i,J-1)
540-
hl(5) = h(i,j+1,k) * G%mask2dCv(i,J)
541-
r_sm_H = 1. / ( ( hl(1) + ( ( hl(2) + hl(3) ) + ( hl(4) + hl(5) ) ) ) + GV%H_subroundoff )
542-
! Mean of T
543-
Tl(1) = tv%T(i,j,k) ; Tl(2) = tv%T(i-1,j,k) ; Tl(3) = tv%T(i+1,j,k)
544-
Tl(4) = tv%T(i,j-1,k) ; Tl(5) = tv%T(i,j+1,k)
545-
mn_T = ( hl(1)*Tl(1) + ( ( hl(2)*Tl(2) + hl(3)*Tl(3) ) + ( hl(4)*Tl(4) + hl(5)*Tl(5) ) ) ) * r_sm_H
546-
! Adjust T vectors to have zero mean
547-
Tl(:) = Tl(:) - mn_T ; mn_T = 0.
548-
! Variance of T
549-
mn_T2 = ( hl(1)*Tl(1)*Tl(1) + ( ( hl(2)*Tl(2)*Tl(2) + hl(3)*Tl(3)*Tl(3) ) &
550-
+ ( hl(4)*Tl(4)*Tl(4) + hl(5)*Tl(5)*Tl(5) ) ) ) * r_sm_H
551-
! Variance should be positive but round-off can violate this. Calculating
552-
! variance directly would fix this but requires more operations.
553-
tv%varT(i,j,k) = CS%Stanley_T2_det_coeff * max(0., mn_T2)
554-
enddo ; enddo ; enddo
555-
endif
556-
557517
h_neglect = GV%H_subroundoff
558518
dz_neglect = GV%H_subroundoff * GV%H_to_Z
559519
I_Rho0 = 1.0 / GV%Rho0
@@ -690,7 +650,6 @@ subroutine PressureForce_FV_Bouss(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm
690650
do k=1,nz
691651
! Calculate 4 integrals through the layer that are required in the
692652
! subsequent calculation.
693-
694653
if (use_EOS) then
695654
! The following routine computes the integrals that are needed to
696655
! calculate the pressure gradient force. Linear profiles for T and S are
@@ -701,13 +660,13 @@ subroutine PressureForce_FV_Bouss(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm
701660
if ( CS%Recon_Scheme == 1 ) then
702661
call int_density_dz_generic_plm(k, tv, T_t, T_b, S_t, S_b, e, &
703662
rho_ref, CS%Rho0, GV%g_Earth, dz_neglect, G%bathyT, &
704-
G%HI, GV, tv%eqn_of_state, US, dpa, intz_dpa, intx_dpa, inty_dpa, &
663+
G%HI, GV, tv%eqn_of_state, US, CS%use_stanley_pgf, dpa, intz_dpa, intx_dpa, inty_dpa, &
705664
useMassWghtInterp=CS%useMassWghtInterp, &
706665
use_inaccurate_form=CS%use_inaccurate_pgf_rho_anom, Z_0p=G%Z_ref)
707666
elseif ( CS%Recon_Scheme == 2 ) then
708667
call int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
709668
rho_ref, CS%Rho0, GV%g_Earth, dz_neglect, G%bathyT, &
710-
G%HI, GV, tv%eqn_of_state, US, dpa, intz_dpa, intx_dpa, inty_dpa, &
669+
G%HI, GV, tv%eqn_of_state, US, CS%use_stanley_pgf, dpa, intz_dpa, intx_dpa, inty_dpa, &
711670
useMassWghtInterp=CS%useMassWghtInterp, Z_0p=G%Z_ref)
712671
endif
713672
else
@@ -797,8 +756,26 @@ subroutine PressureForce_FV_Bouss(h, tv, PFu, PFv, G, GV, US, CS, ALE_CSp, p_atm
797756
endif
798757
endif
799758

759+
if (CS%use_stanley_pgf) then
760+
do j=js,je ; do i=is,ie ;
761+
p_stanley_scalar=0.0
762+
do k=1, nz
763+
p_stanley_scalar = p_stanley_scalar + 0.5 * h(i,j,k) * GV%H_to_Pa !Pressure at mid-point of layer
764+
call calculate_density(tv%T(i,j,k), tv%S(i,j,k), p_stanley_scalar, 0.0, 0.0, 0.0, &
765+
rho_stanley_scalar, tv%eqn_of_state)
766+
rho_pgf(i,j,k) = rho_stanley_scalar
767+
call calculate_density(tv%T(i,j,k), tv%S(i,j,k), p_stanley_scalar, tv%varT(i,j,k), 0.0, 0.0, &
768+
rho_stanley_scalar, tv%eqn_of_state)
769+
rho_stanley_pgf(i,j,k) = rho_stanley_scalar
770+
p_stanley(i,j,k) = p_stanley_scalar
771+
p_stanley_scalar = p_stanley_scalar + 0.5 * h(i,j,k) * GV%H_to_Pa !Pressure at bottom of layer
772+
enddo; enddo; enddo
773+
endif
774+
800775
if (CS%id_e_tidal>0) call post_data(CS%id_e_tidal, e_tidal, CS%diag)
801-
if (CS%id_tvar_sgs>0) call post_data(CS%id_tvar_sgs, tv%varT, CS%diag)
776+
if (CS%id_rho_pgf>0) call post_data(CS%id_rho_pgf, rho_pgf, CS%diag)
777+
if (CS%id_rho_stanley_pgf>0) call post_data(CS%id_rho_stanley_pgf, rho_stanley_pgf, CS%diag)
778+
if (CS%id_p_stanley>0) call post_data(CS%id_p_stanley, p_stanley, CS%diag)
802779

803780
end subroutine PressureForce_FV_Bouss
804781

@@ -859,14 +836,16 @@ subroutine PressureForce_FV_init(Time, G, GV, US, param_file, diag, CS, tides_CS
859836
"boundary cells is extrapolated, rather than using PCM "//&
860837
"in these cells. If true, the same order polynomial is "//&
861838
"used as is used for the interior cells.", default=.true.)
862-
call get_param(param_file, mdl, "PGF_STANLEY_T2_DET_COEFF", CS%Stanley_T2_det_coeff, &
863-
"The coefficient correlating SGS temperature variance with "// &
864-
"the mean temperature gradient in the deterministic part of "// &
865-
"the Stanley form of the Brankart correction. "// &
866-
"Negative values disable the scheme.", units="nondim", default=-1.0)
867-
if (CS%Stanley_T2_det_coeff>=0.) then
868-
CS%id_tvar_sgs = register_diag_field('ocean_model', 'tvar_sgs_pgf', diag%axesTL, &
869-
Time, 'SGS temperature variance used in PGF', 'degC2')
839+
call get_param(param_file, mdl, "USE_STANLEY_PGF", CS%use_stanley_pgf, &
840+
"If true, turn on Stanley SGS T variance parameterization "// &
841+
"in PGF code.", default=.false.)
842+
if (CS%use_stanley_pgf) then
843+
CS%id_rho_pgf = register_diag_field('ocean_model', 'rho_pgf', diag%axesTL, &
844+
Time, 'rho in PGF', 'kg m3')
845+
CS%id_rho_stanley_pgf = register_diag_field('ocean_model', 'rho_stanley_pgf', diag%axesTL, &
846+
Time, 'rho in PGF with Stanley correction', 'kg m3')
847+
CS%id_p_stanley = register_diag_field('ocean_model', 'p_stanley', diag%axesTL, &
848+
Time, 'p in PGF with Stanley correction', 'Pa')
870849
endif
871850
if (CS%tides) then
872851
CS%id_e_tidal = register_diag_field('ocean_model', 'e_tidal', diag%axesT1, &

0 commit comments

Comments
 (0)