Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BT solver wide halo log_param and hifreq diagnostics timestamps #209

Merged
merged 4 commits into from
Sep 21, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions src/core/MOM_barotropic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce,
real :: visc_rem ! A work variable that may equal visc_rem_[uv] [nondim]
real :: vel_prev ! The previous velocity [L T-1 ~> m s-1].
real :: dtbt ! The barotropic time step [T ~> s].
real :: dtbt_diag ! The nominal barotropic time step used in hifreq diagnostics [T ~> s].
! dtbt_diag = dt/(nstep+nfilter)
real :: bebt ! A copy of CS%bebt [nondim].
real :: be_proj ! The fractional amount by which velocities are projected
! when project_velocity is true [nondim]. For now be_proj is set
Expand Down Expand Up @@ -680,18 +682,18 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce,
real, allocatable :: wt_vel(:) ! The raw or relative weights of each of the barotropic timesteps
! in determining the average velocities [nondim]
real, allocatable :: wt_eta(:) ! The raw or relative weights of each of the barotropic timesteps
! in determining the average the average of eta [nondim]
! in determining the average eta [nondim]
real, allocatable :: wt_accel(:) ! The raw or relative weights of each of the barotropic timesteps
! in determining the average accelerations [nondim]
real, allocatable :: wt_trans(:) ! The raw or relative weights of each of the barotropic timesteps
! in determining the average transports [nondim]
real, allocatable :: wt_accel2(:) ! A potentially un-normalized copy of wt_accel [nondim]
real :: sum_wt_vel ! The sum of the raw weights used to find average velocities [nondim]
real :: sum_wt_eta ! The sum of the raw weights used to find average the average of eta [nondim]
real :: sum_wt_eta ! The sum of the raw weights used to find average eta [nondim]
real :: sum_wt_accel ! The sum of the raw weights used to find average accelerations [nondim]
real :: sum_wt_trans ! The sum of the raw weights used to find average transports [nondim]
real :: I_sum_wt_vel ! The inverse of the sum of the raw weights used to find average velocities [nondim]
real :: I_sum_wt_eta ! The inverse of the sum of the raw weights used to find the average of eta [nondim]
real :: I_sum_wt_eta ! The inverse of the sum of the raw weights used to find eta [nondim]
real :: I_sum_wt_accel ! The inverse of the sum of the raw weights used to find average accelerations [nondim]
real :: I_sum_wt_trans ! The inverse of the sum of the raw weights used to find average transports [nondim]
real :: dt_filt ! The half-width of the barotropic filter [T ~> s].
Expand Down Expand Up @@ -1694,6 +1696,8 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce,
if (nstep+nfilter==0 ) call MOM_error(FATAL, &
"btstep: number of barotropic step (nstep+nfilter) is 0")

dtbt_diag = dt/(nstep+nfilter)

! Set up the normalized weights for the filtered velocity.
sum_wt_vel = 0.0 ; sum_wt_eta = 0.0 ; sum_wt_accel = 0.0 ; sum_wt_trans = 0.0
allocate(wt_vel(nstep+nfilter)) ; allocate(wt_eta(nstep+nfilter))
Expand Down Expand Up @@ -2354,7 +2358,7 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce,
!$OMP end parallel

if (do_hifreq_output) then
time_step_end = time_bt_start + real_to_time(n*US%T_to_s*dtbt)
time_step_end = time_bt_start + real_to_time(n*US%T_to_s*dtbt_diag)
call enable_averages(dtbt, time_step_end, CS%diag)
if (CS%id_ubt_hifreq > 0) call post_data(CS%id_ubt_hifreq, ubt(IsdB:IedB,jsd:jed), CS%diag)
if (CS%id_vbt_hifreq > 0) call post_data(CS%id_vbt_hifreq, vbt(isd:ied,JsdB:JedB), CS%diag)
Expand Down Expand Up @@ -4396,13 +4400,6 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
#else
wd_halos(1) = bt_halo_sz; wd_halos(2) = bt_halo_sz
#endif
call log_param(param_file, mdl, "!BT x-halo", wd_halos(1), &
"The barotropic x-halo size that is actually used.", &
layoutParam=.true.)
call log_param(param_file, mdl, "!BT y-halo", wd_halos(2), &
"The barotropic y-halo size that is actually used.", &
layoutParam=.true.)

call get_param(param_file, mdl, "NONLINEAR_BT_CONTINUITY", CS%Nonlinear_continuity, &
"If true, use nonlinear transports in the barotropic "//&
"continuity equation. This does not apply if "//&
Expand Down Expand Up @@ -4623,6 +4620,12 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
call MOM_mesg("barotropic_init: barotropic y-halo size increased.", 3)
endif
#endif
call log_param(param_file, mdl, "!BT x-halo", wd_halos(1), &
"The barotropic x-halo size that is actually used.", &
layoutParam=.true.)
call log_param(param_file, mdl, "!BT y-halo", wd_halos(2), &
"The barotropic y-halo size that is actually used.", &
layoutParam=.true.)

CS%isdw = G%isc-wd_halos(1) ; CS%iedw = G%iec+wd_halos(1)
CS%jsdw = G%jsc-wd_halos(2) ; CS%jedw = G%jec+wd_halos(2)
Expand Down Expand Up @@ -4788,7 +4791,7 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
endif

CS%id_PFu_bt = register_diag_field('ocean_model', 'PFuBT', diag%axesCu1, Time, &
'Zonal Anomalous Barotropic Pressure Force Force Acceleration', 'm s-2', conversion=US%L_T2_to_m_s2)
'Zonal Anomalous Barotropic Pressure Force Acceleration', 'm s-2', conversion=US%L_T2_to_m_s2)
CS%id_PFv_bt = register_diag_field('ocean_model', 'PFvBT', diag%axesCv1, Time, &
'Meridional Anomalous Barotropic Pressure Force Acceleration', 'm s-2', conversion=US%L_T2_to_m_s2)
CS%id_Coru_bt = register_diag_field('ocean_model', 'CoruBT', diag%axesCu1, Time, &
Expand Down