@@ -2847,26 +2847,26 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce,
2847
2847
2848
2848
end subroutine btstep
2849
2849
2850
- ! > This subroutine automatically determines an optimal value for dtbt based
2851
- ! ! on some state of the ocean.
2852
- subroutine set_dtbt (G , GV , US , CS , eta , pbce , BT_cont , gtot_est , SSH_add )
2850
+ ! > This subroutine automatically determines an optimal value for dtbt based on some state of the ocean. Either pbce or
2851
+ ! ! gtot_est is required to calculate gravitational acceleration. Column thickness can be estimated using BT_cont, eta,
2852
+ ! ! and SSH_add (default=0), with priority given in that order. The subroutine sets CS%dtbt_max and CS%dtbt.
2853
+ subroutine set_dtbt (G , GV , US , CS , pbce , gtot_est , BT_cont , eta , SSH_add )
2853
2854
type (ocean_grid_type), intent (inout ) :: G ! < The ocean's grid structure.
2854
2855
type (verticalGrid_type), intent (in ) :: GV ! < The ocean's vertical grid structure.
2855
2856
type (unit_scale_type), intent (in ) :: US ! < A dimensional unit scaling type
2856
2857
type (barotropic_CS), intent (inout ) :: CS ! < Barotropic control structure
2857
- real , dimension (SZI_(G),SZJ_(G)), optional , intent (in ) :: eta ! < The barotropic free surface
2858
- ! ! height anomaly or column mass anomaly [H ~> m or kg m-2].
2859
- real , dimension (SZI_(G),SZJ_(G),SZK_(GV)), optional , intent (in ) :: pbce ! < The baroclinic pressure
2860
- ! ! anomaly in each layer due to free surface
2861
- ! ! height anomalies [L2 H-1 T-2 ~> m s-2 or m4 kg-1 s-2].
2862
- type (BT_cont_type), optional , pointer :: BT_cont ! < A structure with elements that describe
2863
- ! ! the effective open face areas as a
2864
- ! ! function of barotropic flow.
2865
- real , optional , intent (in ) :: gtot_est ! < An estimate of the total gravitational
2866
- ! ! acceleration [L2 H-1 T-2 ~> m s-2 or m4 kg-1 s-2].
2867
- real , optional , intent (in ) :: SSH_add ! < An additional contribution to SSH to
2868
- ! ! provide a margin of error when
2869
- ! ! calculating the external wave speed [Z ~> m].
2858
+ real , dimension (SZI_(G),SZJ_(G),SZK_(GV)), &
2859
+ optional , intent (in ) :: pbce ! < The baroclinic pressure anomaly in each layer due to free
2860
+ ! ! surface height anomalies [L2 H-1 T-2 ~> m s-2 or m4 kg-1 s-2].
2861
+ real , optional , intent (in ) :: gtot_est ! < An estimate of the total gravitational acceleration
2862
+ ! ! [L2 H-1 T-2 ~> m s-2 or m4 kg-1 s-2].
2863
+ type (BT_cont_type), optional , pointer :: BT_cont ! < A structure with elements that describe the effective open
2864
+ ! ! face areas as a function of barotropic flow.
2865
+ real , dimension (SZI_(G),SZJ_(G)), &
2866
+ optional , intent (in ) :: eta ! < The barotropic free surface height anomaly or column mass
2867
+ ! ! anomaly [H ~> m or kg m-2].
2868
+ real , optional , intent (in ) :: SSH_add ! < An additional contribution to SSH to provide a margin of
2869
+ ! ! error when calculating the external wave speed [Z ~> m].
2870
2870
2871
2871
! Local variables
2872
2872
real , dimension (SZI_(G),SZJ_(G)) :: &
@@ -4424,7 +4424,7 @@ end subroutine bt_mass_source
4424
4424
! > barotropic_init initializes a number of time-invariant fields used in the
4425
4425
! ! barotropic calculation and initializes any barotropic fields that have not
4426
4426
! ! already been initialized.
4427
- subroutine barotropic_init (u , v , h , eta , Time , G , GV , US , param_file , diag , CS , &
4427
+ subroutine barotropic_init (u , v , h , Time , G , GV , US , param_file , diag , CS , &
4428
4428
restart_CS , calc_dtbt , BT_cont , SAL_CSp , HA_CSp )
4429
4429
type (ocean_grid_type), intent (inout ) :: G ! < The ocean's grid structure.
4430
4430
type (verticalGrid_type), intent (in ) :: GV ! < The ocean's vertical grid structure.
@@ -4435,9 +4435,6 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
4435
4435
intent (in ) :: v ! < The meridional velocity [L T-1 ~> m s-1].
4436
4436
real , dimension (SZI_(G),SZJ_(G),SZK_(GV)), &
4437
4437
intent (in ) :: h ! < Layer thicknesses [H ~> m or kg m-2].
4438
- real , dimension (SZI_(G),SZJ_(G)), &
4439
- intent (in ) :: eta ! < Free surface height or column mass anomaly
4440
- ! ! [Z ~> m] or [H ~> kg m-2].
4441
4438
type (time_type), target , intent (in ) :: Time ! < The current model time.
4442
4439
type (param_file_type), intent (in ) :: param_file ! < A structure to parse for run-time parameters.
4443
4440
type (diag_ctrl), target , intent (inout ) :: diag ! < A structure that is used to regulate diagnostic
@@ -4465,7 +4462,7 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
4465
4462
real :: SSH_extra ! An estimate of how much higher SSH might get, for use
4466
4463
! in calculating the safe external wave speed [Z ~> m].
4467
4464
real :: dtbt_input ! The input value of DTBT, [nondim] if negative or [s] if positive.
4468
- real :: dtbt_tmp ! A temporary copy of CS%dtbt read from a restart file [T ~> s]
4465
+ real :: dtbt_restart ! A temporary copy of CS%dtbt read from a restart file [T ~> s]
4469
4466
real :: wave_drag_scale ! A scaling factor for the barotropic linear wave drag
4470
4467
! piston velocities [nondim].
4471
4468
character (len= 200 ) :: inputdir ! The directory in which to find input files.
@@ -4978,9 +4975,9 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
4978
4975
4979
4976
CS% dtbt_fraction = 0.98 ; if (dtbt_input < 0.0 ) CS% dtbt_fraction = - dtbt_input
4980
4977
4981
- dtbt_tmp = - 1.0
4978
+ dtbt_restart = - 1.0
4982
4979
if (query_initialized(CS% dtbt, " DTBT" , restart_CS)) then
4983
- dtbt_tmp = CS% dtbt
4980
+ dtbt_restart = CS% dtbt
4984
4981
endif
4985
4982
4986
4983
! Estimate the maximum stable barotropic time step.
@@ -4991,14 +4988,17 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
4991
4988
H_to_Z = GV% H_to_RZ / CS% Rho_BT_lin
4992
4989
do k= 1 ,GV% ke ; gtot_estimate = gtot_estimate + H_to_Z* GV% g_prime(K) ; enddo
4993
4990
endif
4991
+
4992
+ ! CS%dtbt calculated here by set_dtbt is only used when dtbt is not reset during the run, i.e. DTBT_RESET_PERIOD<0.
4994
4993
call set_dtbt(G, GV, US, CS, gtot_est= gtot_estimate, SSH_add= SSH_extra)
4995
4994
4996
4995
if (dtbt_input > 0.0 ) then
4997
4996
CS% dtbt = US% s_to_T * dtbt_input
4998
- elseif (dtbt_tmp > 0.0 ) then
4999
- CS% dtbt = dtbt_tmp
4997
+ elseif (dtbt_restart > 0.0 ) then
4998
+ CS% dtbt = dtbt_restart
5000
4999
endif
5001
- if ((dtbt_tmp > 0.0 ) .and. (dtbt_input > 0.0 )) calc_dtbt = .false.
5000
+
5001
+ calc_dtbt = .true. ; if ((dtbt_restart > 0.0 ) .and. (dtbt_input > 0.0 )) calc_dtbt = .false.
5002
5002
5003
5003
call log_param(param_file, mdl, " DTBT as used" , CS% dtbt, units= " s" , unscale= US% T_to_s)
5004
5004
call log_param(param_file, mdl, " estimated maximum DTBT" , CS% dtbt_max, units= " s" , unscale= US% T_to_s)
0 commit comments